[FFmpeg-devel] [RFC] ac3dec error handling

Reimar Döffinger Reimar.Doeffinger
Sun Jan 24 14:05:47 CET 2010


Hello,
currently ac3dec will handle decode errors by just re-copying the previous
block data and not giving any indication to the application at all.
I think that's no good and below is a proposal that includes two different
(combinable) ways of doing it
1) return only the data that was decoded without issue
2) return -1 if we hit an error
Seems to fix some annoying blips I can hear after seeking in DVDs with MPlayer
(I admit that this is probably an issue in MPlayer, consider it just
an easy way of creating broken AC3 frames).

Index: libavcodec/ac3dec.c
===================================================================
--- libavcodec/ac3dec.c	(revision 21414)
+++ libavcodec/ac3dec.c	(working copy)
@@ -1315,15 +1315,17 @@
     for (ch = 0; ch < s->out_channels; ch++)
         output[ch] = s->output[channel_map[ch]];
     for (blk = 0; blk < s->num_blocks; blk++) {
-        if (!err && decode_audio_block(s, blk)) {
+        if (decode_audio_block(s, blk)) {
             av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
             err = 1;
+            s->num_blocks = blk;
+            break;
         }
         s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
         out_samples += 256 * s->out_channels;
     }
     *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
-    return s->frame_size;
+    return err ? -1 : s->frame_size;
 }
 
 /**




More information about the ffmpeg-devel mailing list