[x264-devel] Write 3D metadata when outputting Matroska

Steve Lhomme git at videolan.org
Thu Mar 13 21:23:51 CET 2014


x264 | branch: master | Steve Lhomme <robux4gmai.com> | Sun Feb 16 13:15:09 2014 +0100| [bc505a156b97817b5355e398938a498c1b33ee66] | committer: Jason Garrett-Glaser

Write 3D metadata when outputting Matroska

For when --frame-packing is set.

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

 output/matroska.c      |    4 +++-
 output/matroska_ebml.c |    6 +++++-
 output/matroska_ebml.h |    2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/output/matroska.c b/output/matroska.c
index baa0f1c..b01fd0a 100644
--- a/output/matroska.c
+++ b/output/matroska.c
@@ -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;
 
diff --git a/output/matroska_ebml.c b/output/matroska_ebml.c
index 55c1cc3..2f871a4 100644
--- a/output/matroska_ebml.c
+++ b/output/matroska_ebml.c
@@ -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 ) );
diff --git a/output/matroska_ebml.h b/output/matroska_ebml.h
index 1c6cad7..1cc46c8 100644
--- a/output/matroska_ebml.h
+++ b/output/matroska_ebml.h
@@ -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 );



More information about the x264-devel mailing list