Commit 0bb3b2ed authored by Steve Lhomme's avatar Steve Lhomme Committed by Fiona Glaser

Write 3D metadata when outputting Matroska

For when --frame-packing is set.
parent f35e3fc2
......@@ -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;
......
......@@ -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 ) );
......
......@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment