Ticket #1485: quicktime_clef_tapt_support.patch

File quicktime_clef_tapt_support.patch, 2.7 KB (added by brams, 4 years ago)

Patch for Quicktime CLEF/TAPT atom support

  • libavformat/isom.h

    diff --git a/libavformat/isom.h b/libavformat/isom.h
    index 542b76b..fde15c9 100644
    a b typedef struct MOVStreamContext { 
    126126    int wrong_dts;        ///< dts are wrong due to huge ctts offset (iMovie files) 
    127127    int width;            ///< tkhd width 
    128128    int height;           ///< tkhd height 
     129    int display_width;    ///< width to override display of video 
     130    int display_height;   ///< height to override display of video 
    129131    int dts_shift;        ///< dts shift when ctts is negative 
    130132    uint32_t palette[256]; 
    131133    int has_palette; 
  • libavformat/mov.c

    diff --git a/libavformat/mov.c b/libavformat/mov.c
    index 222166e..360acf9 100644
    a b static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
    21562156                      sc->time_scale, sc->stts_data[0].duration, INT_MAX); 
    21572157    } 
    21582158 
     2159    /* 
     2160        If a display width / height are set we need to set a proper aspect 
     2161        ratio as Quicktime uses this to force the size of the video. 
     2162    */ 
     2163    if (sc->display_width) 
     2164        st->sample_aspect_ratio = av_d2q( 
     2165            ((double) sc->display_width / sc->display_height) / 
     2166            ((double) sc->width / sc->height), INT_MAX); 
     2167 
    21592168    switch (st->codec->codec_id) { 
    21602169#if CONFIG_H261_DECODER 
    21612170    case CODEC_ID_H261: 
    static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
    25922601    return 0; 
    25932602} 
    25942603 
     2604static int mov_read_clef(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
     2605{ 
     2606    /* 
     2607        Track Clean Aperture Dimensions - overrides other dimensions and 
     2608        aspect ratio information. 
     2609    */ 
     2610    unsigned int width; 
     2611    unsigned int height; 
     2612    AVStream *st; 
     2613    MOVStreamContext *sc; 
     2614 
     2615    avio_skip(pb, 2); /* flags */ 
     2616    width = avio_rb32(pb); /* cleanApertureWidth */ 
     2617    height = avio_rb32(pb); /* cleanApertureHeight */ 
     2618 
     2619    av_log(c->fc, AV_LOG_DEBUG, "clef atom read, forcing size to %ux%u\n", 
     2620           width, height); 
     2621 
     2622    if (c->fc->nb_streams < 1) 
     2623        return 0; 
     2624    st = c->fc->streams[c->fc->nb_streams-1]; 
     2625    sc = st->priv_data; 
     2626 
     2627    sc->display_width = width; 
     2628    sc->display_height = height; 
     2629 
     2630    return 0; 
     2631} 
     2632 
    25952633static const MOVParseTableEntry mov_default_parse_table[] = { 
    25962634{ MKTAG('A','P','R','G'), mov_read_aprg }, 
    25972635{ MKTAG('a','v','s','s'), mov_read_avss }, 
    static const MOVParseTableEntry mov_default_parse_table[] = { 
    26502688{ MKTAG('c','m','o','v'), mov_read_cmov }, 
    26512689{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout */ 
    26522690{ MKTAG('d','v','c','1'), mov_read_dvc1 }, 
     2691{ MKTAG('t','a','p','t'), mov_read_default }, 
     2692{ MKTAG('c','l','e','f'), mov_read_clef }, 
    26532693{ 0, NULL } 
    26542694}; 
    26552695