Originally committed as revision 4468 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Michael Niedermayer authored on 2002/02/02 04:25:09... | ... |
@@ -17,7 +17,7 @@ |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
/* |
20 |
- supported Input formats: YV12, I420, IYUV (grayscale soon too) |
|
20 |
+ supported Input formats: YV12, I420, IYUV, YUY2, BGR32, BGR24 (grayscale soon too) |
|
21 | 21 |
supported output formats: YV12, I420, IYUV, BGR15, BGR16, BGR24, BGR32 (grayscale soon too) |
22 | 22 |
BGR15/16 support dithering |
23 | 23 |
*/ |
... | ... |
@@ -43,7 +43,7 @@ |
43 | 43 |
//#undef ARCH_X86 |
44 | 44 |
#define DITHER1XBPP |
45 | 45 |
|
46 |
-#define RET 0xC3 //near return opcode |
|
46 |
+#define RET 0xC3 //near return opcode for X86 |
|
47 | 47 |
|
48 | 48 |
#ifdef MP_DEBUG |
49 | 49 |
#define ASSERT(x) if(!(x)) { printf("ASSERT " #x " failed\n"); *((int*)0)=0; } |
... | ... |
@@ -58,10 +58,22 @@ |
58 | 58 |
#endif |
59 | 59 |
|
60 | 60 |
//FIXME replace this with something faster |
61 |
-#define isYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_IYUV) |
|
62 | 61 |
#define isPlanarYUV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_IYUV) |
62 |
+#define isYUV(x) ((x)==IMGFMT_YUY2 || isPlanarYUV(x)) |
|
63 | 63 |
#define isHalfChrV(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_IYUV) |
64 |
-#define isHalfChrH(x) ((x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_IYUV) |
|
64 |
+#define isHalfChrH(x) ((x)==IMGFMT_YUY2 || (x)==IMGFMT_YV12 || (x)==IMGFMT_I420 || (x)==IMGFMT_IYUV) |
|
65 |
+#define isPacked(x) ((x)==IMGFMT_YUY2 || (x)==IMGFMT_BGR32|| (x)==IMGFMT_BGR24) |
|
66 |
+ |
|
67 |
+#define RGB2YUV_SHIFT 8 |
|
68 |
+#define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5)) |
|
69 |
+#define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5)) |
|
70 |
+#define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) |
|
71 |
+#define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5)) |
|
72 |
+#define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5)) |
|
73 |
+#define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5)) |
|
74 |
+#define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) |
|
75 |
+#define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) |
|
76 |
+#define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) |
|
65 | 77 |
|
66 | 78 |
extern int verbose; // defined in mplayer.c |
67 | 79 |
/* |
... | ... |
@@ -80,7 +92,7 @@ Optimize C code (yv12 / minmax) |
80 | 80 |
add support for packed pixel yuv input & output |
81 | 81 |
add support for Y8 input & output |
82 | 82 |
add BGR4 output support |
83 |
-add BGR32 / BGR24 input support |
|
83 |
+write special BGR->BGR scaler |
|
84 | 84 |
*/ |
85 | 85 |
|
86 | 86 |
#define ABS(a) ((a) > 0 ? (a) : (-(a))) |
... | ... |
@@ -1105,7 +1117,8 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
1105 | 1105 |
/* sanity check */ |
1106 | 1106 |
if(srcW<4 || srcH<1 || dstW<8 || dstH<1) return NULL; //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code |
1107 | 1107 |
|
1108 |
- if(srcFormat!=IMGFMT_YV12 && srcFormat!=IMGFMT_I420 && srcFormat!=IMGFMT_IYUV) return NULL; |
|
1108 |
+// if(!isSupportedIn(srcFormat)) return NULL; |
|
1109 |
+// if(!isSupportedOut(dstFormat)) return NULL; |
|
1109 | 1110 |
|
1110 | 1111 |
if(!dstFilter) dstFilter= &dummyFilter; |
1111 | 1112 |
if(!srcFilter) srcFilter= &dummyFilter; |
... | ... |
@@ -1135,6 +1148,30 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
1135 | 1135 |
else |
1136 | 1136 |
c->canMMX2BeUsed=0; |
1137 | 1137 |
|
1138 |
+ |
|
1139 |
+ /* dont use full vertical UV input/internaly if the source doesnt even have it */ |
|
1140 |
+ if(isHalfChrV(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_V); |
|
1141 |
+ /* dont use full horizontal UV input if the source doesnt even have it */ |
|
1142 |
+ if(isHalfChrH(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INP); |
|
1143 |
+ /* dont use full horizontal UV internally if the destination doesnt even have it */ |
|
1144 |
+ if(isHalfChrH(dstFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INT); |
|
1145 |
+ |
|
1146 |
+ if(flags&SWS_FULL_CHR_H_INP) c->chrSrcW= srcW; |
|
1147 |
+ else c->chrSrcW= (srcW+1)>>1; |
|
1148 |
+ |
|
1149 |
+ if(flags&SWS_FULL_CHR_H_INT) c->chrDstW= dstW; |
|
1150 |
+ else c->chrDstW= (dstW+1)>>1; |
|
1151 |
+ |
|
1152 |
+ if(flags&SWS_FULL_CHR_V) c->chrSrcH= srcH; |
|
1153 |
+ else c->chrSrcH= (srcH+1)>>1; |
|
1154 |
+ |
|
1155 |
+ if(isHalfChrV(dstFormat)) c->chrDstH= (dstH+1)>>1; |
|
1156 |
+ else c->chrDstH= dstH; |
|
1157 |
+ |
|
1158 |
+ c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW; |
|
1159 |
+ c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH; |
|
1160 |
+ |
|
1161 |
+ |
|
1138 | 1162 |
// match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst |
1139 | 1163 |
// but only for the FAST_BILINEAR mode otherwise do correct scaling |
1140 | 1164 |
// n-2 is the last chrominance sample available |
... | ... |
@@ -1143,22 +1180,19 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
1143 | 1143 |
// first and last pixel |
1144 | 1144 |
if(flags&SWS_FAST_BILINEAR) |
1145 | 1145 |
{ |
1146 |
- if(c->canMMX2BeUsed) c->lumXInc+= 20; |
|
1146 |
+ if(c->canMMX2BeUsed) |
|
1147 |
+ { |
|
1148 |
+ c->lumXInc+= 20; |
|
1149 |
+ c->chrXInc+= 20; |
|
1150 |
+ } |
|
1147 | 1151 |
//we dont use the x86asm scaler if mmx is available |
1148 |
- else if(cpuCaps.hasMMX) c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; |
|
1152 |
+ else if(cpuCaps.hasMMX) |
|
1153 |
+ { |
|
1154 |
+ c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; |
|
1155 |
+ c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20; |
|
1156 |
+ } |
|
1149 | 1157 |
} |
1150 | 1158 |
|
1151 |
- /* set chrXInc & chrDstW */ |
|
1152 |
- if((flags&SWS_FULL_UV_IPOL) && !isHalfChrH(dstFormat)) |
|
1153 |
- c->chrXInc= c->lumXInc>>1, c->chrDstW= dstW; |
|
1154 |
- else |
|
1155 |
- c->chrXInc= c->lumXInc, c->chrDstW= (dstW+1)>>1; |
|
1156 |
- |
|
1157 |
- /* set chrYInc & chrDstH */ |
|
1158 |
- if(isHalfChrV(dstFormat)) |
|
1159 |
- c->chrYInc= c->lumYInc, c->chrDstH= (dstH+1)>>1; |
|
1160 |
- else c->chrYInc= c->lumYInc>>1, c->chrDstH= dstH; |
|
1161 |
- |
|
1162 | 1159 |
/* precalculate horizontal scaler filter coefficients */ |
1163 | 1160 |
{ |
1164 | 1161 |
const int filterAlign= cpuCaps.hasMMX ? 4 : 1; |
... | ... |
@@ -1246,6 +1280,8 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
1246 | 1246 |
fprintf(stderr, "\nSwScaler: BILINEAR scaler "); |
1247 | 1247 |
else if(flags&SWS_BICUBIC) |
1248 | 1248 |
fprintf(stderr, "\nSwScaler: BICUBIC scaler "); |
1249 |
+ else if(flags&SWS_X) |
|
1250 |
+ fprintf(stderr, "\nSwScaler: Experimental scaler "); |
|
1249 | 1251 |
else if(flags&SWS_POINT) |
1250 | 1252 |
fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler "); |
1251 | 1253 |
else if(flags&SWS_AREA) |
... | ... |
@@ -1344,7 +1380,14 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
1344 | 1344 |
|
1345 | 1345 |
printf("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); |
1346 | 1346 |
} |
1347 |
- |
|
1347 |
+ if((flags & SWS_PRINT_INFO) && verbose>1) |
|
1348 |
+ { |
|
1349 |
+ printf("SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
|
1350 |
+ c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc); |
|
1351 |
+ printf("SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
|
1352 |
+ c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc); |
|
1353 |
+ } |
|
1354 |
+ |
|
1348 | 1355 |
return c; |
1349 | 1356 |
} |
1350 | 1357 |
|
... | ... |
@@ -23,7 +23,15 @@ |
23 | 23 |
#define SWS_X 8 |
24 | 24 |
#define SWS_POINT 0x10 |
25 | 25 |
#define SWS_AREA 0x20 |
26 |
-#define SWS_FULL_UV_IPOL 0x100 |
|
26 |
+ |
|
27 |
+//the following 4 flags are not completly implemented |
|
28 |
+//internal chrominace subsamling info |
|
29 |
+#define SWS_FULL_CHR_V 0x100 |
|
30 |
+#define SWS_FULL_CHR_H_INT 0x200 |
|
31 |
+//input subsampling info |
|
32 |
+#define SWS_FULL_CHR_H_INP 0x400 |
|
33 |
+#define SWS_DIRECT_BGR 0x800 |
|
34 |
+ |
|
27 | 35 |
#define SWS_PRINT_INFO 0x1000 |
28 | 36 |
|
29 | 37 |
#define SWS_MAX_REDUCE_CUTOFF 0.002 |
... | ... |
@@ -31,7 +39,7 @@ |
31 | 31 |
/* this struct should be aligned on at least 32-byte boundary */ |
32 | 32 |
typedef struct{ |
33 | 33 |
int srcW, srcH, dstW, dstH; |
34 |
- int chrDstW, chrDstH; |
|
34 |
+ int chrSrcW, chrSrcH, chrDstW, chrDstH; |
|
35 | 35 |
int lumXInc, chrXInc; |
36 | 36 |
int lumYInc, chrYInc; |
37 | 37 |
int dstFormat, srcFormat; |
... | ... |
@@ -50,6 +58,7 @@ typedef struct{ |
50 | 50 |
// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx |
51 | 51 |
int16_t *lumMmxFilter; |
52 | 52 |
int16_t *chrMmxFilter; |
53 |
+ uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull |
|
53 | 54 |
|
54 | 55 |
int hLumFilterSize; |
55 | 56 |
int hChrFilterSize; |
... | ... |
@@ -841,7 +841,7 @@ static inline void RENAME(yuv2rgb2)(uint16_t *buf0, uint16_t *buf1, uint16_t *uv |
841 | 841 |
int yalpha1=yalpha^4095; |
842 | 842 |
int uvalpha1=uvalpha^4095; |
843 | 843 |
|
844 |
- if(flags&SWS_FULL_UV_IPOL) |
|
844 |
+ if(flags&SWS_FULL_CHR_H_INT) |
|
845 | 845 |
{ |
846 | 846 |
|
847 | 847 |
#ifdef HAVE_MMX |
... | ... |
@@ -1267,7 +1267,7 @@ static inline void RENAME(yuv2rgb1)(uint16_t *buf0, uint16_t *uvbuf0, uint16_t * |
1267 | 1267 |
int uvalpha1=uvalpha^4095; |
1268 | 1268 |
const int yalpha1=0; |
1269 | 1269 |
|
1270 |
- if(flags&SWS_FULL_UV_IPOL) |
|
1270 |
+ if(flags&SWS_FULL_CHR_H_INT) |
|
1271 | 1271 |
{ |
1272 | 1272 |
RENAME(yuv2rgb2)(buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, dstFormat, flags); |
1273 | 1273 |
return; |
... | ... |
@@ -1535,6 +1535,96 @@ static inline void RENAME(yuv2rgb1)(uint16_t *buf0, uint16_t *uvbuf0, uint16_t * |
1535 | 1535 |
#endif |
1536 | 1536 |
} |
1537 | 1537 |
|
1538 |
+static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, int width) |
|
1539 |
+{ |
|
1540 |
+#ifdef HAVE_MMXFIXME |
|
1541 |
+#else |
|
1542 |
+ int i; |
|
1543 |
+ for(i=0; i<width; i++) |
|
1544 |
+ dst[i]= src[2*i]; |
|
1545 |
+#endif |
|
1546 |
+} |
|
1547 |
+ |
|
1548 |
+static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
|
1549 |
+{ |
|
1550 |
+#ifdef HAVE_MMXFIXME |
|
1551 |
+#else |
|
1552 |
+ int i; |
|
1553 |
+ for(i=0; i<width; i++) |
|
1554 |
+ { |
|
1555 |
+ dstU[i]= (src1[4*i + 1] + src2[4*i + 1])>>1; |
|
1556 |
+ dstV[i]= (src1[4*i + 3] + src2[4*i + 3])>>1; |
|
1557 |
+ } |
|
1558 |
+#endif |
|
1559 |
+} |
|
1560 |
+ |
|
1561 |
+static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width) |
|
1562 |
+{ |
|
1563 |
+#ifdef HAVE_MMXFIXME |
|
1564 |
+#else |
|
1565 |
+ int i; |
|
1566 |
+ for(i=0; i<width; i++) |
|
1567 |
+ { |
|
1568 |
+ int b= src[i*4+0]; |
|
1569 |
+ int g= src[i*4+1]; |
|
1570 |
+ int r= src[i*4+2]; |
|
1571 |
+ |
|
1572 |
+ dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
|
1573 |
+ } |
|
1574 |
+#endif |
|
1575 |
+} |
|
1576 |
+ |
|
1577 |
+static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
|
1578 |
+{ |
|
1579 |
+#ifdef HAVE_MMXFIXME |
|
1580 |
+#else |
|
1581 |
+ int i; |
|
1582 |
+ for(i=0; i<width; i++) |
|
1583 |
+ { |
|
1584 |
+ int b= src1[8*i + 0] + src1[8*i + 4] + src2[8*i + 0] + src2[8*i + 4]; |
|
1585 |
+ int g= src1[8*i + 1] + src1[8*i + 5] + src2[8*i + 1] + src2[8*i + 5]; |
|
1586 |
+ int r= src1[8*i + 2] + src1[8*i + 6] + src2[8*i + 2] + src2[8*i + 6]; |
|
1587 |
+ |
|
1588 |
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; |
|
1589 |
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; |
|
1590 |
+ } |
|
1591 |
+#endif |
|
1592 |
+} |
|
1593 |
+ |
|
1594 |
+static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, int width) |
|
1595 |
+{ |
|
1596 |
+#ifdef HAVE_MMXFIXME |
|
1597 |
+#else |
|
1598 |
+ int i; |
|
1599 |
+ for(i=0; i<width; i++) |
|
1600 |
+ { |
|
1601 |
+ int b= src[i*3+0]; |
|
1602 |
+ int g= src[i*3+1]; |
|
1603 |
+ int r= src[i*3+2]; |
|
1604 |
+ |
|
1605 |
+ dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
|
1606 |
+ } |
|
1607 |
+#endif |
|
1608 |
+} |
|
1609 |
+ |
|
1610 |
+static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) |
|
1611 |
+{ |
|
1612 |
+#ifdef HAVE_MMXFIXME |
|
1613 |
+#else |
|
1614 |
+ int i; |
|
1615 |
+ for(i=0; i<width; i++) |
|
1616 |
+ { |
|
1617 |
+ int b= src1[6*i + 0] + src1[6*i + 3] + src2[6*i + 0] + src2[6*i + 3]; |
|
1618 |
+ int g= src1[6*i + 1] + src1[6*i + 4] + src2[6*i + 1] + src2[6*i + 4]; |
|
1619 |
+ int r= src1[6*i + 2] + src1[6*i + 5] + src2[6*i + 2] + src2[6*i + 5]; |
|
1620 |
+ |
|
1621 |
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+2)) + 128; |
|
1622 |
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+2)) + 128; |
|
1623 |
+ } |
|
1624 |
+#endif |
|
1625 |
+} |
|
1626 |
+ |
|
1627 |
+ |
|
1538 | 1628 |
// Bilinear / Bicubic scaling |
1539 | 1629 |
static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, |
1540 | 1630 |
int16_t *filter, int16_t *filterPos, int filterSize) |
... | ... |
@@ -1699,8 +1789,25 @@ static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW |
1699 | 1699 |
// *** horizontal scale Y line to temp buffer |
1700 | 1700 |
static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc, |
1701 | 1701 |
int flags, int canMMX2BeUsed, int16_t *hLumFilter, |
1702 |
- int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode) |
|
1702 |
+ int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, |
|
1703 |
+ int srcFormat, uint8_t *formatConvBuffer) |
|
1703 | 1704 |
{ |
1705 |
+ if(srcFormat==IMGFMT_YUY2) |
|
1706 |
+ { |
|
1707 |
+ RENAME(yuy2ToY)(formatConvBuffer, src, srcW); |
|
1708 |
+ src= formatConvBuffer; |
|
1709 |
+ } |
|
1710 |
+ else if(srcFormat==IMGFMT_BGR32) |
|
1711 |
+ { |
|
1712 |
+ RENAME(bgr32ToY)(formatConvBuffer, src, srcW); |
|
1713 |
+ src= formatConvBuffer; |
|
1714 |
+ } |
|
1715 |
+ else if(srcFormat==IMGFMT_BGR24) |
|
1716 |
+ { |
|
1717 |
+ RENAME(bgr24ToY)(formatConvBuffer, src, srcW); |
|
1718 |
+ src= formatConvBuffer; |
|
1719 |
+ } |
|
1720 |
+ |
|
1704 | 1721 |
#ifdef HAVE_MMX |
1705 | 1722 |
// use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) |
1706 | 1723 |
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
... | ... |
@@ -1826,8 +1933,28 @@ FUNNY_Y_CODE |
1826 | 1826 |
|
1827 | 1827 |
inline static void RENAME(hcscale)(uint16_t *dst, int dstWidth, uint8_t *src1, uint8_t *src2, |
1828 | 1828 |
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter, |
1829 |
- int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode) |
|
1829 |
+ int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode, |
|
1830 |
+ int srcFormat, uint8_t *formatConvBuffer) |
|
1830 | 1831 |
{ |
1832 |
+ if(srcFormat==IMGFMT_YUY2) |
|
1833 |
+ { |
|
1834 |
+ RENAME(yuy2ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); |
|
1835 |
+ src1= formatConvBuffer; |
|
1836 |
+ src2= formatConvBuffer+2048; |
|
1837 |
+ } |
|
1838 |
+ else if(srcFormat==IMGFMT_BGR32) |
|
1839 |
+ { |
|
1840 |
+ RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); |
|
1841 |
+ src1= formatConvBuffer; |
|
1842 |
+ src2= formatConvBuffer+2048; |
|
1843 |
+ } |
|
1844 |
+ else if(srcFormat==IMGFMT_BGR24) |
|
1845 |
+ { |
|
1846 |
+ RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW); |
|
1847 |
+ src1= formatConvBuffer; |
|
1848 |
+ src2= formatConvBuffer+2048; |
|
1849 |
+ } |
|
1850 |
+ |
|
1831 | 1851 |
#ifdef HAVE_MMX |
1832 | 1852 |
// use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one) |
1833 | 1853 |
if(!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
... | ... |
@@ -1974,7 +2101,7 @@ FUNNYUVCODE |
1974 | 1974 |
} |
1975 | 1975 |
} |
1976 | 1976 |
|
1977 |
-static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], int srcSliceY, |
|
1977 |
+static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStrideParam[], int srcSliceY, |
|
1978 | 1978 |
int srcSliceH, uint8_t* dstParam[], int dstStride[]){ |
1979 | 1979 |
|
1980 | 1980 |
/* load a few things into local vars to make the code more readable? and faster */ |
... | ... |
@@ -2007,6 +2134,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2007 | 2007 |
const int vChrBufSize= c->vChrBufSize; |
2008 | 2008 |
uint8_t *funnyYCode= c->funnyYCode; |
2009 | 2009 |
uint8_t *funnyUVCode= c->funnyUVCode; |
2010 |
+ uint8_t *formatConvBuffer= c->formatConvBuffer; |
|
2010 | 2011 |
|
2011 | 2012 |
/* vars whch will change and which we need to storw back in the context */ |
2012 | 2013 |
int dstY= c->dstY; |
... | ... |
@@ -2014,6 +2142,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2014 | 2014 |
int chrBufIndex= c->chrBufIndex; |
2015 | 2015 |
int lastInLumBuf= c->lastInLumBuf; |
2016 | 2016 |
int lastInChrBuf= c->lastInChrBuf; |
2017 |
+ int srcStride[3]; |
|
2017 | 2018 |
uint8_t *src[3]; |
2018 | 2019 |
uint8_t *dst[3]; |
2019 | 2020 |
|
... | ... |
@@ -2021,11 +2150,33 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2021 | 2021 |
src[0]= srcParam[0]; |
2022 | 2022 |
src[1]= srcParam[2]; |
2023 | 2023 |
src[2]= srcParam[1]; |
2024 |
- |
|
2025 |
- }else{ |
|
2024 |
+ srcStride[0]= srcStrideParam[0]; |
|
2025 |
+ srcStride[1]= srcStrideParam[2]; |
|
2026 |
+ srcStride[2]= srcStrideParam[1]; |
|
2027 |
+ } |
|
2028 |
+ else if(c->srcFormat==IMGFMT_YV12){ |
|
2026 | 2029 |
src[0]= srcParam[0]; |
2027 | 2030 |
src[1]= srcParam[1]; |
2028 | 2031 |
src[2]= srcParam[2]; |
2032 |
+ srcStride[0]= srcStrideParam[0]; |
|
2033 |
+ srcStride[1]= srcStrideParam[1]; |
|
2034 |
+ srcStride[2]= srcStrideParam[2]; |
|
2035 |
+ } |
|
2036 |
+ else if(isPacked(c->srcFormat)){ |
|
2037 |
+ src[0]= |
|
2038 |
+ src[1]= |
|
2039 |
+ src[2]= srcParam[0]; |
|
2040 |
+ srcStride[0]= srcStrideParam[0]; |
|
2041 |
+ srcStride[1]= |
|
2042 |
+ srcStride[2]= srcStrideParam[0]<<1; |
|
2043 |
+ } |
|
2044 |
+ else if(c->srcFormat==IMGFMT_Y8){ |
|
2045 |
+ src[0]= srcParam[0]; |
|
2046 |
+ src[1]= |
|
2047 |
+ src[2]= NULL; |
|
2048 |
+ srcStride[0]= srcStrideParam[0]; |
|
2049 |
+ srcStride[1]= |
|
2050 |
+ srcStride[2]= 0; |
|
2029 | 2051 |
} |
2030 | 2052 |
|
2031 | 2053 |
if((c->dstFormat == IMGFMT_IYUV) || (c->dstFormat == IMGFMT_I420)){ |
... | ... |
@@ -2038,6 +2189,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2038 | 2038 |
dst[1]= dstParam[1]; |
2039 | 2039 |
dst[2]= dstParam[2]; |
2040 | 2040 |
} |
2041 |
+ |
|
2041 | 2042 |
|
2042 | 2043 |
if(dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0) |
2043 | 2044 |
{ |
... | ... |
@@ -2050,10 +2202,12 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2050 | 2050 |
} |
2051 | 2051 |
} |
2052 | 2052 |
|
2053 |
+ /* Note the user might start scaling the picture in the middle so this will not get executed |
|
2054 |
+ this is not really intended but works currently, so ppl might do it */ |
|
2053 | 2055 |
if(srcSliceY ==0){ |
2054 | 2056 |
lumBufIndex=0; |
2055 | 2057 |
chrBufIndex=0; |
2056 |
- dstY=0; |
|
2058 |
+ dstY=0; |
|
2057 | 2059 |
lastInLumBuf= -1; |
2058 | 2060 |
lastInChrBuf= -1; |
2059 | 2061 |
} |
... | ... |
@@ -2091,7 +2245,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2091 | 2091 |
// printf("%d %d\n", lumBufIndex, vLumBufSize); |
2092 | 2092 |
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
2093 | 2093 |
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
2094 |
- funnyYCode); |
|
2094 |
+ funnyYCode, c->srcFormat, formatConvBuffer); |
|
2095 | 2095 |
lastInLumBuf++; |
2096 | 2096 |
} |
2097 | 2097 |
while(lastInChrBuf < lastChrSrcY) |
... | ... |
@@ -2105,7 +2259,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2105 | 2105 |
//FIXME replace parameters through context struct (some at least) |
2106 | 2106 |
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, |
2107 | 2107 |
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
2108 |
- funnyUVCode); |
|
2108 |
+ funnyUVCode, c->srcFormat, formatConvBuffer); |
|
2109 | 2109 |
lastInChrBuf++; |
2110 | 2110 |
} |
2111 | 2111 |
//wrap buf index around to stay inside the ring buffer |
... | ... |
@@ -2129,7 +2283,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2129 | 2129 |
ASSERT(lastInLumBuf + 1 - srcSliceY >= 0) |
2130 | 2130 |
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc, |
2131 | 2131 |
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize, |
2132 |
- funnyYCode); |
|
2132 |
+ funnyYCode, c->srcFormat, formatConvBuffer); |
|
2133 | 2133 |
lastInLumBuf++; |
2134 | 2134 |
} |
2135 | 2135 |
while(lastInChrBuf+1 < ((srcSliceY + srcSliceH)>>1)) |
... | ... |
@@ -2142,7 +2296,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStride[], |
2142 | 2142 |
ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0) |
2143 | 2143 |
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, |
2144 | 2144 |
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, |
2145 |
- funnyUVCode); |
|
2145 |
+ funnyUVCode, c->srcFormat, formatConvBuffer); |
|
2146 | 2146 |
lastInChrBuf++; |
2147 | 2147 |
} |
2148 | 2148 |
//wrap buf index around to stay inside the ring buffer |