[vlc-commits] vout: merge all three vout_ChangeCrop*()
Rémi Denis-Courmont
git at videolan.org
Mon Feb 8 15:15:00 UTC 2021
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 6 16:59:49 2021 +0200| [3339a4c65fb0826b728fce028af29ccc05665dd5] | committer: Rémi Denis-Courmont
vout: merge all three vout_ChangeCrop*()
...into a single function using struct vout_crop.
This also fixes setting the "crop" variable to the empty string to
actually undo the crop settings. It was incorrectly ignored.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3339a4c65fb0826b728fce028af29ccc05665dd5
---
src/video_output/video_output.c | 61 +++++++++++++++++++++++++---------------
src/video_output/vout_internal.h | 4 +--
src/video_output/vout_intf.c | 23 +++------------
3 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 9ca6dab765..d6370a35a8 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -647,24 +647,6 @@ static void vout_SetCropRatio(vout_thread_sys_t *sys, unsigned num, unsigned den
sys->source.crop.mode = VOUT_CROP_NONE;
}
-void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
-{
- vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
- assert(!sys->dummy);
-
- vlc_mutex_lock(&sys->window_lock);
- vout_SetCropRatio(sys, num, den);
-
- vout_UpdateWindowSizeLocked(sys);
-
- vlc_mutex_lock(&sys->display_lock);
- vlc_mutex_unlock(&sys->window_lock);
-
- if (sys->display != NULL)
- vout_SetDisplayCrop(sys->display, num, den, 0, 0, 0, 0);
- vlc_mutex_unlock(&sys->display_lock);
-}
-
static void vout_SetCropWindow(vout_thread_sys_t *sys,
int x, int y, int width, int height)
{
@@ -722,14 +704,29 @@ static void vout_SetCropBorder(vout_thread_sys_t *sys,
sys->source.crop.border.bottom = bottom;
}
-void vout_ChangeCropBorder(vout_thread_t *vout,
- int left, int top, int right, int bottom)
+void vout_ChangeCrop(vout_thread_t *vout,
+ const struct vout_crop *restrict crop)
{
vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
assert(!sys->dummy);
vlc_mutex_lock(&sys->window_lock);
- vout_SetCropBorder(sys, left, top, right, bottom);
+ switch (crop->mode) {
+ case VOUT_CROP_NONE:
+ vout_SetCropRatio(sys, 0, 0);
+ break;
+ case VOUT_CROP_RATIO:
+ vout_SetCropRatio(sys, crop->ratio.num, crop->ratio.den);
+ break;
+ case VOUT_CROP_WINDOW:
+ vout_SetCropWindow(sys, crop->window.x, crop->window.y,
+ crop->window.width, crop->window.height);
+ break;
+ case VOUT_CROP_BORDER:
+ vout_SetCropBorder(sys, crop->border.left, crop->border.top,
+ crop->border.right, crop->border.bottom);
+ break;
+ }
vout_UpdateWindowSizeLocked(sys);
@@ -737,8 +734,26 @@ void vout_ChangeCropBorder(vout_thread_t *vout,
vlc_mutex_unlock(&sys->window_lock);
if (sys->display != NULL)
- vout_SetDisplayCrop(sys->display, 0, 0,
- left, top, -right, -bottom);
+ switch (crop->mode) {
+ case VOUT_CROP_NONE:
+ vout_SetDisplayCrop(sys->display, 0, 0, 0, 0, 0, 0);
+ break;
+ case VOUT_CROP_RATIO:
+ vout_SetDisplayCrop(sys->display, crop->ratio.num,
+ crop->ratio.den, 0, 0, 0, 0);
+ break;
+ case VOUT_CROP_WINDOW:
+ vout_SetDisplayCrop(sys->display, 0, 0,
+ crop->window.x, crop->window.y,
+ crop->window.width, crop->window.height);
+ break;
+ case VOUT_CROP_BORDER:
+ vout_SetDisplayCrop(sys->display, 0, 0,
+ crop->border.left, crop->border.top,
+ -crop->border.right, -crop->border.bottom);
+ break;
+ }
+
vlc_mutex_unlock(&sys->display_lock);
}
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 42e5748d54..f795af64e5 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -137,9 +137,7 @@ void vout_ChangeDisplaySize(vout_thread_t *, unsigned width, unsigned height);
void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled);
void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned den);
-void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
-void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
-void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
+void vout_ChangeCrop(vout_thread_t *, const struct vout_crop *);
void vout_ControlChangeFilters(vout_thread_t *, const char *);
void vout_ControlChangeInterlacing(vout_thread_t *, bool);
void vout_ControlChangeSubSources(vout_thread_t *, const char *);
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index daa1d70eab..1a20350527 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -480,26 +480,11 @@ static int CropCallback( vlc_object_t *object, char const *cmd,
VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
struct vout_crop crop;
- if (vout_ParseCrop(&crop, newval.psz_string)) {
- switch (crop.mode)
- {
- case VOUT_CROP_RATIO:
- vout_ChangeCropRatio(vout, crop.ratio.num, crop.ratio.den);
- break;
- case VOUT_CROP_WINDOW:
- vout_ChangeCropWindow(vout, crop.window.x, crop.window.y,
- crop.window.width, crop.window.height);
- break;
- case VOUT_CROP_BORDER:
- vout_ChangeCropBorder(vout, crop.border.left, crop.border.top,
- crop.border.right, crop.border.bottom);
- break;
- case VOUT_CROP_NONE:
- break;
- }
- } else {
+ if (vout_ParseCrop(&crop, newval.psz_string))
+ vout_ChangeCrop(vout, &crop);
+ else
msg_Err(object, "Unknown crop format (%s)", newval.psz_string);
- }
+
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list