diff options
author | Reimar Döffinger | 2011-03-22 14:22:07 -0400 |
---|---|---|
committer | Justin Ruggles | 2011-03-22 15:36:47 -0400 |
commit | 4c886d613df8b217c6d62cb2c94e88f848177b23 (patch) | |
tree | a5028e8aac64421591bda1f73dbb78bcda33a58d /libavcodec | |
parent | 40728b5169f23a6420b3d9758f485fd2cd99050d (diff) |
Detect byte-swapped AC-3 and support decoding it directly.
This allows the AC-3 decoder to be used directly with RealMedia
decoders that unlike the libavformat one do not byte-swap automatically.
Since the new code is only used in case we would fail directly otherwise
there should be no risk for regressions.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3dec.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index a9a67ced33..071cc6a54f 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1314,6 +1314,11 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, /* copy input buffer to decoder context to avoid reading past the end of the buffer, which can be caused by a damaged input stream. */ + if (buf_size >= 2 && AV_RB16(buf) == 0x770B) { + // seems to be byte-swapped AC-3 + int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1; + s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt); + } else memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE)); buf = s->input_buffer; /* initialize the GetBitContext with the start of valid AC-3 Frame */ |