Ticket #4251: libavformat-quicktime-32bit-audio-fix.diff

File libavformat-quicktime-32bit-audio-fix.diff, 1.7 KB (added by Richard Goedeken, 12 years ago)

avformat code patch to fix parsing error

  • libavformat/mov.c

    old new  
    13631363}
    13641364
    13651365static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
    1366                                  AVStream *st, MOVStreamContext *sc)
     1366                                 AVStream *st, MOVStreamContext *sc, int is_pcm)
    13671367{
    13681368    int bits_per_sample, flags;
    13691369    uint16_t version = avio_rb16(pb);
     
    13881388
    13891389        if (version == 1) {
    13901390            sc->samples_per_frame = avio_rb32(pb);
    1391             avio_rb32(pb); /* bytes per packet */
     1391            if (is_pcm)
     1392            {
     1393                // hack hack hack because Apple screwed us with QT3
     1394                st->codec->bits_per_coded_sample = avio_rb32(pb) * 8;
     1395                st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample,
     1396                                                               0x06);  // signed, big-endian
     1397            }
     1398            else
     1399            {
     1400                avio_rb32(pb); /* bytes per packet */
     1401            }
    13921402            sc->bytes_per_frame = avio_rb32(pb);
    13931403            avio_rb32(pb); /* bytes per sample */
    13941404        } else if (version == 2) {
     
    17091719            mov_parse_stsd_video(c, pb, st, sc);
    17101720        } else if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
    17111721            st->codec->codec_id = id;
    1712             mov_parse_stsd_audio(c, pb, st, sc);
     1722            int is_pcm = (format == MKTAG('l','p','c','m'));
     1723            mov_parse_stsd_audio(c, pb, st, sc, is_pcm);
    17131724        } else if (st->codec->codec_type==AVMEDIA_TYPE_SUBTITLE){
    17141725            st->codec->codec_id = id;
    17151726            mov_parse_stsd_subtitle(c, pb, st, sc,