OLD | NEW |
---|---|
1 /** | 1 /** |
2 * @file | 2 * @file |
3 * Vorbis I decoder | 3 * Vorbis I decoder |
4 * @author Denes Balatoni ( dbalatoni programozo hu ) | 4 * @author Denes Balatoni ( dbalatoni programozo hu ) |
5 * | 5 * |
6 * This file is part of FFmpeg. | 6 * This file is part of FFmpeg. |
7 * | 7 * |
8 * FFmpeg is free software; you can redistribute it and/or | 8 * FFmpeg is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 | 653 |
654 res_setup->type = get_bits(gb, 16); | 654 res_setup->type = get_bits(gb, 16); |
655 | 655 |
656 av_dlog(NULL, " %u. residue type %d\n", i, res_setup->type); | 656 av_dlog(NULL, " %u. residue type %d\n", i, res_setup->type); |
657 | 657 |
658 res_setup->begin = get_bits(gb, 24); | 658 res_setup->begin = get_bits(gb, 24); |
659 res_setup->end = get_bits(gb, 24); | 659 res_setup->end = get_bits(gb, 24); |
660 res_setup->partition_size = get_bits(gb, 24) + 1; | 660 res_setup->partition_size = get_bits(gb, 24) + 1; |
661 /* Validations to prevent a buffer overflow later. */ | 661 /* Validations to prevent a buffer overflow later. */ |
662 if (res_setup->begin>res_setup->end || | 662 if (res_setup->begin>res_setup->end || |
663 res_setup->end > vc->avccontext->channels * vc->blocksize[1] / 2 || | 663 res_setup->end > (res_setup->type == 2 ? vc->avccontext->channels : 1) * vc->blocksize[1] / 2 || |
rbultje1
2011/10/27 23:36:13
I'm clearly not knowledgeable enough to understand
| |
664 (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MA X_PARTITIONS) { | 664 (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MA X_PARTITIONS) { |
665 av_log(vc->avccontext, AV_LOG_ERROR, | 665 av_log(vc->avccontext, AV_LOG_ERROR, |
666 "partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n", | 666 "partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n", |
667 res_setup->type, res_setup->begin, res_setup->end, | 667 res_setup->type, res_setup->begin, res_setup->end, |
668 res_setup->partition_size, vc->blocksize[1] / 2); | 668 res_setup->partition_size, vc->blocksize[1] / 2); |
669 return -1; | 669 return -1; |
670 } | 670 } |
671 | 671 |
672 res_setup->classifications = get_bits(gb, 6) + 1; | 672 res_setup->classifications = get_bits(gb, 6) + 1; |
673 GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count) | 673 GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count) |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1461 unsigned mode_number, blockflag, blocksize; | 1461 unsigned mode_number, blockflag, blocksize; |
1462 int i, j; | 1462 int i, j; |
1463 uint8_t no_residue[255]; | 1463 uint8_t no_residue[255]; |
1464 uint8_t do_not_decode[255]; | 1464 uint8_t do_not_decode[255]; |
1465 vorbis_mapping *mapping; | 1465 vorbis_mapping *mapping; |
1466 float *ch_res_ptr = vc->channel_residues; | 1466 float *ch_res_ptr = vc->channel_residues; |
1467 float *ch_floor_ptr = vc->channel_floors; | 1467 float *ch_floor_ptr = vc->channel_floors; |
1468 uint8_t res_chan[255]; | 1468 uint8_t res_chan[255]; |
1469 unsigned res_num = 0; | 1469 unsigned res_num = 0; |
1470 int retlen = 0; | 1470 int retlen = 0; |
1471 int ch_left = vc->audio_channels; | |
1471 | 1472 |
1472 if (get_bits1(gb)) { | 1473 if (get_bits1(gb)) { |
1473 av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); | 1474 av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); |
1474 return -1; // packet type not audio | 1475 return -1; // packet type not audio |
1475 } | 1476 } |
1476 | 1477 |
1477 if (vc->mode_count == 1) { | 1478 if (vc->mode_count == 1) { |
1478 mode_number = 0; | 1479 mode_number = 0; |
1479 } else { | 1480 } else { |
1480 GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count) | 1481 GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 if (no_residue[j]) { | 1536 if (no_residue[j]) { |
1536 do_not_decode[ch] = 1; | 1537 do_not_decode[ch] = 1; |
1537 } else { | 1538 } else { |
1538 do_not_decode[ch] = 0; | 1539 do_not_decode[ch] = 0; |
1539 } | 1540 } |
1540 ++ch; | 1541 ++ch; |
1541 ++res_num; | 1542 ++res_num; |
1542 } | 1543 } |
1543 } | 1544 } |
1544 residue = &vc->residues[mapping->submap_residue[i]]; | 1545 residue = &vc->residues[mapping->submap_residue[i]]; |
1546 if (ch_left < ch) { | |
1547 av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_fl oor_decode.\n"); | |
1548 return -1; | |
1549 } | |
1545 vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocks ize/2); | 1550 vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocks ize/2); |
1546 | 1551 |
1547 ch_res_ptr += ch * blocksize / 2; | 1552 ch_res_ptr += ch * blocksize / 2; |
1553 ch_left -= ch; | |
1548 } | 1554 } |
1549 | 1555 |
1550 // Inverse coupling | 1556 // Inverse coupling |
1551 | 1557 |
1552 for (i = mapping->coupling_steps - 1; i >= 0; --i) { //warning: i has to be signed | 1558 for (i = mapping->coupling_steps - 1; i >= 0; --i) { //warning: i has to be signed |
1553 float *mag, *ang; | 1559 float *mag, *ang; |
1554 | 1560 |
1555 mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2; | 1561 mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2; |
1556 ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2; | 1562 ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2; |
1557 vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2); | 1563 vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1674 NULL, | 1680 NULL, |
1675 vorbis_decode_close, | 1681 vorbis_decode_close, |
1676 vorbis_decode_frame, | 1682 vorbis_decode_frame, |
1677 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), | 1683 .long_name = NULL_IF_CONFIG_SMALL("Vorbis"), |
1678 .channel_layouts = ff_vorbis_channel_layouts, | 1684 .channel_layouts = ff_vorbis_channel_layouts, |
1679 .sample_fmts = (const enum AVSampleFormat[]) { | 1685 .sample_fmts = (const enum AVSampleFormat[]) { |
1680 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE | 1686 AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE |
1681 }, | 1687 }, |
1682 }; | 1688 }; |
1683 | 1689 |
OLD | NEW |