[FFmpeg-cvslog] r23446 - in branches/0.6: . doc/APIchanges libswscale/rgb2rgb.c libswscale/rgb2rgb.h libswscale/swscale.c libswscale/swscale.h

siretart subversion
Thu Jun 3 22:16:42 CEST 2010


Author: siretart
Date: Thu Jun  3 22:16:42 2010
New Revision: 23446

Log:
Add an entry to APIchanges for the addition of sws_convertPalette8ToPacked32 -24


backport r23415 by siretart

Modified:
   branches/0.6/   (props changed)
   branches/0.6/doc/APIchanges
   branches/0.6/libswscale/rgb2rgb.c
   branches/0.6/libswscale/rgb2rgb.h
   branches/0.6/libswscale/swscale.c
   branches/0.6/libswscale/swscale.h

Modified: branches/0.6/doc/APIchanges
==============================================================================
--- branches/0.6/doc/APIchanges	Thu Jun  3 22:11:36 2010	(r23445)
+++ branches/0.6/doc/APIchanges	Thu Jun  3 22:16:42 2010	(r23446)
@@ -12,6 +12,9 @@ libavutil:   2009-03-08
 
 API changes, most recent first:
 
+2010-06-01 - r31301 - lsws 0.11.0 - convertPalette API
+  Add sws_convertPalette8ToPacked32 and sws_convertPalette8ToPacked24
+
 2010-05-26 - r23334 - lavc 52.72.0 - CODEC_CAP_EXPERIMENTAL
   Add CODEC_CAP_EXPERIMENTAL flag.
 

Modified: branches/0.6/libswscale/rgb2rgb.c
==============================================================================
--- branches/0.6/libswscale/rgb2rgb.c	Thu Jun  3 22:11:36 2010	(r23445)
+++ branches/0.6/libswscale/rgb2rgb.c	Thu Jun  3 22:16:42 2010	(r23446)
@@ -207,31 +207,15 @@ void sws_rgb2rgb_init(int flags)
         rgb2rgb_init_C();
 }
 
-/**
- * Convert the palette to the same packet 32-bit format as the palette
- */
+#if LIBSWSCALE_VERSION_MAJOR < 1
 void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 {
-    long i;
-
-    for (i=0; i<num_pixels; i++)
-        ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
+    sws_convertPalette8ToPacked32(src, dst, num_pixels, palette);
 }
 
-/**
- * Palette format: ABCD -> dst format: ABC
- */
 void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
 {
-    long i;
-
-    for (i=0; i<num_pixels; i++) {
-        //FIXME slow?
-        dst[0]= palette[src[i]*4+0];
-        dst[1]= palette[src[i]*4+1];
-        dst[2]= palette[src[i]*4+2];
-        dst+= 3;
-    }
+    sws_convertPalette8ToPacked24(src, dst, num_pixels, palette);
 }
 
 /**
@@ -250,21 +234,7 @@ void palette8tobgr16(const uint8_t *src,
         ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]);
 }
 
-/**
- * Palette is assumed to contain BGR15, see rgb32to15 to convert the palette.
- */
-void palette8torgb15(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]];
-}
-void palette8tobgr15(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]]);
-}
+#endif
 
 void rgb32to24(const uint8_t *src, uint8_t *dst, long src_size)
 {

Modified: branches/0.6/libswscale/rgb2rgb.h
==============================================================================
--- branches/0.6/libswscale/rgb2rgb.h	Thu Jun  3 22:11:36 2010	(r23445)
+++ branches/0.6/libswscale/rgb2rgb.h	Thu Jun  3 22:16:42 2010	(r23446)
@@ -4,7 +4,7 @@
  *               Software YUV to YUV converter
  *               Software YUV to RGB converter
  *  Written by Nick Kurshev.
- *  palette & YUV & runtime CPU stuff by Michael (michaelni at gmx.at)
+ *  YUV & runtime CPU stuff by Michael (michaelni at gmx.at)
  *
  * This file is part of FFmpeg.
  *
@@ -28,6 +28,9 @@
 
 #include <inttypes.h>
 
+#include "libswscale/swscale.h"
+#include "libavutil/avutil.h"
+
 /* A full collection of RGB to RGB(BGR) converters */
 extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size);
 extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size);
@@ -66,12 +69,15 @@ void shuffle_bytes_2103(const uint8_t *s
 void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, long src_size);
 void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, long src_size);
 
-void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
-void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
-void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
-void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
-void palette8torgb15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
-void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+#if LIBSWSCALE_VERSION_MAJOR < 1
+/* deprecated, use the public versions in swscale.h */
+attribute_deprecated void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+attribute_deprecated void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+
+/* totally deprecated, please fix code that uses this */
+attribute_deprecated void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+attribute_deprecated void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+#endif
 
 /**
  * Height should be a multiple of 2 and width should be a multiple of 16.

Modified: branches/0.6/libswscale/swscale.c
==============================================================================
--- branches/0.6/libswscale/swscale.c	Thu Jun  3 22:11:36 2010	(r23445)
+++ branches/0.6/libswscale/swscale.c	Thu Jun  3 22:16:42 2010	(r23446)
@@ -1424,12 +1424,12 @@ static int palToRgbWrapper(SwsContext *c
 
     if (usePal(srcFormat)) {
         switch (dstFormat) {
-        case PIX_FMT_RGB32  : conv = palette8topacked32; break;
-        case PIX_FMT_BGR32  : conv = palette8topacked32; break;
-        case PIX_FMT_BGR32_1: conv = palette8topacked32; break;
-        case PIX_FMT_RGB32_1: conv = palette8topacked32; break;
-        case PIX_FMT_RGB24  : conv = palette8topacked24; break;
-        case PIX_FMT_BGR24  : conv = palette8topacked24; break;
+        case PIX_FMT_RGB32  : conv = sws_convertPalette8ToPacked32; break;
+        case PIX_FMT_BGR32  : conv = sws_convertPalette8ToPacked32; break;
+        case PIX_FMT_BGR32_1: conv = sws_convertPalette8ToPacked32; break;
+        case PIX_FMT_RGB32_1: conv = sws_convertPalette8ToPacked32; break;
+        case PIX_FMT_RGB24  : conv = sws_convertPalette8ToPacked24; break;
+        case PIX_FMT_BGR24  : conv = sws_convertPalette8ToPacked24; break;
         }
     }
 
@@ -1962,3 +1962,26 @@ int sws_scale_ordered(SwsContext *c, con
     return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
 }
 #endif
+
+/* Convert the palette to the same packed 32-bit format as the palette */
+void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+    long i;
+
+    for (i=0; i<num_pixels; i++)
+        ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
+}
+
+/* Palette format: ABCD -> dst format: ABC */
+void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
+{
+    long i;
+
+    for (i=0; i<num_pixels; i++) {
+        //FIXME slow?
+        dst[0]= palette[src[i]*4+0];
+        dst[1]= palette[src[i]*4+1];
+        dst[2]= palette[src[i]*4+2];
+        dst+= 3;
+    }
+}

Modified: branches/0.6/libswscale/swscale.h
==============================================================================
--- branches/0.6/libswscale/swscale.h	Thu Jun  3 22:11:36 2010	(r23445)
+++ branches/0.6/libswscale/swscale.h	Thu Jun  3 22:16:42 2010	(r23446)
@@ -30,7 +30,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBSWSCALE_VERSION_MAJOR 0
-#define LIBSWSCALE_VERSION_MINOR 10
+#define LIBSWSCALE_VERSION_MINOR 11
 #define LIBSWSCALE_VERSION_MICRO 0
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
@@ -302,4 +302,29 @@ struct SwsContext *sws_getCachedContext(
                                         int flags, SwsFilter *srcFilter,
                                         SwsFilter *dstFilter, const double *param);
 
+/**
+ * Converts an 8bit paletted frame into a frame with a color depth of 32-bits.
+ *
+ * The output frame will have the same packed format as the palette.
+ *
+ * @param src        source frame buffer
+ * @param dst        destination frame buffer
+ * @param num_pixels number of pixels to convert
+ * @param palette    array with [256] entries, which must match color arrangement (RGB or BGR) of src
+ */
+void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+
+/**
+ * Converts an 8bit paletted frame into a frame with a color depth of 24 bits.
+ *
+ * With the palette format "ABCD", the destination frame ends up with the format "ABC".
+ *
+ * @param src        source frame buffer
+ * @param dst        destination frame buffer
+ * @param num_pixels number of pixels to convert
+ * @param palette    array with [256] entries, which must match color arrangement (RGB or BGR) of src
+ */
+void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette);
+
+
 #endif /* SWSCALE_SWSCALE_H */



More information about the ffmpeg-cvslog mailing list