Ticket #57: 0001-Add-reading-of-disc-number-to-mov.c.patch

File 0001-Add-reading-of-disc-number-to-mov.c.patch, 2.4 KB (added by rrt, 6 years ago)
  • libavformat/mov.c

    From 7d8740ee5e38fa60b0ea2dcdd46dedd34e7ad820 Mon Sep 17 00:00:00 2001
    From: Reuben Thomas <rrt@sc3d.org>
    Date: Tue, 12 Apr 2011 18:37:57 +0100
    Subject: [PATCH] Add reading of disc number to mov.c.
    
    ---
     libavformat/mov.c |   14 ++++++++------
     1 files changed, 8 insertions(+), 6 deletions(-)
    
    diff --git a/libavformat/mov.c b/libavformat/mov.c
    index ad5d6a8..a2f3644 100644
    a b typedef struct MOVParseTableEntry { 
    7979 
    8080static const MOVParseTableEntry mov_default_parse_table[]; 
    8181 
    82 static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len) 
     82static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *type) 
    8383{ 
    8484    char buf[16]; 
    8585 
    8686    avio_rb16(pb); // unknown 
    8787    snprintf(buf, sizeof(buf), "%d", avio_rb16(pb)); 
    88     av_metadata_set2(&c->fc->metadata, "track", buf, 0); 
     88    av_metadata_set2(&c->fc->metadata, type, buf, 0); 
    8989 
    90     avio_rb16(pb); // total tracks 
     90    avio_rb16(pb); // total tracks/discs 
    9191 
    9292    return 0; 
    9393} 
    static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
    138138    const char *key = NULL; 
    139139    uint16_t str_size, langcode = 0; 
    140140    uint32_t data_type = 0; 
    141     int (*parse)(MOVContext*, AVIOContext*, unsigned) = NULL; 
     141    int (*parse)(MOVContext*, AVIOContext*, unsigned, const char *) = NULL; 
    142142 
    143143    switch (atom.type) { 
    144144    case MKTAG(0xa9,'n','a','m'): key = "title";     break; 
    static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
    161161    case MKTAG( 't','v','e','n'): key = "episode_id";break; 
    162162    case MKTAG( 't','v','n','n'): key = "network";   break; 
    163163    case MKTAG( 't','r','k','n'): key = "track"; 
    164         parse = mov_metadata_trkn; break; 
     164        parse = mov_metadata_track_or_disc_number; break; 
     165    case MKTAG( 'd','i','s','k'): key = "disc"; 
     166        parse = mov_metadata_track_or_disc_number; break; 
    165167    } 
    166168 
    167169    if (c->itunes_metadata && atom.size > 8) { 
    static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) 
    196198    str_size = FFMIN3(sizeof(str)-1, str_size, atom.size); 
    197199 
    198200    if (parse) 
    199         parse(c, pb, str_size); 
     201        parse(c, pb, str_size, key); 
    200202    else { 
    201203        if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded 
    202204            mov_read_mac_string(c, pb, str_size, str, sizeof(str));