feat: transcoder

This commit is contained in:
2024-11-11 11:31:23 +00:00
parent 8032966982
commit e4ec570239
8 changed files with 194 additions and 40 deletions

View File

@ -238,7 +238,7 @@ impl Decoder {
}
/// Flush all decoders
pub unsafe fn flush(&mut self) -> Result<Vec<(*mut AVFrame, *mut AVStream)>, Error> {
pub unsafe fn flush(&mut self) -> Result<Vec<*mut AVFrame>, Error> {
let mut pkgs = Vec::new();
for ctx in self.codecs.values_mut() {
pkgs.extend(Self::decode_pkt_internal(
@ -254,7 +254,7 @@ impl Decoder {
ctx: *mut AVCodecContext,
pkt: *mut AVPacket,
stream: *mut AVStream,
) -> Result<Vec<(*mut AVFrame, *mut AVStream)>, Error> {
) -> Result<Vec<*mut AVFrame>, Error> {
let mut ret = avcodec_send_packet(ctx, pkt);
bail_ffmpeg!(ret, "Failed to decode packet");
@ -270,7 +270,7 @@ impl Decoder {
}
(*frame).pict_type = AV_PICTURE_TYPE_NONE; // encoder prints warnings
pkgs.push((frame, stream));
pkgs.push(frame);
}
Ok(pkgs)
}
@ -279,7 +279,7 @@ impl Decoder {
&mut self,
pkt: *mut AVPacket,
stream: *mut AVStream,
) -> Result<Vec<(*mut AVFrame, *mut AVStream)>, Error> {
) -> Result<Vec<*mut AVFrame>, Error> {
if pkt.is_null() {
return self.flush();
}