Commit e9e12f0e authored by Luca Abeni's avatar Luca Abeni

Remove the dependency of libswscale on img_format.h

Originally committed as revision 19878 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
parent 5784b620
...@@ -22,24 +22,25 @@ ...@@ -22,24 +22,25 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdarg.h> #include <stdarg.h>
#undef HAVE_AV_CONFIG_H
#include "avutil.h"
#include "swscale.h" #include "swscale.h"
#include "libmpcodecs/img_format.h"
static int testFormat[]={ static int testFormat[]={
IMGFMT_YVU9, PIX_FMT_YUV410P,
IMGFMT_YV12, PIX_FMT_YUV420P,
//IMGFMT_IYUV, //IMGFMT_IYUV,
IMGFMT_I420, //IMGFMT_I420,
IMGFMT_BGR15, PIX_FMT_BGR555,
IMGFMT_BGR16, PIX_FMT_BGR565,
IMGFMT_BGR24, PIX_FMT_BGR24,
IMGFMT_BGR32, PIX_FMT_RGB32,
IMGFMT_RGB24, PIX_FMT_RGB24,
IMGFMT_RGB32, PIX_FMT_BGR32,
//IMGFMT_Y8, //IMGFMT_Y8,
IMGFMT_Y800, PIX_FMT_GRAY8,
//IMGFMT_YUY2, //IMGFMT_YUY2,
0 PIX_FMT_NONE
}; };
static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){ static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){
...@@ -73,12 +74,12 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma ...@@ -73,12 +74,12 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
for(i=0; i<3; i++){ for(i=0; i<3; i++){
// avoid stride % bpp != 0 // avoid stride % bpp != 0
if(srcFormat==IMGFMT_RGB24 || srcFormat==IMGFMT_BGR24) if(srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
srcStride[i]= srcW*3; srcStride[i]= srcW*3;
else else
srcStride[i]= srcW*4; srcStride[i]= srcW*4;
if(dstFormat==IMGFMT_RGB24 || dstFormat==IMGFMT_BGR24) if(dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
dstStride[i]= dstW*3; dstStride[i]= dstW*3;
else else
dstStride[i]= dstW*4; dstStride[i]= dstW*4;
...@@ -86,11 +87,16 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma ...@@ -86,11 +87,16 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
src[i]= (uint8_t*) malloc(srcStride[i]*srcH); src[i]= (uint8_t*) malloc(srcStride[i]*srcH);
dst[i]= (uint8_t*) malloc(dstStride[i]*dstH); dst[i]= (uint8_t*) malloc(dstStride[i]*dstH);
out[i]= (uint8_t*) malloc(refStride[i]*h); out[i]= (uint8_t*) malloc(refStride[i]*h);
if ((src[i] == NULL) || (dst[i] == NULL) || (out[i] == NULL)) {
perror("Malloc");
goto end;
}
} }
srcContext= sws_getContext(w, h, IMGFMT_YV12, srcW, srcH, srcFormat, flags, NULL, NULL, NULL); srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL); dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL);
outContext= sws_getContext(dstW, dstH, dstFormat, w, h, IMGFMT_YV12, flags, NULL, NULL, NULL); outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL);
if(srcContext==NULL ||dstContext==NULL ||outContext==NULL){ if(srcContext==NULL ||dstContext==NULL ||outContext==NULL){
printf("Failed allocating swsContext\n"); printf("Failed allocating swsContext\n");
goto end; goto end;
...@@ -110,7 +116,7 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma ...@@ -110,7 +116,7 @@ static void doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcForma
ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1); ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1); ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
if(srcFormat == IMGFMT_Y800 || dstFormat==IMGFMT_Y800) ssdU=ssdV=0; //FIXME check that output is really gray if(srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray
ssdY/= w*h; ssdY/= w*h;
ssdU/= w*h/4; ssdU/= w*h/4;
...@@ -155,10 +161,10 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){ ...@@ -155,10 +161,10 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){
for(srcFormatIndex=0; ;srcFormatIndex++){ for(srcFormatIndex=0; ;srcFormatIndex++){
srcFormat= testFormat[srcFormatIndex]; srcFormat= testFormat[srcFormatIndex];
if(!srcFormat) break; if(srcFormat == PIX_FMT_NONE) break;
for(dstFormatIndex=0; ;dstFormatIndex++){ for(dstFormatIndex=0; ;dstFormatIndex++){
dstFormat= testFormat[dstFormatIndex]; dstFormat= testFormat[dstFormatIndex];
if(!dstFormat) break; if(dstFormat == PIX_FMT_NONE) break;
// if(!isSupportedOut(dstFormat)) continue; // if(!isSupportedOut(dstFormat)) continue;
printf("%s -> %s\n", printf("%s -> %s\n",
sws_format_name(srcFormat), sws_format_name(srcFormat),
...@@ -190,7 +196,7 @@ int main(int argc, char **argv){ ...@@ -190,7 +196,7 @@ int main(int argc, char **argv){
int x, y; int x, y;
struct SwsContext *sws; struct SwsContext *sws;
sws= sws_getContext(W/12, H/12, IMGFMT_BGR32, W, H, IMGFMT_YV12, 2, NULL, NULL, NULL); sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUV420P, 2, NULL, NULL, NULL);
for(y=0; y<H; y++){ for(y=0; y<H; y++){
for(x=0; x<W*4; x++){ for(x=0; x<W*4; x++){
......
...@@ -74,7 +74,6 @@ untested special converters ...@@ -74,7 +74,6 @@ untested special converters
#include "swscale_internal.h" #include "swscale_internal.h"
#include "x86_cpu.h" #include "x86_cpu.h"
#include "bswap.h" #include "bswap.h"
#include "libmpcodecs/img_format.h"
#include "rgb2rgb.h" #include "rgb2rgb.h"
#ifdef USE_FASTMEMCPY #ifdef USE_FASTMEMCPY
#include "libvo/fastmemcpy.h" #include "libvo/fastmemcpy.h"
...@@ -106,25 +105,17 @@ untested special converters ...@@ -106,25 +105,17 @@ untested special converters
#define PI 3.14159265358979323846 #define PI 3.14159265358979323846
#endif #endif
//FIXME replace this with something faster #define isSupportedIn(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
#define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YVU9 \ || (x)==PIX_FMT_RGB32|| (x)==PIX_FMT_BGR24|| (x)==PIX_FMT_BGR565|| (x)==PIX_FMT_BGR555\
|| (x)==IMGFMT_NV12 || (x)==IMGFMT_NV21 \ || (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24\
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P) || (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P\
#define isYUV(x) ((x)==IMGFMT_UYVY || (x)==IMGFMT_YUY2 || isPlanarYUV(x)) || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P)
#define isGray(x) ((x)==IMGFMT_Y800) #define isSupportedOut(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
#define isRGB(x) (((x)&IMGFMT_RGB_MASK)==IMGFMT_RGB) || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P\
#define isBGR(x) (((x)&IMGFMT_BGR_MASK)==IMGFMT_BGR)
#define isSupportedIn(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
|| (x)==IMGFMT_BGR32|| (x)==IMGFMT_BGR24|| (x)==IMGFMT_BGR16|| (x)==IMGFMT_BGR15\
|| (x)==IMGFMT_RGB32|| (x)==IMGFMT_RGB24\
|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9\
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P)
#define isSupportedOut(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY\
|| (x)==IMGFMT_444P || (x)==IMGFMT_422P || (x)==IMGFMT_411P\
|| isRGB(x) || isBGR(x)\ || isRGB(x) || isBGR(x)\
|| (x)==IMGFMT_NV12 || (x)==IMGFMT_NV21\ || (x)==PIX_FMT_NV12 || (x)==PIX_FMT_NV21\
|| (x)==IMGFMT_Y800 || (x)==IMGFMT_YVU9) || (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P)
#define isPacked(x) ((x)==IMGFMT_YUY2 || (x)==IMGFMT_UYVY ||isRGB(x) || isBGR(x)) #define isPacked(x) ((x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 ||isRGB(x) || isBGR(x))
#define RGB2YUV_SHIFT 16 #define RGB2YUV_SHIFT 16
#define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5)) #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
...@@ -213,37 +204,82 @@ extern const uint8_t dither_8x8_32[8][8]; ...@@ -213,37 +204,82 @@ extern const uint8_t dither_8x8_32[8][8];
extern const uint8_t dither_8x8_73[8][8]; extern const uint8_t dither_8x8_73[8][8];
extern const uint8_t dither_8x8_220[8][8]; extern const uint8_t dither_8x8_220[8][8];
/* Used for ffmpeg --> MPlayer format name conversion */ char *sws_format_name(enum PixelFormat format)
static const int fmt_name[PIX_FMT_NB] = {
[PIX_FMT_YUV420P] = IMGFMT_I420, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
[PIX_FMT_YUV422] = IMGFMT_Y422,
[PIX_FMT_RGB24] = IMGFMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
[PIX_FMT_BGR24] = IMGFMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
[PIX_FMT_YUV422P] = IMGFMT_422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
[PIX_FMT_YUV444P] = IMGFMT_444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
[PIX_FMT_RGBA32] = IMGFMT_BGR32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
[PIX_FMT_YUV410P] = IMGFMT_YVU9, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
[PIX_FMT_YUV411P] = IMGFMT_411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
[PIX_FMT_RGB565] = IMGFMT_RGB16, ///< always stored in cpu endianness
[PIX_FMT_RGB555] = IMGFMT_RGB15, ///< always stored in cpu endianness, most significant bit to 1
[PIX_FMT_UYVY422] = IMGFMT_UYVY, ///< Packed pixel, Cb Y0 Cr Y1
[PIX_FMT_GRAY8] = IMGFMT_Y800, ///< Gray jpeg
};
char *sws_format_name(int format)
{ {
static char fmt_name[64]; switch (format) {
char *res; case PIX_FMT_YUV420P:
static int buffer; return "yuv420p";
case PIX_FMT_YUYV422:
res = fmt_name + buffer * 32; return "yuyv422";
buffer = 1 - buffer; case PIX_FMT_RGB24:
snprintf(res, 32, "0x%x (%c%c%c%c)", format, return "rgb24";
format >> 24, (format >> 16) & 0xFF, case PIX_FMT_BGR24:
(format >> 8) & 0xFF, return "bgr24";
format & 0xFF); case PIX_FMT_YUV422P:
return "yuv422p";
return res; case PIX_FMT_YUV444P:
return "yuv444p";
case PIX_FMT_RGB32:
return "rgb32";
case PIX_FMT_YUV410P:
return "yuv410p";
case PIX_FMT_YUV411P:
return "yuv411p";
case PIX_FMT_RGB565:
return "rgb565";
case PIX_FMT_RGB555:
return "rgb555";
case PIX_FMT_GRAY8:
return "gray8";
case PIX_FMT_MONOWHITE:
return "mono white";
case PIX_FMT_MONOBLACK:
return "mono black";
case PIX_FMT_PAL8:
return "Palette";
case PIX_FMT_YUVJ420P:
return "yuvj420p";
case PIX_FMT_YUVJ422P:
return "yuvj422p";
case PIX_FMT_YUVJ444P:
return "yuvj444p";
case PIX_FMT_XVMC_MPEG2_MC:
return "xvmc_mpeg2_mc";
case PIX_FMT_XVMC_MPEG2_IDCT:
return "xvmc_mpeg2_idct";
case PIX_FMT_UYVY422:
return "uyvy422";
case PIX_FMT_UYYVYY411:
return "uyyvyy411";
case PIX_FMT_RGB32_1:
return "rgb32x";
case PIX_FMT_BGR32_1:
return "bgr32x";
case PIX_FMT_BGR32:
return "bgr32";
case PIX_FMT_BGR565:
return "bgr565";
case PIX_FMT_BGR555:
return "bgr555";
case PIX_FMT_BGR8:
return "bgr8";
case PIX_FMT_BGR4:
return "bgr4";
case PIX_FMT_BGR4_BYTE:
return "bgr4 byte";
case PIX_FMT_RGB8:
return "rgb8";
case PIX_FMT_RGB4:
return "rgb4";
case PIX_FMT_RGB4_BYTE:
return "rgb4 byte";
case PIX_FMT_NV12:
return "nv12";
case PIX_FMT_NV21:
return "nv21";
default:
return "Unknown format";
}
} }
#if defined(ARCH_X86) || defined(ARCH_X86_64) #if defined(ARCH_X86) || defined(ARCH_X86_64)
...@@ -308,7 +344,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -308,7 +344,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
if(uDest == NULL) if(uDest == NULL)
return; return;
if(dstFormat == IMGFMT_NV12) if(dstFormat == PIX_FMT_NV12)
for(i=0; i<chrDstW; i++) for(i=0; i<chrDstW; i++)
{ {
int u=1<<18; int u=1<<18;
...@@ -430,14 +466,14 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -430,14 +466,14 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
#define YSCALE_YUV_2_ANYRGB_C(func, func2)\ #define YSCALE_YUV_2_ANYRGB_C(func, func2)\
switch(c->dstFormat)\ switch(c->dstFormat)\
{\ {\
case IMGFMT_BGR32:\ case PIX_FMT_RGB32:\
case IMGFMT_RGB32:\ case PIX_FMT_BGR32:\
func(uint32_t)\ func(uint32_t)\
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\ ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\ ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
} \ } \
break;\ break;\
case IMGFMT_RGB24:\ case PIX_FMT_RGB24:\
func(uint8_t)\ func(uint8_t)\
((uint8_t*)dest)[0]= r[Y1];\ ((uint8_t*)dest)[0]= r[Y1];\
((uint8_t*)dest)[1]= g[Y1];\ ((uint8_t*)dest)[1]= g[Y1];\
...@@ -448,7 +484,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -448,7 +484,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
dest+=6;\ dest+=6;\
}\ }\
break;\ break;\
case IMGFMT_BGR24:\ case PIX_FMT_BGR24:\
func(uint8_t)\ func(uint8_t)\
((uint8_t*)dest)[0]= b[Y1];\ ((uint8_t*)dest)[0]= b[Y1];\
((uint8_t*)dest)[1]= g[Y1];\ ((uint8_t*)dest)[1]= g[Y1];\
...@@ -459,8 +495,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -459,8 +495,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
dest+=6;\ dest+=6;\
}\ }\
break;\ break;\
case IMGFMT_RGB16:\ case PIX_FMT_RGB565:\
case IMGFMT_BGR16:\ case PIX_FMT_BGR565:\
{\ {\
const int dr1= dither_2x2_8[y&1 ][0];\ const int dr1= dither_2x2_8[y&1 ][0];\
const int dg1= dither_2x2_4[y&1 ][0];\ const int dg1= dither_2x2_4[y&1 ][0];\
...@@ -474,8 +510,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -474,8 +510,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\ }\
}\ }\
break;\ break;\
case IMGFMT_RGB15:\ case PIX_FMT_RGB555:\
case IMGFMT_BGR15:\ case PIX_FMT_BGR555:\
{\ {\
const int dr1= dither_2x2_8[y&1 ][0];\ const int dr1= dither_2x2_8[y&1 ][0];\
const int dg1= dither_2x2_8[y&1 ][1];\ const int dg1= dither_2x2_8[y&1 ][1];\
...@@ -489,8 +525,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -489,8 +525,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\ }\
}\ }\
break;\ break;\
case IMGFMT_RGB8:\ case PIX_FMT_RGB8:\
case IMGFMT_BGR8:\ case PIX_FMT_BGR8:\
{\ {\
const uint8_t * const d64= dither_8x8_73[y&7];\ const uint8_t * const d64= dither_8x8_73[y&7];\
const uint8_t * const d32= dither_8x8_32[y&7];\ const uint8_t * const d32= dither_8x8_32[y&7];\
...@@ -500,8 +536,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -500,8 +536,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\ }\
}\ }\
break;\ break;\
case IMGFMT_RGB4:\ case PIX_FMT_RGB4:\
case IMGFMT_BGR4:\ case PIX_FMT_BGR4:\
{\ {\
const uint8_t * const d64= dither_8x8_73 [y&7];\ const uint8_t * const d64= dither_8x8_73 [y&7];\
const uint8_t * const d128=dither_8x8_220[y&7];\ const uint8_t * const d128=dither_8x8_220[y&7];\
...@@ -511,8 +547,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -511,8 +547,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\ }\
}\ }\
break;\ break;\
case IMGFMT_RG4B:\ case PIX_FMT_RGB4_BYTE:\
case IMGFMT_BG4B:\ case PIX_FMT_BGR4_BYTE:\
{\ {\
const uint8_t * const d64= dither_8x8_73 [y&7];\ const uint8_t * const d64= dither_8x8_73 [y&7];\
const uint8_t * const d128=dither_8x8_220[y&7];\ const uint8_t * const d128=dither_8x8_220[y&7];\
...@@ -522,8 +558,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -522,8 +558,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
}\ }\
}\ }\
break;\ break;\
case IMGFMT_RGB1:\ case PIX_FMT_MONOBLACK:\
case IMGFMT_BGR1:\
{\ {\
const uint8_t * const d128=dither_8x8_220[y&7];\ const uint8_t * const d128=dither_8x8_220[y&7];\
uint8_t *g= c->table_gU[128] + c->table_gV[128];\ uint8_t *g= c->table_gU[128] + c->table_gV[128];\
...@@ -587,7 +622,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -587,7 +622,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
*/\ */\
}\ }\
break;\ break;\
case IMGFMT_YUY2:\ case PIX_FMT_YUYV422:\
func2\ func2\
((uint8_t*)dest)[2*i2+0]= Y1;\ ((uint8_t*)dest)[2*i2+0]= Y1;\
((uint8_t*)dest)[2*i2+1]= U;\ ((uint8_t*)dest)[2*i2+1]= U;\
...@@ -595,7 +630,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ...@@ -595,7 +630,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
((uint8_t*)dest)[2*i2+3]= V;\ ((uint8_t*)dest)[2*i2+3]= V;\
} \ } \
break;\ break;\
case IMGFMT_UYVY:\ case PIX_FMT_UYVY422:\
func2\ func2\
((uint8_t*)dest)[2*i2+0]= U;\ ((uint8_t*)dest)[2*i2+0]= U;\
((uint8_t*)dest)[2*i2+1]= Y1;\ ((uint8_t*)dest)[2*i2+1]= Y1;\
...@@ -613,14 +648,14 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -613,14 +648,14 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
int i; int i;
switch(c->dstFormat) switch(c->dstFormat)
{ {
case IMGFMT_RGB32: case PIX_FMT_BGR32:
case IMGFMT_BGR32: case PIX_FMT_RGB32:
YSCALE_YUV_2_RGBX_C(uint32_t) YSCALE_YUV_2_RGBX_C(uint32_t)
((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1]; ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];
((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2]; ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];
} }
break; break;
case IMGFMT_RGB24: case PIX_FMT_RGB24:
YSCALE_YUV_2_RGBX_C(uint8_t) YSCALE_YUV_2_RGBX_C(uint8_t)
((uint8_t*)dest)[0]= r[Y1]; ((uint8_t*)dest)[0]= r[Y1];
((uint8_t*)dest)[1]= g[Y1]; ((uint8_t*)dest)[1]= g[Y1];
...@@ -631,7 +666,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -631,7 +666,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
dest+=6; dest+=6;
} }
break; break;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
YSCALE_YUV_2_RGBX_C(uint8_t) YSCALE_YUV_2_RGBX_C(uint8_t)
((uint8_t*)dest)[0]= b[Y1]; ((uint8_t*)dest)[0]= b[Y1];
((uint8_t*)dest)[1]= g[Y1]; ((uint8_t*)dest)[1]= g[Y1];
...@@ -642,8 +677,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -642,8 +677,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
dest+=6; dest+=6;
} }
break; break;
case IMGFMT_RGB16: case PIX_FMT_RGB565:
case IMGFMT_BGR16: case PIX_FMT_BGR565:
{ {
const int dr1= dither_2x2_8[y&1 ][0]; const int dr1= dither_2x2_8[y&1 ][0];
const int dg1= dither_2x2_4[y&1 ][0]; const int dg1= dither_2x2_4[y&1 ][0];
...@@ -657,8 +692,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -657,8 +692,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_RGB15: case PIX_FMT_RGB555:
case IMGFMT_BGR15: case PIX_FMT_BGR555:
{ {
const int dr1= dither_2x2_8[y&1 ][0]; const int dr1= dither_2x2_8[y&1 ][0];
const int dg1= dither_2x2_8[y&1 ][1]; const int dg1= dither_2x2_8[y&1 ][1];
...@@ -672,8 +707,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -672,8 +707,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_RGB8: case PIX_FMT_RGB8:
case IMGFMT_BGR8: case PIX_FMT_BGR8:
{ {
const uint8_t * const d64= dither_8x8_73[y&7]; const uint8_t * const d64= dither_8x8_73[y&7];
const uint8_t * const d32= dither_8x8_32[y&7]; const uint8_t * const d32= dither_8x8_32[y&7];
...@@ -683,8 +718,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -683,8 +718,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_RGB4: case PIX_FMT_RGB4:
case IMGFMT_BGR4: case PIX_FMT_BGR4:
{ {
const uint8_t * const d64= dither_8x8_73 [y&7]; const uint8_t * const d64= dither_8x8_73 [y&7];
const uint8_t * const d128=dither_8x8_220[y&7]; const uint8_t * const d128=dither_8x8_220[y&7];
...@@ -694,8 +729,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -694,8 +729,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_RG4B: case PIX_FMT_RGB4_BYTE:
case IMGFMT_BG4B: case PIX_FMT_BGR4_BYTE:
{ {
const uint8_t * const d64= dither_8x8_73 [y&7]; const uint8_t * const d64= dither_8x8_73 [y&7];
const uint8_t * const d128=dither_8x8_220[y&7]; const uint8_t * const d128=dither_8x8_220[y&7];
...@@ -705,8 +740,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -705,8 +740,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_RGB1: case PIX_FMT_MONOBLACK:
case IMGFMT_BGR1:
{ {
const uint8_t * const d128=dither_8x8_220[y&7]; const uint8_t * const d128=dither_8x8_220[y&7];
uint8_t *g= c->table_gU[128] + c->table_gV[128]; uint8_t *g= c->table_gU[128] + c->table_gV[128];
...@@ -739,7 +773,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -739,7 +773,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
} }
} }
break; break;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
YSCALE_YUV_2_PACKEDX_C(void) YSCALE_YUV_2_PACKEDX_C(void)
((uint8_t*)dest)[2*i2+0]= Y1; ((uint8_t*)dest)[2*i2+0]= Y1;
((uint8_t*)dest)[2*i2+1]= U; ((uint8_t*)dest)[2*i2+1]= U;
...@@ -747,7 +781,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ...@@ -747,7 +781,7 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
((uint8_t*)dest)[2*i2+3]= V; ((uint8_t*)dest)[2*i2+3]= V;
} }
break; break;
case IMGFMT_UYVY: case PIX_FMT_UYVY422:
YSCALE_YUV_2_PACKEDX_C(void) YSCALE_YUV_2_PACKEDX_C(void)
((uint8_t*)dest)[2*i2+0]= U; ((uint8_t*)dest)[2*i2+0]= U;
((uint8_t*)dest)[2*i2+1]= Y1; ((uint8_t*)dest)[2*i2+1]= Y1;
...@@ -1483,7 +1517,7 @@ static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i ...@@ -1483,7 +1517,7 @@ static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], i
} }
} }
dst = dstParam[1] + dstStride[1]*srcSliceY/2; dst = dstParam[1] + dstStride[1]*srcSliceY/2;
if (c->dstFormat == IMGFMT_NV12) if (c->dstFormat == PIX_FMT_NV12)
interleaveBytes( src[1],src[2],dst,c->srcW/2,srcSliceH/2,srcStride[1],srcStride[2],dstStride[0] ); interleaveBytes( src[1],src[2],dst,c->srcW/2,srcSliceH/2,srcStride[1],srcStride[2],dstStride[0] );
else else
interleaveBytes( src[2],src[1],dst,c->srcW/2,srcSliceH/2,srcStride[2],srcStride[1],dstStride[0] ); interleaveBytes( src[2],src[1],dst,c->srcW/2,srcSliceH/2,srcStride[2],srcStride[1],dstStride[0] );
...@@ -1514,10 +1548,10 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr ...@@ -1514,10 +1548,10 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
const int srcFormat= c->srcFormat; const int srcFormat= c->srcFormat;
const int dstFormat= c->dstFormat; const int dstFormat= c->dstFormat;
const int srcBpp= ((srcFormat&0xFF) + 7)>>3; const int srcBpp= (fmt_depth(srcFormat) + 7) >> 3;
const int dstBpp= ((dstFormat&0xFF) + 7)>>3; const int dstBpp= (fmt_depth(dstFormat) + 7) >> 3;
const int srcId= (srcFormat&0xFF)>>2; // 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 const int srcId= fmt_depth(srcFormat) >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */
const int dstId= (dstFormat&0xFF)>>2; const int dstId= fmt_depth(dstFormat) >> 2;
void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL; void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL;
/* BGR -> BGR */ /* BGR -> BGR */
...@@ -1616,7 +1650,7 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int ...@@ -1616,7 +1650,7 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
} }
} }
if(c->dstFormat==IMGFMT_YV12){ if(c->dstFormat==PIX_FMT_YUV420P){
planar2x(src[1], dst[1], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[1]); planar2x(src[1], dst[1], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[1]);
planar2x(src[2], dst[2], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[2]); planar2x(src[2], dst[2], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[2]);
}else{ }else{
...@@ -1626,50 +1660,6 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int ...@@ -1626,50 +1660,6 @@ static int yvu9toyv12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int
return srcSliceH; return srcSliceH;
} }
/**
* bring pointers in YUV order instead of YVU
*/
static inline void sws_orderYUV(int format, uint8_t * sortedP[], int sortedStride[], uint8_t * p[], int stride[]){
if(format == IMGFMT_YV12 || format == IMGFMT_YVU9
|| format == IMGFMT_444P || format == IMGFMT_422P || format == IMGFMT_411P){
sortedP[0]= p[0];
sortedP[1]= p[2];
sortedP[2]= p[1];
sortedStride[0]= stride[0];
sortedStride[1]= stride[2];
sortedStride[2]= stride[1];
}
else if(isPacked(format) || isGray(format) || format == IMGFMT_Y8)
{
sortedP[0]= p[0];
sortedP[1]=
sortedP[2]= NULL;
sortedStride[0]= stride[0];
sortedStride[1]=
sortedStride[2]= 0;
}
else if(format == IMGFMT_I420 || format == IMGFMT_IYUV)
{
sortedP[0]= p[0];
sortedP[1]= p[1];
sortedP[2]= p[2];
sortedStride[0]= stride[0];
sortedStride[1]= stride[1];
sortedStride[2]= stride[2];
}
else if(format == IMGFMT_NV12 || format == IMGFMT_NV21)
{
sortedP[0]= p[0];
sortedP[1]= p[1];
sortedP[2]= NULL;
sortedStride[0]= stride[0];
sortedStride[1]= stride[1];
sortedStride[2]= 0;
}else{
MSG_ERR("internal error in orderYUV\n");
}
}
/* unscaled copy like stuff (assumes nearly identical formats) */ /* unscaled copy like stuff (assumes nearly identical formats) */
static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
...@@ -1734,45 +1724,33 @@ static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli ...@@ -1734,45 +1724,33 @@ static int simpleCopy(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
return srcSliceH; return srcSliceH;
} }
static int remove_dup_fourcc(int fourcc)
{
switch(fourcc)
{
case IMGFMT_I420:
case IMGFMT_IYUV: return IMGFMT_YV12;
case IMGFMT_Y8 : return IMGFMT_Y800;
case IMGFMT_IF09: return IMGFMT_YVU9;
default: return fourcc;
}
}
static void getSubSampleFactors(int *h, int *v, int format){ static void getSubSampleFactors(int *h, int *v, int format){
switch(format){ switch(format){
case IMGFMT_UYVY: case PIX_FMT_UYVY422:
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
*h=1; *h=1;
*v=0; *v=0;
break; break;
case IMGFMT_YV12: case PIX_FMT_YUV420P:
case IMGFMT_Y800: //FIXME remove after different subsamplings are fully implemented case PIX_FMT_GRAY8: //FIXME remove after different subsamplings are fully implemented
case IMGFMT_NV12: case PIX_FMT_NV12:
case IMGFMT_NV21: case PIX_FMT_NV21:
*h=1; *h=1;
*v=1; *v=1;
break; break;
case IMGFMT_YVU9: case PIX_FMT_YUV410P:
*h=2; *h=2;
*v=2; *v=2;
break; break;
case IMGFMT_444P: case PIX_FMT_YUV444P:
*h=0; *h=0;
*v=0; *v=0;
break; break;
case IMGFMT_422P: case PIX_FMT_YUV422P:
*h=1; *h=1;
*v=0; *v=0;
break; break;
case IMGFMT_411P: case PIX_FMT_YUV411P:
*h=2; *h=2;
*v=0; *v=0;
break; break;
...@@ -1863,14 +1841,13 @@ int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int ...@@ -1863,14 +1841,13 @@ int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int
return 0; return 0;
} }
SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int dstH, int origDstFormat, int flags, SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, double *param){ SwsFilter *srcFilter, SwsFilter *dstFilter, double *param){
SwsContext *c; SwsContext *c;
int i; int i;
int usesVFilter, usesHFilter; int usesVFilter, usesHFilter;
int unscaled, needsDither; int unscaled, needsDither;
int srcFormat, dstFormat;
SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; SwsFilter dummyFilter= {NULL, NULL, NULL, NULL};
#if defined(ARCH_X86) || defined(ARCH_X86_64) #if defined(ARCH_X86) || defined(ARCH_X86_64)
if(flags & SWS_CPU_CAPS_MMX) if(flags & SWS_CPU_CAPS_MMX)
...@@ -1892,20 +1869,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -1892,20 +1869,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
if(clip_table[512] != 255) globalInit(); if(clip_table[512] != 255) globalInit();
if(rgb15to16 == NULL) sws_rgb2rgb_init(flags); if(rgb15to16 == NULL) sws_rgb2rgb_init(flags);
/* avoid duplicate Formats, so we don't need to check to much */
if (origSrcFormat < PIX_FMT_NB) {
origSrcFormat = fmt_name[origSrcFormat];
}
if (origDstFormat < PIX_FMT_NB) {
origDstFormat = fmt_name[origDstFormat];
}
srcFormat = remove_dup_fourcc(origSrcFormat);
dstFormat = remove_dup_fourcc(origDstFormat);
unscaled = (srcW == dstW && srcH == dstH); unscaled = (srcW == dstW && srcH == dstH);
needsDither= (isBGR(dstFormat) || isRGB(dstFormat)) needsDither= (isBGR(dstFormat) || isRGB(dstFormat))
&& (dstFormat&0xFF)<24 && (fmt_depth(dstFormat))<24
&& ((dstFormat&0xFF)<(srcFormat&0xFF) || (!(isRGB(srcFormat) || isBGR(srcFormat)))); && ((fmt_depth(dstFormat))<(fmt_depth(srcFormat)) || (!(isRGB(srcFormat) || isBGR(srcFormat))));
if(!isSupportedIn(srcFormat)) if(!isSupportedIn(srcFormat))
{ {
...@@ -1941,8 +1908,6 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -1941,8 +1908,6 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
c->flags= flags; c->flags= flags;
c->dstFormat= dstFormat; c->dstFormat= dstFormat;
c->srcFormat= srcFormat; c->srcFormat= srcFormat;
c->origDstFormat= origDstFormat;
c->origSrcFormat= origSrcFormat;
c->vRounder= 4* 0x0001000100010001ULL; c->vRounder= 4* 0x0001000100010001ULL;
usesHFilter= usesVFilter= 0; usesHFilter= usesVFilter= 0;
...@@ -1992,23 +1957,23 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -1992,23 +1957,23 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
if(unscaled && !usesHFilter && !usesVFilter) if(unscaled && !usesHFilter && !usesVFilter)
{ {
/* yv12_to_nv12 */ /* yv12_to_nv12 */
if(srcFormat == IMGFMT_YV12 && (dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21)) if(srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21))
{ {
c->swScale= PlanarToNV12Wrapper; c->swScale= PlanarToNV12Wrapper;
} }
/* yuv2bgr */ /* yuv2bgr */
if((srcFormat==IMGFMT_YV12 || srcFormat==IMGFMT_422P) && (isBGR(dstFormat) || isRGB(dstFormat))) if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
{ {
c->swScale= yuv2rgb_get_func_ptr(c); c->swScale= yuv2rgb_get_func_ptr(c);
} }
if( srcFormat==IMGFMT_YVU9 && dstFormat==IMGFMT_YV12 ) if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
{ {
c->swScale= yvu9toyv12Wrapper; c->swScale= yvu9toyv12Wrapper;
} }
/* bgr24toYV12 */ /* bgr24toYV12 */
if(srcFormat==IMGFMT_BGR24 && dstFormat==IMGFMT_YV12) if(srcFormat==PIX_FMT_BGR24 && dstFormat==PIX_FMT_YUV420P)
c->swScale= bgr24toyv12Wrapper; c->swScale= bgr24toyv12Wrapper;
/* rgb/bgr -> rgb/bgr (no dither needed forms) */ /* rgb/bgr -> rgb/bgr (no dither needed forms) */
...@@ -2026,10 +1991,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2026,10 +1991,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
c->swScale= rgb2rgbWrapper; c->swScale= rgb2rgbWrapper;
/* yv12_to_yuy2 */ /* yv12_to_yuy2 */
if(srcFormat == IMGFMT_YV12 && if(srcFormat == PIX_FMT_YUV420P &&
(dstFormat == IMGFMT_YUY2 || dstFormat == IMGFMT_UYVY)) (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422))
{ {
if (dstFormat == IMGFMT_YUY2) if (dstFormat == PIX_FMT_YUYV422)
c->swScale= PlanarToYuy2Wrapper; c->swScale= PlanarToYuy2Wrapper;
else else
c->swScale= PlanarToUyvyWrapper; c->swScale= PlanarToUyvyWrapper;
...@@ -2038,10 +2003,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2038,10 +2003,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
#ifdef COMPILE_ALTIVEC #ifdef COMPILE_ALTIVEC
if ((c->flags & SWS_CPU_CAPS_ALTIVEC) && if ((c->flags & SWS_CPU_CAPS_ALTIVEC) &&
((srcFormat == IMGFMT_YV12 && ((srcFormat == PIX_FMT_YUV420P &&
(dstFormat == IMGFMT_YUY2 || dstFormat == IMGFMT_UYVY)))) { (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)))) {
// unscaled YV12 -> packed YUV, we want speed // unscaled YV12 -> packed YUV, we want speed
if (dstFormat == IMGFMT_YUY2) if (dstFormat == PIX_FMT_YUYV422)
c->swScale= yv12toyuy2_unscaled_altivec; c->swScale= yv12toyuy2_unscaled_altivec;
else else
c->swScale= yv12touyvy_unscaled_altivec; c->swScale= yv12touyvy_unscaled_altivec;
...@@ -2245,7 +2210,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2245,7 +2210,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
else else
MSG_INFO("\nSwScaler: ehh flags invalid?! "); MSG_INFO("\nSwScaler: ehh flags invalid?! ");
if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16) if(dstFormat==PIX_FMT_BGR555 || dstFormat==PIX_FMT_BGR565)
MSG_INFO("from %s to%s %s ", MSG_INFO("from %s to%s %s ",
sws_format_name(srcFormat), dither, sws_format_name(dstFormat)); sws_format_name(srcFormat), dither, sws_format_name(dstFormat));
else else
...@@ -2316,14 +2281,14 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int ...@@ -2316,14 +2281,14 @@ SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int
MSG_V("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); MSG_V("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
} }
if(dstFormat==IMGFMT_BGR24) if(dstFormat==PIX_FMT_BGR24)
MSG_V("SwScaler: using %s YV12->BGR24 Converter\n", MSG_V("SwScaler: using %s YV12->BGR24 Converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C")); (flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if(dstFormat==IMGFMT_BGR32) else if(dstFormat==PIX_FMT_RGB32)
MSG_V("SwScaler: using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); MSG_V("SwScaler: using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==IMGFMT_BGR16) else if(dstFormat==PIX_FMT_BGR565)
MSG_V("SwScaler: using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); MSG_V("SwScaler: using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==IMGFMT_BGR15) else if(dstFormat==PIX_FMT_BGR555)
MSG_V("SwScaler: using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); MSG_V("SwScaler: using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
MSG_V("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); MSG_V("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
...@@ -2379,14 +2344,12 @@ int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli ...@@ -2379,14 +2344,12 @@ int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
/** /**
* swscale warper, so we don't need to export the SwsContext * swscale warper, so we don't need to export the SwsContext
*/ */
int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStrideParam[]){ int srcSliceH, uint8_t* dstParam[], int dstStride[]){
int srcStride[3];
int dstStride[3];
uint8_t *src[3]; uint8_t *src[3];
uint8_t *dst[3]; uint8_t *dst[3];
sws_orderYUV(c->origSrcFormat, src, srcStride, srcParam, srcStrideParam); src[0] = srcParam[0]; src[1] = srcParam[1]; src[2] = srcParam[2];
sws_orderYUV(c->origDstFormat, dst, dstStride, dstParam, dstStrideParam); dst[0] = dstParam[0]; dst[1] = dstParam[1]; dst[2] = dstParam[2];
//printf("sws: slice %d %d\n", srcSliceY, srcSliceH); //printf("sws: slice %d %d\n", srcSliceY, srcSliceH);
return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride); return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
......
...@@ -173,4 +173,52 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, ...@@ -173,4 +173,52 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
char *sws_format_name(int format); char *sws_format_name(int format);
//FIXME replace this with something faster
#define isPlanarYUV(x) ((x)==PIX_FMT_YUV410P || (x)==PIX_FMT_YUV420P \
|| (x)==PIX_FMT_YUV411P || (x)==PIX_FMT_YUV422P \
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_NV12 \
|| (x)==PIX_FMT_NV21)
#define isYUV(x) ((x)==PIX_FMT_UYVY422 || (x)==PIX_FMT_YUYV422 || isPlanarYUV(x))
#define isGray(x) ((x)==PIX_FMT_GRAY8)
#define isRGB(x) ((x)==PIX_FMT_BGR32 || (x)==PIX_FMT_RGB24 \
|| (x)==PIX_FMT_RGB565 || (x)==PIX_FMT_RGB555 \
|| (x)==PIX_FMT_RGB8 || (x)==PIX_FMT_RGB4 \
|| (x)==PIX_FMT_MONOBLACK)
#define isBGR(x) ((x)==PIX_FMT_RGB32 || (x)==PIX_FMT_BGR24 \
|| (x)==PIX_FMT_BGR565 || (x)==PIX_FMT_BGR555 \
|| (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_BGR4 \
|| (x)==PIX_FMT_MONOBLACK)
static inline int fmt_depth(int fmt)
{
switch(fmt) {
case PIX_FMT_BGRA:
case PIX_FMT_ABGR:
case PIX_FMT_RGBA:
case PIX_FMT_ARGB:
return 32;
case PIX_FMT_BGR24:
case PIX_FMT_RGB24:
return 24;
case PIX_FMT_BGR565:
case PIX_FMT_RGB565:
return 16;
case PIX_FMT_BGR555:
case PIX_FMT_RGB555:
return 15;
case PIX_FMT_BGR8:
case PIX_FMT_RGB8:
return 8;
case PIX_FMT_BGR4:
case PIX_FMT_RGB4:
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_RGB4_BYTE:
return 4;
case PIX_FMT_MONOBLACK:
return 1;
default:
return 0;
}
}
#endif #endif
...@@ -1039,14 +1039,14 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1039,14 +1039,14 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
#ifdef HAVE_MMX #ifdef HAVE_MMX
if(c->flags & SWS_ACCURATE_RND){ if(c->flags & SWS_ACCURATE_RND){
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_BGR32: case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa) WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize
...@@ -1060,7 +1060,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1060,7 +1060,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
); );
return; return;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1073,7 +1073,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1073,7 +1073,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
WRITEBGR15(%4, %5, %%REGa) WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1086,7 +1086,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1086,7 +1086,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
WRITEBGR16(%4, %5, %%REGa) WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1101,13 +1101,13 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1101,13 +1101,13 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
}else{ }else{
switch(c->dstFormat) switch(c->dstFormat)
{ {
case IMGFMT_BGR32: case PIX_FMT_RGB32:
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
WRITEBGR32(%4, %5, %%REGa) WRITEBGR32(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
"lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize
...@@ -1120,7 +1120,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1120,7 +1120,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
); );
return; return;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1133,7 +1133,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1133,7 +1133,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
WRITEBGR15(%4, %5, %%REGa) WRITEBGR15(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1146,7 +1146,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1146,7 +1146,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
WRITEBGR16(%4, %5, %%REGa) WRITEBGR16(%4, %5, %%REGa)
YSCALEYUV2PACKEDX_END YSCALEYUV2PACKEDX_END
return; return;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
/* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
...@@ -1163,9 +1163,9 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ ...@@ -1163,9 +1163,9 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_
#ifdef HAVE_ALTIVEC #ifdef HAVE_ALTIVEC
/* The following list of supported dstFormat values should /* The following list of supported dstFormat values should
match what's found in the body of altivec_yuv2packedX() */ match what's found in the body of altivec_yuv2packedX() */
if(c->dstFormat==IMGFMT_ABGR || c->dstFormat==IMGFMT_BGRA || if(c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA ||
c->dstFormat==IMGFMT_BGR24 || c->dstFormat==IMGFMT_RGB24 || c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
c->dstFormat==IMGFMT_RGBA || c->dstFormat==IMGFMT_ARGB) c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)
altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize, altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize, chrFilter, chrSrc, chrFilterSize,
dest, dstW, dstY); dest, dstW, dstY);
...@@ -1192,7 +1192,7 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1192,7 +1192,7 @@ static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *
switch(dstFormat) switch(dstFormat)
{ {
#ifdef HAVE_MMX #ifdef HAVE_MMX
case IMGFMT_BGR32: case PIX_FMT_RGB32:
asm volatile( asm volatile(
...@@ -1217,7 +1217,7 @@ FULL_YSCALEYUV2RGB ...@@ -1217,7 +1217,7 @@ FULL_YSCALEYUV2RGB
: "%"REG_a : "%"REG_a
); );
break; break;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
asm volatile( asm volatile(
FULL_YSCALEYUV2RGB FULL_YSCALEYUV2RGB
...@@ -1266,7 +1266,7 @@ FULL_YSCALEYUV2RGB ...@@ -1266,7 +1266,7 @@ FULL_YSCALEYUV2RGB
: "%"REG_a, "%"REG_b : "%"REG_a, "%"REG_b
); );
break; break;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
asm volatile( asm volatile(
FULL_YSCALEYUV2RGB FULL_YSCALEYUV2RGB
...@@ -1299,7 +1299,7 @@ FULL_YSCALEYUV2RGB ...@@ -1299,7 +1299,7 @@ FULL_YSCALEYUV2RGB
: "%"REG_a : "%"REG_a
); );
break; break;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
asm volatile( asm volatile(
FULL_YSCALEYUV2RGB FULL_YSCALEYUV2RGB
...@@ -1333,11 +1333,11 @@ FULL_YSCALEYUV2RGB ...@@ -1333,11 +1333,11 @@ FULL_YSCALEYUV2RGB
); );
break; break;
#endif #endif
case IMGFMT_RGB32: case PIX_FMT_BGR32:
#ifndef HAVE_MMX #ifndef HAVE_MMX
case IMGFMT_BGR32: case PIX_FMT_RGB32:
#endif #endif
if(dstFormat==IMGFMT_BGR32) if(dstFormat==PIX_FMT_RGB32)
{ {
int i; int i;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -1354,7 +1354,7 @@ FULL_YSCALEYUV2RGB ...@@ -1354,7 +1354,7 @@ FULL_YSCALEYUV2RGB
dest+= 4; dest+= 4;
} }
} }
else if(dstFormat==IMGFMT_BGR24) else if(dstFormat==PIX_FMT_BGR24)
{ {
int i; int i;
for(i=0;i<dstW;i++){ for(i=0;i<dstW;i++){
...@@ -1368,7 +1368,7 @@ FULL_YSCALEYUV2RGB ...@@ -1368,7 +1368,7 @@ FULL_YSCALEYUV2RGB
dest+= 3; dest+= 3;
} }
} }
else if(dstFormat==IMGFMT_BGR16) else if(dstFormat==PIX_FMT_BGR565)
{ {
int i; int i;
for(i=0;i<dstW;i++){ for(i=0;i<dstW;i++){
...@@ -1383,7 +1383,7 @@ FULL_YSCALEYUV2RGB ...@@ -1383,7 +1383,7 @@ FULL_YSCALEYUV2RGB
clip_table16r[(Y + yuvtab_3343[V]) >>13]; clip_table16r[(Y + yuvtab_3343[V]) >>13];
} }
} }
else if(dstFormat==IMGFMT_BGR15) else if(dstFormat==PIX_FMT_BGR555)
{ {
int i; int i;
for(i=0;i<dstW;i++){ for(i=0;i<dstW;i++){
...@@ -1406,7 +1406,7 @@ FULL_YSCALEYUV2RGB ...@@ -1406,7 +1406,7 @@ FULL_YSCALEYUV2RGB
switch(c->dstFormat) switch(c->dstFormat)
{ {
//Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
case IMGFMT_BGR32: case PIX_FMT_RGB32:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1420,7 +1420,7 @@ FULL_YSCALEYUV2RGB ...@@ -1420,7 +1420,7 @@ FULL_YSCALEYUV2RGB
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1433,7 +1433,7 @@ FULL_YSCALEYUV2RGB ...@@ -1433,7 +1433,7 @@ FULL_YSCALEYUV2RGB
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1454,7 +1454,7 @@ FULL_YSCALEYUV2RGB ...@@ -1454,7 +1454,7 @@ FULL_YSCALEYUV2RGB
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1474,7 +1474,7 @@ FULL_YSCALEYUV2RGB ...@@ -1474,7 +1474,7 @@ FULL_YSCALEYUV2RGB
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1516,7 +1516,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1516,7 +1516,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
{ {
switch(dstFormat) switch(dstFormat)
{ {
case IMGFMT_BGR32: case PIX_FMT_RGB32:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1530,7 +1530,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1530,7 +1530,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1544,7 +1544,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1544,7 +1544,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1564,7 +1564,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1564,7 +1564,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1585,7 +1585,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1585,7 +1585,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1605,7 +1605,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1605,7 +1605,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
{ {
switch(dstFormat) switch(dstFormat)
{ {
case IMGFMT_BGR32: case PIX_FMT_RGB32:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1619,7 +1619,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1619,7 +1619,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1633,7 +1633,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1633,7 +1633,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR15: case PIX_FMT_BGR555:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1653,7 +1653,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1653,7 +1653,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_BGR16: case PIX_FMT_BGR565:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1674,7 +1674,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * ...@@ -1674,7 +1674,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *
"a" (&c->redDither) "a" (&c->redDither)
); );
return; return;
case IMGFMT_YUY2: case PIX_FMT_YUYV422:
asm volatile( asm volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -2435,42 +2435,42 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i ...@@ -2435,42 +2435,42 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos) int32_t *mmx2FilterPos)
{ {
if(srcFormat==IMGFMT_YUY2) if(srcFormat==PIX_FMT_YUYV422)
{ {
RENAME(yuy2ToY)(formatConvBuffer, src, srcW); RENAME(yuy2ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_UYVY) else if(srcFormat==PIX_FMT_UYVY422)
{ {
RENAME(uyvyToY)(formatConvBuffer, src, srcW); RENAME(uyvyToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_BGR32) else if(srcFormat==PIX_FMT_RGB32)
{ {
RENAME(bgr32ToY)(formatConvBuffer, src, srcW); RENAME(bgr32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_BGR24) else if(srcFormat==PIX_FMT_BGR24)
{ {
RENAME(bgr24ToY)(formatConvBuffer, src, srcW); RENAME(bgr24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_BGR16) else if(srcFormat==PIX_FMT_BGR565)
{ {
RENAME(bgr16ToY)(formatConvBuffer, src, srcW); RENAME(bgr16ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_BGR15) else if(srcFormat==PIX_FMT_BGR555)
{ {
RENAME(bgr15ToY)(formatConvBuffer, src, srcW); RENAME(bgr15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_RGB32) else if(srcFormat==PIX_FMT_BGR32)
{ {
RENAME(rgb32ToY)(formatConvBuffer, src, srcW); RENAME(rgb32ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
} }
else if(srcFormat==IMGFMT_RGB24) else if(srcFormat==PIX_FMT_RGB24)
{ {
RENAME(rgb24ToY)(formatConvBuffer, src, srcW); RENAME(rgb24ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer; src= formatConvBuffer;
...@@ -2622,49 +2622,49 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, ...@@ -2622,49 +2622,49 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter, int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
int32_t *mmx2FilterPos) int32_t *mmx2FilterPos)
{ {
if(srcFormat==IMGFMT_YUY2) if(srcFormat==PIX_FMT_YUYV422)
{ {
RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_UYVY) else if(srcFormat==PIX_FMT_UYVY422)
{ {
RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(uyvyToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_BGR32) else if(srcFormat==PIX_FMT_RGB32)
{ {
RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_BGR24) else if(srcFormat==PIX_FMT_BGR24)
{ {
RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_BGR16) else if(srcFormat==PIX_FMT_BGR565)
{ {
RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(bgr16ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_BGR15) else if(srcFormat==PIX_FMT_BGR555)
{ {
RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(bgr15ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_RGB32) else if(srcFormat==PIX_FMT_BGR32)
{ {
RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
src2= formatConvBuffer+2048; src2= formatConvBuffer+2048;
} }
else if(srcFormat==IMGFMT_RGB24) else if(srcFormat==PIX_FMT_RGB24)
{ {
RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW);
src1= formatConvBuffer; src1= formatConvBuffer;
...@@ -2902,7 +2902,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s ...@@ -2902,7 +2902,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
{ {
static volatile int i=0; static volatile int i=0;
i++; i++;
if(srcFormat==IMGFMT_YV12 && i==1 && srcSliceH>= c->srcH) if(srcFormat==PIX_FMT_YUV420P && i==1 && srcSliceH>= c->srcH)
selfTest(src, srcStride, c->srcW, c->srcH); selfTest(src, srcStride, c->srcW, c->srcH);
i--; i--;
} }
...@@ -3081,7 +3081,7 @@ i--; ...@@ -3081,7 +3081,7 @@ i--;
} }
} }
#endif #endif
if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){ if(dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1; const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
RENAME(yuv2nv12X)(c, RENAME(yuv2nv12X)(c,
...@@ -3141,7 +3141,7 @@ i--; ...@@ -3141,7 +3141,7 @@ i--;
{ {
int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
if(dstFormat == IMGFMT_NV12 || dstFormat == IMGFMT_NV21){ if(dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
const int chrSkipMask= (1<<c->chrDstVSubSample)-1; const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi if(dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
yuv2nv12XinC( yuv2nv12XinC(
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "swscale.h" #include "swscale.h"
#include "swscale_internal.h" #include "swscale_internal.h"
#include "libmpcodecs/img_format.h" //FIXME try to reduce dependency of such stuff
#ifdef HAVE_MLIB #ifdef HAVE_MLIB
#include "yuv2rgb_mlib.c" #include "yuv2rgb_mlib.c"
...@@ -259,7 +258,7 @@ static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSlic ...@@ -259,7 +258,7 @@ static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSlic
int srcSliceH, uint8_t* dst[], int dstStride[]){\ int srcSliceH, uint8_t* dst[], int dstStride[]){\
int y;\ int y;\
\ \
if(c->srcFormat == IMGFMT_422P){\ if(c->srcFormat == PIX_FMT_YUV422P){\
srcStride[1] *= 2;\ srcStride[1] *= 2;\
srcStride[2] *= 2;\ srcStride[2] *= 2;\
}\ }\
...@@ -581,18 +580,18 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c) ...@@ -581,18 +580,18 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
#if defined(HAVE_MMX2) || defined(HAVE_MMX) #if defined(HAVE_MMX2) || defined(HAVE_MMX)
if(c->flags & SWS_CPU_CAPS_MMX2){ if(c->flags & SWS_CPU_CAPS_MMX2){
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_BGR32: return yuv420_rgb32_MMX2; case PIX_FMT_RGB32: return yuv420_rgb32_MMX2;
case IMGFMT_BGR24: return yuv420_rgb24_MMX2; case PIX_FMT_BGR24: return yuv420_rgb24_MMX2;
case IMGFMT_BGR16: return yuv420_rgb16_MMX2; case PIX_FMT_BGR565: return yuv420_rgb16_MMX2;
case IMGFMT_BGR15: return yuv420_rgb15_MMX2; case PIX_FMT_BGR555: return yuv420_rgb15_MMX2;
} }
} }
if(c->flags & SWS_CPU_CAPS_MMX){ if(c->flags & SWS_CPU_CAPS_MMX){
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_BGR32: return yuv420_rgb32_MMX; case PIX_FMT_RGB32: return yuv420_rgb32_MMX;
case IMGFMT_BGR24: return yuv420_rgb24_MMX; case PIX_FMT_BGR24: return yuv420_rgb24_MMX;
case IMGFMT_BGR16: return yuv420_rgb16_MMX; case PIX_FMT_BGR565: return yuv420_rgb16_MMX;
case IMGFMT_BGR15: return yuv420_rgb15_MMX; case PIX_FMT_BGR555: return yuv420_rgb15_MMX;
} }
} }
#endif #endif
...@@ -613,22 +612,21 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c) ...@@ -613,22 +612,21 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
MSG_WARN("No accelerated colorspace conversion found\n"); MSG_WARN("No accelerated colorspace conversion found\n");
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_RGB32: case PIX_FMT_BGR32:
case IMGFMT_BGR32: return yuv2rgb_c_32; case PIX_FMT_RGB32: return yuv2rgb_c_32;
case IMGFMT_RGB24: return yuv2rgb_c_24_rgb; case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
case IMGFMT_BGR24: return yuv2rgb_c_24_bgr; case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
case IMGFMT_RGB16: case PIX_FMT_RGB565:
case IMGFMT_BGR16: case PIX_FMT_BGR565:
case IMGFMT_RGB15: case PIX_FMT_RGB555:
case IMGFMT_BGR15: return yuv2rgb_c_16; case PIX_FMT_BGR555: return yuv2rgb_c_16;
case IMGFMT_RGB8: case PIX_FMT_RGB8:
case IMGFMT_BGR8: return yuv2rgb_c_8_ordered_dither; case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
case IMGFMT_RGB4: case PIX_FMT_RGB4:
case IMGFMT_BGR4: return yuv2rgb_c_4_ordered_dither; case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
case IMGFMT_RG4B: case PIX_FMT_RGB4_BYTE:
case IMGFMT_BG4B: return yuv2rgb_c_4b_ordered_dither; case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
case IMGFMT_RGB1: case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
case IMGFMT_BGR1: return yuv2rgb_c_1_ordered_dither;
default: default:
assert(0); assert(0);
} }
...@@ -645,8 +643,8 @@ static int div_round (int dividend, int divisor) ...@@ -645,8 +643,8 @@ 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) int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
{ {
const int isRgb = IMGFMT_IS_BGR(c->dstFormat); const int isRgb = isBGR(c->dstFormat);
const int bpp = isRgb?IMGFMT_RGB_DEPTH(c->dstFormat):IMGFMT_BGR_DEPTH(c->dstFormat); const int bpp = fmt_depth(c->dstFormat);
int i; int i;
uint8_t table_Y[1024]; uint8_t table_Y[1024];
uint32_t *table_32 = 0; uint32_t *table_32 = 0;
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
#include "rgb2rgb.h" #include "rgb2rgb.h"
#include "swscale.h" #include "swscale.h"
#include "swscale_internal.h" #include "swscale_internal.h"
#include "libmpcodecs/img_format.h" //FIXME try to reduce dependency of such stuff
#undef PROFILE_THE_BEAST #undef PROFILE_THE_BEAST
#undef INC_SCALING #undef INC_SCALING
...@@ -697,45 +696,41 @@ SwsFunc yuv2rgb_init_altivec (SwsContext *c) ...@@ -697,45 +696,41 @@ SwsFunc yuv2rgb_init_altivec (SwsContext *c)
if ((c->srcW & 0xf) != 0) return NULL; if ((c->srcW & 0xf) != 0) return NULL;
switch (c->srcFormat) { switch (c->srcFormat) {
case IMGFMT_YVU9: case PIX_FMT_YUV410P:
case IMGFMT_IF09: case PIX_FMT_YUV420P:
case IMGFMT_YV12: /*case IMGFMT_CLPL: ??? */
case IMGFMT_I420: case PIX_FMT_GRAY8:
case IMGFMT_IYUV: case PIX_FMT_NV12:
case IMGFMT_CLPL: case PIX_FMT_NV21:
case IMGFMT_Y800:
case IMGFMT_Y8:
case IMGFMT_NV12:
case IMGFMT_NV21:
if ((c->srcH & 0x1) != 0) if ((c->srcH & 0x1) != 0)
return NULL; return NULL;
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_RGB24: case PIX_FMT_RGB24:
MSG_WARN("ALTIVEC: Color Space RGB24\n"); MSG_WARN("ALTIVEC: Color Space RGB24\n");
return altivec_yuv2_rgb24; return altivec_yuv2_rgb24;
case IMGFMT_BGR24: case PIX_FMT_BGR24:
MSG_WARN("ALTIVEC: Color Space BGR24\n"); MSG_WARN("ALTIVEC: Color Space BGR24\n");
return altivec_yuv2_bgr24; return altivec_yuv2_bgr24;
case IMGFMT_ARGB: case PIX_FMT_ARGB:
MSG_WARN("ALTIVEC: Color Space ARGB\n"); MSG_WARN("ALTIVEC: Color Space ARGB\n");
return altivec_yuv2_argb; return altivec_yuv2_argb;
case IMGFMT_ABGR: case PIX_FMT_ABGR:
MSG_WARN("ALTIVEC: Color Space ABGR\n"); MSG_WARN("ALTIVEC: Color Space ABGR\n");
return altivec_yuv2_abgr; return altivec_yuv2_abgr;
case IMGFMT_RGBA: case PIX_FMT_RGBA:
MSG_WARN("ALTIVEC: Color Space RGBA\n"); MSG_WARN("ALTIVEC: Color Space RGBA\n");
return altivec_yuv2_rgba; return altivec_yuv2_rgba;
case IMGFMT_BGRA: case PIX_FMT_BGRA:
MSG_WARN("ALTIVEC: Color Space BGRA\n"); MSG_WARN("ALTIVEC: Color Space BGRA\n");
return altivec_yuv2_bgra; return altivec_yuv2_bgra;
default: return NULL; default: return NULL;
} }
break; break;
case IMGFMT_UYVY: case PIX_FMT_UYVY422:
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_RGB32: case PIX_FMT_BGR32:
MSG_WARN("ALTIVEC: Color Space UYVY -> RGB32\n"); MSG_WARN("ALTIVEC: Color Space UYVY -> RGB32\n");
return altivec_uyvy_rgb32; return altivec_uyvy_rgb32;
default: return NULL; default: return NULL;
...@@ -868,12 +863,12 @@ altivec_yuv2packedX (SwsContext *c, ...@@ -868,12 +863,12 @@ altivec_yuv2packedX (SwsContext *c,
B = vec_packclp (B0,B1); B = vec_packclp (B0,B1);
switch(c->dstFormat) { switch(c->dstFormat) {
case IMGFMT_ABGR: out_abgr (R,G,B,out); break; case PIX_FMT_ABGR: out_abgr (R,G,B,out); break;
case IMGFMT_BGRA: out_bgra (R,G,B,out); break; case PIX_FMT_BGRA: out_bgra (R,G,B,out); break;
case IMGFMT_RGBA: out_rgba (R,G,B,out); break; case PIX_FMT_RGBA: out_rgba (R,G,B,out); break;
case IMGFMT_ARGB: out_argb (R,G,B,out); break; case PIX_FMT_ARGB: out_argb (R,G,B,out); break;
case IMGFMT_RGB24: out_rgb24 (R,G,B,out); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,out); break;
case IMGFMT_BGR24: out_bgr24 (R,G,B,out); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,out); break;
default: default:
{ {
/* If this is reached, the caller should have called yuv2packedXinC /* If this is reached, the caller should have called yuv2packedXinC
...@@ -947,12 +942,12 @@ altivec_yuv2packedX (SwsContext *c, ...@@ -947,12 +942,12 @@ altivec_yuv2packedX (SwsContext *c,
nout = (vector unsigned char *)scratch; nout = (vector unsigned char *)scratch;
switch(c->dstFormat) { switch(c->dstFormat) {
case IMGFMT_ABGR: out_abgr (R,G,B,nout); break; case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break;
case IMGFMT_BGRA: out_bgra (R,G,B,nout); break; case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break;
case IMGFMT_RGBA: out_rgba (R,G,B,nout); break; case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break;
case IMGFMT_ARGB: out_argb (R,G,B,nout); break; case PIX_FMT_ARGB: out_argb (R,G,B,nout); break;
case IMGFMT_RGB24: out_rgb24 (R,G,B,nout); break; case PIX_FMT_RGB24: out_rgb24 (R,G,B,nout); break;
case IMGFMT_BGR24: out_bgr24 (R,G,B,nout); break; case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break;
default: default:
/* Unreachable, I think. */ /* Unreachable, I think. */
MSG_ERR("altivec_yuv2packedX doesn't support %s output\n", MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
......
...@@ -30,12 +30,11 @@ ...@@ -30,12 +30,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "libmpcodecs/img_format.h" //FIXME try to reduce dependency of such stuff
#include "swscale.h" #include "swscale.h"
static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -49,7 +48,7 @@ static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], i ...@@ -49,7 +48,7 @@ static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], i
static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -63,7 +62,7 @@ static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], i ...@@ -63,7 +62,7 @@ static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], i
static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -79,9 +78,9 @@ static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], in ...@@ -79,9 +78,9 @@ static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], in
SwsFunc yuv2rgb_init_mlib(SwsContext *c) SwsFunc yuv2rgb_init_mlib(SwsContext *c)
{ {
switch(c->dstFormat){ switch(c->dstFormat){
case IMGFMT_RGB24: return mlib_YUV2RGB420_24; case PIX_FMT_RGB24: return mlib_YUV2RGB420_24;
case IMGFMT_RGB32: return mlib_YUV2ARGB420_32; case PIX_FMT_BGR32: return mlib_YUV2ARGB420_32;
case IMGFMT_BGR32: return mlib_YUV2ABGR420_32; case PIX_FMT_RGB32: return mlib_YUV2ABGR420_32;
default: return NULL; default: return NULL;
} }
} }
......
...@@ -127,7 +127,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStr ...@@ -127,7 +127,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStr
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size; int y, h_size;
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -222,7 +222,7 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStr ...@@ -222,7 +222,7 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStr
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size; int y, h_size;
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -311,7 +311,7 @@ static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStr ...@@ -311,7 +311,7 @@ static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStr
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size; int y, h_size;
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
...@@ -457,7 +457,7 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStr ...@@ -457,7 +457,7 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStr
int srcSliceH, uint8_t* dst[], int dstStride[]){ int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size; int y, h_size;
if(c->srcFormat == IMGFMT_422P){ if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2; srcStride[1] *= 2;
srcStride[2] *= 2; srcStride[2] *= 2;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment