[FFmpeg-devel] [PATCH] Detect DNET/byte-swapped AC-3 and support decoding it directly.

Justin Ruggles justin.ruggles
Sun Mar 6 17:58:36 CET 2011

On 03/05/2011 11:20 AM, Reimar D?ffinger wrote:

> On Sat, Mar 05, 2011 at 11:10:24AM -0500, Justin Ruggles wrote:
>> This will only work if avctx->error_recognition >= FF_ER_CAREFUL because
>> otherwise s->input_buffer is not allocated and the original buffer is
>> used directly.
>> We could move the allocation from ac3_decode_init() to
>> ac3_decode_frame() based on both error_recognition and detection of
>> byte-swapped header.
> I'll send an updated patch, however I think that code is completely
> broken.
> The only reason for that copy as I understand it is to avoid a crash.
> I don't consider it reasonable for a codec to crash.
> That is not to mention that it seems nonsense to depend on
> error_recognition, this has nothing at all to do with whether
> errors are recognized, I would suspect this is a leftover from
> the time when this was called error_resilience and it meaning was misunderstood.

I agree.  The use does not seem to fit in with the meaning of that
field.  The purpose was to avoid a crash without having to add many
buffer size checks throughout the code.  Since the maximum read amount
based solely on decoded elements from the bitstream is a known fixed
value, it is more efficient to prevent buffer overread this way.

I think removing the error_recognition condition would be fine.


More information about the ffmpeg-devel mailing list