Mercurial > libavcodec.hg
comparison dca.c @ 6463:9f397992ddff libavcodec
Don't use unchecked data from the bitstream.
| author | banan |
|---|---|
| date | Thu, 06 Mar 2008 14:22:02 +0000 |
| parents | 8e63d869a904 |
| children | 48759bfbd073 |
comparison
equal
deleted
inserted
replaced
| 6462:745a4216b352 | 6463:9f397992ddff |
|---|---|
| 123 int surround_sum; ///< surround sum/difference flag | 123 int surround_sum; ///< surround sum/difference flag |
| 124 int dialog_norm; ///< dialog normalisation parameter | 124 int dialog_norm; ///< dialog normalisation parameter |
| 125 | 125 |
| 126 /* Primary audio coding header */ | 126 /* Primary audio coding header */ |
| 127 int subframes; ///< number of subframes | 127 int subframes; ///< number of subframes |
| 128 int total_channels; ///< number of channels including extensions | |
| 128 int prim_channels; ///< number of primary audio channels | 129 int prim_channels; ///< number of primary audio channels |
| 129 int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count | 130 int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count |
| 130 int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband | 131 int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband |
| 131 int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index | 132 int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index |
| 132 int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book | 133 int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book |
| 318 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | 319 av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
| 319 #endif | 320 #endif |
| 320 | 321 |
| 321 /* Primary audio coding header */ | 322 /* Primary audio coding header */ |
| 322 s->subframes = get_bits(&s->gb, 4) + 1; | 323 s->subframes = get_bits(&s->gb, 4) + 1; |
| 323 s->prim_channels = get_bits(&s->gb, 3) + 1; | 324 s->total_channels = get_bits(&s->gb, 3) + 1; |
| 325 s->prim_channels = s->total_channels; | |
| 326 if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) | |
| 327 s->prim_channels = DCA_PRIM_CHANNELS_MAX; /* We only support DTS core */ | |
| 324 | 328 |
| 325 | 329 |
| 326 for (i = 0; i < s->prim_channels; i++) { | 330 for (i = 0; i < s->prim_channels; i++) { |
| 327 s->subband_activity[i] = get_bits(&s->gb, 5) + 2; | 331 s->subband_activity[i] = get_bits(&s->gb, 5) + 2; |
| 328 if (s->subband_activity[i] > DCA_SUBBANDS) | 332 if (s->subband_activity[i] > DCA_SUBBANDS) |
| 425 for (k = 0; k < s->vq_start_subband[j]; k++) { | 429 for (k = 0; k < s->vq_start_subband[j]; k++) { |
| 426 if (s->bitalloc_huffman[j] == 6) | 430 if (s->bitalloc_huffman[j] == 6) |
| 427 s->bitalloc[j][k] = get_bits(&s->gb, 5); | 431 s->bitalloc[j][k] = get_bits(&s->gb, 5); |
| 428 else if (s->bitalloc_huffman[j] == 5) | 432 else if (s->bitalloc_huffman[j] == 5) |
| 429 s->bitalloc[j][k] = get_bits(&s->gb, 4); | 433 s->bitalloc[j][k] = get_bits(&s->gb, 4); |
| 430 else { | 434 else if (s->bitalloc_huffman[j] == 7) { |
| 435 av_log(s->avctx, AV_LOG_ERROR, | |
| 436 "Invalid bit allocation index\n"); | |
| 437 return -1; | |
| 438 } else { | |
| 431 s->bitalloc[j][k] = | 439 s->bitalloc[j][k] = |
| 432 get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); | 440 get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); |
| 433 } | 441 } |
| 434 | 442 |
| 435 if (s->bitalloc[j][k] > 26) { | 443 if (s->bitalloc[j][k] > 26) { |
