Browse code

deprecate palette8topacked32 in favor of public API functions sws_convertPalette8ToPacked32 and -24

additionallym deprecate palette8torgb16 and its bgr variant without
replacement. These functions are not meant to be used by applications.

Discussed at: http://comments.gmane.org/gmane.comp.video.ffmpeg.devel/109340

Originally committed as revision 31301 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale

Reinhard Tartler authored on 2010/06/02 04:35:16
Showing 4 changed files
... ...
@@ -207,31 +207,15 @@ void sws_rgb2rgb_init(int flags)
207 207
         rgb2rgb_init_C();
208 208
 }
209 209
 
210
-/**
211
- * Convert the palette to the same packet 32-bit format as the palette
212
- */
210
+#if LIBSWSCALE_VERSION_MAJOR < 1
213 211
 void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
214 212
 {
215
-    long i;
216
-
217
-    for (i=0; i<num_pixels; i++)
218
-        ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
213
+    sws_convertPalette8ToPacked32(src, dst, num_pixels, palette);
219 214
 }
220 215
 
221
-/**
222
- * Palette format: ABCD -> dst format: ABC
223
- */
224 216
 void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
225 217
 {
226
-    long i;
227
-
228
-    for (i=0; i<num_pixels; i++) {
229
-        //FIXME slow?
230
-        dst[0]= palette[src[i]*4+0];
231
-        dst[1]= palette[src[i]*4+1];
232
-        dst[2]= palette[src[i]*4+2];
233
-        dst+= 3;
234
-    }
218
+    sws_convertPalette8ToPacked24(src, dst, num_pixels, palette);
235 219
 }
236 220
 
237 221
 /**
... ...
@@ -249,6 +233,7 @@ void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const ui
249 249
     for (i=0; i<num_pixels; i++)
250 250
         ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]);
251 251
 }
252
+#endif
252 253
 
253 254
 void rgb32to24(const uint8_t *src, uint8_t *dst, long src_size)
254 255
 {
... ...
@@ -4,7 +4,7 @@
4 4
  *               Software YUV to YUV converter
5 5
  *               Software YUV to RGB converter
6 6
  *  Written by Nick Kurshev.
7
- *  palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
7
+ *  YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
8 8
  *
9 9
  * This file is part of FFmpeg.
10 10
  *
... ...
@@ -28,6 +28,9 @@
28 28
 
29 29
 #include <inttypes.h>
30 30
 
31
+#include "libswscale/swscale.h"
32
+#include "libavutil/avutil.h"
33
+
31 34
 /* A full collection of RGB to RGB(BGR) converters */
32 35
 extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size);
33 36
 extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size);
... ...
@@ -66,10 +69,15 @@ void shuffle_bytes_2103(const uint8_t *src, uint8_t *dst, long src_size);
66 66
 void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, long src_size);
67 67
 void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, long src_size);
68 68
 
69
-void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
70
-void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
71
-void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
72
-void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
69
+#if LIBSWSCALE_VERSION_MAJOR < 1
70
+/* deprecated, use the public versions in swscale.h */
71
+attribute_deprecated void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
72
+attribute_deprecated void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
73
+
74
+/* totally deprecated, please fix code that uses this */
75
+attribute_deprecated void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
76
+attribute_deprecated void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
77
+#endif
73 78
 
74 79
 /**
75 80
  * Height should be a multiple of 2 and width should be a multiple of 16.
... ...
@@ -1419,12 +1419,12 @@ static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[],
1419 1419
 
1420 1420
     if (usePal(srcFormat)) {
1421 1421
         switch (dstFormat) {
1422
-        case PIX_FMT_RGB32  : conv = palette8topacked32; break;
1423
-        case PIX_FMT_BGR32  : conv = palette8topacked32; break;
1424
-        case PIX_FMT_BGR32_1: conv = palette8topacked32; break;
1425
-        case PIX_FMT_RGB32_1: conv = palette8topacked32; break;
1426
-        case PIX_FMT_RGB24  : conv = palette8topacked24; break;
1427
-        case PIX_FMT_BGR24  : conv = palette8topacked24; break;
1422
+        case PIX_FMT_RGB32  : conv = sws_convertPalette8ToPacked32; break;
1423
+        case PIX_FMT_BGR32  : conv = sws_convertPalette8ToPacked32; break;
1424
+        case PIX_FMT_BGR32_1: conv = sws_convertPalette8ToPacked32; break;
1425
+        case PIX_FMT_RGB32_1: conv = sws_convertPalette8ToPacked32; break;
1426
+        case PIX_FMT_RGB24  : conv = sws_convertPalette8ToPacked24; break;
1427
+        case PIX_FMT_BGR24  : conv = sws_convertPalette8ToPacked24; break;
1428 1428
         }
1429 1429
     }
1430 1430
 
... ...
@@ -1957,3 +1957,26 @@ int sws_scale_ordered(SwsContext *c, const uint8_t* const src[], int srcStride[]
1957 1957
     return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
1958 1958
 }
1959 1959
 #endif
1960
+
1961
+/* Convert the palette to the same packed 32-bit format as the palette */
1962
+void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
1963
+{
1964
+    long i;
1965
+
1966
+    for (i=0; i<num_pixels; i++)
1967
+        ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
1968
+}
1969
+
1970
+/* Palette format: ABCD -> dst format: ABC */
1971
+void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
1972
+{
1973
+    long i;
1974
+
1975
+    for (i=0; i<num_pixels; i++) {
1976
+        //FIXME slow?
1977
+        dst[0]= palette[src[i]*4+0];
1978
+        dst[1]= palette[src[i]*4+1];
1979
+        dst[2]= palette[src[i]*4+2];
1980
+        dst+= 3;
1981
+    }
1982
+}
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/avutil.h"
31 31
 
32 32
 #define LIBSWSCALE_VERSION_MAJOR 0
33
-#define LIBSWSCALE_VERSION_MINOR 10
33
+#define LIBSWSCALE_VERSION_MINOR 11
34 34
 #define LIBSWSCALE_VERSION_MICRO 0
35 35
 
36 36
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
... ...
@@ -303,4 +303,29 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context,
303 303
                                         int flags, SwsFilter *srcFilter,
304 304
                                         SwsFilter *dstFilter, const double *param);
305 305
 
306
+/**
307
+ * Converts an 8bit paletted frame into a frame with a color depth of 32-bits.
308
+ *
309
+ * The output frame will have the same packed format as the palette.
310
+ *
311
+ * @param src        source frame buffer
312
+ * @param dst        destination frame buffer
313
+ * @param num_pixels number of pixels to convert
314
+ * @param palette    array with [256] entries, which must match color arrangement (RGB or BGR) of src
315
+ */
316
+void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
317
+
318
+/**
319
+ * Converts an 8bit paletted frame into a frame with a color depth of 24 bits.
320
+ *
321
+ * With the palette format "ABCD", the destination frame ends up with the format "ABC".
322
+ *
323
+ * @param src        source frame buffer
324
+ * @param dst        destination frame buffer
325
+ * @param num_pixels number of pixels to convert
326
+ * @param palette    array with [256] entries, which must match color arrangement (RGB or BGR) of src
327
+ */
328
+void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
329
+
330
+
306 331
 #endif /* SWSCALE_SWSCALE_H */