[vlc-commits] [Git][videolan/vlc][3.0.x] croppadd: handle metadata rotated videos

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Feb 22 11:26:17 UTC 2022



Rémi Denis-Courmont pushed to branch 3.0.x at VideoLAN / VLC


Commits:
d3e78c23 by Mitch Capper at 2022-02-22T10:49:01+00:00
croppadd: handle metadata rotated videos

(cherry picked from commit 419ad46d792b586ba038c452eddb59c96d9befc2)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

- - - - -


1 changed file:

- modules/video_filter/croppadd.c


Changes:

=====================================
modules/video_filter/croppadd.c
=====================================
@@ -123,6 +123,29 @@ struct filter_sys_t
     int i_paddright;
 };
 
+#define IDX_TOP 0
+#define IDX_LEFT 1
+#define IDX_BOTTOM 2
+#define IDX_RIGHT 3
+
+struct transform {
+    unsigned idx_top;
+    unsigned idx_left;
+    /* idx_bottom is idx_top XOR 2
+       idx_right is idx_left XOR 2 */
+};
+
+static const struct transform transforms[8] = {
+    [ORIENT_TOP_LEFT]     = { IDX_TOP,    IDX_LEFT },
+    [ORIENT_TOP_RIGHT]    = { IDX_TOP,    IDX_RIGHT },
+    [ORIENT_BOTTOM_LEFT]  = { IDX_BOTTOM, IDX_LEFT },
+    [ORIENT_BOTTOM_RIGHT] = { IDX_BOTTOM, IDX_RIGHT },
+    [ORIENT_LEFT_TOP]     = { IDX_LEFT,   IDX_TOP },
+    [ORIENT_LEFT_BOTTOM]  = { IDX_LEFT,   IDX_BOTTOM },
+    [ORIENT_RIGHT_TOP]    = { IDX_RIGHT,  IDX_TOP },
+    [ORIENT_RIGHT_BOTTOM] = { IDX_RIGHT,  IDX_BOTTOM },
+};
+
 /*****************************************************************************
  * OpenFilter: probe the filter and return score
  *****************************************************************************/
@@ -174,6 +197,23 @@ static int OpenFilter( vlc_object_t *p_this )
     GET_OPTION( paddleft )
     GET_OPTION( paddright )
 
+    video_format_t *fmt = &p_filter->fmt_in.video;
+    video_orientation_t orientation = fmt->orientation;
+    const struct transform *tx = &transforms[orientation];
+    /* In the same order as IDX_ constants values */
+    unsigned crop[] = { p_sys->i_croptop, p_sys->i_cropleft, p_sys->i_cropbottom, p_sys->i_cropright };
+    unsigned padd[] = { p_sys->i_paddtop, p_sys->i_paddleft, p_sys->i_paddbottom, p_sys->i_paddright };
+
+    p_sys->i_croptop = crop[tx->idx_top];
+    p_sys->i_cropleft = crop[tx->idx_left];
+    p_sys->i_cropbottom = crop[tx->idx_top ^ 2];
+    p_sys->i_cropright = crop[tx->idx_left ^ 2];
+
+    p_sys->i_paddtop = padd[tx->idx_top];
+    p_sys->i_paddleft = padd[tx->idx_left];
+    p_sys->i_paddbottom = padd[tx->idx_top ^ 2];
+    p_sys->i_paddright = padd[tx->idx_left ^ 2];
+
     p_filter->fmt_out.video.i_height =
     p_filter->fmt_out.video.i_visible_height =
         p_filter->fmt_in.video.i_visible_height



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/d3e78c235b349fe25e3952980ead13a49d39b136

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/d3e78c235b349fe25e3952980ead13a49d39b136
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list