Remove the dependency of libswscale on img_format.h
[ffmpeg.git] / libswscale / swscale_internal.h
index fd74ecb..d338c4e 100644 (file)
@@ -173,4 +173,52 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
 
 char *sws_format_name(int format);
 
+//FIXME replace this with something faster
+#define isPlanarYUV(x) ((x)==PIX_FMT_YUV410P || (x)==PIX_FMT_YUV420P   \
+                       || (x)==PIX_FMT_YUV411P || (x)==PIX_FMT_YUV422P \
+                       || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_NV12    \
+                       || (x)==PIX_FMT_NV21)
+#define isYUV(x)       ((x)==PIX_FMT_UYVY422 || (x)==PIX_FMT_YUYV422 || isPlanarYUV(x))
+#define isGray(x)      ((x)==PIX_FMT_GRAY8)
+#define isRGB(x)       ((x)==PIX_FMT_BGR32 || (x)==PIX_FMT_RGB24       \
+                       || (x)==PIX_FMT_RGB565 || (x)==PIX_FMT_RGB555   \
+                       || (x)==PIX_FMT_RGB8 || (x)==PIX_FMT_RGB4       \
+                       || (x)==PIX_FMT_MONOBLACK)
+#define isBGR(x)       ((x)==PIX_FMT_RGB32 || (x)==PIX_FMT_BGR24       \
+                       || (x)==PIX_FMT_BGR565 || (x)==PIX_FMT_BGR555   \
+                       || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_BGR4       \
+                       || (x)==PIX_FMT_MONOBLACK)
+
+static inline int fmt_depth(int fmt)
+{
+    switch(fmt) {
+        case PIX_FMT_BGRA:
+        case PIX_FMT_ABGR:
+        case PIX_FMT_RGBA:
+        case PIX_FMT_ARGB:
+            return 32;
+        case PIX_FMT_BGR24:
+        case PIX_FMT_RGB24:
+            return 24;
+        case PIX_FMT_BGR565:
+        case PIX_FMT_RGB565:
+            return 16;
+        case PIX_FMT_BGR555:
+        case PIX_FMT_RGB555:
+            return 15;
+        case PIX_FMT_BGR8:
+        case PIX_FMT_RGB8:
+            return 8;
+        case PIX_FMT_BGR4:
+        case PIX_FMT_RGB4:
+        case PIX_FMT_BGR4_BYTE:
+        case PIX_FMT_RGB4_BYTE:
+            return 4;
+        case PIX_FMT_MONOBLACK:
+            return 1;
+        default:
+            return 0;
+    }
+}
+
 #endif