Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: patched-ffmpeg-mt/libswscale/swscale.c

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: patched-ffmpeg-mt/libswscale/swscale.c
===================================================================
--- patched-ffmpeg-mt/libswscale/swscale.c (revision 41250)
+++ patched-ffmpeg-mt/libswscale/swscale.c (working copy)
@@ -27,7 +27,7 @@
{BGR,RGB}{1,4,8,15,16} support dithering
unscaled special converters (YV12=I420=IYUV, Y800=Y8)
- YV12 -> {BGR,RGB}{1,4,8,15,16,24,32}
+ YV12 -> {BGR,RGB}{1,4,8,12,15,16,24,32}
x -> x
YUV9 -> YV12
YUV9/YV12 -> Y800
@@ -90,10 +90,8 @@
(x)==PIX_FMT_PAL8 \
|| (x)==PIX_FMT_YUYV422 \
|| (x)==PIX_FMT_UYVY422 \
- || isRGB(x) \
- || isBGR(x) \
+ || isAnyRGB(x) \
)
-#define usePal(x) (av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL)
#define RGB2YUV_SHIFT 15
#define BY ( (int)(0.114*219/255*(1<<RGB2YUV_SHIFT)+0.5))
@@ -199,6 +197,13 @@
{ 0, 4, 0, 4, 0, 4, 0, 4, },
};
+DECLARE_ALIGNED(8, const uint8_t, dither_4x4_16)[4][8]={
+{ 8, 4, 11, 7, 8, 4, 11, 7, },
+{ 2, 14, 1, 13, 2, 14, 1, 13, },
+{ 10, 6, 9, 5, 10, 6, 9, 5, },
+{ 0, 12, 3, 15, 0, 12, 3, 15, },
+};
+
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, },
@@ -766,8 +771,10 @@
dest+=6;\
}\
break;\
- case PIX_FMT_RGB565:\
- case PIX_FMT_BGR565:\
+ case PIX_FMT_RGB565BE:\
+ case PIX_FMT_RGB565LE:\
+ case PIX_FMT_BGR565BE:\
+ case PIX_FMT_BGR565LE:\
{\
const int dr1= dither_2x2_8[y&1 ][0];\
const int dg1= dither_2x2_4[y&1 ][0];\
@@ -781,8 +788,10 @@
}\
}\
break;\
- case PIX_FMT_RGB555:\
- case PIX_FMT_BGR555:\
+ case PIX_FMT_RGB555BE:\
+ case PIX_FMT_RGB555LE:\
+ case PIX_FMT_BGR555BE:\
+ case PIX_FMT_BGR555LE:\
{\
const int dr1= dither_2x2_8[y&1 ][0];\
const int dg1= dither_2x2_8[y&1 ][1];\
@@ -1133,7 +1142,7 @@
#endif
#if ARCH_PPC
-#if HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT
+#if HAVE_ALTIVEC
#define COMPILE_ALTIVEC
#endif
#endif //ARCH_PPC
@@ -1236,7 +1245,7 @@
}
#else
-#if ARCH_PPC
+#if ARCH_PPC && COMPILE_ALTIVEC
if (flags & SWS_CPU_CAPS_ALTIVEC) {
sws_init_swScale_altivec(c);
return swScale_altivec;
@@ -1268,7 +1277,7 @@
#endif //!CONFIG_RUNTIME_CPUDETECT
}
-static int PlanarToNV12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1294,7 +1303,7 @@
return srcSliceH;
}
-static int PlanarToYuy2Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int planarToYuy2Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1304,7 +1313,7 @@
return srcSliceH;
}
-static int PlanarToUyvyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int planarToUyvyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1314,7 +1323,7 @@
return srcSliceH;
}
-static int YUV422PToYuy2Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1324,7 +1333,7 @@
return srcSliceH;
}
-static int YUV422PToUyvyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1334,7 +1343,7 @@
return srcSliceH;
}
-static int YUYV2YUV420Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1349,7 +1358,7 @@
return srcSliceH;
}
-static int YUYV2YUV422Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1361,7 +1370,7 @@
return srcSliceH;
}
-static int UYVY2YUV420Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1376,7 +1385,7 @@
return srcSliceH;
}
-static int UYVY2YUV422Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dstParam[], int dstStride[])
{
uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
@@ -1388,8 +1397,8 @@
return srcSliceH;
}
-static int pal2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dst[], int dstStride[])
+static int palToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[])
{
const enum PixelFormat srcFormat= c->srcFormat;
const enum PixelFormat dstFormat= c->dstFormat;
@@ -1424,9 +1433,16 @@
return srcSliceH;
}
+#define isRGBA32(x) ( \
+ (x) == PIX_FMT_ARGB \
+ || (x) == PIX_FMT_RGBA \
+ || (x) == PIX_FMT_BGRA \
+ || (x) == PIX_FMT_ABGR \
+ )
+
/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
-static int rgb2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dst[], int dstStride[])
+static int rgbToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[])
{
const enum PixelFormat srcFormat= c->srcFormat;
const enum PixelFormat dstFormat= c->dstFormat;
@@ -1436,9 +1452,25 @@
const int dstId= c->dstFormatBpp >> 2;
void (*conv)(const uint8_t *src, uint8_t *dst, long src_size)=NULL;
+#define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)
+
+ if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
+ if ( CONV_IS(ABGR, RGBA)
+ || CONV_IS(ARGB, BGRA)
+ || CONV_IS(BGRA, ARGB)
+ || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
+ else if (CONV_IS(ABGR, ARGB)
+ || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
+ else if (CONV_IS(ABGR, BGRA)
+ || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
+ else if (CONV_IS(BGRA, RGBA)
+ || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
+ else if (CONV_IS(BGRA, ABGR)
+ || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
+ } else
/* BGR -> BGR */
- if ( (isBGR(srcFormat) && isBGR(dstFormat))
- || (isRGB(srcFormat) && isRGB(dstFormat))) {
+ if ( (isBGRinInt(srcFormat) && isBGRinInt(dstFormat))
+ || (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
switch(srcId | (dstId<<4)) {
case 0x34: conv= rgb16to15; break;
case 0x36: conv= rgb24to15; break;
@@ -1453,8 +1485,8 @@
case 0x84: conv= rgb16to32; break;
case 0x86: conv= rgb24to32; break;
}
- } else if ( (isBGR(srcFormat) && isRGB(dstFormat))
- || (isRGB(srcFormat) && isBGR(dstFormat))) {
+ } else if ( (isBGRinInt(srcFormat) && isRGBinInt(dstFormat))
+ || (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
switch(srcId | (dstId<<4)) {
case 0x33: conv= rgb15tobgr15; break;
case 0x34: conv= rgb16tobgr15; break;
@@ -1471,7 +1503,6 @@
case 0x83: conv= rgb15tobgr32; break;
case 0x84: conv= rgb16tobgr32; break;
case 0x86: conv= rgb24tobgr32; break;
- case 0x88: conv= rgb32tobgr32; break;
}
}
@@ -1480,14 +1511,18 @@
sws_format_name(srcFormat), sws_format_name(dstFormat));
} else {
const uint8_t *srcPtr= src[0];
- if(srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
+ uint8_t *dstPtr= dst[0];
+ if ((srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) && !isRGBA32(dstFormat))
srcPtr += ALT32_CORR;
+ if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) && !isRGBA32(srcFormat))
+ dstPtr += ALT32_CORR;
+
if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0)
- conv(srcPtr, dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
+ conv(srcPtr, dstPtr + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
else {
int i;
- uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
+ dstPtr += dstStride[0]*srcSliceY;
for (i=0; i<srcSliceH; i++) {
conv(srcPtr, dstPtr, c->srcW*srcBpp);
@@ -1499,7 +1534,7 @@
return srcSliceH;
}
-static int bgr24toyv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
rgb24toyv12(
@@ -1514,7 +1549,7 @@
return srcSliceH;
}
-static int yvu9toyv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[])
{
int i;
@@ -1550,8 +1585,8 @@
}
/* unscaled copy like stuff (assumes nearly identical formats) */
-static int packedCopy(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dst[], int dstStride[])
+static int packedCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[])
{
if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
memcpy(dst[0] + dstStride[0]*srcSliceY, src[0], srcSliceH*dstStride[0]);
@@ -1575,8 +1610,8 @@
return srcSliceH;
}
-static int planarCopy(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dst[], int dstStride[])
+static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[])
{
int plane, i, j;
for (plane=0; plane<4; plane++) {
@@ -1660,31 +1695,31 @@
const int dstH = c->dstH;
int needsDither;
- needsDither= (isBGR(dstFormat) || isRGB(dstFormat))
+ needsDither= isAnyRGB(dstFormat)
&& c->dstFormatBpp < 24
- && (c->dstFormatBpp < c->srcFormatBpp || (!(isRGB(srcFormat) || isBGR(srcFormat))));
+ && (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
/* yv12_to_nv12 */
if ((srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) && (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)) {
- c->swScale= PlanarToNV12Wrapper;
+ c->swScale= planarToNv12Wrapper;
}
/* yuv2bgr */
- if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && (isBGR(dstFormat) || isRGB(dstFormat))
+ if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && isAnyRGB(dstFormat)
&& !(flags & SWS_ACCURATE_RND) && !(dstH&1)) {
c->swScale= ff_yuv2rgb_get_func_ptr(c);
}
if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT)) {
- c->swScale= yvu9toyv12Wrapper;
+ c->swScale= yvu9ToYv12Wrapper;
}
/* bgr24toYV12 */
if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND))
- c->swScale= bgr24toyv12Wrapper;
+ c->swScale= bgr24ToYv12Wrapper;
/* RGB/BGR -> RGB/BGR (no dither needed forms) */
- if ( (isBGR(srcFormat) || isRGB(srcFormat))
- && (isBGR(dstFormat) || isRGB(dstFormat))
+ if ( isAnyRGB(srcFormat)
+ && isAnyRGB(dstFormat)
&& srcFormat != PIX_FMT_BGR8 && dstFormat != PIX_FMT_BGR8
&& srcFormat != PIX_FMT_RGB8 && dstFormat != PIX_FMT_RGB8
&& srcFormat != PIX_FMT_BGR4 && dstFormat != PIX_FMT_BGR4
@@ -1693,12 +1728,10 @@
&& srcFormat != PIX_FMT_RGB4_BYTE && dstFormat != PIX_FMT_RGB4_BYTE
&& srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK
&& 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;
+ c->swScale= rgbToRgbWrapper;
if ((usePal(srcFormat) && (
dstFormat == PIX_FMT_RGB32 ||
@@ -1707,13 +1740,13 @@
dstFormat == PIX_FMT_BGR32 ||
dstFormat == PIX_FMT_BGR32_1 ||
dstFormat == PIX_FMT_BGR24)))
- c->swScale= pal2rgbWrapper;
+ c->swScale= palToRgbWrapper;
if (srcFormat == PIX_FMT_YUV422P) {
if (dstFormat == PIX_FMT_YUYV422)
- c->swScale= YUV422PToYuy2Wrapper;
+ c->swScale= yuv422pToYuy2Wrapper;
else if (dstFormat == PIX_FMT_UYVY422)
- c->swScale= YUV422PToUyvyWrapper;
+ c->swScale= yuv422pToUyvyWrapper;
}
/* LQ converters if -sws 0 or -sws 4*/
@@ -1721,19 +1754,19 @@
/* yv12_to_yuy2 */
if (srcFormat == PIX_FMT_YUV420P || srcFormat == PIX_FMT_YUVA420P) {
if (dstFormat == PIX_FMT_YUYV422)
- c->swScale= PlanarToYuy2Wrapper;
+ c->swScale= planarToYuy2Wrapper;
else if (dstFormat == PIX_FMT_UYVY422)
- c->swScale= PlanarToUyvyWrapper;
+ c->swScale= planarToUyvyWrapper;
}
}
if(srcFormat == PIX_FMT_YUYV422 && (dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
- c->swScale= YUYV2YUV420Wrapper;
+ c->swScale= yuyvToYuv420Wrapper;
if(srcFormat == PIX_FMT_UYVY422 && (dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
- c->swScale= UYVY2YUV420Wrapper;
+ c->swScale= uyvyToYuv420Wrapper;
if(srcFormat == PIX_FMT_YUYV422 && dstFormat == PIX_FMT_YUV422P)
- c->swScale= YUYV2YUV422Wrapper;
+ c->swScale= yuyvToYuv422Wrapper;
if(srcFormat == PIX_FMT_UYVY422 && dstFormat == PIX_FMT_YUV422P)
- c->swScale= UYVY2YUV422Wrapper;
+ c->swScale= uyvyToYuv422Wrapper;
#ifdef COMPILE_ALTIVEC
if ((c->flags & SWS_CPU_CAPS_ALTIVEC) &&
@@ -1761,9 +1794,9 @@
&& srcFormat != PIX_FMT_NV12 && srcFormat != PIX_FMT_NV21))
{
if (isPacked(c->srcFormat))
- c->swScale= packedCopy;
+ c->swScale= packedCopyWrapper;
else /* Planar YUV or gray */
- c->swScale= planarCopy;
+ c->swScale= planarCopyWrapper;
}
#if ARCH_BFIN
if (flags & SWS_CPU_CAPS_BFIN)
@@ -1826,6 +1859,8 @@
r= (i>>3 )*255;
g= ((i>>1)&3)*85;
b= (i&1 )*255;
+ } else if(c->srcFormat == PIX_FMT_GRAY8) {
+ r = g = b = i;
} else {
assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
b= (i>>3 )*255;

Powered by Google App Engine
This is Rietveld 408576698