[FFmpeg-devel] [PATCH 1/2] examples: demuxing: do partial audio packet decoding

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Jul 14 11:52:00 CEST 2013


On Sun, Jul 14, 2013 at 11:43:46AM +0200, Stefano Sabatini wrote:
> On date Saturday 2013-07-13 15:53:19 +0200, wm4 encoded:
> > This assumes one audio packet is decoded one time. This is not true:
> > packets can be partially decoded. Then you have to "adjust" the packet
> > and pass the undecoded part of the packet to the decode function again.
> > ---
> >  doc/examples/demuxing.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> > 
> > diff --git a/doc/examples/demuxing.c b/doc/examples/demuxing.c
> > index 8a1b69b..1c0f1ff 100644
> > --- a/doc/examples/demuxing.c
> > +++ b/doc/examples/demuxing.c
> > @@ -60,6 +60,7 @@ static int audio_frame_count = 0;
> >  static int decode_packet(int *got_frame, int cached)
> >  {
> >      int ret = 0;
> > +    int decoded = pkt.size;
> 
> After re-reading the docs, avcodec_decode_video2 should return the
> consumed bytes as well, so we can assume that ret will contain
> pkt.size after decoding.

NO! Maybe you meant the right thing, but "consumed bytes" can be
less than pkt.size, e.g. if there is garbage/padding or multiple
frames in one packet.
I haven't checked the surrounding code, so "consumed bytes" might
actually be better to use than pkt.size, just pointing out
that it's better to think which is more desirable instead of
assuming that they are the same.


More information about the ffmpeg-devel mailing list