Mercurial > libavcodec.hg
comparison mlpdec.c @ 9350:1432fb0ee5d7 libavcodec
mlpdec: Filters and matrices may change only once per substream per access unit.
author | ramiro |
---|---|
date | Mon, 06 Apr 2009 00:58:03 +0000 |
parents | 1a3bb292b65d |
children | 54bc8a2727b0 |
comparison
equal
deleted
inserted
replaced
9349:1a3bb292b65d | 9350:1432fb0ee5d7 |
---|---|
136 | 136 |
137 SubStream substream[MAX_SUBSTREAMS]; | 137 SubStream substream[MAX_SUBSTREAMS]; |
138 | 138 |
139 ChannelParams channel_params[MAX_CHANNELS]; | 139 ChannelParams channel_params[MAX_CHANNELS]; |
140 | 140 |
141 int matrix_changed; | |
142 int filter_changed[MAX_CHANNELS][NUM_FILTERS]; | |
143 | |
141 int8_t noise_buffer[MAX_BLOCKSIZE_POW2]; | 144 int8_t noise_buffer[MAX_BLOCKSIZE_POW2]; |
142 int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS]; | 145 int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS]; |
143 int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS+2]; | 146 int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS+2]; |
144 } MLPDecodeContext; | 147 } MLPDecodeContext; |
145 | 148 |
441 int i, order; | 444 int i, order; |
442 | 445 |
443 // Filter is 0 for FIR, 1 for IIR. | 446 // Filter is 0 for FIR, 1 for IIR. |
444 assert(filter < 2); | 447 assert(filter < 2); |
445 | 448 |
449 m->filter_changed[channel][filter]++; | |
450 | |
446 order = get_bits(gbp, 4); | 451 order = get_bits(gbp, 4); |
447 if (order > max_order) { | 452 if (order > max_order) { |
448 av_log(m->avctx, AV_LOG_ERROR, | 453 av_log(m->avctx, AV_LOG_ERROR, |
449 "%cIR filter order %d is greater than maximum %d.\n", | 454 "%cIR filter order %d is greater than maximum %d.\n", |
450 fchar, order, max_order); | 455 fchar, order, max_order); |
502 static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp) | 507 static int read_matrix_params(MLPDecodeContext *m, SubStream *s, GetBitContext *gbp) |
503 { | 508 { |
504 unsigned int mat, ch; | 509 unsigned int mat, ch; |
505 | 510 |
506 s->num_primitive_matrices = get_bits(gbp, 4); | 511 s->num_primitive_matrices = get_bits(gbp, 4); |
512 m->matrix_changed++; | |
507 | 513 |
508 for (mat = 0; mat < s->num_primitive_matrices; mat++) { | 514 for (mat = 0; mat < s->num_primitive_matrices; mat++) { |
509 int frac_bits, max_chan; | 515 int frac_bits, max_chan; |
510 s->matrix_out_ch[mat] = get_bits(gbp, 4); | 516 s->matrix_out_ch[mat] = get_bits(gbp, 4); |
511 frac_bits = get_bits(gbp, 4); | 517 frac_bits = get_bits(gbp, 4); |
998 | 1004 |
999 for (substr = 0; substr <= m->max_decoded_substream; substr++) { | 1005 for (substr = 0; substr <= m->max_decoded_substream; substr++) { |
1000 SubStream *s = &m->substream[substr]; | 1006 SubStream *s = &m->substream[substr]; |
1001 init_get_bits(&gb, buf, substream_data_len[substr] * 8); | 1007 init_get_bits(&gb, buf, substream_data_len[substr] * 8); |
1002 | 1008 |
1009 m->matrix_changed = 0; | |
1010 memset(m->filter_changed, 0, sizeof(m->filter_changed)); | |
1011 | |
1003 s->blockpos = 0; | 1012 s->blockpos = 0; |
1004 do { | 1013 do { |
1014 unsigned int ch; | |
1015 | |
1005 if (get_bits1(&gb)) { | 1016 if (get_bits1(&gb)) { |
1006 if (get_bits1(&gb)) { | 1017 if (get_bits1(&gb)) { |
1007 /* A restart header should be present. */ | 1018 /* A restart header should be present. */ |
1008 if (read_restart_header(m, &gb, buf, substr) < 0) | 1019 if (read_restart_header(m, &gb, buf, substr) < 0) |
1009 goto next_substr; | 1020 goto next_substr; |
1015 } | 1026 } |
1016 | 1027 |
1017 if (read_decoding_params(m, &gb, substr) < 0) | 1028 if (read_decoding_params(m, &gb, substr) < 0) |
1018 goto next_substr; | 1029 goto next_substr; |
1019 } | 1030 } |
1031 | |
1032 if (m->matrix_changed > 1) { | |
1033 av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n"); | |
1034 goto next_substr; | |
1035 } | |
1036 for (ch = 0; ch < s->max_channel; ch++) | |
1037 if (m->filter_changed[ch][FIR] > 1 || | |
1038 m->filter_changed[ch][IIR] > 1) { | |
1039 av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n"); | |
1040 goto next_substr; | |
1041 } | |
1020 | 1042 |
1021 if (!s->restart_seen) { | 1043 if (!s->restart_seen) { |
1022 goto next_substr; | 1044 goto next_substr; |
1023 } | 1045 } |
1024 | 1046 |