]> git.sesse.net Git - x264/commitdiff
Write 3D metadata when outputting Matroska
authorSteve Lhomme <robux@videolan.org>
Sun, 16 Feb 2014 12:15:09 +0000 (13:15 +0100)
committerFiona Glaser <fiona@x264.com>
Wed, 12 Mar 2014 04:10:22 +0000 (21:10 -0700)
For when --frame-packing is set.

output/matroska.c
output/matroska_ebml.c
output/matroska_ebml.h

index baa0f1ca793a4bbe1946be7c112c0285ac564869..b01fd0ac96bb8f9e7db20195823d2f5ae9221176 100644 (file)
@@ -33,6 +33,7 @@ typedef struct
     int width, height, d_width, d_height;
 
     int display_size_units;
+    int stereo_mode;
 
     int64_t frame_duration;
 
@@ -79,6 +80,7 @@ static int set_param( hnd_t handle, x264_param_t *p_param )
     p_mkv->width = p_mkv->d_width = p_param->i_width;
     p_mkv->height = p_mkv->d_height = p_param->i_height;
     p_mkv->display_size_units = DS_PIXELS;
+    p_mkv->stereo_mode = p_param->i_frame_packing;
 
     if( p_param->vui.i_sar_width && p_param->vui.i_sar_height
         && p_param->vui.i_sar_width != p_param->vui.i_sar_height )
@@ -147,7 +149,7 @@ static int write_headers( hnd_t handle, x264_nal_t *p_nal )
     ret = mk_write_header( p_mkv->w, "x264" X264_VERSION, "V_MPEG4/ISO/AVC",
                            avcC, avcC_len, p_mkv->frame_duration, 50000,
                            p_mkv->width, p_mkv->height,
-                           p_mkv->d_width, p_mkv->d_height, p_mkv->display_size_units );
+                           p_mkv->d_width, p_mkv->d_height, p_mkv->display_size_units, p_mkv->stereo_mode );
     if( ret < 0 )
         return ret;
 
index 55c1cc376741299f4bee0d7efb855f06c8acd621..2f871a478c295676558551f76fe5f04cffeed00e 100644 (file)
@@ -317,13 +317,15 @@ mk_writer *mk_create_writer( const char *filename )
     return w;
 }
 
+static const uint8_t mk_stereo_modes[6] = {5,9,7,1,3,13};
+
 int mk_write_header( mk_writer *w, const char *writing_app,
                      const char *codec_id,
                      const void *codec_private, unsigned codec_private_size,
                      int64_t default_frame_duration,
                      int64_t timescale,
                      unsigned width, unsigned height,
-                     unsigned d_width, unsigned d_height, int display_size_units )
+                     unsigned d_width, unsigned d_height, int display_size_units, int stereo_mode )
 {
     mk_context  *c, *ti, *v;
 
@@ -379,6 +381,8 @@ int mk_write_header( mk_writer *w, const char *writing_app,
     CHECK( mk_write_uint( v, 0x54b2, display_size_units ) );
     CHECK( mk_write_uint( v, 0x54b0, d_width ) );
     CHECK( mk_write_uint( v, 0x54ba, d_height ) );
+    if( stereo_mode >= 0 && stereo_mode <= 5 )
+        CHECK( mk_write_uint( v, 0x53b8, mk_stereo_modes[stereo_mode] ) );
     CHECK( mk_close_context( v, 0 ) );
 
     CHECK( mk_close_context( ti, 0 ) );
index 1c6cad7ac34a1505b6625d30410371f534393be8..1cc46c8d3dd65a9a784bcf8f4d9490eecb5cd6a9 100644 (file)
@@ -42,7 +42,7 @@ int mk_write_header( mk_writer *w, const char *writing_app,
                      int64_t default_frame_duration,
                      int64_t timescale,
                      unsigned width, unsigned height,
-                     unsigned d_width, unsigned d_height, int display_size_units );
+                     unsigned d_width, unsigned d_height, int display_size_units, int stereo_mode );
 
 int mk_start_frame( mk_writer *w );
 int mk_add_frame_data( mk_writer *w, const void *data, unsigned size );