]> git.sesse.net Git - x264/blobdiff - output/matroska.c
aarch64: Remove broken CFLAGS in configure
[x264] / output / matroska.c
index baa0f1ca793a4bbe1946be7c112c0285ac564869..e5ab963131942fb42344c34893ff9d8bcadedd5c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * matroska.c: matroska muxer
  *****************************************************************************
- * Copyright (C) 2005-2014 x264 project
+ * Copyright (C) 2005-2015 x264 project
  *
  * Authors: Mike Matsnev <mike@haali.su>
  *
@@ -33,6 +33,7 @@ typedef struct
     int width, height, d_width, d_height;
 
     int display_size_units;
+    int stereo_mode;
 
     int64_t frame_duration;
 
@@ -61,9 +62,14 @@ static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt
     return 0;
 }
 
+#define STEREO_COUNT 7
+static const uint8_t stereo_modes[STEREO_COUNT] = {5,9,7,1,3,13,0};
+static const uint8_t stereo_w_div[STEREO_COUNT] = {1,2,1,2,1,1,1};
+static const uint8_t stereo_h_div[STEREO_COUNT] = {1,1,2,1,2,1,1};
+
 static int set_param( hnd_t handle, x264_param_t *p_param )
 {
-    mkv_hnd_t   *p_mkv = handle;
+    mkv_hnd_t *p_mkv = handle;
     int64_t dw, dh;
 
     if( p_param->i_fps_num > 0 && !p_param->b_vfr_input )
@@ -76,24 +82,27 @@ static int set_param( hnd_t handle, x264_param_t *p_param )
         p_mkv->frame_duration = 0;
     }
 
-    p_mkv->width = p_mkv->d_width = p_param->i_width;
-    p_mkv->height = p_mkv->d_height = p_param->i_height;
+    dw = p_mkv->width = p_param->i_width;
+    dh = p_mkv->height = p_param->i_height;
     p_mkv->display_size_units = DS_PIXELS;
-
+    p_mkv->stereo_mode = -1;
+    if( p_param->i_frame_packing >= 0 && p_param->i_frame_packing < STEREO_COUNT )
+    {
+        p_mkv->stereo_mode = stereo_modes[p_param->i_frame_packing];
+        dw /= stereo_w_div[p_param->i_frame_packing];
+        dh /= stereo_h_div[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 )
     {
         if ( p_param->vui.i_sar_width > p_param->vui.i_sar_height ) {
-            dw = (int64_t)p_param->i_width * p_param->vui.i_sar_width / p_param->vui.i_sar_height;
-            dh = p_param->i_height;
+            dw = dw * p_param->vui.i_sar_width / p_param->vui.i_sar_height;
         } else {
-            dw = p_param->i_width;
-            dh = (int64_t)p_param->i_height * p_param->vui.i_sar_height / p_param->vui.i_sar_width;
+            dh = dh * p_param->vui.i_sar_height / p_param->vui.i_sar_width;
         }
-
-        p_mkv->d_width = (int)dw;
-        p_mkv->d_height = (int)dh;
     }
+    p_mkv->d_width = (int)dw;
+    p_mkv->d_height = (int)dh;
 
     p_mkv->i_timebase_num = p_param->i_timebase_num;
     p_mkv->i_timebase_den = p_param->i_timebase_den;
@@ -147,12 +156,12 @@ 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 );
+    free( avcC );
+
     if( ret < 0 )
         return ret;
 
-    free( avcC );
-
     // SEI
 
     if( !p_mkv->b_writing_frame )