[vlc-devel] commit: Added YUV fourcc helpers mainly for vout. (Laurent Aimar )

git version control git at videolan.org
Wed Aug 5 22:37:04 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Aug  5 20:17:16 2009 +0200| [4e34f941f1d66422b1273f3c147523aa4af866b7] | committer: Laurent Aimar 

Added YUV fourcc helpers mainly for vout.

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

 include/vlc_fourcc.h |   15 +++++
 src/libvlccore.sym   |    2 +
 src/misc/fourcc.c    |  153 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+), 0 deletions(-)

diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index 8c5a12b..6250b00 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -350,5 +350,20 @@ VLC_EXPORT( vlc_fourcc_t, vlc_fourcc_GetCodecAudio, ( vlc_fourcc_t i_fourcc, int
  */
 VLC_EXPORT( const char *, vlc_fourcc_GetDescription, ( int i_cat, vlc_fourcc_t i_fourcc ) );
 
+/**
+ * It returns a list (terminated with the value 0) of YUV fourccs in
+ * decreasing priority order for the given chroma.
+ *
+ * It will always return a non NULL pointer that must not freed.
+ */
+VLC_EXPORT( const vlc_fourcc_t *, vlc_fourcc_GetYUVFallback, ( vlc_fourcc_t ) );
+
+/**
+ * It returns true if the two fourccs are equivalent if their U&V planes are
+ * swapped.
+ */
+VLC_EXPORT( bool, vlc_fourcc_AreUVPlanesSwapped, (vlc_fourcc_t , vlc_fourcc_t ) );
+
+
 #endif /* _VLC_FOURCC_H */
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 9db46ae..b332277 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -483,6 +483,8 @@ vlc_fourcc_GetCodec
 vlc_fourcc_GetCodecAudio
 vlc_fourcc_GetCodecFromString
 vlc_fourcc_GetDescription
+vlc_fourcc_GetYUVFallback
+vlc_fourcc_AreUVPlanesSwapped
 vlc_gai_strerror
 vlc_gc_init
 vlc_getaddrinfo
diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index 566de2d..67da661 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -1283,3 +1283,156 @@ const char *vlc_fourcc_GetDescription( int i_cat, vlc_fourcc_t i_fourcc )
     return e.psz_description;
 }
 
+
+/* */
+#define VLC_CODEC_YUV_PLANAR_420 \
+    VLC_CODEC_I420, VLC_CODEC_YV12, VLC_CODEC_J420
+
+#define VLC_CODEC_YUV_PLANAR_422 \
+    VLC_CODEC_I422, VLC_CODEC_J422
+
+#define VLC_CODEC_YUV_PLANAR_440 \
+    VLC_CODEC_I440, VLC_CODEC_J440
+
+#define VLC_CODEC_YUV_PLANAR_444 \
+    VLC_CODEC_I444, VLC_CODEC_J444
+
+#define VLC_CODEC_YUV_PACKED \
+    VLC_CODEC_YUYV, VLC_CODEC_YVYU, \
+    VLC_CODEC_UYVY, VLC_CODEC_VYUY
+
+#define VLC_CODEC_FALLBACK_420 \
+    VLC_CODEC_YUV_PLANAR_422, VLC_CODEC_YUV_PACKED, \
+    VLC_CODEC_YUV_PLANAR_444, VLC_CODEC_YUV_PLANAR_440, \
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211
+
+static const vlc_fourcc_t p_I420_fallback[] = {
+    VLC_CODEC_I420, VLC_CODEC_YV12, VLC_CODEC_J420, VLC_CODEC_FALLBACK_420, 0
+};
+static const vlc_fourcc_t p_J420_fallback[] = {
+    VLC_CODEC_J420, VLC_CODEC_I420, VLC_CODEC_YV12, VLC_CODEC_FALLBACK_420, 0
+};
+static const vlc_fourcc_t p_YV12_fallback[] = {
+    VLC_CODEC_YV12, VLC_CODEC_I420, VLC_CODEC_J420, VLC_CODEC_FALLBACK_420, 0
+};
+
+#define VLC_CODEC_FALLBACK_422 \
+    VLC_CODEC_YUV_PACKED, VLC_CODEC_YUV_PLANAR_420, \
+    VLC_CODEC_YUV_PLANAR_444, VLC_CODEC_YUV_PLANAR_440, \
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211
+
+static const vlc_fourcc_t p_I422_fallback[] = {
+    VLC_CODEC_I422, VLC_CODEC_J422, VLC_CODEC_FALLBACK_422, 0
+};
+static const vlc_fourcc_t p_J422_fallback[] = {
+    VLC_CODEC_J422, VLC_CODEC_I422, VLC_CODEC_FALLBACK_422, 0
+};
+
+#define VLC_CODEC_FALLBACK_444 \
+    VLC_CODEC_YUV_PLANAR_422, VLC_CODEC_YUV_PACKED, \
+    VLC_CODEC_YUV_PLANAR_420, VLC_CODEC_YUV_PLANAR_440, \
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211
+
+static const vlc_fourcc_t p_I444_fallback[] = {
+    VLC_CODEC_I444, VLC_CODEC_J444, VLC_CODEC_FALLBACK_444, 0
+};
+static const vlc_fourcc_t p_J444_fallback[] = {
+    VLC_CODEC_J444, VLC_CODEC_I444, VLC_CODEC_FALLBACK_444, 0
+};
+
+static const vlc_fourcc_t p_I440_fallback[] = {
+    VLC_CODEC_I440,
+    VLC_CODEC_YUV_PLANAR_420,
+    VLC_CODEC_YUV_PLANAR_422,
+    VLC_CODEC_YUV_PLANAR_444,
+    VLC_CODEC_YUV_PACKED,
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211,
+};
+
+#define VLC_CODEC_FALLBACK_PACKED \
+    VLC_CODEC_YUV_PLANAR_422, VLC_CODEC_YUV_PLANAR_420, \
+    VLC_CODEC_YUV_PLANAR_444, VLC_CODEC_YUV_PLANAR_440, \
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211
+
+static const vlc_fourcc_t p_YUYV_fallback[] = {
+    VLC_CODEC_YUYV,
+    VLC_CODEC_YVYU,
+    VLC_CODEC_UYVY,
+    VLC_CODEC_VYUY,
+    VLC_CODEC_FALLBACK_PACKED, 0
+};
+static const vlc_fourcc_t p_YVYU_fallback[] = {
+    VLC_CODEC_YVYU,
+    VLC_CODEC_YUYV,
+    VLC_CODEC_UYVY,
+    VLC_CODEC_VYUY,
+    VLC_CODEC_FALLBACK_PACKED, 0
+};
+static const vlc_fourcc_t p_UYVY_fallback[] = {
+    VLC_CODEC_UYVY,
+    VLC_CODEC_VYUY,
+    VLC_CODEC_YUYV,
+    VLC_CODEC_YVYU,
+    VLC_CODEC_FALLBACK_PACKED, 0
+};
+static const vlc_fourcc_t p_VYUY_fallback[] = {
+    VLC_CODEC_VYUY,
+    VLC_CODEC_UYVY,
+    VLC_CODEC_YUYV,
+    VLC_CODEC_YVYU,
+    VLC_CODEC_FALLBACK_PACKED, 0
+};
+
+static const vlc_fourcc_t *pp_YUV_fallback[] = {
+    p_YV12_fallback,
+    p_I420_fallback,
+    p_J420_fallback,
+    p_I422_fallback,
+    p_J422_fallback,
+    p_I444_fallback,
+    p_J444_fallback,
+    p_I440_fallback,
+    p_YUYV_fallback,
+    p_YVYU_fallback,
+    p_UYVY_fallback,
+    p_VYUY_fallback,
+    NULL,
+};
+
+static const vlc_fourcc_t p_list_YUV[] = {
+    VLC_CODEC_YUV_PLANAR_420,
+    VLC_CODEC_YUV_PLANAR_422,
+    VLC_CODEC_YUV_PLANAR_440,
+    VLC_CODEC_YUV_PLANAR_444,
+    VLC_CODEC_YUV_PACKED,
+    VLC_CODEC_I411, VLC_CODEC_I410, VLC_CODEC_Y211,
+    0,
+};
+
+const vlc_fourcc_t *vlc_fourcc_GetYUVFallback( vlc_fourcc_t i_fourcc )
+{
+    for( unsigned i = 0; pp_YUV_fallback[i]; i++ )
+    {
+        if( pp_YUV_fallback[i][0] == i_fourcc )
+            return pp_YUV_fallback[i];
+    }
+    return p_list_YUV;
+}
+
+bool vlc_fourcc_AreUVPlanesSwapped( vlc_fourcc_t a, vlc_fourcc_t b )
+{
+    return (((a == VLC_CODEC_I420 || a == VLC_CODEC_J420) && b == VLC_CODEC_YV12) ||
+            ((b == VLC_CODEC_I420 || b == VLC_CODEC_J420) && a == VLC_CODEC_YV12));
+}
+
+#if 0
+static inline bool vlc_fourcc_IsYUV(vlc_fourcc_t fcc)
+{
+    for( unsigned i = 0; p_list_YUV[i]; i++ )
+    {
+        if( p_list_YUV[i] == fcc )
+            return true;
+    }
+    return false;
+}
+#endif




More information about the vlc-devel mailing list