[vlc-commits] vout: split VoutValidateFormat() in two functions

Rémi Denis-Courmont git at videolan.org
Wed Jan 23 17:04:22 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jan 21 21:46:39 2019 +0200| [65a703344c78baec789485eb9db6dcf58882898c] | committer: Rémi Denis-Courmont

vout: split VoutValidateFormat() in two functions

No functional changes.

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

 src/video_output/video_output.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index daac63ee33..d4a81a704a 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -75,16 +75,18 @@ static void VoutDestructor(vlc_object_t *);
 #define VOUT_MWAIT_TOLERANCE VLC_TICK_FROM_MS(4)
 
 /* */
-static int VoutValidateFormat(video_format_t *dst,
-                              const video_format_t *src)
+static bool VoutCheckFormat(const video_format_t *src)
 {
     if (src->i_width == 0  || src->i_width  > 8192 ||
         src->i_height == 0 || src->i_height > 8192)
-        return VLC_EGENERIC;
+        return false;
     if (src->i_sar_num <= 0 || src->i_sar_den <= 0)
-        return VLC_EGENERIC;
+        return false;
+    return true;
+}
 
-    /* */
+static void VoutFixFormat(video_format_t *dst, const video_format_t *src)
+{
     video_format_Copy(dst, src);
     dst->i_chroma = vlc_fourcc_GetCodec(VIDEO_ES, src->i_chroma);
     vlc_ureduce( &dst->i_sar_num, &dst->i_sar_den,
@@ -94,7 +96,6 @@ static int VoutValidateFormat(video_format_t *dst,
         dst->i_sar_den = 1;
     }
     video_format_FixRgb(dst);
-    return VLC_SUCCESS;
 }
 
 static bool VideoFormatIsCropArEqual(video_format_t *dst,
@@ -112,9 +113,12 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
                                  input_thread_t *input)
 {
     video_format_t original;
-    if (VoutValidateFormat(&original, cfg->fmt))
+
+    if (!VoutCheckFormat(cfg->fmt))
         return NULL;
 
+    VoutFixFormat(&original, cfg->fmt);
+
     /* Allocate descriptor */
     vout_thread_t *vout = vlc_custom_create(object,
                                             sizeof(*vout) + sizeof(*vout->p),
@@ -1514,11 +1518,13 @@ static int ThreadReinit(vout_thread_t *vout,
     vout->p->pause.is_on = false;
     vout->p->pause.date  = VLC_TICK_INVALID;
 
-    if (VoutValidateFormat(&original, cfg->fmt)) {
+    if (!VoutCheckFormat(cfg->fmt)) {
         ThreadStop(vout, NULL);
         return VLC_EGENERIC;
     }
 
+    VoutFixFormat(&original, cfg->fmt);
+
     /* We ignore ar changes at this point, they are dynamically supported.
      * #19268: don't ignore crop changes (fix vouts using the crop size of the
      * previous format). */



More information about the vlc-commits mailing list