aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-28 13:29:23 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-28 13:29:29 +0200
commit7fe88bc66c8d1a03a1a64a2bf9984bc173b203f1 (patch)
tree4f254865812166ec269b99abfca1098e3bd26743
parent333e708520a53df727d951a0672829d1d5414b07 (diff)
parent26605efed72e70edabc999e819961f9628450212 (diff)
downloadffmpeg-7fe88bc66c8d1a03a1a64a2bf9984bc173b203f1.tar.gz
Merge remote-tracking branch 'qatar/release/9' into release/1.1
* qatar/release/9: ac3: Return proper error codes ac3: Clean up the error paths ac3: Do not clash with normal AVERROR Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/aac_ac3_parser.h14
-rw-r--r--libavcodec/ac3dec.c39
2 files changed, 28 insertions, 25 deletions
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index ca49d2fc2a..c2506a5bfd 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -28,13 +28,13 @@
#include "parser.h"
typedef enum {
- AAC_AC3_PARSE_ERROR_SYNC = -1,
- AAC_AC3_PARSE_ERROR_BSID = -2,
- AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -3,
- AAC_AC3_PARSE_ERROR_FRAME_SIZE = -4,
- AAC_AC3_PARSE_ERROR_FRAME_TYPE = -5,
- AAC_AC3_PARSE_ERROR_CRC = -6,
- AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -7,
+ AAC_AC3_PARSE_ERROR_SYNC = -0x1030c0a,
+ AAC_AC3_PARSE_ERROR_BSID = -0x2030c0a,
+ AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
+ AAC_AC3_PARSE_ERROR_FRAME_SIZE = -0x4030c0a,
+ AAC_AC3_PARSE_ERROR_FRAME_TYPE = -0x5030c0a,
+ AAC_AC3_PARSE_ERROR_CRC = -0x6030c0a,
+ AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -0x7030c0a,
} AACAC3ParseError;
typedef struct AACAC3ParseContext {
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ca8d24e084..efec001c01 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -292,7 +292,7 @@ static int parse_frame_header(AC3DecodeContext *s)
return ff_eac3_parse_header(s);
} else {
av_log(s->avctx, AV_LOG_ERROR, "E-AC-3 support not compiled in\n");
- return -1;
+ return AVERROR(ENOSYS);
}
}
@@ -787,12 +787,12 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (start_subband >= end_subband) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"range (%d >= %d)\n", start_subband, end_subband);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (dst_start_freq >= src_start_freq) {
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->spx_dst_start_freq = dst_start_freq;
@@ -869,7 +869,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (channel_mode < AC3_CHMODE_STEREO) {
av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* check for enhanced coupling */
@@ -899,7 +899,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (cpl_start_subband >= cpl_end_subband) {
av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
cpl_start_subband, cpl_end_subband);
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
s->end_freq[CPL_CH] = cpl_end_subband * 12 + 37;
@@ -921,7 +921,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
if (!blk) {
av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
"be present in block 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
} else {
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
}
@@ -951,7 +951,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
} else if (!blk) {
av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
"be present in block 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
} else {
/* channel not in coupling */
@@ -1006,7 +1006,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
int bandwidth_code = get_bits(gbc, 6);
if (bandwidth_code > 60) {
av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code);
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->end_freq[ch] = bandwidth_code * 3 + 73;
}
@@ -1029,7 +1029,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s->num_exp_groups[ch], s->dexps[ch][0],
&s->dexps[ch][s->start_freq[ch]+!!ch])) {
av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (ch != CPL_CH && ch != s->lfe_ch)
skip_bits(gbc, 2); /* skip gainrng */
@@ -1049,7 +1049,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
} else if (!blk) {
av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
"be present in block 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
@@ -1080,7 +1080,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
}
} else if (!s->eac3 && !blk) {
av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
@@ -1119,7 +1119,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
} else if (!s->eac3 && !blk) {
av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
"be present in block 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->first_cpl_leak = 0;
}
@@ -1131,7 +1131,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s->dba_mode[ch] = get_bits(gbc, 2);
if (s->dba_mode[ch] == DBA_RESERVED) {
av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
}
@@ -1172,7 +1172,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s->dba_offsets[ch], s->dba_lengths[ch],
s->dba_values[ch], s->mask[ch])) {
av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
if (bit_alloc_stages[ch] > 0) {
@@ -1291,7 +1291,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
switch (err) {
case AAC_AC3_PARSE_ERROR_SYNC:
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
- return -1;
+ return AVERROR_INVALIDDATA;
case AAC_AC3_PARSE_ERROR_BSID:
av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
break;
@@ -1305,7 +1305,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
/* skip frame if CRC is ok. otherwise use error concealment. */
/* TODO: add support for substreams and dependent frames */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
- av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "
+ av_log(avctx, AV_LOG_WARNING, "unsupported frame type : "
"skipping frame\n");
*got_frame_ptr = 0;
return buf_size;
@@ -1313,9 +1313,12 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
}
break;
- default:
- av_log(avctx, AV_LOG_ERROR, "invalid header\n");
+ case AAC_AC3_PARSE_ERROR_CRC:
+ case AAC_AC3_PARSE_ERROR_CHANNEL_CFG:
break;
+ default: // Normal AVERROR do not try to recover.
+ *got_frame_ptr = 0;
+ return err;
}
} else {
/* check that reported frame size fits in input buffer */