[vlc-devel] [PATCH] provide the display format from the demuxer to the vout to respect cropping

Steve Lhomme robUx4 at videolabs.io
Mon Mar 9 16:51:29 CET 2015


Fixes #13982

The cropping is added to the user defined cropping from the GUI so that
parts of the video that should not be displayed are never displayed
---
 include/vlc_aout.h                    |  3 ++-
 include/vlc_vout.h                    |  3 ++-
 include/vlc_vout_wrapper.h            |  2 +-
 modules/visualization/goom.c          |  6 ++---
 modules/visualization/visual/visual.c |  8 +++----
 src/audio_output/aout_internal.h      |  2 +-
 src/audio_output/filters.c            |  4 ++--
 src/input/decoder.c                   | 14 +++++++----
 src/input/resource.c                  | 22 +++++++++--------
 src/input/resource.h                  |  3 ++-
 src/video_output/display.c            | 45 ++++++++++++++++++++++-------------
 src/video_output/display.h            |  1 +
 src/video_output/video_output.c       | 22 +++++++++++++----
 src/video_output/vout_internal.h      |  1 +
 src/video_output/vout_wrapper.c       |  6 +++--
 15 files changed, 90 insertions(+), 52 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 032157f..50a7ac9 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -334,6 +334,7 @@ VLC_API void aout_FiltersDelete(vlc_object_t *, aout_filters_t *);
 VLC_API bool aout_FiltersAdjustResampling(aout_filters_t *, int);
 VLC_API block_t *aout_FiltersPlay(aout_filters_t *, block_t *, int rate);
 
-VLC_API vout_thread_t * aout_filter_RequestVout( filter_t *, vout_thread_t *p_vout, video_format_t *p_fmt );
+VLC_API vout_thread_t * aout_filter_RequestVout( filter_t *, vout_thread_t *p_vout,
+                                                 video_format_t *p_fmt_in, video_format_t *p_fmt_out );
 
 #endif /* VLC_AOUT_H */
diff --git a/include/vlc_vout.h b/include/vlc_vout.h
index 15f321d..e38c412 100644
--- a/include/vlc_vout.h
+++ b/include/vlc_vout.h
@@ -54,7 +54,8 @@ typedef struct {
     vout_thread_t        *vout;
     vlc_object_t         *input;
     bool                 change_fmt;
-    const video_format_t *fmt;
+    const video_format_t *p_fmt_in;
+    const video_format_t *p_fmt_out;
     unsigned             dpb_size;
 } vout_configuration_t;
 
diff --git a/include/vlc_vout_wrapper.h b/include/vlc_vout_wrapper.h
index 419bfc8..3562817 100644
--- a/include/vlc_vout_wrapper.h
+++ b/include/vlc_vout_wrapper.h
@@ -74,7 +74,7 @@ typedef struct {
 /**
  * It creates a vout managed display.
  */
-vout_display_t *vout_NewDisplay( vout_thread_t *, const video_format_t *,
+vout_display_t *vout_NewDisplay( vout_thread_t *, const video_format_t *, const video_format_t *,
     const vout_display_state_t *, const char *module,
     mtime_t double_click_timeout, mtime_t hide_timeout );
 /**
diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c
index a57da5b..1b58147 100644
--- a/modules/visualization/goom.c
+++ b/modules/visualization/goom.c
@@ -135,7 +135,7 @@ static int Open( vlc_object_t *p_this )
     fmt.i_chroma = VLC_CODEC_RGB32;
     fmt.i_sar_num = fmt.i_sar_den = 1;
 
-    p_thread->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt );
+    p_thread->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt, &fmt );
     if( p_thread->p_vout == NULL )
     {
         msg_Err( p_filter, "no suitable vout module" );
@@ -162,7 +162,7 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_filter, "cannot lauch goom thread" );
         vlc_mutex_destroy( &p_thread->lock );
         vlc_cond_destroy( &p_thread->wait );
-        aout_filter_RequestVout( p_filter, p_thread->p_vout, NULL );
+        aout_filter_RequestVout( p_filter, p_thread->p_vout, NULL, NULL );
         free( p_thread );
         free( p_sys );
         return VLC_EGENERIC;
@@ -366,7 +366,7 @@ static void Close( vlc_object_t *p_this )
     vlc_join( p_sys->p_thread->thread, NULL );
 
     /* Free data */
-    aout_filter_RequestVout( p_filter, p_sys->p_thread->p_vout, NULL );
+    aout_filter_RequestVout( p_filter, p_sys->p_thread->p_vout, NULL, NULL );
     vlc_mutex_destroy( &p_sys->p_thread->lock );
     vlc_cond_destroy( &p_sys->p_thread->wait );
 
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 5ce328d..9bd2e27 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -299,7 +299,7 @@ static int Open( vlc_object_t *p_this )
         .i_sar_num = 1,
         .i_sar_den = 1,
     };
-    p_sys->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt );
+    p_sys->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt, &fmt );
     if( p_sys->p_vout == NULL )
     {
         msg_Err( p_filter, "no suitable vout module" );
@@ -309,7 +309,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->fifo = block_FifoNew();
     if( unlikely( p_sys->fifo == NULL ) )
     {
-        aout_filter_RequestVout( p_filter, p_sys->p_vout, NULL );
+        aout_filter_RequestVout( p_filter, p_sys->p_vout, NULL, NULL );
         goto error;
     }
 
@@ -317,7 +317,7 @@ static int Open( vlc_object_t *p_this )
                    VLC_THREAD_PRIORITY_VIDEO ) )
     {
         block_FifoRelease( p_sys->fifo );
-        aout_filter_RequestVout( p_filter, p_sys->p_vout, NULL );
+        aout_filter_RequestVout( p_filter, p_sys->p_vout, NULL, NULL );
         goto error;
     }
 
@@ -403,7 +403,7 @@ static void Close( vlc_object_t *p_this )
     vlc_cancel( p_sys->thread );
     vlc_join( p_sys->thread, NULL );
     block_FifoRelease( p_sys->fifo );
-    aout_filter_RequestVout( p_filter, p_filter->p_sys->p_vout, NULL );
+    aout_filter_RequestVout( p_filter, p_filter->p_sys->p_vout, NULL, NULL );
 
     /* Free the list */
     for( int i = 0; i < p_sys->i_effect; i++ )
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 10c790b..ce219dc 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -38,7 +38,7 @@ enum {
 struct aout_request_vout
 {
     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
-                                               video_format_t *, bool );
+                                               video_format_t *, video_format_t *, bool );
     void *p_private;
 };
 
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 74c5a6a..a9d97ea 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -311,7 +311,7 @@ static int VisualizationCallback (vlc_object_t *obj, const char *var,
 }
 
 vout_thread_t *aout_filter_RequestVout (filter_t *filter, vout_thread_t *vout,
-                                        video_format_t *fmt)
+                                        video_format_t *p_fmt_in, video_format_t *p_fmt_out)
 {
     /* NOTE: This only works from aout_filters_t.
      * If you want to use visualization filters from another place, you will
@@ -324,7 +324,7 @@ vout_thread_t *aout_filter_RequestVout (filter_t *filter, vout_thread_t *vout,
     bool recycle = false;
     free (visual);
 
-    return req->pf_request_vout (req->p_private, vout, fmt, recycle);
+    return req->pf_request_vout (req->p_private, vout, p_fmt_in, p_fmt_out, recycle);
 }
 
 static int AppendFilter(vlc_object_t *obj, const char *type, const char *name,
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 451024b..64f8838 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1828,7 +1828,7 @@ static void DeleteDecoder( decoder_t * p_dec )
         vout_Reset( p_owner->p_vout );
 
         /* */
-        input_resource_RequestVout( p_owner->p_resource, p_owner->p_vout, NULL,
+        input_resource_RequestVout( p_owner->p_resource, p_owner->p_vout, NULL, NULL,
                                     0, true );
         if( p_owner->p_input != NULL )
             input_SendEventVout( p_owner->p_input );
@@ -1898,14 +1898,15 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
     p_dec->p_description = NULL;
 }
 static vout_thread_t *aout_request_vout( void *p_private,
-                                         vout_thread_t *p_vout, video_format_t *p_fmt, bool b_recyle )
+                                         vout_thread_t *p_vout, video_format_t *p_fmt_in,
+                                         video_format_t *p_fmt_out, bool b_recyle )
 {
     decoder_t *p_dec = p_private;
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
     input_thread_t *p_input = p_owner->p_input;
 
-    p_vout = input_resource_RequestVout( p_owner->p_resource, p_vout, p_fmt, 1,
-                                         b_recyle );
+    p_vout = input_resource_RequestVout( p_owner->p_resource, p_vout, p_fmt_in, p_fmt_out,
+                                         1, b_recyle );
     if( p_input != NULL )
         input_SendEventVout( p_input );
 
@@ -2087,6 +2088,9 @@ static int vout_update_format( decoder_t *p_dec )
         vlc_ureduce( &fmt.i_sar_num, &fmt.i_sar_den,
                      fmt.i_sar_num, fmt.i_sar_den, 50000 );
 
+        vlc_ureduce( &p_dec->fmt_in.video.i_sar_num, &p_dec->fmt_in.video.i_sar_den,
+                     p_dec->fmt_in.video.i_sar_num, p_dec->fmt_in.video.i_sar_den, 50000 );
+
         vlc_mutex_lock( &p_owner->lock );
 
         p_vout = p_owner->p_vout;
@@ -2112,7 +2116,7 @@ static int vout_update_format( decoder_t *p_dec )
             break;
         }
         p_vout = input_resource_RequestVout( p_owner->p_resource,
-                                             p_vout, &fmt,
+                                             p_vout, &fmt, &p_dec->fmt_in.video,
                                              dpb_size +
                                              p_dec->i_extra_picture_buffers + 1,
                                              true );
diff --git a/src/input/resource.c b/src/input/resource.c
index 3440288..4306075 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -193,12 +193,12 @@ static void DisplayVoutTitle( input_resource_t *p_resource,
 }
 static vout_thread_t *RequestVout( input_resource_t *p_resource,
                                    vout_thread_t *p_vout,
-                                   video_format_t *p_fmt, unsigned dpb_size,
-                                   bool b_recycle )
+                                   video_format_t *p_fmt_in, video_format_t *p_fmt_out,
+                                   unsigned dpb_size, bool b_recycle )
 {
     vlc_assert_locked( &p_resource->lock );
 
-    if( !p_vout && !p_fmt )
+    if( !p_vout && !p_fmt_in )
     {
         if( p_resource->p_vout_free )
         {
@@ -209,7 +209,7 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
         return NULL;
     }
 
-    if( p_fmt )
+    if( p_fmt_in )
     {
         /* */
         if( !p_vout && p_resource->p_vout_free )
@@ -233,7 +233,8 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
             .vout       = p_vout,
             .input      = VLC_OBJECT(p_resource->p_input),
             .change_fmt = true,
-            .fmt        = p_fmt,
+            .p_fmt_in   = p_fmt_in,
+            .p_fmt_out  = p_fmt_out,
             .dpb_size   = dpb_size,
         };
         p_vout = vout_Request( p_resource->p_parent, &cfg );
@@ -273,7 +274,8 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
                 .vout       = p_vout,
                 .input      = NULL,
                 .change_fmt = false,
-                .fmt        = NULL,
+                .p_fmt_in   = NULL,
+                .p_fmt_out  = NULL,
                 .dpb_size   = 0,
             };
             p_resource->p_vout_free = vout_Request( p_resource->p_parent, &cfg );
@@ -458,11 +460,11 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
 
 vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
                                             vout_thread_t *p_vout,
-                                            video_format_t *p_fmt, unsigned dpb_size,
-                                            bool b_recycle )
+                                            video_format_t *p_fmt_in, video_format_t *p_fmt_out,
+                                            unsigned dpb_size, bool b_recycle )
 {
     vlc_mutex_lock( &p_resource->lock );
-    vout_thread_t *p_ret = RequestVout( p_resource, p_vout, p_fmt, dpb_size, b_recycle );
+    vout_thread_t *p_ret = RequestVout( p_resource, p_vout, p_fmt_in, p_fmt_out, dpb_size, b_recycle );
     vlc_mutex_unlock( &p_resource->lock );
 
     return p_ret;
@@ -480,7 +482,7 @@ void input_resource_HoldVouts( input_resource_t *p_resource, vout_thread_t ***pp
 
 void input_resource_TerminateVout( input_resource_t *p_resource )
 {
-    input_resource_RequestVout( p_resource, NULL, NULL, 0, false );
+    input_resource_RequestVout( p_resource, NULL, NULL, NULL, 0, false );
 }
 bool input_resource_HasVout( input_resource_t *p_resource )
 {
diff --git a/src/input/resource.h b/src/input/resource.h
index 4c24c74..3d31e1a 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -39,7 +39,8 @@ sout_instance_t *input_resource_RequestSout( input_resource_t *, sout_instance_t
 /**
  * This function handles vout request.
  */
-vout_thread_t *input_resource_RequestVout( input_resource_t *, vout_thread_t *, video_format_t *, unsigned dpb_size, bool b_recycle );
+vout_thread_t *input_resource_RequestVout( input_resource_t *, vout_thread_t *, video_format_t *,
+                                           video_format_t *, unsigned dpb_size, bool b_recycle );
 
 /**
  * This function returns one of the current vout if any.
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 3e3a3d5..94b1bd2 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -361,6 +361,7 @@ struct vout_display_owner_sys_t {
         unsigned den;
     } sar;
 
+    /* set when the crop values set by the user changed */
     bool ch_crop;
     struct {
         int      left;
@@ -373,6 +374,7 @@ struct vout_display_owner_sys_t {
 
     /* */
     video_format_t source;
+    video_format_t cropped;
     filter_chain_t *filters;
 
     /* Lock protecting the variables used by
@@ -968,29 +970,29 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
             unsigned crop_num = osys->crop.num;
             unsigned crop_den = osys->crop.den;
             if (crop_num > 0 && crop_den > 0) {
-                video_format_t fmt = osys->source;
+                video_format_t fmt = osys->cropped;
                 fmt.i_sar_num = source.i_sar_num;
                 fmt.i_sar_den = source.i_sar_den;
                 VoutDisplayCropRatio(&osys->crop.left,  &osys->crop.top,
                                      &osys->crop.right, &osys->crop.bottom,
                                      &fmt, crop_num, crop_den);
             }
-            const int right_max  = osys->source.i_x_offset + osys->source.i_visible_width;
-            const int bottom_max = osys->source.i_y_offset + osys->source.i_visible_height;
-            int left   = VLC_CLIP((int)osys->source.i_x_offset + osys->crop.left,
+            const int right_max  = osys->cropped.i_x_offset + osys->cropped.i_visible_width;
+            const int bottom_max = osys->cropped.i_y_offset + osys->cropped.i_visible_height;
+            int left   = VLC_CLIP((int)osys->cropped.i_x_offset + osys->crop.left,
                                 0, right_max - 1);
-            int top    = VLC_CLIP((int)osys->source.i_y_offset + osys->crop.top,
+            int top    = VLC_CLIP((int)osys->cropped.i_y_offset + osys->crop.top,
                                 0, bottom_max - 1);
             int right, bottom;
             if (osys->crop.right <= 0)
-                right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) + osys->crop.right;
+                right = (int)(osys->cropped.i_x_offset + osys->cropped.i_visible_width) + osys->crop.right;
             else
-                right = (int)osys->source.i_x_offset + osys->crop.right;
+                right = (int)osys->cropped.i_x_offset + osys->crop.right;
             right = VLC_CLIP(right, left + 1, right_max);
             if (osys->crop.bottom <= 0)
-                bottom = (int)(osys->source.i_y_offset + osys->source.i_visible_height) + osys->crop.bottom;
+                bottom = (int)(osys->cropped.i_y_offset + osys->cropped.i_visible_height) + osys->crop.bottom;
             else
-                bottom = (int)osys->source.i_y_offset + osys->crop.bottom;
+                bottom = (int)osys->cropped.i_y_offset + osys->crop.bottom;
             bottom = VLC_CLIP(bottom, top + 1, bottom_max);
 
             source.i_x_offset       = left;
@@ -998,6 +1000,7 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
             source.i_visible_width  = right - left;
             source.i_visible_height = bottom - top;
             video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
+            video_format_Print(VLC_OBJECT(vd), "INTERNAL ", &osys->cropped);
             video_format_Print(VLC_OBJECT(vd), "CROPPED", &source);
             if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP, &source)) {
                 msg_Err(vd, "Failed to change source crop TODO implement crop at core");
@@ -1012,13 +1015,13 @@ bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
                 osys->fit_window = 1;
             }
             vd->source = source;
-            osys->crop.left   = source.i_x_offset - osys->source.i_x_offset;
-            osys->crop.top    = source.i_y_offset - osys->source.i_y_offset;
+            osys->crop.left   = source.i_x_offset - osys->cropped.i_x_offset;
+            osys->crop.top    = source.i_y_offset - osys->cropped.i_y_offset;
             /* FIXME for right/bottom we should keep the 'type' border vs window */
             osys->crop.right  = (source.i_x_offset + source.i_visible_width) -
-                                (osys->source.i_x_offset + osys->source.i_visible_width);
+                                (osys->cropped.i_x_offset + osys->cropped.i_visible_width);
             osys->crop.bottom = (source.i_y_offset + source.i_visible_height) -
-                                (osys->source.i_y_offset + osys->source.i_visible_height);
+                                (osys->cropped.i_y_offset + osys->cropped.i_visible_height);
             osys->crop.num    = crop_num;
             osys->crop.den    = crop_den;
             osys->ch_crop = false;
@@ -1184,6 +1187,7 @@ void vout_SetDisplayCrop(vout_display_t *vd,
 
 static vout_display_t *DisplayNew(vout_thread_t *vout,
                                   const video_format_t *source,
+                                  const video_format_t *output,
                                   const vout_display_state_t *state,
                                   const char *module,
                                   bool is_wrapper, vout_display_t *wrapper,
@@ -1238,6 +1242,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     osys->event.fifo = NULL;
 
     osys->source = *source;
+    osys->cropped = *output;
     osys->crop.left   = 0;
     osys->crop.top    = 0;
     osys->crop.right  = 0;
@@ -1275,6 +1280,12 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
         osys->sar.den != source->i_sar_den)
         osys->ch_sar = true;
 
+    if( source->i_visible_width != output->i_visible_width ||
+        source->i_visible_height != output->i_visible_height ||
+        source->i_x_offset != output->i_x_offset ||
+        source->i_y_offset != output->i_y_offset )
+        osys->ch_crop = true;
+
     return p_display;
 }
 
@@ -1310,12 +1321,13 @@ void vout_DeleteDisplay(vout_display_t *vd, vout_display_state_t *state)
  *****************************************************************************/
 vout_display_t *vout_NewDisplay(vout_thread_t *vout,
                                 const video_format_t *source,
+                                const video_format_t *output,
                                 const vout_display_state_t *state,
                                 const char *module,
                                 mtime_t double_click_timeout,
                                 mtime_t hide_timeout)
 {
-    return DisplayNew(vout, source, state, module, false, NULL,
+    return DisplayNew(vout, source, output, state, module, false, NULL,
                       double_click_timeout, hide_timeout, NULL);
 }
 
@@ -1495,6 +1507,7 @@ static void SplitterClose(vout_display_t *vd)
 
 vout_display_t *vout_NewSplitter(vout_thread_t *vout,
                                  const video_format_t *source,
+                                 const video_format_t *p_output,
                                  const vout_display_state_t *state,
                                  const char *module,
                                  const char *splitter_module,
@@ -1508,7 +1521,7 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
 
     /* */
     vout_display_t *wrapper =
-        DisplayNew(vout, source, state, module, true, NULL,
+        DisplayNew(vout, source, p_output, state, module, true, NULL,
                     double_click_timeout, hide_timeout, NULL);
     if (!wrapper) {
         video_splitter_Delete(splitter);
@@ -1557,7 +1570,7 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
         ostate.cfg.zoom.num = 1;
         ostate.cfg.zoom.den = 1;
 
-        vout_display_t *vd = DisplayNew(vout, &output->fmt, &ostate,
+        vout_display_t *vd = DisplayNew(vout, &output->fmt, p_output, &ostate,
                                         output->psz_module ? output->psz_module : module,
                                         false, wrapper,
                                         double_click_timeout, hide_timeout, &vdo);
diff --git a/src/video_output/display.h b/src/video_output/display.h
index ce20111..b7ce263 100644
--- a/src/video_output/display.h
+++ b/src/video_output/display.h
@@ -25,6 +25,7 @@
 
 vout_display_t *vout_NewSplitter(vout_thread_t *vout,
                                  const video_format_t *source,
+                                 const video_format_t *output,
                                  const vout_display_state_t *state,
                                  const char *module,
                                  const char *splitter_module,
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 40701b7..2515575 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -114,7 +114,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
                                  const vout_configuration_t *cfg)
 {
     video_format_t original;
-    if (VoutValidateFormat(&original, cfg->fmt))
+    if (VoutValidateFormat(&original, cfg->p_fmt_in))
         return NULL;
 
     /* Allocate descriptor */
@@ -130,6 +130,12 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
     vout->p = (vout_thread_sys_t*)&vout[1];
 
     vout->p->original = original;
+    vout->p->cropped = *cfg->p_fmt_out;
+    if ( !vout->p->cropped.i_visible_height || !vout->p->cropped.i_visible_width )
+    {
+        vout->p->cropped.i_visible_height = vout->p->original.i_visible_height;
+        vout->p->cropped.i_visible_width = vout->p->original.i_visible_width;
+    }
     vout->p->dpb_size = cfg->dpb_size;
 
     vout_control_Init(&vout->p->control);
@@ -169,8 +175,8 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
             .x = var_InheritInteger(vout, "video-x"),
             .y = var_InheritInteger(vout, "video-y"),
 #endif
-            .width = cfg->fmt->i_visible_width,
-            .height = cfg->fmt->i_visible_height,
+            .width = cfg->p_fmt_out->i_visible_width,
+            .height = cfg->p_fmt_out->i_visible_height,
         };
 
         vout_window_t *window = vout_display_window_New(vout, &wcfg);
@@ -218,7 +224,7 @@ vout_thread_t *vout_Request(vlc_object_t *object,
                               const vout_configuration_t *cfg)
 {
     vout_thread_t *vout = cfg->vout;
-    if (cfg->change_fmt && !cfg->fmt) {
+    if (cfg->change_fmt && !cfg->p_fmt_in) {
         if (vout)
             vout_CloseAndRelease(vout);
         return NULL;
@@ -1409,7 +1415,7 @@ static int ThreadReinit(vout_thread_t *vout,
                         const vout_configuration_t *cfg)
 {
     video_format_t original;
-    if (VoutValidateFormat(&original, cfg->fmt)) {
+    if (VoutValidateFormat(&original, cfg->p_fmt_in)) {
         ThreadStop(vout, NULL);
         ThreadClean(vout);
         return VLC_EGENERIC;
@@ -1448,6 +1454,12 @@ static int ThreadReinit(vout_thread_t *vout,
     }
 
     vout->p->original = original;
+    vout->p->cropped = *cfg->p_fmt_out;
+    if ( !vout->p->cropped.i_visible_height || !vout->p->cropped.i_visible_width )
+    {
+        vout->p->cropped.i_visible_height = vout->p->original.i_visible_height;
+        vout->p->cropped.i_visible_width = vout->p->original.i_visible_width;
+    }
     vout->p->dpb_size = cfg->dpb_size;
     if (ThreadStart(vout, &state)) {
         ThreadClean(vout);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 3b01567..1238683 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -54,6 +54,7 @@ struct vout_thread_sys_t
 
     /* */
     video_format_t  original;   /* Original format ie coming from the decoder */
+    video_format_t  cropped;    /* Original format ie coming from the demuxer */
     unsigned        dpb_size;
 
     /* Snapshot interface */
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index d172bcc..cb7cc01 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -61,10 +61,12 @@ int vout_OpenWrapper(vout_thread_t *vout,
     const mtime_t hide_timeout = var_CreateGetInteger(vout, "mouse-hide-timeout") * 1000;
 
     if (splitter_name) {
-        sys->display.vd = vout_NewSplitter(vout, &vout->p->original, state, "$vout", splitter_name,
+        sys->display.vd = vout_NewSplitter(vout, &vout->p->original, &vout->p->cropped,
+                                           state, "$vout", splitter_name,
                                            double_click_timeout, hide_timeout);
     } else {
-        sys->display.vd = vout_NewDisplay(vout, &vout->p->original, state, "$vout",
+        sys->display.vd = vout_NewDisplay(vout, &vout->p->original, &vout->p->cropped,
+                                          state, "$vout",
                                           double_click_timeout, hide_timeout);
     }
     if (!sys->display.vd) {
-- 
2.2.2




More information about the vlc-devel mailing list