aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-09-04 21:59:15 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-09-04 21:59:15 +0000
commit9990e4269c37d77a26777a98e42c59179bdda7fb (patch)
tree21355d417f8bf71e09d31e56d7b1807f672579a1
parent6b682df2337eeec0fceafc1a54b8c7d1804d03cf (diff)
downloadffmpeg-9990e4269c37d77a26777a98e42c59179bdda7fb.tar.gz
Support PIX_FMT_RGB32_1 and PIX_FMT_BGR32_1.
Fixes issue248. Originally committed as revision 27522 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
-rw-r--r--libswscale/swscale.c19
-rw-r--r--libswscale/swscale_internal.h8
-rw-r--r--libswscale/swscale_template.c22
-rw-r--r--libswscale/yuv2rgb.c12
4 files changed, 53 insertions, 8 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 7be684ba88..7b96298781 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -22,7 +22,7 @@
*/
/*
- supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09, PAL8
+ supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR32_1, BGR24, BGR16, BGR15, RGB32, RGB32_1, RGB24, Y8/Y800, YVU9/IF09, PAL8
supported output formats: YV12, I420/IYUV, YUY2, UYVY, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09
{BGR,RGB}{1,4,8,15,16} support dithering
@@ -104,10 +104,12 @@ unsigned swscale_version(void)
|| (x)==PIX_FMT_YUYV422 \
|| (x)==PIX_FMT_UYVY422 \
|| (x)==PIX_FMT_RGB32 \
+ || (x)==PIX_FMT_RGB32_1 \
|| (x)==PIX_FMT_BGR24 \
|| (x)==PIX_FMT_BGR565 \
|| (x)==PIX_FMT_BGR555 \
|| (x)==PIX_FMT_BGR32 \
+ || (x)==PIX_FMT_BGR32_1 \
|| (x)==PIX_FMT_RGB24 \
|| (x)==PIX_FMT_RGB565 \
|| (x)==PIX_FMT_RGB555 \
@@ -498,6 +500,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
{\
case PIX_FMT_RGB32:\
case PIX_FMT_BGR32:\
+ case PIX_FMT_RGB32_1:\
+ case PIX_FMT_BGR32_1:\
func(uint32_t)\
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
@@ -680,6 +684,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
{
case PIX_FMT_BGR32:
case PIX_FMT_RGB32:
+ case PIX_FMT_BGR32_1:
+ case PIX_FMT_RGB32_1:
YSCALE_YUV_2_RGBX_C(uint32_t)
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];
@@ -1573,7 +1579,7 @@ static int PlanarToUyvyWrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
return srcSliceH;
}
-/* {RGB,BGR}{15,16,24,32} -> {RGB,BGR}{15,16,24,32} */
+/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
const int srcFormat= c->srcFormat;
@@ -1632,12 +1638,15 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
if(conv)
{
+ uint8_t *srcPtr= src[0];
+ if(srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
+ srcPtr += ALT32_CORR;
+
if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0)
- conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
+ conv(srcPtr, dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
else
{
int i;
- uint8_t *srcPtr= src[0];
uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
for (i=0; i<srcSliceH; i++)
@@ -2150,6 +2159,8 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
&& srcFormat != PIX_FMT_BGR4_BYTE && dstFormat != PIX_FMT_BGR4_BYTE
&& srcFormat != PIX_FMT_RGB4_BYTE && dstFormat != PIX_FMT_RGB4_BYTE
&& srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK
+ && dstFormat != PIX_FMT_RGB32_1
+ && dstFormat != PIX_FMT_BGR32_1
&& !needsDither)
c->swScale= rgb2rgbWrapper;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index a14e85cf30..2efaa23bf5 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -34,6 +34,12 @@
#define VOFW 2048
#define VOF (VOFW*2)
+#ifdef WORDS_BIGENDIAN
+#define ALT32_CORR (-1)
+#else
+#define ALT32_CORR 1
+#endif
+
typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
@@ -222,6 +228,7 @@ const char *sws_format_name(int format);
)
#define isRGB(x) ( \
(x)==PIX_FMT_RGB32 \
+ || (x)==PIX_FMT_RGB32_1 \
|| (x)==PIX_FMT_RGB24 \
|| (x)==PIX_FMT_RGB565 \
|| (x)==PIX_FMT_RGB555 \
@@ -232,6 +239,7 @@ const char *sws_format_name(int format);
)
#define isBGR(x) ( \
(x)==PIX_FMT_BGR32 \
+ || (x)==PIX_FMT_BGR32_1 \
|| (x)==PIX_FMT_BGR24 \
|| (x)==PIX_FMT_BGR565 \
|| (x)==PIX_FMT_BGR555 \
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index fdb14fb0a1..888428cb73 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -2522,6 +2522,11 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i
RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
+ else if (srcFormat==PIX_FMT_RGB32_1)
+ {
+ RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW);
+ src= formatConvBuffer;
+ }
else if (srcFormat==PIX_FMT_BGR24)
{
RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
@@ -2542,6 +2547,11 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i
RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
+ else if (srcFormat==PIX_FMT_BGR32_1)
+ {
+ RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW);
+ src= formatConvBuffer;
+ }
else if (srcFormat==PIX_FMT_RGB24)
{
RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
@@ -2727,6 +2737,12 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1,
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
+ else if (srcFormat==PIX_FMT_RGB32_1)
+ {
+ RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+VOFW;
+ }
else if (srcFormat==PIX_FMT_BGR24)
{
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
@@ -2751,6 +2767,12 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1,
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
+ else if (srcFormat==PIX_FMT_BGR32_1)
+ {
+ RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+VOFW;
+ }
else if (srcFormat==PIX_FMT_RGB24)
{
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW);
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index c177cba0c1..5aa42c046c 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -644,6 +644,8 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
switch(c->dstFormat){
+ case PIX_FMT_BGR32_1:
+ case PIX_FMT_RGB32_1:
case PIX_FMT_BGR32:
case PIX_FMT_RGB32: return yuv2rgb_c_32;
case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
@@ -676,6 +678,7 @@ static int div_round (int dividend, int divisor)
int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
{
const int isRgb = c->dstFormat==PIX_FMT_RGB32
+ || c->dstFormat==PIX_FMT_RGB32_1
|| c->dstFormat==PIX_FMT_BGR24
|| c->dstFormat==PIX_FMT_RGB565
|| c->dstFormat==PIX_FMT_RGB555
@@ -684,7 +687,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|| c->dstFormat==PIX_FMT_MONOBLACK;
const int bpp = fmt_depth(c->dstFormat);
- int i;
+ int i, base;
uint8_t table_Y[1024];
uint32_t *table_32 = 0;
uint16_t *table_16 = 0;
@@ -733,6 +736,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
switch (bpp) {
case 32:
table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
+ base= (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
entry_size = sizeof (uint32_t);
table_r = table_32 + 197;
@@ -740,11 +744,11 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
table_g = table_32 + 197 + 2*682;
for (i = -197; i < 256+197; i++)
- ((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0);
+ ((uint32_t *)table_r)[i] = table_Y[i+384] << ((isRgb ? 16 : 0) + base);
for (i = -132; i < 256+132; i++)
- ((uint32_t *)table_g)[i] = table_Y[i+384] << 8;
+ ((uint32_t *)table_g)[i] = table_Y[i+384] << (8 + base);
for (i = -232; i < 256+232; i++)
- ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16);
+ ((uint32_t *)table_b)[i] = table_Y[i+384] << ((isRgb ? 0 : 16) + base);
break;
case 24: