[vlc-devel] commit: Do not destroy vout on aspect ratio change only. (Laurent Aimar )

git version control git at videolan.org
Wed Sep 10 22:26:45 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Sep 10 22:24:35 2008 +0200| [3065dd7bff1eaad874566db22c07b5538a575904] | committer: Laurent Aimar 

Do not destroy vout on aspect ratio change only.

The user aspect ratio and resize will still be lost on an AR aspect ratio change.
(we may want to keep at least the requested resie).

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

 src/video_output/video_output.c |   67 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index fcb98ac..157db2f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -130,6 +130,7 @@ static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data
 vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
                                video_format_t *p_fmt )
 {
+    const bool b_vout_provided = p_vout != NULL;
     if( !p_fmt )
     {
         /* Video output is no longer used.
@@ -154,6 +155,8 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
         char *psz_filter_chain;
         vlc_value_t val;
 
+        vlc_mutex_lock( &p_vout->change_lock );
+
         /* We don't directly check for the "vout-filter" variable for obvious
          * performance reasons. */
         if( p_vout->b_filter_change )
@@ -180,11 +183,13 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
             free( psz_filter_chain );
         }
 
-        if( ( p_vout->fmt_render.i_width != p_fmt->i_width ) ||
-            ( p_vout->fmt_render.i_height != p_fmt->i_height ) ||
-            ( p_vout->fmt_render.i_aspect != p_fmt->i_aspect ) ||
+        if( p_vout->fmt_render.i_chroma != p_fmt->i_chroma ||
+            p_vout->fmt_render.i_width != p_fmt->i_width ||
+            p_vout->fmt_render.i_height != p_fmt->i_height ||
             p_vout->b_filter_change )
         {
+            vlc_mutex_unlock( &p_vout->change_lock );
+
             /* We are not interested in this format, close this vout */
             vout_CloseAndRelease( p_vout );
             vlc_object_release( p_vout );
@@ -193,11 +198,63 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
         else
         {
             /* This video output is cool! Hijack it. */
+            if( p_vout->fmt_render.i_aspect != p_fmt->i_aspect )
+            {
+                /* Correct aspect ratio on change
+                 * FIXME factorize this code with other aspect ration related code */
+                unsigned int i_sar_num;
+                unsigned int i_sar_den;
+                unsigned int i_aspect;
+
+                i_aspect = p_fmt->i_aspect;
+                vlc_ureduce( &i_sar_num, &i_sar_den,
+                             p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
+#if 0
+                /* What's that, it does not seems to be used correcly everywhere
+                 * beside the previous p_vout->fmt_render.i_aspect != p_fmt->i_aspect
+                 * should be fixed to use it too then */
+                if( p_vout->i_par_num > 0 && p_vout->i_par_den > 0 )
+                {
+                    i_sar_num *= p_vout->i_par_den;
+                    i_sar_den *= p_vout->i_par_num;
+                    i_aspect = i_aspect * p_vout->i_par_den / p_vout->i_par_num;
+                }
+#endif
+
+                if( i_sar_num > 0 && i_sar_den > 0 && i_aspect > 0 )
+                {
+                    p_vout->fmt_in.i_sar_num = i_sar_num;
+                    p_vout->fmt_in.i_sar_den = i_sar_den;
+                    p_vout->fmt_in.i_aspect  = i_aspect;
+
+                    p_vout->fmt_render.i_sar_num = i_sar_num;
+                    p_vout->fmt_render.i_sar_den = i_sar_den;
+                    p_vout->fmt_render.i_aspect  = i_aspect;
+
+                    p_vout->render.i_aspect   = i_aspect;
+
+                    p_vout->i_changes |= VOUT_ASPECT_CHANGE;
+
+                }
+            }
+            vlc_mutex_unlock( &p_vout->change_lock );
+
+            vlc_object_release( p_vout );
+        }
+
+        if( p_vout )
+        {
+            msg_Dbg( p_this, "reusing provided vout" );
+
             spu_Attach( p_vout->p_spu, p_this, true );
+
+            vlc_object_detach( p_vout );
             vlc_object_attach( p_vout, p_this );
-            if( p_vout->b_title_show )
+
+            /* Display title if we are not using the vout given to vout_Request.
+             * XXX for now b_vout_provided is always true at this stage */
+            if( p_vout->b_title_show && !b_vout_provided )
                 DisplayTitleOnOSD( p_vout );
-            vlc_object_release( p_vout );
         }
     }
 




More information about the vlc-devel mailing list