diff libmpcodecs/vf_palette.c @ 31237:878762329600

avoid using swscale internals by copying in palette8torbg16 and its bgr variant
author siretart
date Tue, 01 Jun 2010 21:07:02 +0000
parents 661755507236
children 7af3e6f901fd
line wrap: on
line diff
--- a/libmpcodecs/vf_palette.c	Tue Jun 01 20:12:58 2010 +0000
+++ b/libmpcodecs/vf_palette.c	Tue Jun 01 21:07:02 2010 +0000
@@ -28,9 +28,9 @@
 #include "img_format.h"
 #include "mp_image.h"
 #include "vf.h"
+#include "mpbswap.h"
 
 #include "libswscale/swscale.h"
-#include "libswscale/rgb2rgb.h"
 
 //===========================================================================//
 
@@ -53,6 +53,23 @@
     0
 };
 
+/**
+ * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette.
+ */
+static void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+    long i;
+    for (i=0; i<num_pixels; i++)
+        ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]];
+}
+
+static void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+    long i;
+    for (i=0; i<num_pixels; i++)
+        ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]);
+}
+
 static unsigned int gray_pal[256];
 
 static unsigned int find_best(struct vf_instance *vf, unsigned int fmt){