[vlc-commits] video_output: read the user crop values before creating the display

Steve Lhomme git at videolan.org
Thu Sep 3 07:47:41 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Sep  1 11:43:17 2020 +0200| [6aa75628de91926ef5c058c19b72fb9dabd818e5] | committer: Steve Lhomme

video_output: read the user crop values before creating the display

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

 src/video_output/video_output.c  | 33 +++++++++++++++++++++++++++++++++
 src/video_output/vout_internal.h |  4 ++++
 src/video_output/vout_intf.c     |  2 +-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a1e43a07ff..de03a3a044 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -2196,6 +2196,37 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori
     return 0;
 }
 
+static void vout_InitSource(vout_thread_sys_t *vout)
+{
+    char *psz_crop = var_InheritString(&vout->obj, "crop");
+    if (psz_crop) {
+        unsigned num, den;
+        unsigned y, x;
+        unsigned width, height;
+        enum vout_crop_mode mode;
+
+        if (GetCropMode(psz_crop, &mode, &num, &den,
+                        &x, &y, &width, &height))
+        {
+            switch (mode)
+            {
+            case VOUT_CROP_RATIO:
+                vout_SetCropRatio(vout, num, den);
+                break;
+            case VOUT_CROP_WINDOW:
+                vout_SetCropWindow(vout, x, y, width, height);
+                break;
+            case VOUT_CROP_BORDER:
+                vout_SetCropBorder(vout, x, y, width, height);
+                break;
+            case VOUT_CROP_NONE:
+                break;
+            }
+        }
+        free(psz_crop);
+    }
+}
+
 int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input)
 {
     vout_thread_sys_t *vout = VOUT_THREAD_TO_SYS(cfg->vout);
@@ -2218,6 +2249,8 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
     }
 
     vlc_mutex_lock(&sys->window_lock);
+    vout_InitSource(vout);
+
     if (EnableWindowLocked(vout, &original) != 0)
     {
         /* the window was not enabled, nor the display started */
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index ef6625c1ee..54eb4a7c0a 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -104,6 +104,10 @@ int vout_ChangeSource( vout_thread_t *p_vout, const video_format_t *fmt );
 enum vout_crop_mode {
     VOUT_CROP_NONE, VOUT_CROP_RATIO, VOUT_CROP_WINDOW, VOUT_CROP_BORDER,
 };
+bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
+                        unsigned *num, unsigned *den,
+                        unsigned *x, unsigned *y,
+                        unsigned *width, unsigned *height );
 
 /* TODO to move them to vlc_vout.h */
 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 534f783a45..630961125b 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -450,7 +450,7 @@ exit:
     free( psz_path );
 }
 
-static bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
+bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
                         unsigned *num, unsigned *den,
                         unsigned *x, unsigned *y,
                         unsigned *width, unsigned *height )



More information about the vlc-commits mailing list