Commit 9440e966 authored by jbr's avatar jbr

flacdec: give a more accurate error message when validating channel

layout. differentiates between invalid values and unsupported values.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18153 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent d3e39813
...@@ -483,7 +483,7 @@ static inline int decode_subframe(FLACContext *s, int channel) ...@@ -483,7 +483,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
static int decode_frame(FLACContext *s) static int decode_frame(FLACContext *s)
{ {
int bs_code, sr_code, bps_code, i; 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; GetBitContext *gb = &s->gb;
/* frame sync code */ /* frame sync code */
...@@ -496,10 +496,17 @@ static int decode_frame(FLACContext *s) ...@@ -496,10 +496,17 @@ static int decode_frame(FLACContext *s)
/* channels and decorrelation */ /* channels and decorrelation */
ch_mode = get_bits(gb, 4); ch_mode = get_bits(gb, 4);
if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) { if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) {
channels = ch_mode + 1;
ch_mode = FLAC_CHMODE_INDEPENDENT; ch_mode = FLAC_CHMODE_INDEPENDENT;
} else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) { } else if (ch_mode <= FLAC_CHMODE_MID_SIDE) {
av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", channels = 2;
ch_mode, s->channels); } 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; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment