[FFmpeg-cvslog] movenc: write the display transform matrix

Anton Khirnov git at videolan.org
Fri Mar 20 01:46:08 CET 2015


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Mar 12 23:14:08 2015 +0100| [cf18e777aed9f73011c7ab7cbab8003189d4b9d8] | committer: Anton Khirnov

movenc: write the display transform matrix

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf18e777aed9f73011c7ab7cbab8003189d4b9d8
---

 libavformat/movenc.c |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 492da03..7b711bc 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1507,12 +1507,19 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
     int flags   = MOV_TKHD_FLAG_IN_MOVIE;
     int group   = 0;
 
+    uint32_t *display_matrix = NULL;
+    int      display_matrix_size, i;
 
     if (st) {
         if (mov->per_stream_grouping)
             group = st->index;
         else
             group = st->codec->codec_type;
+
+        display_matrix = (uint32_t*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX,
+                                                            &display_matrix_size);
+        if (display_matrix_size < 9 * sizeof(*display_matrix))
+            display_matrix = NULL;
     }
 
     if (track->flags & MOV_TRACK_ENABLED)
@@ -1553,15 +1560,20 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
     avio_wb16(pb, 0); /* reserved */
 
     /* Matrix structure */
-    avio_wb32(pb, 0x00010000); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x00010000); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x0); /* reserved */
-    avio_wb32(pb, 0x40000000); /* reserved */
+    if (display_matrix) {
+        for (i = 0; i < 9; i++)
+            avio_wb32(pb, display_matrix[i]);
+    } else {
+        avio_wb32(pb, 0x00010000); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x00010000); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x0); /* reserved */
+        avio_wb32(pb, 0x40000000); /* reserved */
+    }
 
     /* Track width and height, for visual only */
     if (st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||



More information about the ffmpeg-cvslog mailing list