Commit 6bae23c6 authored by bcoudurier's avatar bcoudurier

fix trkn metadata parsing

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18001 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 2f132b0e
...@@ -79,6 +79,19 @@ typedef struct MOVParseTableEntry { ...@@ -79,6 +79,19 @@ typedef struct MOVParseTableEntry {
static const MOVParseTableEntry mov_default_parse_table[]; static const MOVParseTableEntry mov_default_parse_table[];
static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
{
char buf[16];
get_be16(pb); // unknown
snprintf(buf, sizeof(buf), "%d", get_be16(pb));
av_metadata_set(&c->fc->metadata, "track", buf);
get_be16(pb); // total tracks
return 0;
}
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{ {
#ifdef MOV_EXPORT_ALL_METADATA #ifdef MOV_EXPORT_ALL_METADATA
...@@ -87,6 +100,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -87,6 +100,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
char str[1024], key2[16], language[4] = {0}; char str[1024], key2[16], language[4] = {0};
const char *key = NULL; const char *key = NULL;
uint16_t str_size; uint16_t str_size;
int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL;
switch (atom.type) { switch (atom.type) {
case MKTAG(0xa9,'n','a','m'): key = "title"; break; case MKTAG(0xa9,'n','a','m'): key = "title"; break;
...@@ -101,6 +115,8 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -101,6 +115,8 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
case MKTAG(0xa9,'g','e','n'): key = "genre"; break; case MKTAG(0xa9,'g','e','n'): key = "genre"; break;
case MKTAG(0xa9,'t','o','o'): case MKTAG(0xa9,'t','o','o'):
case MKTAG(0xa9,'e','n','c'): key = "muxer"; break; case MKTAG(0xa9,'e','n','c'): key = "muxer"; break;
case MKTAG( 't','r','k','n'): key = "track";
parse = mov_metadata_trkn; break;
} }
if (c->itunes_metadata && atom.size > 8) { if (c->itunes_metadata && atom.size > 8) {
...@@ -132,6 +148,10 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -132,6 +148,10 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return -1; return -1;
str_size = FFMIN3(sizeof(str)-1, str_size, atom.size); str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
if (parse)
parse(c, pb, str_size);
else {
get_buffer(pb, str, str_size); get_buffer(pb, str, str_size);
str[str_size] = 0; str[str_size] = 0;
av_metadata_set(&c->fc->metadata, key, str); av_metadata_set(&c->fc->metadata, key, str);
...@@ -139,6 +159,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -139,6 +159,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
snprintf(key2, sizeof(key2), "%s-%s", key, language); snprintf(key2, sizeof(key2), "%s-%s", key, language);
av_metadata_set(&c->fc->metadata, key2, str); av_metadata_set(&c->fc->metadata, key2, str);
} }
}
#ifdef DEBUG_METADATA #ifdef DEBUG_METADATA
av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language); av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language);
av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n", av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n",
...@@ -1428,17 +1449,6 @@ static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -1428,17 +1449,6 @@ static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return 0; return 0;
} }
static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
char track[16];
get_be32(pb); // type
get_be32(pb); // unknown
snprintf(track, sizeof(track), "%d", get_be32(pb));
av_metadata_set(&c->fc->metadata, "track", track);
dprintf(c->fc, "%.4s %s\n", (char*)&atom.type, track);
return 0;
}
static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{ {
int i; int i;
...@@ -1790,7 +1800,6 @@ static const MOVParseTableEntry mov_default_parse_table[] = { ...@@ -1790,7 +1800,6 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('t','r','a','k'), mov_read_trak }, { MKTAG('t','r','a','k'), mov_read_trak },
{ MKTAG('t','r','a','f'), mov_read_default }, { MKTAG('t','r','a','f'), mov_read_default },
{ MKTAG('t','r','e','x'), mov_read_trex }, { MKTAG('t','r','e','x'), mov_read_trex },
{ MKTAG('t','r','k','n'), mov_read_trkn },
{ MKTAG('t','r','u','n'), mov_read_trun }, { MKTAG('t','r','u','n'), mov_read_trun },
{ MKTAG('u','d','t','a'), mov_read_default }, { MKTAG('u','d','t','a'), mov_read_default },
{ MKTAG('w','a','v','e'), mov_read_wave }, { MKTAG('w','a','v','e'), mov_read_wave },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment