[FFmpeg-devel] mov: extract stsd vendor field in metadata.

Submitted by liangsi on Nov. 10, 2016, 12:42 a.m.

Details

Message ID 1478738555-415-1-git-send-email-zhennihuang@google.com
State New
Headers show

Commit Message

liangsi Nov. 10, 2016, 12:42 a.m.
Also updates fate ref for rgb24-mkv as the output video will contain the
new metadata field and have different md5sum and file size.
---
 libavformat/mov.c        | 18 ++++++++++++++++--
 tests/ref/fate/rgb24-mkv |  4 ++--
 2 files changed, 18 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Nov. 10, 2016, 4:18 p.m.
On Wed, Nov 09, 2016 at 04:42:35PM -0800, Zhenni Huang wrote:
> Also updates fate ref for rgb24-mkv as the output video will contain the
> new metadata field and have different md5sum and file size.
> ---
>  libavformat/mov.c        | 18 ++++++++++++++++--
>  tests/ref/fate/rgb24-mkv |  4 ++--
>  2 files changed, 18 insertions(+), 4 deletions(-)

breaks
fate-mov-zombie
i think it needs an update too

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4222088..7ed2fcb 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1824,6 +1824,8 @@  static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
     uint8_t codec_name[32];
     int64_t stsd_start;
     unsigned int len;
+    int video_vendor_id = 0;
+    char video_vendor_id_buffer[5];
 
     /* The first 16 bytes of the video sample description are already
      * read in ff_mov_read_stsd_entries() */
@@ -1831,7 +1833,13 @@  static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
 
     avio_rb16(pb); /* version */
     avio_rb16(pb); /* revision level */
-    avio_rb32(pb); /* vendor */
+
+    /* set video_vendor_id */
+    video_vendor_id = avio_rl32(pb); /* vendor */
+    memset(video_vendor_id_buffer, 0, 5);
+    memcpy(video_vendor_id_buffer, (char*)&video_vendor_id, 4);
+    av_dict_set(&st->metadata, "vendor_id", video_vendor_id_buffer, 0);
+
     avio_rb32(pb); /* temporal quality */
     avio_rb32(pb); /* spatial quality */
 
@@ -1880,9 +1888,15 @@  static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
     int bits_per_sample, flags;
     uint16_t version = avio_rb16(pb);
     AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE);
+    int audio_vendor_id = 0;
+    char audio_vendor_id_buffer[5];
 
     avio_rb16(pb); /* revision level */
-    avio_rb32(pb); /* vendor */
+
+    audio_vendor_id = avio_rl32(pb); /* vendor */
+    memset(audio_vendor_id_buffer, 0, 5);
+    memcpy(audio_vendor_id_buffer, (char*)&audio_vendor_id, 4);
+    av_dict_set(&st->metadata, "vendor_id", audio_vendor_id_buffer, 0);
 
     st->codecpar->channels              = avio_rb16(pb); /* channel count */
     st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */
diff --git a/tests/ref/fate/rgb24-mkv b/tests/ref/fate/rgb24-mkv
index 88d22c1..ba6311d 100644
--- a/tests/ref/fate/rgb24-mkv
+++ b/tests/ref/fate/rgb24-mkv
@@ -1,5 +1,5 @@ 
-94cce0d7d5b14b4c86e74a1ca454c5aa *tests/data/fate/rgb24-mkv.matroska
-58361 tests/data/fate/rgb24-mkv.matroska
+29e4fffecb2002912fc05ed910679ce3 *tests/data/fate/rgb24-mkv.matroska
+58390 tests/data/fate/rgb24-mkv.matroska
 #tb 0: 1/10
 #media_type 0: video
 #codec_id 0: rawvideo