Commit a5d36b5a authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato
Browse files

crav1e: Update to address some feedbacks

parent 26d1e27d
......@@ -17,7 +17,7 @@ use std::os::raw::c_int;
/// Raw video Frame
///
/// It can be allocated throught rav1e_frame_new(), populated using rav1e_frame_fill_plane()
/// and freed using rav1e_frame_drop().
/// and freed using rav1e_frame_unref().
pub struct Frame(Arc<rav1e::Frame>);
type EncoderStatus=rav1e::EncoderStatus;
......@@ -27,7 +27,7 @@ type EncoderStatus=rav1e::EncoderStatus;
/// Instantiate it using rav1e_config_default() and fine-tune it using
/// rav1e_config_parse().
///
/// Use rav1e_config_drop() to free its memory.
/// Use rav1e_config_unref() to free its memory.
pub struct Config {
cfg: rav1e::Config,
last_err: Option<EncoderStatus>,
......@@ -38,7 +38,7 @@ pub struct Config {
/// Contains the encoding state, it is created by rav1e_context_new() using an
/// Encoder configuration.
///
/// Use rav1e_context_drop() to free its memory.
/// Use rav1e_context_unref() to free its memory.
pub struct Context {
ctx: rav1e::Context,
last_err: Option<EncoderStatus>,
......@@ -50,13 +50,13 @@ type FrameType = rav1e::FrameType;
///
/// The encoded packets are retrieved using rav1e_receive_packet().
///
/// Use rav1e_packet_drop() to free its memory.
/// Use rav1e_packet_unref() to free its memory.
#[repr(C)]
pub struct Packet {
/// Encoded data buffer
pub data: *const u8,
/// Encoded data buffer size
pub len: usize,
pub len: u64,
/// Frame sequence number
pub number: u64,
/// Frame type
......@@ -64,21 +64,21 @@ pub struct Packet {
}
type ChromaSampling=rav1e::ChromaSampling;
type Ratio=rav1e::Ratio;
type Rational=rav1e::Rational;
#[no_mangle]
pub unsafe extern "C" fn rav1e_config_default(
width: usize,
height: usize,
bit_depth: usize,
width: u32,
height: u32,
bit_depth: u8,
chroma_sampling: ChromaSampling,
timebase: Ratio,
timebase: Rational,
) -> *mut Config {
let cfg = rav1e::Config {
frame_info: rav1e::FrameInfo {
width,
height,
bit_depth,
width: width as usize,
height: height as usize,
bit_depth: bit_depth as usize,
chroma_sampling,
},
timebase,
......@@ -94,7 +94,7 @@ pub unsafe extern "C" fn rav1e_config_default(
}
#[no_mangle]
pub unsafe extern "C" fn rav1e_config_drop(cfg: *mut Config) {
pub unsafe extern "C" fn rav1e_config_unref(cfg: *mut Config) {
let _ = Box::from_raw(cfg);
}
......@@ -139,7 +139,7 @@ pub unsafe extern "C" fn rav1e_context_new(cfg: *const Config) -> *mut Context {
}
#[no_mangle]
pub unsafe extern "C" fn rav1e_context_drop(ctx: *mut Context) {
pub unsafe extern "C" fn rav1e_context_unref(ctx: *mut Context) {
let _ = Box::from_raw(ctx);
}
......@@ -147,7 +147,7 @@ pub unsafe extern "C" fn rav1e_context_drop(ctx: *mut Context) {
///
/// It must be populated using rav1e_frame_fill_plane().
///
/// The frame is reference counted and must be released passing it to rav1e_frame_drop(),
/// The frame is reference counted and must be released passing it to rav1e_frame_unref(),
/// see rav1e_send_frame().
#[no_mangle]
pub unsafe extern "C" fn rav1e_frame_new(ctx: *const Context) -> *mut Frame {
......@@ -158,8 +158,8 @@ pub unsafe extern "C" fn rav1e_frame_new(ctx: *const Context) -> *mut Frame {
}
#[no_mangle]
pub unsafe extern "C" fn rav1e_frame_drop(ctx: *mut Frame) {
let _ = Arc::from_raw(ctx);
pub unsafe extern "C" fn rav1e_frame_unref(frame: *mut Frame) {
let _ = Arc::from_raw(frame);
}
/// Send the frame for encoding
......@@ -197,7 +197,7 @@ pub unsafe extern "C" fn rav1e_receive_packet(
(*ctx).last_err = None;
let packet = Packet {
data: p.data.as_ptr(),
len: p.data.len(),
len: p.data.len() as u64,
number: p.number,
frame_type: p.frame_type,
};
......@@ -208,7 +208,7 @@ pub unsafe extern "C" fn rav1e_receive_packet(
}
#[no_mangle]
pub unsafe extern fn rav1e_packet_drop(pkt: *mut Packet) {
pub unsafe extern fn rav1e_packet_unref(pkt: *mut Packet) {
let _ = Box::from_raw(pkt);
}
......@@ -216,22 +216,25 @@ pub unsafe extern fn rav1e_packet_drop(pkt: *mut Packet) {
///
/// Its format is compatible with the AV1 Matroska and ISOBMFF specification.
#[no_mangle]
pub unsafe extern fn rav1e_container_sequence_header(ctx: *mut Context, len: *mut usize) -> *mut u8 {
pub unsafe extern fn rav1e_container_sequence_header(ctx: *mut Context, buf_size: *mut usize) -> *mut u8 {
let buf = (*ctx).ctx.container_sequence_header();
*len = buf.len();
*buf_size = buf.len();
Box::into_raw(buf.into_boxed_slice()) as *mut u8
}
pub unsafe extern fn rav1e_container_sequence_header_drop(sequence: *mut u8) {
#[no_mangle]
pub unsafe extern fn rav1e_container_sequence_header_unref(sequence: *mut u8) {
let _ = Box::from_raw(sequence);
}
/// Fill a frame plane
///
/// Currently the frame contains 3 frames, the first is luminance followed by
/// Currently the frame contains 3 planes, the first is luminance followed by
/// chrominance.
///
/// The data is copied and this function has to be called for each plane.
#[no_mangle]
pub unsafe extern "C" fn rav1e_frame_fill_plane(
frame: *mut Frame,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment