| @@ -221,9 +221,11 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream *st) · 220 unmodified lines |
| 221 | channels += avio_r8(pb); | 221 | channels += avio_r8(pb); |
| 222 | avio_skip(pb, 3); | 222 | avio_skip(pb, 3); |
| 223 | } | 223 | } |
| 224 | st->codecpar->channels = channels; | 224 | av_channel_layout_uninit(&st->codecpar->ch_layout); |
| | 225 | st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; |
| | 226 | st->codecpar->ch_layout.nb_channels = channels; |
| 225 | | 227 | |
| 226 | if (st->codecpar->channels <= 0 || st->codecpar->sample_rate <= 0) | 228 | if (st->codecpar->ch_layout.nb_channels <= 0 || st->codecpar->sample_rate <= 0) |
| 227 | return AVERROR_INVALIDDATA; | 229 | return AVERROR_INVALIDDATA; |
| 228 | | 230 | |
| 229 | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); | 231 | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); |
| @@ -611,15 +613,15 @@ break_loop: · 381 unmodified lines |
| 611 | | 613 | |
| 612 | if ( st->codecpar->bit_rate > 0 && data_size > 0 | 614 | if ( st->codecpar->bit_rate > 0 && data_size > 0 |
| 613 | && st->codecpar->sample_rate > 0 | 615 | && st->codecpar->sample_rate > 0 |
| 614 | && sample_count > 0 && st->codecpar->channels > 1 | 616 | && sample_count > 0 && st->codecpar->ch_layout.nb_channels > 1 |
| 615 | && sample_count % st->codecpar->channels == 0) { | 617 | && sample_count % st->codecpar->ch_layout.nb_channels == 0) { |
| 616 | if (fabs(8.0 * data_size * st->codecpar->channels * st->codecpar->sample_rate / | 618 | if (fabs(8.0 * data_size * st->codecpar->ch_layout.nb_channels * st->codecpar->sample_rate / |
| 617 | sample_count /st->codecpar->bit_rate - 1.0) < 0.3) | 619 | sample_count /st->codecpar->bit_rate - 1.0) < 0.3) |
| 618 | sample_count /= st->codecpar->channels; | 620 | sample_count /= st->codecpar->ch_layout.nb_channels; |
| 619 | } | 621 | } |
| 620 | | 622 | |
| 621 | if ( data_size > 0 && sample_count && st->codecpar->channels | 623 | if (data_size > 0 && sample_count && st->codecpar->ch_layout.nb_channels && |
| 622 | && (data_size << 3) / sample_count / st->codecpar->channels > st->codecpar->bits_per_coded_sample + 1) { | 624 | (data_size << 3) / sample_count / st->codecpar->ch_layout.nb_channels > st->codecpar->bits_per_coded_sample + 1) { |
| 623 | av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); | 625 | av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count); |
| 624 | sample_count = 0; | 626 | sample_count = 0; |
| 625 | } | 627 | } |
| @@ -632,34 +634,34 @@ break_loop: · 6 unmodified lines |
| 632 | } | 634 | } |
| 633 | | 635 | |
| 634 | if (!sample_count || av_get_exact_bits_per_sample(st->codecpar->codec_id) > 0) | 636 | if (!sample_count || av_get_exact_bits_per_sample(st->codecpar->codec_id) > 0) |
| 635 | if ( st->codecpar->channels | 637 | if ( st->codecpar->ch_layout.nb_channels |
| 636 | && data_size | 638 | && data_size |
| 637 | && av_get_bits_per_sample(st->codecpar->codec_id) | 639 | && av_get_bits_per_sample(st->codecpar->codec_id) |
| 638 | && wav->data_end <= avio_size(pb)) | 640 | && wav->data_end <= avio_size(pb)) |
| 639 | sample_count = (data_size << 3) | 641 | sample_count = (data_size << 3) |
| 640 | / | 642 | / |
| 641 | (st->codecpar->channels * (uint64_t)av_get_bits_per_sample(st->codecpar->codec_id)); | 643 | (st->codecpar->ch_layout.nb_channels * (uint64_t)av_get_bits_per_sample(st->codecpar->codec_id)); |
| 642 | | 644 | |
| 643 | if (sample_count) | 645 | if (sample_count) |
| 644 | st->duration = sample_count; | 646 | st->duration = sample_count; |
| 645 | | 647 | |
| 646 | if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S32LE && | 648 | if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S32LE && |
| 647 | st->codecpar->block_align == st->codecpar->channels * 4 && | 649 | st->codecpar->block_align == st->codecpar->ch_layout.nb_channels * 4 && |
| 648 | st->codecpar->bits_per_coded_sample == 32 && | 650 | st->codecpar->bits_per_coded_sample == 32 && |
| 649 | st->codecpar->extradata_size == 2 && | 651 | st->codecpar->extradata_size == 2 && |
| 650 | AV_RL16(st->codecpar->extradata) == 1) { | 652 | AV_RL16(st->codecpar->extradata) == 1) { |
| 651 | st->codecpar->codec_id = AV_CODEC_ID_PCM_F16LE; | 653 | st->codecpar->codec_id = AV_CODEC_ID_PCM_F16LE; |
| 652 | st->codecpar->bits_per_coded_sample = 16; | 654 | st->codecpar->bits_per_coded_sample = 16; |
| 653 | } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE && | 655 | } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE && |
| 654 | st->codecpar->block_align == st->codecpar->channels * 4 && | 656 | st->codecpar->block_align == st->codecpar->ch_layout.nb_channels * 4 && |
| 655 | st->codecpar->bits_per_coded_sample == 24) { | 657 | st->codecpar->bits_per_coded_sample == 24) { |
| 656 | st->codecpar->codec_id = AV_CODEC_ID_PCM_F24LE; | 658 | st->codecpar->codec_id = AV_CODEC_ID_PCM_F24LE; |
| 657 | } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 || | 659 | } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 || |
| 658 | st->codecpar->codec_id == AV_CODEC_ID_XMA2) { | 660 | st->codecpar->codec_id == AV_CODEC_ID_XMA2) { |
| 659 | st->codecpar->block_align = 2048; | 661 | st->codecpar->block_align = 2048; |
| 660 | } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2 && | 662 | } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->ch_layout.nb_channels > 2 && |
| 661 | st->codecpar->block_align < INT_MAX / st->codecpar->channels) { | 663 | st->codecpar->block_align < INT_MAX / st->codecpar->ch_layout.nb_channels) { |
| 662 | st->codecpar->block_align *= st->codecpar->channels; | 664 | st->codecpar->block_align *= st->codecpar->ch_layout.nb_channels; |
| 663 | } | 665 | } |
| 664 | | 666 | |
| 665 | ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); | 667 | ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); |