Commit 77328b1c authored by ramiro's avatar ramiro

mlpdec: Validate max_channel and max_matrix_channel.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18649 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent ce58f7cb
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "avcodec.h" #include "avcodec.h"
/** Last possible matrix channel for each codec */
#define MAX_MATRIX_CHANNEL_MLP 5
#define MAX_MATRIX_CHANNEL_TRUEHD 7
/** Maximum number of channels that can be decoded. */ /** Maximum number of channels that can be decoded. */
#define MAX_CHANNELS 16 #define MAX_CHANNELS 16
......
...@@ -335,6 +335,9 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, ...@@ -335,6 +335,9 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
uint8_t checksum; uint8_t checksum;
uint8_t lossless_check; uint8_t lossless_check;
int start_count = get_bits_count(gbp); int start_count = get_bits_count(gbp);
const int max_matrix_channel = m->avctx->codec_id == CODEC_ID_MLP
? MAX_MATRIX_CHANNEL_MLP
: MAX_MATRIX_CHANNEL_TRUEHD;
sync_word = get_bits(gbp, 13); sync_word = get_bits(gbp, 13);
s->noise_type = get_bits1(gbp); s->noise_type = get_bits1(gbp);
...@@ -352,6 +355,19 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, ...@@ -352,6 +355,19 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
s->max_channel = get_bits(gbp, 4); s->max_channel = get_bits(gbp, 4);
s->max_matrix_channel = get_bits(gbp, 4); s->max_matrix_channel = get_bits(gbp, 4);
if (s->max_matrix_channel > max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Max matrix channel cannot be greater than %d.\n",
max_matrix_channel);
return -1;
}
if (s->max_channel != s->max_matrix_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Max channel must be equal max matrix channel.\n");
return -1;
}
if (s->min_channel > s->max_channel) { if (s->min_channel > s->max_channel) {
av_log(m->avctx, AV_LOG_ERROR, av_log(m->avctx, AV_LOG_ERROR,
"Substream min channel cannot be greater than max channel.\n"); "Substream min channel cannot be greater than max channel.\n");
......
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