MCPcopy Index your code
hub / github.com/Recordscript/recordscript / encode

Method encode

libs/scrap/src/common/aom.rs:310–343  ·  view source on GitHub ↗
(&mut self, pts: i64, data: &[u8], stride_align: usize)

Source from the content-addressed store, hash-verified

308
309impl AomEncoder {
310 pub fn encode(&mut self, pts: i64, data: &[u8], stride_align: usize) -> Result<EncodeFrames> {
311 let bpp = if self.i444 { 24 } else { 12 };
312 if data.len() < self.width * self.height * bpp / 8 {
313 return Err(Error::FailedCall("len not enough".to_string()));
314 }
315 let fmt = if self.i444 {
316 aom_img_fmt::AOM_IMG_FMT_I444
317 } else {
318 aom_img_fmt::AOM_IMG_FMT_I420
319 };
320
321 let mut image = Default::default();
322 call_aom_ptr!(aom_img_wrap(
323 &mut image,
324 fmt,
325 self.width as _,
326 self.height as _,
327 stride_align as _,
328 data.as_ptr() as _,
329 ));
330
331 call_aom!(aom_codec_encode(
332 &mut self.ctx,
333 &image,
334 pts as _,
335 1, // Duration
336 0, // Flags
337 ));
338
339 Ok(EncodeFrames {
340 ctx: &mut self.ctx,
341 iter: ptr::null(),
342 })
343 }
344
345 #[inline]
346 pub fn create_video_frame(frames: Vec<EncodedVideoFrame>) -> VideoFrame {

Callers 5

encode_to_messageMethod · 0.45
test_vpxFunction · 0.45
test_av1Function · 0.45
test_encoderFunction · 0.45
mainFunction · 0.45

Calls 1

to_stringMethod · 0.80

Tested by 3

test_vpxFunction · 0.36
test_av1Function · 0.36
test_encoderFunction · 0.36