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

Stefano Sabatini stefasab at gmail.com
Fri Jul 19 12:20:16 CEST 2013


On date Thursday 2013-07-18 15:45:35 +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;
>  
>      if (pkt.stream_index == video_stream_idx) {
>          /* decode video frame */
> @@ -91,6 +92,11 @@ static int decode_packet(int *got_frame, int cached)
>              fprintf(stderr, "Error decoding audio frame\n");
>              return ret;
>          }

> +        /* Some audio decoders decode only part of the packet, and have to be
> +         * called again with the remainder of the packet data.
> +         * Sample: fate-suite/lossless-audio/luckynight-partial.shn
> +         * Also, some decoders might over-read the packet. */
> +        decoded = FFMIN(ret, pkt.size);

I'm not happy about this, which I consider a bug workaround which
should be fixed in the library.

Please file a bug report so we can remove the application-level hack.
-- 
FFmpeg = Fostering & Fostering Mysterious Plastic Evil Gargoyle


More information about the ffmpeg-devel mailing list