Revision c6026e43

View differences:

libavformat/mov.c
79 79

  
80 80
static const MOVParseTableEntry mov_default_parse_table[];
81 81

  
82
static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
83
{
84
    char buf[16];
85

  
86
    get_be16(pb); // unknown
87
    snprintf(buf, sizeof(buf), "%d", get_be16(pb));
88
    av_metadata_set(&c->fc->metadata, "track", buf);
89

  
90
    get_be16(pb); // total tracks
91

  
92
    return 0;
93
}
94

  
82 95
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
83 96
{
84 97
#ifdef MOV_EXPORT_ALL_METADATA
......
87 100
    char str[1024], key2[16], language[4] = {0};
88 101
    const char *key = NULL;
89 102
    uint16_t str_size;
103
    int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL;
90 104

  
91 105
    switch (atom.type) {
92 106
    case MKTAG(0xa9,'n','a','m'): key = "title";     break;
......
101 115
    case MKTAG(0xa9,'g','e','n'): key = "genre";     break;
102 116
    case MKTAG(0xa9,'t','o','o'):
103 117
    case MKTAG(0xa9,'e','n','c'): key = "muxer";     break;
118
    case MKTAG( 't','r','k','n'): key = "track";
119
        parse = mov_metadata_trkn; break;
104 120
    }
105 121

  
106 122
    if (c->itunes_metadata && atom.size > 8) {
......
132 148
        return -1;
133 149

  
134 150
    str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
151

  
152
    if (parse)
153
        parse(c, pb, str_size);
154
    else {
135 155
    get_buffer(pb, str, str_size);
136 156
    str[str_size] = 0;
137 157
    av_metadata_set(&c->fc->metadata, key, str);
......
139 159
        snprintf(key2, sizeof(key2), "%s-%s", key, language);
140 160
        av_metadata_set(&c->fc->metadata, key2, str);
141 161
    }
162
    }
142 163
#ifdef DEBUG_METADATA
143 164
    av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language);
144 165
    av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n",
......
1428 1449
    return 0;
1429 1450
}
1430 1451

  
1431
static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1432
{
1433
    char track[16];
1434
    get_be32(pb); // type
1435
    get_be32(pb); // unknown
1436
    snprintf(track, sizeof(track), "%d", get_be32(pb));
1437
    av_metadata_set(&c->fc->metadata, "track", track);
1438
    dprintf(c->fc, "%.4s %s\n", (char*)&atom.type, track);
1439
    return 0;
1440
}
1441

  
1442 1452
static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1443 1453
{
1444 1454
    int i;
......
1790 1800
{ MKTAG('t','r','a','k'), mov_read_trak },
1791 1801
{ MKTAG('t','r','a','f'), mov_read_default },
1792 1802
{ MKTAG('t','r','e','x'), mov_read_trex },
1793
{ MKTAG('t','r','k','n'), mov_read_trkn },
1794 1803
{ MKTAG('t','r','u','n'), mov_read_trun },
1795 1804
{ MKTAG('u','d','t','a'), mov_read_default },
1796 1805
{ MKTAG('w','a','v','e'), mov_read_wave },

Also available in: Unified diff