summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-08-31 22:39:04 +0200
committerDudemanguy <random342@airmail.cc>2023-09-08 02:27:08 +0000
commitfef4481bfec74ea20e3c78cedd657977cac16434 (patch)
tree8f130f065e0ffcaf2ce411797f3f16032ee66ce3
parentb47a58516af2c36e66c3987748b5b4a1275ed9e7 (diff)
downloadmpv-fef4481bfec74ea20e3c78cedd657977cac16434.tar.bz2
mpv-fef4481bfec74ea20e3c78cedd657977cac16434.tar.xz
m_option: make m_rect_apply center based
This makes it easier to apply crops without need to manually calc the offset. I wanted for it to be top-left corner based, but maybe it was not that good idea in retrospect. Also rename scrw/scrh, since they don't refer to screen. It was copied form m_geometry apply.
-rw-r--r--DOCS/man/options.rst2
-rw-r--r--options/m_option.c14
-rw-r--r--options/m_option.h2
3 files changed, 7 insertions, 11 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index b271ab4a62..139e32a289 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1571,7 +1571,7 @@ Video
applied to the source video rectangle (before anamorphic stretch) by the VO.
A crop rectangle that is not within the video rectangle will be ignored.
This works with hwdec, unlike the equivalent 'lavfi-crop'. Setting the crop
- to '0x0' disables it.
+ to '0' disables it. When offset is omitted, the central area will be cropped.
``--video-zoom=<value>``
Adjust the video display scale factor by the given value. The parameter is
diff --git a/options/m_option.c b/options/m_option.c
index 14fd119704..b7cc4f7996 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2381,20 +2381,16 @@ const m_option_type_t m_option_type_size_box = {
.equal = geometry_equal,
};
-void m_rect_apply(struct mp_rect *rc, int scrw, int scrh, struct m_geometry *gm)
+void m_rect_apply(struct mp_rect *rc, int w, int h, struct m_geometry *gm)
{
- *rc = (struct mp_rect){0};
- m_geometry_apply(&rc->x0, &rc->y0, &rc->x1, &rc->y1, scrw, scrh, gm);
+ *rc = (struct mp_rect){0, 0, w, h};
+ m_geometry_apply(&rc->x0, &rc->y0, &rc->x1, &rc->y1, w, h, gm);
if (!gm->xy_valid && gm->wh_valid && rc->x1 == 0 && rc->y1 == 0)
return;
- if (!gm->xy_valid) {
- rc->x0 = 0;
- rc->y0 = 0;
- }
if (!gm->wh_valid || rc->x1 == 0 || rc->x1 == INT_MIN)
- rc->x1 = scrw - rc->x0;
+ rc->x1 = w - rc->x0;
if (!gm->wh_valid || rc->y1 == 0 || rc->y1 == INT_MIN)
- rc->y1 = scrh - rc->y0;
+ rc->y1 = h - rc->y0;
rc->x1 += rc->x0;
rc->y1 += rc->y0;
}
diff --git a/options/m_option.h b/options/m_option.h
index 0683822988..3e86485930 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -105,7 +105,7 @@ struct m_geometry {
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
int scrw, int scrh, struct m_geometry *gm);
-void m_rect_apply(struct mp_rect *rc, int scrw, int scrh, struct m_geometry *gm);
+void m_rect_apply(struct mp_rect *rc, int w, int h, struct m_geometry *gm);
struct m_channels {
bool set : 1;