[MPlayer-dev-eng] remove palette8torgb15 and palette8torgb15, was: make swscale's palette functions public

Reinhard Tartler siretart at tauware.de
Tue Jun 1 22:01:45 CEST 2010


On Mo, Mai 31, 2010 at 18:49:14 (CEST), Reimar Döffinger wrote:

> Seems fine, though I think vf_palette might not be 100% working anymore anyway.
> At the very least it is not really useful with FFmpeg decoders since they all use the
> same palette format.

Now with this patch in, I'm proposing this change for vf_palette to
avoid using swscale internals:

Index: vf_palette.c
===================================================================
--- vf_palette.c	(revision 31301)
+++ vf_palette.c	(working copy)
@@ -30,7 +30,6 @@
 #include "vf.h"
 
 #include "libswscale/swscale.h"
-#include "libswscale/rgb2rgb.h"
 
 //===========================================================================//
 
@@ -53,6 +52,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] = ((((const uint16_t *)palette)[src[i]]) >> 8) | 
+                               ((((const uint16_t *)palette)[src[i]]) << 8);
+}
+
 static unsigned int gray_pal[256];
 
 static unsigned int find_best(struct vf_instance *vf, unsigned int fmt){


-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4



More information about the MPlayer-dev-eng mailing list