Mercurial > libavcodec.hg
comparison mlpdec.c @ 9531:19a70bcc2220 libavcodec
mlpdec: Validate max_channel and max_matrix_channel.
author | ramiro |
---|---|
date | Tue, 21 Apr 2009 22:12:30 +0000 |
parents | dbb16aa52d43 |
children | 2aabf1a58f19 |
comparison
equal
deleted
inserted
replaced
9530:dbb16aa52d43 | 9531:19a70bcc2220 |
---|---|
333 unsigned int ch; | 333 unsigned int ch; |
334 int sync_word, tmp; | 334 int sync_word, tmp; |
335 uint8_t checksum; | 335 uint8_t checksum; |
336 uint8_t lossless_check; | 336 uint8_t lossless_check; |
337 int start_count = get_bits_count(gbp); | 337 int start_count = get_bits_count(gbp); |
338 const int max_matrix_channel = m->avctx->codec_id == CODEC_ID_MLP | |
339 ? MAX_MATRIX_CHANNEL_MLP | |
340 : MAX_MATRIX_CHANNEL_TRUEHD; | |
338 | 341 |
339 sync_word = get_bits(gbp, 13); | 342 sync_word = get_bits(gbp, 13); |
340 s->noise_type = get_bits1(gbp); | 343 s->noise_type = get_bits1(gbp); |
341 | 344 |
342 if ((m->avctx->codec_id == CODEC_ID_MLP && s->noise_type) || | 345 if ((m->avctx->codec_id == CODEC_ID_MLP && s->noise_type) || |
349 skip_bits(gbp, 16); /* Output timestamp */ | 352 skip_bits(gbp, 16); /* Output timestamp */ |
350 | 353 |
351 s->min_channel = get_bits(gbp, 4); | 354 s->min_channel = get_bits(gbp, 4); |
352 s->max_channel = get_bits(gbp, 4); | 355 s->max_channel = get_bits(gbp, 4); |
353 s->max_matrix_channel = get_bits(gbp, 4); | 356 s->max_matrix_channel = get_bits(gbp, 4); |
357 | |
358 if (s->max_matrix_channel > max_matrix_channel) { | |
359 av_log(m->avctx, AV_LOG_ERROR, | |
360 "Max matrix channel cannot be greater than %d.\n", | |
361 max_matrix_channel); | |
362 return -1; | |
363 } | |
364 | |
365 if (s->max_channel != s->max_matrix_channel) { | |
366 av_log(m->avctx, AV_LOG_ERROR, | |
367 "Max channel must be equal max matrix channel.\n"); | |
368 return -1; | |
369 } | |
354 | 370 |
355 if (s->min_channel > s->max_channel) { | 371 if (s->min_channel > s->max_channel) { |
356 av_log(m->avctx, AV_LOG_ERROR, | 372 av_log(m->avctx, AV_LOG_ERROR, |
357 "Substream min channel cannot be greater than max channel.\n"); | 373 "Substream min channel cannot be greater than max channel.\n"); |
358 return -1; | 374 return -1; |