]> git.sesse.net Git - vlc/commitdiff
* modules/codec/x264.c: fixed aspect ratio.
authorGildas Bazin <gbazin@videolan.org>
Mon, 20 Sep 2004 10:23:59 +0000 (10:23 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 20 Sep 2004 10:23:59 +0000 (10:23 +0000)
modules/codec/x264.c

index a2e182eebb32a7a8a4db03e44966da77309d1bcd..30185eb19a075a0f85f6c9d03caf5bc0db673dc0 100644 (file)
@@ -135,11 +135,16 @@ static int  Open ( vlc_object_t *p_this )
 
     if( p_enc->fmt_in.video.i_aspect > 0 )
     {
-        p_sys->param.vui.i_sar_width = p_enc->fmt_in.video.i_aspect *
-                                       p_enc->fmt_in.video.i_height *
-                                       p_enc->fmt_in.video.i_height /
-                                       p_enc->fmt_in.video.i_width;
-        p_sys->param.vui.i_sar_height = p_enc->fmt_in.video.i_height;
+        int64_t i_num, i_den;
+        int i_dst_num, i_dst_den;
+
+        i_num = p_enc->fmt_in.video.i_aspect *
+            (int64_t)p_enc->fmt_in.video.i_height;
+        i_den = VOUT_ASPECT_FACTOR * p_enc->fmt_in.video.i_width;
+        vlc_reduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
+
+        p_sys->param.vui.i_sar_width = i_dst_num;
+        p_sys->param.vui.i_sar_height = i_dst_den;
     }
     if( p_enc->fmt_in.video.i_frame_rate_base > 0 )
     {