[vlc-devel] commit: Embedded snapshot: properly initialize snapshot-width/ -height if they were not specified (Olivier Aubert )

git version control git at videolan.org
Fri Aug 8 17:18:53 CEST 2008


vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Fri Aug  8 17:21:04 2008 +0200| [9029b521eafa56eb501a3c4d3808f79bf91d1a96] | committer: Olivier Aubert 

Embedded snapshot: properly initialize snapshot-width/-height if they were not specified

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

 src/video_output/vout_intf.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 7460763..4d9a755 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -484,9 +484,30 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         /* Save the snapshot to a memory zone */
         fmt_in = p_vout->fmt_in;
         fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
+        fmt_out.i_chroma = VLC_FOURCC( 'p','n','g',' ' );
+
         fmt_out.i_width = var_GetInteger( p_vout, "snapshot-width" );
         fmt_out.i_height = var_GetInteger( p_vout, "snapshot-height" );
-        fmt_out.i_chroma = VLC_FOURCC( 'p','n','g',' ' );
+        /* If snapshot-width and/or snapshot height were not specified,
+           use a default snapshot width of 320 */
+	if( fmt_out.i_width == 0 && fmt_out.i_height == 0 )
+        {
+            fmt_out.i_width = 320;
+        }
+
+	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 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_width;
+        }
+	else
+        {
+            fmt_out.i_width = fmt_in.i_width;
+            fmt_out.i_height = fmt_in.i_height;
+        }
 
         p_block = ( block_t* ) image_Write( p_image, p_pic, &fmt_in, &fmt_out );
         if( !p_block )




More information about the vlc-devel mailing list