diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2009-03-22 21:07:43 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2009-03-22 21:07:43 +0000 |
commit | 7660dc6f4f53dfff96f7702a41e4150f472bdc6a (patch) | |
tree | d3d9254b4fe7492bb27bbb10e3ec3cc8fcf7a385 /libavcodec | |
parent | d2863e72ab34338b4d3eb0b0f80d183d4b0ba4e4 (diff) | |
download | ffmpeg-7660dc6f4f53dfff96f7702a41e4150f472bdc6a.tar.gz |
flacdec: give a more accurate error message when validating channel
layout. differentiates between invalid values and unsupported values.
Originally committed as revision 18153 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/flacdec.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index b067dc561c..eea2b0e094 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -483,7 +483,7 @@ static inline int decode_subframe(FLACContext *s, int channel) static int decode_frame(FLACContext *s) { int bs_code, sr_code, bps_code, i; - int ch_mode, bps, blocksize, samplerate; + int ch_mode, bps, blocksize, samplerate, channels; GetBitContext *gb = &s->gb; /* frame sync code */ @@ -496,10 +496,17 @@ static int decode_frame(FLACContext *s) /* channels and decorrelation */ ch_mode = get_bits(gb, 4); if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) { + channels = ch_mode + 1; ch_mode = FLAC_CHMODE_INDEPENDENT; - } else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) { - av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", - ch_mode, s->channels); + } else if (ch_mode <= FLAC_CHMODE_MID_SIDE) { + channels = 2; + } else { + av_log(s->avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", ch_mode); + return -1; + } + if (channels != s->channels) { + av_log(s->avctx, AV_LOG_ERROR, "switching channel layout mid-stream " + "is not supported\n"); return -1; } |