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

Method encode

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

Source from the content-addressed store, hash-verified

246
247impl VpxEncoder {
248 pub fn encode(&mut self, pts: i64, data: &[u8], stride_align: usize) -> Result<EncodeFrames> {
249 let bpp = if self.i444 { 24 } else { 12 };
250 if data.len() < self.width * self.height * bpp / 8 {
251 return Err(Error::FailedCall("len not enough".to_string()));
252 }
253 let fmt = if self.i444 {
254 vpx_img_fmt::VPX_IMG_FMT_I444
255 } else {
256 vpx_img_fmt::VPX_IMG_FMT_I420
257 };
258
259 let mut image = Default::default();
260 call_vpx_ptr!(vpx_img_wrap(
261 &mut image,
262 fmt,
263 self.width as _,
264 self.height as _,
265 stride_align as _,
266 data.as_ptr() as _,
267 ));
268
269 call_vpx!(vpx_codec_encode(
270 &mut self.ctx,
271 &image,
272 pts as _,
273 1, // Duration
274 0, // Flags
275 VPX_DL_REALTIME as _,
276 ));
277
278 Ok(EncodeFrames {
279 ctx: &mut self.ctx,
280 iter: ptr::null(),
281 })
282 }
283
284 /// Notify the encoder to return any pending packets
285 pub fn flush(&mut self) -> Result<EncodeFrames> {

Callers 1

encode_to_messageMethod · 0.45

Calls 1

to_stringMethod · 0.80

Tested by

no test coverage detected