diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-07-07 02:56:01 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-07-07 02:56:01 +0300 |
commit | a2037a2effbd4622d0e8336245a9b14c3f886bde (patch) | |
tree | bd2face6dd36d2663197b23a33da9e9b2814f70c /libswscale | |
parent | 0c2773a709276681575d2507aa60ee85c2d0b850 (diff) | |
parent | 43079c51daa8c12b0a44e5ad8022c979dd9e8336 (diff) | |
download | mpv-a2037a2effbd4622d0e8336245a9b14c3f886bde.tar.bz2 mpv-a2037a2effbd4622d0e8336245a9b14c3f886bde.tar.xz |
Merge svn changes up to r29412
Diffstat (limited to 'libswscale')
-rw-r--r-- | libswscale/ppc/swscale_altivec_template.c | 8 | ||||
-rw-r--r-- | libswscale/ppc/yuv2rgb_altivec.c | 4 | ||||
-rw-r--r-- | libswscale/swscale-example.c | 10 | ||||
-rw-r--r-- | libswscale/swscale.c | 216 | ||||
-rw-r--r-- | libswscale/swscale.h | 31 | ||||
-rw-r--r-- | libswscale/swscale_internal.h | 70 | ||||
-rw-r--r-- | libswscale/swscale_template.c | 194 | ||||
-rw-r--r-- | libswscale/yuv2rgb.c | 41 |
8 files changed, 356 insertions, 218 deletions
diff --git a/libswscale/ppc/swscale_altivec_template.c b/libswscale/ppc/swscale_altivec_template.c index c24970464c..8919177bcc 100644 --- a/libswscale/ppc/swscale_altivec_template.c +++ b/libswscale/ppc/swscale_altivec_template.c @@ -92,7 +92,7 @@ yuv2yuvX_altivec_real(const int16_t *lumFilter, int16_t **lumSrc, int lumFilterS const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)}; register int i, j; { - int __attribute__ ((aligned (16))) val[dstW]; + DECLARE_ALIGNED(16, int, val[dstW]); for (i = 0; i < (dstW -7); i+=4) { vec_st(vini, i << 2, val); @@ -140,8 +140,8 @@ yuv2yuvX_altivec_real(const int16_t *lumFilter, int16_t **lumSrc, int lumFilterS altivec_packIntArrayToCharArray(val, dest, dstW); } if (uDest != 0) { - int __attribute__ ((aligned (16))) u[chrDstW]; - int __attribute__ ((aligned (16))) v[chrDstW]; + DECLARE_ALIGNED(16, int, u[chrDstW]); + DECLARE_ALIGNED(16, int, v[chrDstW]); for (i = 0; i < (chrDstW -7); i+=4) { vec_st(vini, i << 2, u); @@ -214,7 +214,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, const int16_t *filterPos, int filterSize) { register int i; - int __attribute__ ((aligned (16))) tempo[4]; + DECLARE_ALIGNED(16, int, tempo[4]); if (filterSize % 4) { for (i=0; i<dstW; i++) { diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c index 43879ea62d..550afc4023 100644 --- a/libswscale/ppc/yuv2rgb_altivec.c +++ b/libswscale/ppc/yuv2rgb_altivec.c @@ -753,7 +753,7 @@ SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c) void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation) { union { - signed short tmp[8] __attribute__ ((aligned(16))); + DECLARE_ALIGNED(16, signed short, tmp[8]); vector signed short vec; } buf; @@ -800,7 +800,7 @@ ff_yuv2packedX_altivec(SwsContext *c, vector signed short RND = vec_splat_s16(1<<3); vector unsigned short SCL = vec_splat_u16(4); - unsigned long scratch[16] __attribute__ ((aligned (16))); + DECLARE_ALIGNED(16, unsigned long, scratch[16]); vector signed short *YCoeffs, *CCoeffs; diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c index 8d60332897..c9916e5489 100644 --- a/libswscale/swscale-example.c +++ b/libswscale/swscale-example.c @@ -30,6 +30,12 @@ #include "swscale.h" #include "swscale_internal.h" +#undef fprintf +#undef free +#undef malloc +#undef perror +#undef printf + static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, int w, int h){ int x,y; uint64_t ssd=0; @@ -66,11 +72,15 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, int srcFormat // avoid stride % bpp != 0 if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24) srcStride[i]= srcW*3; + else if (srcFormat==PIX_FMT_RGB48BE || srcFormat==PIX_FMT_RGB48LE) + srcStride[i]= srcW*6; else srcStride[i]= srcW*4; if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24) dstStride[i]= dstW*3; + else if (dstFormat==PIX_FMT_RGB48BE || dstFormat==PIX_FMT_RGB48LE) + dstStride[i]= dstW*6; else dstStride[i]= dstW*4; diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 31e3b83cde..31cf36ae05 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -108,6 +108,8 @@ unsigned swscale_version(void) || (x)==PIX_FMT_YUVA420P \ || (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_UYVY422 \ + || (x)==PIX_FMT_RGB48BE \ + || (x)==PIX_FMT_RGB48LE \ || (x)==PIX_FMT_RGB32 \ || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_BGR24 \ @@ -281,17 +283,17 @@ static unsigned char clip_table[768]; static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b); -static const uint8_t __attribute__((aligned(8))) dither_2x2_4[2][8]={ +DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_4[2][8])={ { 1, 3, 1, 3, 1, 3, 1, 3, }, { 2, 0, 2, 0, 2, 0, 2, 0, }, }; -static const uint8_t __attribute__((aligned(8))) dither_2x2_8[2][8]={ +DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_8[2][8])={ { 6, 2, 6, 2, 6, 2, 6, 2, }, { 0, 4, 0, 4, 0, 4, 0, 4, }, }; -const uint8_t __attribute__((aligned(8))) dither_8x8_32[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32[8][8])={ { 17, 9, 23, 15, 16, 8, 22, 14, }, { 5, 29, 3, 27, 4, 28, 2, 26, }, { 21, 13, 19, 11, 20, 12, 18, 10, }, @@ -303,7 +305,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_32[8][8]={ }; #if 0 -const uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_64[8][8])={ { 0, 48, 12, 60, 3, 51, 15, 63, }, { 32, 16, 44, 28, 35, 19, 47, 31, }, { 8, 56, 4, 52, 11, 59, 7, 55, }, @@ -315,7 +317,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={ }; #endif -const uint8_t __attribute__((aligned(8))) dither_8x8_73[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73[8][8])={ { 0, 55, 14, 68, 3, 58, 17, 72, }, { 37, 18, 50, 32, 40, 22, 54, 35, }, { 9, 64, 5, 59, 13, 67, 8, 63, }, @@ -327,7 +329,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_73[8][8]={ }; #if 0 -const uint8_t __attribute__((aligned(8))) dither_8x8_128[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_128[8][8])={ { 68, 36, 92, 60, 66, 34, 90, 58, }, { 20, 116, 12, 108, 18, 114, 10, 106, }, { 84, 52, 76, 44, 82, 50, 74, 42, }, @@ -340,7 +342,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_128[8][8]={ #endif #if 1 -const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={ {117, 62, 158, 103, 113, 58, 155, 100, }, { 34, 199, 21, 186, 31, 196, 17, 182, }, {144, 89, 131, 76, 141, 86, 127, 72, }, @@ -352,7 +354,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ }; #elif 1 // tries to correct a gamma of 1.5 -const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={ { 0, 143, 18, 200, 2, 156, 25, 215, }, { 78, 28, 125, 64, 89, 36, 138, 74, }, { 10, 180, 3, 161, 16, 195, 8, 175, }, @@ -364,7 +366,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ }; #elif 1 // tries to correct a gamma of 2.0 -const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={ { 0, 124, 8, 193, 0, 140, 12, 213, }, { 55, 14, 104, 42, 66, 19, 119, 52, }, { 3, 168, 1, 145, 6, 187, 3, 162, }, @@ -376,7 +378,7 @@ const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ }; #else // tries to correct a gamma of 2.5 -const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={ +DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={ { 0, 107, 3, 187, 0, 125, 6, 212, }, { 39, 7, 86, 28, 49, 11, 102, 36, }, { 1, 158, 0, 131, 3, 180, 1, 151, }, @@ -463,6 +465,10 @@ const char *sws_format_name(enum PixelFormat format) return "rgb4"; case PIX_FMT_RGB4_BYTE: return "rgb4 byte"; + case PIX_FMT_RGB48BE: + return "rgb48be"; + case PIX_FMT_RGB48LE: + return "rgb48le"; case PIX_FMT_NV12: return "nv12"; case PIX_FMT_NV21: @@ -847,6 +853,24 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc #define YSCALE_YUV_2_ANYRGB_C(func, func2, func_g16, func_monoblack)\ switch(c->dstFormat)\ {\ + case PIX_FMT_RGB48BE:\ + case PIX_FMT_RGB48LE:\ + func(uint8_t,0)\ + ((uint8_t*)dest)[ 0]= r[Y1];\ + ((uint8_t*)dest)[ 1]= r[Y1];\ + ((uint8_t*)dest)[ 2]= g[Y1];\ + ((uint8_t*)dest)[ 3]= g[Y1];\ + ((uint8_t*)dest)[ 4]= b[Y1];\ + ((uint8_t*)dest)[ 5]= b[Y1];\ + ((uint8_t*)dest)[ 6]= r[Y2];\ + ((uint8_t*)dest)[ 7]= r[Y2];\ + ((uint8_t*)dest)[ 8]= g[Y2];\ + ((uint8_t*)dest)[ 9]= g[Y2];\ + ((uint8_t*)dest)[10]= b[Y2];\ + ((uint8_t*)dest)[11]= b[Y2];\ + dest+=12;\ + }\ + break;\ case PIX_FMT_RGBA:\ case PIX_FMT_BGRA:\ if (CONFIG_SMALL){\ @@ -1118,15 +1142,171 @@ static void fillPlane(uint8_t* plane, int stride, int width, int height, int y, } } +static inline void rgb48ToY(uint8_t *dst, const uint8_t *src, int width) +{ + int i; + for (i = 0; i < width; i++) { + int r = src[i*6+0]; + int g = src[i*6+2]; + int b = src[i*6+4]; + + dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + } +} + +static inline void rgb48ToUV(uint8_t *dstU, uint8_t *dstV, + uint8_t *src1, uint8_t *src2, int width) +{ + int i; + assert(src1==src2); + for (i = 0; i < width; i++) { + int r = src1[6*i + 0]; + int g = src1[6*i + 2]; + int b = src1[6*i + 4]; + + dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; + } +} + +static inline void rgb48ToUV_half(uint8_t *dstU, uint8_t *dstV, + uint8_t *src1, uint8_t *src2, int width) +{ + int i; + assert(src1==src2); + for (i = 0; i < width; i++) { + int r= src1[12*i + 0] + src1[12*i + 6]; + int g= src1[12*i + 2] + src1[12*i + 8]; + int b= src1[12*i + 4] + src1[12*i + 10]; + + dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); + dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1); + } +} + +#define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\ +static inline void name(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\ +{\ + int i;\ + for (i=0; i<width; i++)\ + {\ + int b= (((const type*)src)[i]>>shb)&maskb;\ + int g= (((const type*)src)[i]>>shg)&maskg;\ + int r= (((const type*)src)[i]>>shr)&maskr;\ +\ + dst[i]= (((RY)*r + (GY)*g + (BY)*b + (33<<((S)-1)))>>(S));\ + }\ +} + +BGR2Y(uint32_t, bgr32ToY,16, 0, 0, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8) +BGR2Y(uint32_t, rgb32ToY, 0, 0,16, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8) +BGR2Y(uint16_t, bgr16ToY, 0, 0, 0, 0x001F, 0x07E0, 0xF800, RY<<11, GY<<5, BY , RGB2YUV_SHIFT+8) +BGR2Y(uint16_t, bgr15ToY, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RY<<10, GY<<5, BY , RGB2YUV_SHIFT+7) +BGR2Y(uint16_t, rgb16ToY, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RY , GY<<5, BY<<11, RGB2YUV_SHIFT+8) +BGR2Y(uint16_t, rgb15ToY, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RY , GY<<5, BY<<10, RGB2YUV_SHIFT+7) + +static inline void abgrToA(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused){ + int i; + for (i=0; i<width; i++){ + dst[i]= src[4*i]; + } +} + +#define BGR2UV(type, name, shr, shg, shb, maska, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S)\ +static inline void name(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\ +{\ + int i;\ + for (i=0; i<width; i++)\ + {\ + int b= (((const type*)src)[i]&maskb)>>shb;\ + int g= (((const type*)src)[i]&maskg)>>shg;\ + int r= (((const type*)src)[i]&maskr)>>shr;\ +\ + dstU[i]= ((RU)*r + (GU)*g + (BU)*b + (257<<((S)-1)))>>(S);\ + dstV[i]= ((RV)*r + (GV)*g + (BV)*b + (257<<((S)-1)))>>(S);\ + }\ +}\ +static inline void name ## _half(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\ +{\ + int i;\ + for (i=0; i<width; i++)\ + {\ + int pix0= ((const type*)src)[2*i+0];\ + int pix1= ((const type*)src)[2*i+1];\ + int g= (pix0&~(maskr|maskb))+(pix1&~(maskr|maskb));\ + int b= ((pix0+pix1-g)&(maskb|(2*maskb)))>>shb;\ + int r= ((pix0+pix1-g)&(maskr|(2*maskr)))>>shr;\ + g&= maskg|(2*maskg);\ +\ + g>>=shg;\ +\ + dstU[i]= ((RU)*r + (GU)*g + (BU)*b + (257<<(S)))>>((S)+1);\ + dstV[i]= ((RV)*r + (GV)*g + (BV)*b + (257<<(S)))>>((S)+1);\ + }\ +} + +BGR2UV(uint32_t, bgr32ToUV,16, 0, 0, 0xFF000000, 0xFF0000, 0xFF00, 0x00FF, RU<< 8, GU , BU<< 8, RV<< 8, GV , BV<< 8, RGB2YUV_SHIFT+8) +BGR2UV(uint32_t, rgb32ToUV, 0, 0,16, 0xFF000000, 0x00FF, 0xFF00, 0xFF0000, RU<< 8, GU , BU<< 8, RV<< 8, GV , BV<< 8, RGB2YUV_SHIFT+8) +BGR2UV(uint16_t, bgr16ToUV, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, RU<<11, GU<<5, BU , RV<<11, GV<<5, BV , RGB2YUV_SHIFT+8) +BGR2UV(uint16_t, bgr15ToUV, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RU<<10, GU<<5, BU , RV<<10, GV<<5, BV , RGB2YUV_SHIFT+7) +BGR2UV(uint16_t, rgb16ToUV, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RU , GU<<5, BU<<11, RV , GV<<5, BV<<11, RGB2YUV_SHIFT+8) +BGR2UV(uint16_t, rgb15ToUV, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RU , GU<<5, BU<<10, RV , GV<<5, BV<<10, RGB2YUV_SHIFT+7) + +static inline void palToY(uint8_t *dst, const uint8_t *src, long width, uint32_t *pal) +{ + int i; + for (i=0; i<width; i++) + { + int d= src[i]; + + dst[i]= pal[d] & 0xFF; + } +} + +static inline void palToUV(uint8_t *dstU, uint8_t *dstV, + const uint8_t *src1, const uint8_t *src2, + long width, uint32_t *pal) +{ + int i; + assert(src1 == src2); + for (i=0; i<width; i++) + { + int p= pal[src1[i]]; + + dstU[i]= p>>8; + dstV[i]= p>>16; + } +} + +static inline void monowhite2Y(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) +{ + int i, j; + for (i=0; i<width/8; i++){ + int d= ~src[i]; + for(j=0; j<8; j++) + dst[8*i+j]= ((d>>(7-j))&1)*255; + } +} + +static inline void monoblack2Y(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) +{ + int i, j; + for (i=0; i<width/8; i++){ + int d= src[i]; + for(j=0; j<8; j++) + dst[8*i+j]= ((d>>(7-j))&1)*255; + } +} + + //Note: we have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one //Plain C versions -#if !HAVE_MMX || CONFIG_RUNTIME_CPUDETECT || !CONFIG_GPL +#if ((!HAVE_MMX || !CONFIG_GPL) && !HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT #define COMPILE_C #endif #if ARCH_PPC -#if (HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL -#undef COMPILE_C +#if HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT #define COMPILE_ALTIVEC #endif #endif //ARCH_PPC @@ -1792,10 +1972,10 @@ static void globalInit(void){ static SwsFunc getSwsFunc(SwsContext *c) { -#if CONFIG_RUNTIME_CPUDETECT && CONFIG_GPL +#if CONFIG_RUNTIME_CPUDETECT int flags = c->flags; -#if ARCH_X86 +#if ARCH_X86 && CONFIG_GPL // ordered per speed fastest first if (flags & SWS_CPU_CAPS_MMX2) { sws_init_swScale_MMX2(c); @@ -1823,7 +2003,7 @@ static SwsFunc getSwsFunc(SwsContext *c) #endif sws_init_swScale_C(c); return swScale_C; -#endif /* ARCH_X86 */ +#endif /* ARCH_X86 && CONFIG_GPL */ #else //CONFIG_RUNTIME_CPUDETECT #if HAVE_MMX2 sws_init_swScale_MMX2(c); @@ -2385,7 +2565,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d __asm__ volatile("emms\n\t"::: "memory"); #endif -#if !CONFIG_RUNTIME_CPUDETECT || !CONFIG_GPL //ensure that the flags match the compiled variant if cpudetect is off +#if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN); #if HAVE_MMX2 flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2; @@ -2551,6 +2731,8 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d && srcFormat != PIX_FMT_MONOWHITE && dstFormat != PIX_FMT_MONOWHITE && dstFormat != PIX_FMT_RGB32_1 && dstFormat != PIX_FMT_BGR32_1 + && srcFormat != PIX_FMT_RGB48LE && dstFormat != PIX_FMT_RGB48LE + && srcFormat != PIX_FMT_RGB48BE && dstFormat != PIX_FMT_RGB48BE && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)))) c->swScale= rgb2rgbWrapper; diff --git a/libswscale/swscale.h b/libswscale/swscale.h index f5856c381c..a151095858 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -133,8 +133,8 @@ struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat SwsFilter *dstFilter, const double *param); /** - * Scales the image slice in \p srcSlice and puts the resulting scaled - * slice in the image in \p dst. A slice is a sequence of consecutive + * Scales the image slice in srcSlice and puts the resulting scaled + * slice in the image in dst. A slice is a sequence of consecutive * rows in an image. * * @param context the scaling context previously created with @@ -188,8 +188,8 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, SwsVector *sws_getGaussianVec(double variance, double quality); /** - * Allocates and returns a vector with \p length coefficients, all - * with the same value \p c. + * Allocates and returns a vector with length coefficients, all + * with the same value c. */ SwsVector *sws_getConstVec(double c, int length); @@ -200,13 +200,12 @@ SwsVector *sws_getConstVec(double c, int length); SwsVector *sws_getIdentityVec(void); /** - * Scales all the coefficients of \p a by the \p scalar value. + * Scales all the coefficients of a by the scalar value. */ void sws_scaleVec(SwsVector *a, double scalar); /** - * Scales all the coefficients of \p a so that their sum equals \p - * height." + * Scales all the coefficients of a so that their sum equals height. */ void sws_normalizeVec(SwsVector *a, double height); void sws_convVec(SwsVector *a, SwsVector *b); @@ -215,8 +214,8 @@ void sws_subVec(SwsVector *a, SwsVector *b); void sws_shiftVec(SwsVector *a, int shift); /** - * Allocates and returns a clone of the vector \p a, that is a vector - * with the same coefficients as \p a. + * Allocates and returns a clone of the vector a, that is a vector + * with the same coefficients as a. */ SwsVector *sws_cloneVec(SwsVector *a); @@ -228,8 +227,8 @@ attribute_deprecated void sws_printVec(SwsVector *a); #endif /** - * Prints with av_log() a textual representation of the vector \p a - * if \p log_level <= av_log_level. + * Prints with av_log() a textual representation of the vector a + * if log_level <= av_log_level. */ void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level); @@ -242,16 +241,16 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, void sws_freeFilter(SwsFilter *filter); /** - * Checks if \p context can be reused, otherwise reallocates a new + * Checks if context can be reused, otherwise reallocates a new * one. * - * If \p context is NULL, just calls sws_getContext() to get a new + * If context is NULL, just calls sws_getContext() to get a new * context. Otherwise, checks if the parameters are the ones already - * saved in \p context. If that is the case, returns the current - * context. Otherwise, frees \p context and gets a new context with + * saved in context. If that is the case, returns the current + * context. Otherwise, frees context and gets a new context with * the new parameters. * - * Be warned that \p srcFilter and \p dstFilter are not checked, they + * Be warned that srcFilter and dstFilter are not checked, they * are assumed to remain the same. */ struct SwsContext *sws_getCachedContext(struct SwsContext *context, diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d9bbb6c1e2..60a08a7849 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -28,6 +28,7 @@ #endif #include "libavutil/avutil.h" +#include "libavutil/internal.h" #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long @@ -166,26 +167,26 @@ typedef struct SwsContext{ #define Y_TEMP "11*8+4*4*256*2+40" #define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48" - uint64_t redDither __attribute__((aligned(8))); - uint64_t greenDither __attribute__((aligned(8))); - uint64_t blueDither __attribute__((aligned(8))); - - uint64_t yCoeff __attribute__((aligned(8))); - uint64_t vrCoeff __attribute__((aligned(8))); - uint64_t ubCoeff __attribute__((aligned(8))); - uint64_t vgCoeff __attribute__((aligned(8))); - uint64_t ugCoeff __attribute__((aligned(8))); - uint64_t yOffset __attribute__((aligned(8))); - uint64_t uOffset __attribute__((aligned(8))); - uint64_t vOffset __attribute__((aligned(8))); + DECLARE_ALIGNED(8, uint64_t, redDither); + DECLARE_ALIGNED(8, uint64_t, greenDither); + DECLARE_ALIGNED(8, uint64_t, blueDither); + + DECLARE_ALIGNED(8, uint64_t, yCoeff); + DECLARE_ALIGNED(8, uint64_t, vrCoeff); + DECLARE_ALIGNED(8, uint64_t, ubCoeff); + DECLARE_ALIGNED(8, uint64_t, vgCoeff); + DECLARE_ALIGNED(8, uint64_t, ugCoeff); + DECLARE_ALIGNED(8, uint64_t, yOffset); + DECLARE_ALIGNED(8, uint64_t, uOffset); + DECLARE_ALIGNED(8, uint64_t, vOffset); int32_t lumMmxFilter[4*MAX_FILTER_SIZE]; int32_t chrMmxFilter[4*MAX_FILTER_SIZE]; int dstW; - uint64_t esp __attribute__((aligned(8))); - uint64_t vRounder __attribute__((aligned(8))); - uint64_t u_temp __attribute__((aligned(8))); - uint64_t v_temp __attribute__((aligned(8))); - uint64_t y_temp __attribute__((aligned(8))); + DECLARE_ALIGNED(8, uint64_t, esp); + DECLARE_ALIGNED(8, uint64_t, vRounder); + DECLARE_ALIGNED(8, uint64_t, u_temp); + DECLARE_ALIGNED(8, uint64_t, v_temp); + DECLARE_ALIGNED(8, uint64_t, y_temp); int32_t alpMmxFilter[4*MAX_FILTER_SIZE]; #if HAVE_ALTIVEC @@ -200,21 +201,21 @@ typedef struct SwsContext{ #endif #if ARCH_BFIN - uint32_t oy __attribute__((aligned(4))); - uint32_t oc __attribute__((aligned(4))); - uint32_t zero __attribute__((aligned(4))); - uint32_t cy __attribute__((aligned(4))); - uint32_t crv __attribute__((aligned(4))); - uint32_t rmask __attribute__((aligned(4))); - uint32_t cbu __attribute__((aligned(4))); - uint32_t bmask __attribute__((aligned(4))); - uint32_t cgu __attribute__((aligned(4))); - uint32_t cgv __attribute__((aligned(4))); - uint32_t gmask __attribute__((aligned(4))); + DECLARE_ALIGNED(4, uint32_t, oy); + DECLARE_ALIGNED(4, uint32_t, oc); + DECLARE_ALIGNED(4, uint32_t, zero); + DECLARE_ALIGNED(4, uint32_t, cy); + DECLARE_ALIGNED(4, uint32_t, crv); + DECLARE_ALIGNED(4, uint32_t, rmask); + DECLARE_ALIGNED(4, uint32_t, cbu); + DECLARE_ALIGNED(4, uint32_t, bmask); + DECLARE_ALIGNED(4, uint32_t, cgu); + DECLARE_ALIGNED(4, uint32_t, cgv); + DECLARE_ALIGNED(4, uint32_t, gmask); #endif #if HAVE_VIS - uint64_t sparc_coeffs[10] __attribute__((aligned(8))); + DECLARE_ALIGNED(8, uint64_t, sparc_coeffs[10]); #endif /* function pointers for swScale() */ @@ -293,12 +294,14 @@ void ff_yuv2packedX_altivec(SwsContext *c, const int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, int dstW, int dstY); -const char *sws_format_name(int format); +const char *sws_format_name(enum PixelFormat format); //FIXME replace this with something faster #define is16BPS(x) ( \ (x)==PIX_FMT_GRAY16BE \ || (x)==PIX_FMT_GRAY16LE \ + || (x)==PIX_FMT_RGB48BE \ + || (x)==PIX_FMT_RGB48LE \ || (x)==PIX_FMT_YUV420PLE \ || (x)==PIX_FMT_YUV422PLE \ || (x)==PIX_FMT_YUV444PLE \ @@ -342,7 +345,9 @@ const char *sws_format_name(int format); || (x)==PIX_FMT_GRAY16LE \ ) #define isRGB(x) ( \ - (x)==PIX_FMT_RGB32 \ + (x)==PIX_FMT_RGB48BE \ + || (x)==PIX_FMT_RGB48LE \ + || (x)==PIX_FMT_RGB32 \ || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_RGB24 \ || (x)==PIX_FMT_RGB565 \ @@ -376,6 +381,9 @@ const char *sws_format_name(int format); static inline int fmt_depth(int fmt) { switch(fmt) { + case PIX_FMT_RGB48BE: + case PIX_FMT_RGB48LE: + return 48; case PIX_FMT_BGRA: case PIX_FMT_ABGR: case PIX_FMT_RGBA: diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index a605b9b663..279cab034b 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -1799,74 +1799,6 @@ static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *s #endif } -#define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\ -static inline void RENAME(name)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\ -{\ - int i;\ - for (i=0; i<width; i++)\ - {\ - int b= (((const type*)src)[i]>>shb)&maskb;\ - int g= (((const type*)src)[i]>>shg)&maskg;\ - int r= (((const type*)src)[i]>>shr)&maskr;\ -\ - dst[i]= (((RY)*r + (GY)*g + (BY)*b + (33<<((S)-1)))>>(S));\ - }\ -} - -BGR2Y(uint32_t, bgr32ToY,16, 0, 0, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8) -BGR2Y(uint32_t, rgb32ToY, 0, 0,16, 0x00FF, 0xFF00, 0x00FF, RY<< 8, GY , BY<< 8, RGB2YUV_SHIFT+8) -BGR2Y(uint16_t, bgr16ToY, 0, 0, 0, 0x001F, 0x07E0, 0xF800, RY<<11, GY<<5, BY , RGB2YUV_SHIFT+8) -BGR2Y(uint16_t, bgr15ToY, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RY<<10, GY<<5, BY , RGB2YUV_SHIFT+7) -BGR2Y(uint16_t, rgb16ToY, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RY , GY<<5, BY<<11, RGB2YUV_SHIFT+8) -BGR2Y(uint16_t, rgb15ToY, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RY , GY<<5, BY<<10, RGB2YUV_SHIFT+7) - -static inline void RENAME(abgrToA)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused){ - int i; - for (i=0; i<width; i++){ - dst[i]= src[4*i]; - } -} - -#define BGR2UV(type, name, shr, shg, shb, maska, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S)\ -static inline void RENAME(name)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\ -{\ - int i;\ - for (i=0; i<width; i++)\ - {\ - int b= (((const type*)src)[i]&maskb)>>shb;\ - int g= (((const type*)src)[i]&maskg)>>shg;\ - int r= (((const type*)src)[i]&maskr)>>shr;\ -\ - dstU[i]= ((RU)*r + (GU)*g + (BU)*b + (257<<((S)-1)))>>(S);\ - dstV[i]= ((RV)*r + (GV)*g + (BV)*b + (257<<((S)-1)))>>(S);\ - }\ -}\ -static inline void RENAME(name ## _half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, const uint8_t *dummy, long width, uint32_t *unused)\ -{\ - int i;\ - for (i=0; i<width; i++)\ - {\ - int pix0= ((const type*)src)[2*i+0];\ - int pix1= ((const type*)src)[2*i+1];\ - int g= (pix0&~(maskr|maskb))+(pix1&~(maskr|maskb));\ - int b= ((pix0+pix1-g)&(maskb|(2*maskb)))>>shb;\ - int r= ((pix0+pix1-g)&(maskr|(2*maskr)))>>shr;\ - g&= maskg|(2*maskg);\ -\ - g>>=shg;\ -\ - dstU[i]= ((RU)*r + (GU)*g + (BU)*b + (257<<(S)))>>((S)+1);\ - dstV[i]= ((RV)*r + (GV)*g + (BV)*b + (257<<(S)))>>((S)+1);\ - }\ -} - -BGR2UV(uint32_t, bgr32ToUV,16, 0, 0, 0xFF000000, 0xFF0000, 0xFF00, 0x00FF, RU<< 8, GU , BU<< 8, RV<< 8, GV , BV<< 8, RGB2YUV_SHIFT+8) -BGR2UV(uint32_t, rgb32ToUV, 0, 0,16, 0xFF000000, 0x00FF, 0xFF00, 0xFF0000, RU<< 8, GU , BU<< 8, RV<< 8, GV , BV<< 8, RGB2YUV_SHIFT+8) -BGR2UV(uint16_t, bgr16ToUV, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, RU<<11, GU<<5, BU , RV<<11, GV<<5, BV , RGB2YUV_SHIFT+8) -BGR2UV(uint16_t, bgr15ToUV, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, RU<<10, GU<<5, BU , RV<<10, GV<<5, BV , RGB2YUV_SHIFT+7) -BGR2UV(uint16_t, rgb16ToUV, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RU , GU<<5, BU<<11, RV , GV<<5, BV<<11, RGB2YUV_SHIFT+8) -BGR2UV(uint16_t, rgb15ToUV, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RU , GU<<5, BU<<10, RV , GV<<5, BV<<10, RGB2YUV_SHIFT+7) - #if HAVE_MMX static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, const uint8_t *src, long width, int srcFormat) { @@ -2084,52 +2016,6 @@ static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const ui } -static inline void RENAME(palToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *pal) -{ - int i; - for (i=0; i<width; i++) - { - int d= src[i]; - - dst[i]= pal[d] & 0xFF; - } -} - -static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - long width, uint32_t *pal) -{ - int i; - assert(src1 == src2); - for (i=0; i<width; i++) - { - int p= pal[src1[i]]; - - dstU[i]= p>>8; - dstV[i]= p>>16; - } -} - -static inline void RENAME(monowhite2Y)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) -{ - int i, j; - for (i=0; i<width/8; i++){ - int d= ~src[i]; - for(j=0; j<8; j++) - dst[8*i+j]= ((d>>(7-j))&1)*255; - } -} - -static inline void RENAME(monoblack2Y)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) -{ - int i, j; - for (i=0; i<width/8; i++){ - int d= src[i]; - for(j=0; j<8; j++) - dst[8*i+j]= ((d>>(7-j))&1)*255; - } -} - // bilinear / bicubic scaling static inline void RENAME(hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW, int xInc, const int16_t *filter, const int16_t *filterPos, long filterSize) @@ -2335,10 +2221,10 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, int srcFormat, uint8_t *formatConvBuffer, uint32_t *pal, int isAlpha) { - int32_t *mmx2FilterPos = c->lumMmx2FilterPos; - int16_t *mmx2Filter = c->lumMmx2Filter; - int canMMX2BeUsed = c->canMMX2BeUsed; - void *funnyYCode = c->funnyYCode; + int32_t av_unused *mmx2FilterPos = c->lumMmx2FilterPos; + int16_t av_unused *mmx2Filter = c->lumMmx2Filter; + int av_unused canMMX2BeUsed = c->canMMX2BeUsed; + void av_unused *funnyYCode = c->funnyYCode; void (*internal_func)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->hascale_internal : c->hyscale_internal; if (isAlpha) { @@ -2349,6 +2235,9 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, src += ALT32_CORR; } + if (srcFormat == PIX_FMT_RGB48LE) + src++; + if (internal_func) { internal_func(formatConvBuffer, src, srcW, pal); src= formatConvBuffer; @@ -2369,7 +2258,7 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, #if HAVE_MMX2 int i; #if defined(PIC) - uint64_t ebxsave __attribute__((aligned(8))); + DECLARE_ALIGNED(8, uint64_t, ebxsave); #endif if (canMMX2BeUsed) { @@ -2525,10 +2414,10 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, int srcFormat, uint8_t *formatConvBuffer, uint32_t *pal) { - int32_t *mmx2FilterPos = c->chrMmx2FilterPos; - int16_t *mmx2Filter = c->chrMmx2Filter; - int canMMX2BeUsed = c->canMMX2BeUsed; - void *funnyUVCode = c->funnyUVCode; + int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos; + int16_t av_unused *mmx2Filter = c->chrMmx2Filter; + int av_unused canMMX2BeUsed = c->canMMX2BeUsed; + void av_unused *funnyUVCode = c->funnyUVCode; if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE) return; @@ -2538,6 +2427,11 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, src2 += ALT32_CORR; } + if (srcFormat==PIX_FMT_RGB48LE) { + src1++; + src2++; + } + if (c->hcscale_internal) { c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); src1= formatConvBuffer; @@ -2560,7 +2454,7 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, #if HA |