[vlc-devel] [PATCH 1/5] fourcc: add a generic GetFallback helper function

Niklas Haas vlc at haasn.xyz
Wed Oct 10 03:46:33 CEST 2018


From: Niklas Haas <git at haasn.xyz>

There's only GetYUVFallback and GetRGBFallback. This one picks the right
function based on the type of fourcc in use.
---
 include/vlc_fourcc.h | 9 +++++++++
 src/libvlccore.sym   | 1 +
 src/misc/fourcc.c    | 7 +++++++
 3 files changed, 17 insertions(+)

diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index 871f01043a..bd192b160c 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -685,6 +685,15 @@ VLC_API const vlc_fourcc_t * vlc_fourcc_GetYUVFallback( vlc_fourcc_t );
  */
 VLC_API const vlc_fourcc_t * vlc_fourcc_GetRGBFallback( vlc_fourcc_t );
 
+/**
+ * It returns a list (terminated with the value 0) of fourccs in decreasing
+ * priority order for the given chroma. It will return either YUV or RGB
+ * fallbacks depending on whether or not the fourcc given is YUV.
+ *
+ * It will always return a non NULL pointer that must not be freed.
+ */
+VLC_API const vlc_fourcc_t * vlc_fourcc_GetFallback( vlc_fourcc_t );
+
 /**
  * It returns true if the given fourcc is YUV and false otherwise.
  */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a1709cb9f6..1a9fea3735 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -576,6 +576,7 @@ vlc_fourcc_GetChromaDescription
 vlc_fourcc_IsYUV
 vlc_fourcc_GetRGBFallback
 vlc_fourcc_GetYUVFallback
+vlc_fourcc_GetFallback
 vlc_fourcc_AreUVPlanesSwapped
 vlc_getaddrinfo
 vlc_getaddrinfo_i11e
diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index e99ac32774..98fa40cf79 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -620,6 +620,13 @@ const vlc_fourcc_t *vlc_fourcc_GetRGBFallback( vlc_fourcc_t i_fourcc )
     return GetFallback( i_fourcc, pp_RGB_fallback, p_RGB32_fallback );
 }
 
+const vlc_fourcc_t *vlc_fourcc_GetFallback( vlc_fourcc_t i_fourcc )
+{
+    return vlc_fourcc_IsYUV( i_fourcc)
+            ? vlc_fourcc_GetYUVFallback( i_fourcc )
+            : vlc_fourcc_GetRGBFallback( i_fourcc );
+}
+
 bool vlc_fourcc_AreUVPlanesSwapped( vlc_fourcc_t a, vlc_fourcc_t b )
 {
     static const vlc_fourcc_t pp_swapped[][4] = {
-- 
2.19.0



More information about the vlc-devel mailing list