Permalink
Browse files

Add TV metadata patch for libav 0.7

  • Loading branch information...
Anthony Doko authored and jblache committed Aug 27, 2011
1 parent 4472f9e commit 29fe36522d8c4e567426a6cda4d16c7c631cf707
Showing with 81 additions and 0 deletions.
  1. +81 −0 ffmpeg/libav-0.7.patch
View
@@ -0,0 +1,81 @@
+--- libav/libavformat/mov.c 2011-08-09 14:03:47.622688230 -0700
++++ libav/libavformat/mov.c 2011-08-09 14:09:33.181475099 -0700
+@@ -81,19 +81,46 @@
+
+ static const MOVParseTableEntry mov_default_parse_table[];
+
+-static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len)
++static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
+ {
+ char buf[16];
+
+ avio_rb16(pb); // unknown
+ snprintf(buf, sizeof(buf), "%d", avio_rb16(pb));
+- av_dict_set(&c->fc->metadata, "track", buf, 0);
++ av_dict_set(&c->fc->metadata, key, buf, 0);
+
+ avio_rb16(pb); // total tracks
+
+ return 0;
+ }
+
++static int mov_metadata_int8(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
++{
++ char buf[16];
++
++ /* bypass padding bytes */
++ get_byte(pb);
++ get_byte(pb);
++ get_byte(pb);
++
++ snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb));
++ buf[sizeof(buf)-1] = 0;
++ av_metadata_set2(&c->fc->metadata, key, buf, 0);
++
++ return 0;
++}
++
++static int mov_metadata_stik(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
++{
++ char buf[16];
++
++ snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb));
++ buf[sizeof(buf)-1] = 0;
++ av_metadata_set2(&c->fc->metadata, key, buf, 0);
++
++ return 0;
++}
++
+ static const uint32_t mac_to_unicode[128] = {
+ 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
+ 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
+@@ -140,7 +167,7 @@
+ const char *key = NULL;
+ uint16_t str_size, langcode = 0;
+ uint32_t data_type = 0;
+- int (*parse)(MOVContext*, AVIOContext*, unsigned) = NULL;
++ int (*parse)(MOVContext*, AVIOContext*, unsigned, const char *) = NULL;
+
+ switch (atom.type) {
+ case MKTAG(0xa9,'n','a','m'): key = "title"; break;
+@@ -162,6 +189,11 @@
+ case MKTAG( 't','v','s','h'): key = "show"; break;
+ case MKTAG( 't','v','e','n'): key = "episode_id";break;
+ case MKTAG( 't','v','n','n'): key = "network"; break;
++ case MKTAG( 't','v','e','s'): key = "episode_sort";
++ case MKTAG( 't','v','s','n'): key = "season_number";
++ parse = mov_metadata_int8; break;
++ case MKTAG( 's','t','i','k'): key = "stik";
++ parse = mov_metadata_stik; break;
+ case MKTAG( 't','r','k','n'): key = "track";
+ parse = mov_metadata_trkn; break;
+ }
+@@ -198,7 +230,7 @@
+ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
+
+ if (parse)
+- parse(c, pb, str_size);
++ parse(c, pb, str_size, key);
+ else {
+ if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
+ mov_read_mac_string(c, pb, str_size, str, sizeof(str));

0 comments on commit 29fe365

Please sign in to comment.