Created
February 16, 2014 13:47
-
-
Save robUx4/9034455 to your computer and use it in GitHub Desktop.
x264 stereo mode patch for Matroska
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/output/matroska.c b/output/matroska.c | |
index baa0f1c..f623a2f 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 stereomode; | |
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->stereomode = 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->stereomode ); | |
if( ret < 0 ) | |
return ret; | |
diff --git a/output/matroska_ebml.c b/output/matroska_ebml.c | |
index 55c1cc3..487fc61 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; | |
} | |
+const int stereomodes[7]={0,0,0,0,1,3,0}; // 2D,2D,2D,2D,side by side,top-bottom,2D | |
+ | |
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 stereomode ) | |
{ | |
mk_context *c, *ti, *v; | |
@@ -379,6 +381,7 @@ 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 ) ); | |
+ CHECK( mk_write_uint( v, 0x53b8, stereomodes[stereomode+1] ) ); | |
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..e567a19 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 stereomode ); | |
int mk_start_frame( mk_writer *w ); | |
int mk_add_frame_data( mk_writer *w, const void *data, unsigned size ); | |
-- | |
1.7.11.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment