<html><head></head><body>Hi,<br><br>I'll have to disagree on both points. Destination<-Source is the standard order in C/C++ and widely used in VLC for similar constructs such as the format helpers. As for the name, I don't see the inconsistency at all. It uses literally the most common function naming pattern in VLC.Mmmmmmmmm<br><br><div class="gmail_quote">Le 8 février 2021 09:59:08 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2021-02-06 17:27, remi@remlab.net wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">From: Rémi Denis-Courmont <remi@remlab.net><br><br>This changes the parser function to output into a single structure<br>rather than half a dozen different variables.<br><br>No functional changes.<hr>  src/video_output/video_output.c  | 18 +++++++-------<br>  src/video_output/vout_internal.h |  5 +---<br>  src/video_output/vout_intf.c     | 41 +++++++++++++++-----------------<br>  3 files changed, 28 insertions(+), 36 deletions(-)<br><br>diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c<br>index d01bf880d6..9ca6dab765 100644<br>--- a/src/video_output/video_output.c<br>+++ b/src/video_output/video_output.c<br>@@ -2214,24 +2214,22 @@ static void vout_InitSource(vout_thread_sys_t *vout)<br>  <br>      char *psz_crop = var_InheritString(&vout->obj, "crop");<br>      if (psz_crop) {<br>-        unsigned num, den;<br>-        unsigned y, x;<br>-        unsigned width, height;<br>-        enum vout_crop_mode mode;<br>+        struct vout_crop crop;<br>  <br>-        if (GetCropMode(psz_crop, &mode, &num, &den,<br>-                        &x, &y, &width, &height))<br>+        if (vout_ParseCrop(&crop, psz_crop))<br>          {<br>-            switch (mode)<br>+            switch (crop.mode)<br>              {<br>              case VOUT_CROP_RATIO:<br>-                vout_SetCropRatio(vout, num, den);<br>+                vout_SetCropRatio(vout, crop.ratio.num, crop.ratio.den);<br>                  break;<br>              case VOUT_CROP_WINDOW:<br>-                vout_SetCropWindow(vout, x, y, width, height);<br>+                vout_SetCropWindow(vout, crop.window.x, crop.window.y,<br>+                                   crop.window.width, crop.window.height);<br>                  break;<br>              case VOUT_CROP_BORDER:<br>-                vout_SetCropBorder(vout, x, y, width, height);<br>+                vout_SetCropBorder(vout, crop.border.left, crop.border.top,<br>+                                   crop.border.right, crop.border.bottom);<br>                  break;<br>              case VOUT_CROP_NONE:<br>                  break;<br>diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h<br>index a351106224..42e5748d54 100644<br>--- a/src/video_output/vout_internal.h<br>+++ b/src/video_output/vout_internal.h<br>@@ -126,10 +126,7 @@ struct vout_crop {<br>      };<br>  };<br>  <br>-bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,<br>-                        unsigned *num, unsigned *den,<br>-                        unsigned *x, unsigned *y,<br>-                        unsigned *width, unsigned *height );<br>+bool vout_ParseCrop(struct vout_crop *, const char *crop_str);<br></blockquote><br>The naming and ordering of parameters is inconsistent with the code around.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">  bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den);<br>  <br>  /* TODO to move them to vlc_vout.h */<br>diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c<br>index a4ea6bf5af..daa1d70eab 100644<br>--- a/src/video_output/vout_intf.c<br>+++ b/src/video_output/vout_intf.c<br>@@ -449,22 +449,21 @@ exit:<br>      free( psz_path );<br>  }<br>  <br>-bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,<br>-                        unsigned *num, unsigned *den,<br>-                        unsigned *x, unsigned *y,<br>-                        unsigned *width, unsigned *height )<br>+bool vout_ParseCrop(struct vout_crop *restrict cfg, const char *crop_str)<br>  {<br>-    if (sscanf(crop_str, "%u:%u", num, den) == 2) {<br>-        *mode = VOUT_CROP_RATIO;<br>+    if (sscanf(crop_str, "%u:%u", &cfg->ratio.num, &cfg->ratio.den) == 2) {<br>+        cfg->mode = VOUT_CROP_RATIO;<br>      } else if (sscanf(crop_str, "%ux%u+%u+%u",<br>-                      width, height, x, y) == 4) {<br>-        *mode = VOUT_CROP_WINDOW;<br>+                      &cfg->window.width, &cfg->window.height,<br>+                      &cfg->window.x, &cfg->window.y) == 4) {<br>+        cfg->mode = VOUT_CROP_WINDOW;<br>      } else if (sscanf(crop_str, "%u+%u+%u+%u",<br>-                    x, y, width, height) == 4) {<br>-        *mode = VOUT_CROP_BORDER;<br>+                      &cfg->border.left, &cfg->border.top,<br>+                      &cfg->border.right, &cfg->border.bottom) == 4) {<br>+        cfg->mode = VOUT_CROP_BORDER;<br>      } else if (*crop_str == '\0') {<br>-        *mode = VOUT_CROP_RATIO;<br>-        *num = *den = 0;<br>+        cfg->mode = VOUT_CROP_RATIO;<br>+        cfg->ratio.num = cfg->ratio.den = 0;<br>      } else {<br>          return false;<br>      }<br>@@ -479,23 +478,21 @@ static int CropCallback( vlc_object_t *object, char const *cmd,<br>  {<br>      vout_thread_t *vout = (vout_thread_t *)object;<br>      VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);<br>-    unsigned num, den;<br>-    unsigned y, x;<br>-    unsigned width, height;<br>-    enum vout_crop_mode mode;<br>+    struct vout_crop crop;<br>  <br>-    if (GetCropMode(newval.psz_string, &mode, &num, &den,<br>-                    &x, &y, &width, &height)) {<br>-        switch (mode)<br>+    if (vout_ParseCrop(&crop, newval.psz_string)) {<br>+        switch (crop.mode)<br>          {<br>              case VOUT_CROP_RATIO:<br>-                vout_ChangeCropRatio(vout, num, den);<br>+                vout_ChangeCropRatio(vout, crop.ratio.num, crop.ratio.den);<br>                  break;<br>              case VOUT_CROP_WINDOW:<br>-                vout_ChangeCropWindow(vout, x, y, width, height);<br>+                vout_ChangeCropWindow(vout, crop.window.x, crop.window.y,<br>+                                      crop.window.width, crop.window.height);<br>                  break;<br>              case VOUT_CROP_BORDER:<br>-                vout_ChangeCropBorder(vout, x, y, width, height);<br>+                vout_ChangeCropBorder(vout, crop.border.left, crop.border.top,<br>+                                      crop.border.right, crop.border.bottom);<br>                  break;<br>              case VOUT_CROP_NONE:<br>                  break;<br>-- <br>2.30.0<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>