[vlc-devel] commit: snapshot core : correct aspect ratio issue (trac #2705) ( Erwan Tulou )

git version control git at videolan.org
Tue May 26 02:12:54 CEST 2009


vlc | branch: master | Erwan Tulou <brezhoneg1 at yahoo.fr> | Mon May 25 13:40:16 2009 +0200| [49f85e90c83f84f43b03337327f4697b31b0d4fd] | committer: Jean-Baptiste Kempf 

snapshot core : correct aspect ratio issue (trac #2705)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49f85e90c83f84f43b03337327f4697b31b0d4fd
---

 src/video_output/video_output.c  |    3 ++
 src/video_output/vout_pictures.c |   45 ++++++++++++++++++++++----------------
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 3c932f6..825e1d6 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1213,6 +1213,9 @@ static void* RunThread( void *p_this )
 
                 picture_Copy( p_pic, p_directbuffer );
 
+                p_pic->format.i_sar_num = p_vout->fmt_out.i_sar_num;
+                p_pic->format.i_sar_den = p_vout->fmt_out.i_sar_den;
+
                 p_pic->p_next = p_vout->p->snapshot.p_picture;
                 p_vout->p->snapshot.p_picture = p_pic;
                 p_vout->p->snapshot.i_request--;
diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c
index d0da611..0f408f8 100644
--- a/src/video_output/vout_pictures.c
+++ b/src/video_output/vout_pictures.c
@@ -1114,30 +1114,37 @@ int picture_Export( vlc_object_t *p_obj,
     fmt_out.i_sar_num =
     fmt_out.i_sar_den = 1;
     fmt_out.i_chroma  = i_format;
-    fmt_out.i_width   = i_override_width;
-    fmt_out.i_height  = i_override_height;
 
-    if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+    /* compute original width/height */
+    unsigned int i_original_width;
+    unsigned int i_original_height;
+    if( fmt_in.i_sar_num >= fmt_in.i_sar_den )
     {
-        fmt_out.i_height = fmt_in.i_height * fmt_out.i_width / fmt_in.i_width;
-        const int i_height = fmt_out.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
-        if( i_height > 0 )
-            fmt_out.i_height = i_height;
+        i_original_width = fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
+        i_original_height = fmt_in.i_height;
     }
     else
     {
-        if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
-        {
-            fmt_out.i_width = fmt_in.i_width * fmt_out.i_height / fmt_in.i_height;
-        }
-        else
-        {
-            fmt_out.i_width = fmt_in.i_width;
-            fmt_out.i_height = fmt_in.i_height;
-        }
-        const int i_width = fmt_out.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
-        if( i_width > 0 )
-            fmt_out.i_width = i_width;
+        i_original_width =  fmt_in.i_width;
+        i_original_height = fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
+    }
+
+    /* */
+    fmt_out.i_width  = ( i_override_width < 0 ) ?
+                       i_original_width : i_override_width;
+    fmt_out.i_height = ( i_override_height < 0 ) ?
+                       i_original_height : i_override_height;
+
+    /* scale if only one direction is provided */
+    if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+    {
+        fmt_out.i_height = fmt_in.i_height * fmt_out.i_width
+                     * fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num;
+    }
+    else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
+    {
+        fmt_out.i_width  = fmt_in.i_width * fmt_out.i_height
+                     * fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den;
     }
 
     image_handler_t *p_image = image_HandlerCreate( p_obj );




More information about the vlc-devel mailing list