]> git.sesse.net Git - vlc/commitdiff
* src/misc/image.c, src/video_output/vout_intf.c: handle aspect ratio changes in...
authorGildas Bazin <gbazin@videolan.org>
Thu, 17 Mar 2005 19:16:15 +0000 (19:16 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 17 Mar 2005 19:16:15 +0000 (19:16 +0000)
* modules/video_output/picture.c: set all the fields of fmt_in for image_Convert().

modules/video_output/picture.c
src/misc/image.c
src/video_output/vout_intf.c

index f09cb15637649c1142802d04730cc84685e830df..31008b429f8ebc5c8bfd7fa6681ff52fc73498cb 100644 (file)
@@ -2,7 +2,7 @@
  * picture.c:
  *****************************************************************************
  * Copyright (C) 2004-2005 VideoLAN
- * $Id: picture.c 10081 2005-03-01 15:33:51Z dionoea $
+ * $Id$
  *
  * Authors: Antoine Cellerier <dionoea@videolan.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -426,9 +426,7 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
         picture_t *p_new_pic2;
 #endif
 
-        fmt_in.i_chroma = p_vout->render.i_chroma;
-        fmt_in.i_width = p_vout->render.i_width;
-        fmt_in.i_height = p_vout->render.i_height;
+        fmt_in = p_vout->fmt_in;
 
 #ifdef IMAGE_2PASSES
         fmt_middle.i_chroma = p_vout->render.i_chroma;
index af7d6dd1dc216d4313642ae0f4c8bbc7e53a1a25..d5c3964c659f97e8d61d507d3f66b00b8d5ea75e 100644 (file)
@@ -356,9 +356,28 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
     void (*pf_release)( picture_t * );
     picture_t *p_pif;
 
+    if( !p_fmt_out->i_width && !p_fmt_out->i_height &&
+        p_fmt_out->i_sar_num && p_fmt_out->i_sar_den &&
+        p_fmt_out->i_sar_num * p_fmt_in->i_sar_den !=
+        p_fmt_out->i_sar_den * p_fmt_in->i_sar_num )
+    {
+        p_fmt_out->i_width =
+            p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
+            p_fmt_in->i_width / p_fmt_in->i_sar_den / p_fmt_out->i_sar_num;
+        p_fmt_out->i_visible_width =
+            p_fmt_in->i_sar_num * (int64_t)p_fmt_out->i_sar_den *
+            p_fmt_in->i_visible_width / p_fmt_in->i_sar_den /
+            p_fmt_out->i_sar_num;
+    }
+
     if( !p_fmt_out->i_chroma ) p_fmt_out->i_chroma = p_fmt_in->i_chroma;
-    if( !p_fmt_out->i_width ) p_fmt_out->i_width = p_fmt_in->i_width;
-    if( !p_fmt_out->i_height ) p_fmt_out->i_height = p_fmt_in->i_height;
+    if( !p_fmt_out->i_width )
+        p_fmt_out->i_width = p_fmt_out->i_visible_width = p_fmt_in->i_width;
+    if( !p_fmt_out->i_height )
+        p_fmt_out->i_height = p_fmt_out->i_visible_height = p_fmt_in->i_height;
+    if( !p_fmt_out->i_sar_num ) p_fmt_out->i_sar_num = p_fmt_in->i_sar_num;
+    if( !p_fmt_out->i_sar_den ) p_fmt_out->i_sar_den = p_fmt_in->i_sar_den;
+    if( !p_fmt_out->i_aspect ) p_fmt_out->i_aspect = p_fmt_in->i_aspect;
 
     if( p_image->p_filter )
     if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
@@ -580,14 +599,29 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
     {
         p_enc->fmt_in.video.i_width = fmt_out->i_width;
         p_enc->fmt_in.video.i_height = fmt_out->i_height;
+
+        if( fmt_out->i_visible_width > 0 &&
+            fmt_out->i_visible_height > 0 )
+        {
+            p_enc->fmt_in.video.i_visible_width = fmt_out->i_visible_width;
+            p_enc->fmt_in.video.i_visible_height = fmt_out->i_visible_height;
+        }
+        else
+        {
+            p_enc->fmt_in.video.i_visible_width = fmt_out->i_width;
+            p_enc->fmt_in.video.i_visible_height = fmt_out->i_height;
+        }
     }
     else if( fmt_out->i_sar_num && fmt_out->i_sar_den &&
-            fmt_out->i_sar_num * fmt_in->i_sar_den !=
+             fmt_out->i_sar_num * fmt_in->i_sar_den !=
              fmt_out->i_sar_den * fmt_in->i_sar_num )
     {
         p_enc->fmt_in.video.i_width =
-           fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
+            fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den * fmt_in->i_width /
             fmt_in->i_sar_den / fmt_out->i_sar_num;
+        p_enc->fmt_in.video.i_visible_width =
+            fmt_in->i_sar_num * (int64_t)fmt_out->i_sar_den *
+            fmt_in->i_visible_width / fmt_in->i_sar_den / fmt_out->i_sar_num;
     }
 
     p_enc->fmt_in.video.i_frame_rate = 25;
index b18a7dfa56b7fc16c9ae975ce2067d9b0ad2d1a6..21ddb100915ca9e2f0ab018d9818f3984edd1ba0 100644 (file)
@@ -361,11 +361,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     free( format.psz_string );
 
     /* Save the snapshot */
-    fmt_in.i_chroma = p_vout->render.i_chroma;
-    fmt_in.i_width = p_vout->render.i_width;
-    fmt_in.i_height = p_vout->render.i_height;
-    fmt_in.i_sar_num = p_vout->fmt_render.i_sar_num;
-    fmt_in.i_sar_den = p_vout->fmt_render.i_sar_den;
+    fmt_in = p_vout->fmt_in;
     fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
     i_ret = image_WriteUrl( p_image, p_pic, &fmt_in, &fmt_out, psz_filename );
     if( i_ret != VLC_SUCCESS )
@@ -380,10 +376,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     free( psz_filename );
 
     /* Inject a subpicture with the snapshot */
+    memset( &fmt_out, 0, sizeof(fmt_out) );
     fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
-    fmt_out.i_width = fmt_out.i_visible_width = p_vout->render.i_width;
-    fmt_out.i_height = fmt_out.i_visible_height = p_vout->render.i_height;
-    fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
     p_pif = image_Convert( p_image, p_pic, &fmt_in, &fmt_out );
     image_HandlerDelete( p_image );
     if( !p_pif ) return VLC_EGENERIC;