]> git.sesse.net Git - vlc/commitdiff
Added YUV fourcc helpers mainly for vout.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 5 Aug 2009 18:17:16 +0000 (20:17 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 5 Aug 2009 20:32:15 +0000 (22:32 +0200)
include/vlc_fourcc.h
src/libvlccore.sym
src/misc/fourcc.c

index 8c5a12b9d48d9fdce4bdc17fc08109c9742c467b..6250b0080c9010915236781100d7234b2d2d398e 100644 (file)
@@ -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 */
 
index 9db46ae351dc3d629b56c2b8509ab7ee6a8e2e0e..b332277c678f5c17c9b57fdff5904b9f52267726 100644 (file)
@@ -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
index 566de2d1818cb4708529de42f13f9316d4c5809f..67da6610811de96493606c97cf2850ded7ba179b 100644 (file)
@@ -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