Revision aa9380c8 libavformat/riff.c

View differences:

libavformat/riff.c
492 492

  
493 493
    id = avio_rl16(pb);
494 494
    codec->codec_type = AVMEDIA_TYPE_AUDIO;
495
    codec->codec_tag = id;
496 495
    codec->channels = avio_rl16(pb);
497 496
    codec->sample_rate = avio_rl32(pb);
498 497
    codec->bit_rate = avio_rl32(pb) * 8;
......
501 500
        codec->bits_per_coded_sample = 8;
502 501
    }else
503 502
        codec->bits_per_coded_sample = avio_rl16(pb);
503
    if (id == 0xFFFE) {
504
        codec->codec_tag = 0;
505
    } else {
506
        codec->codec_tag = id;
507
        codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
508
    }
504 509
    if (size >= 18) {  /* We're obviously dealing with WAVEFORMATEX */
505 510
        int cbSize = avio_rl16(pb); /* cbSize */
506 511
        size -= 18;
507 512
        cbSize = FFMIN(size, cbSize);
508 513
        if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
514
            ff_asf_guid subformat;
509 515
            codec->bits_per_coded_sample = avio_rl16(pb);
510 516
            codec->channel_layout = avio_rl32(pb); /* dwChannelMask */
511
            id = avio_rl32(pb); /* 4 first bytes of GUID */
512
            avio_skip(pb, 12); /* skip end of GUID */
517
            ff_get_guid(pb, &subformat);
518
            if (!memcmp(subformat + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
519
                codec->codec_tag = AV_RL32(subformat);
520
                codec->codec_id = ff_wav_codec_get_id(codec->codec_tag, codec->bits_per_coded_sample);
521
            } else {
522
                codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
523
                if (!codec->codec_id)
524
                    av_log(codec, AV_LOG_WARNING, "unknown subformat:"FF_PRI_GUID"\n", FF_ARG_GUID(subformat));
525
            }
513 526
            cbSize -= 22;
514 527
            size -= 22;
515 528
        }
......
524 537
        if (size > 0)
525 538
            avio_skip(pb, size);
526 539
    }
527
    codec->codec_id = ff_wav_codec_get_id(id, codec->bits_per_coded_sample);
528 540
    if (codec->codec_id == CODEC_ID_AAC_LATM) {
529 541
        /* channels and sample_rate values are those prior to applying SBR and/or PS */
530 542
        codec->channels    = 0;

Also available in: Unified diff