Commit 21e54c72 authored by michael's avatar michael

yvu9 support (other planar yuv formats with other chroma subsamplings should be trivial to add, if they had a IMGFMT)
disabled broken (=new) converters (they cause random sig11)
various bugfixes


git-svn-id: file:///var/local/repositories/mplayer/trunk/postproc@6533 b3059339-0415-0410-9bf9-f77b7e298cf2
parent 49b05166
This diff is collapsed.
...@@ -655,7 +655,7 @@ ...@@ -655,7 +655,7 @@
static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW,
int16_t * lumMmxFilter, int16_t * chrMmxFilter) int16_t * lumMmxFilter, int16_t * chrMmxFilter)
{ {
#ifdef HAVE_MMX #ifdef HAVE_MMX
...@@ -664,14 +664,14 @@ static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lu ...@@ -664,14 +664,14 @@ static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lu
asm volatile( asm volatile(
YSCALEYUV2YV12X(0) YSCALEYUV2YV12X(0)
:: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize), :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize),
"r" (chrMmxFilter+chrFilterSize*4), "r" (uDest), "m" (dstW>>1) "r" (chrMmxFilter+chrFilterSize*4), "r" (uDest), "m" (chrDstW)
: "%eax", "%edx", "%esi" : "%eax", "%edx", "%esi"
); );
asm volatile( asm volatile(
YSCALEYUV2YV12X(4096) YSCALEYUV2YV12X(4096)
:: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize), :: "m" (-chrFilterSize), "r" (chrSrc+chrFilterSize),
"r" (chrMmxFilter+chrFilterSize*4), "r" (vDest), "m" (dstW>>1) "r" (chrMmxFilter+chrFilterSize*4), "r" (vDest), "m" (chrDstW)
: "%eax", "%edx", "%esi" : "%eax", "%edx", "%esi"
); );
} }
...@@ -683,29 +683,29 @@ static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lu ...@@ -683,29 +683,29 @@ static inline void RENAME(yuv2yuvX)(int16_t *lumFilter, int16_t **lumSrc, int lu
: "%eax", "%edx", "%esi" : "%eax", "%edx", "%esi"
); );
#else #else
yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, yuv2yuvXinC(c, lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize, chrFilter, chrSrc, chrFilterSize,
dest, uDest, vDest, dstW); dest, uDest, vDest);
#endif #endif
} }
static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW) uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{ {
#ifdef HAVE_MMX #ifdef HAVE_MMX
if(uDest != NULL) if(uDest != NULL)
{ {
asm volatile( asm volatile(
YSCALEYUV2YV121 YSCALEYUV2YV121
:: "r" (chrSrc + (dstW>>1)), "r" (uDest + (dstW>>1)), :: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
"g" (-(dstW>>1)) "g" (-chrDstW)
: "%eax" : "%eax"
); );
asm volatile( asm volatile(
YSCALEYUV2YV121 YSCALEYUV2YV121
:: "r" (chrSrc + 2048 + (dstW>>1)), "r" (vDest + (dstW>>1)), :: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
"g" (-(dstW>>1)) "g" (-chrDstW)
: "%eax" : "%eax"
); );
} }
...@@ -731,7 +731,7 @@ static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc, ...@@ -731,7 +731,7 @@ static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
} }
if(uDest != NULL) if(uDest != NULL)
for(i=0; i<(dstW>>1); i++) for(i=0; i<chrDstW; i++)
{ {
int u=chrSrc[i]>>7; int u=chrSrc[i]>>7;
int v=chrSrc[i + 2048]>>7; int v=chrSrc[i + 2048]>>7;
...@@ -2582,6 +2582,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar ...@@ -2582,6 +2582,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar
const int dstW= c->dstW; const int dstW= c->dstW;
const int dstH= c->dstH; const int dstH= c->dstH;
const int chrDstW= c->chrDstW; const int chrDstW= c->chrDstW;
const int chrSrcW= c->chrSrcW;
const int lumXInc= c->lumXInc; const int lumXInc= c->lumXInc;
const int chrXInc= c->chrXInc; const int chrXInc= c->chrXInc;
const int dstFormat= c->dstFormat; const int dstFormat= c->dstFormat;
...@@ -2609,6 +2610,8 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar ...@@ -2609,6 +2610,8 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar
uint8_t *funnyYCode= c->funnyYCode; uint8_t *funnyYCode= c->funnyYCode;
uint8_t *funnyUVCode= c->funnyUVCode; uint8_t *funnyUVCode= c->funnyUVCode;
uint8_t *formatConvBuffer= c->formatConvBuffer; uint8_t *formatConvBuffer= c->formatConvBuffer;
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
/* vars whch will change and which we need to storw back in the context */ /* vars whch will change and which we need to storw back in the context */
int dstY= c->dstY; int dstY= c->dstY;
...@@ -2629,7 +2632,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar ...@@ -2629,7 +2632,7 @@ static void RENAME(swScale)(SwsContext *c, uint8_t* srcParam[], int srcStridePar
srcStride[1]= srcStrideParam[2]; srcStride[1]= srcStrideParam[2];
srcStride[2]= srcStrideParam[1]; srcStride[2]= srcStrideParam[1];
} }
else if(c->srcFormat==IMGFMT_YV12){ else if(c->srcFormat==IMGFMT_YV12 || c->srcFormat==IMGFMT_YVU9){
src[0]= srcParam[0]; src[0]= srcParam[0];
src[1]= srcParam[1]; src[1]= srcParam[1];
src[2]= srcParam[2]; src[2]= srcParam[2];
...@@ -2726,7 +2729,7 @@ i--; ...@@ -2726,7 +2729,7 @@ i--;
ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1) ASSERT(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1)
// Do we have enough lines in this slice to output the dstY line // Do we have enough lines in this slice to output the dstY line
if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < ((srcSliceY + srcSliceH + 1)>>1)) if(lastLumSrcY < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample))
{ {
//Do horizontal scaling //Do horizontal scaling
while(lastInLumBuf < lastLumSrcY) while(lastInLumBuf < lastLumSrcY)
...@@ -2746,16 +2749,16 @@ i--; ...@@ -2746,16 +2749,16 @@ i--;
} }
while(lastInChrBuf < lastChrSrcY) while(lastInChrBuf < lastChrSrcY)
{ {
uint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1]; uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
uint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2]; uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++; chrBufIndex++;
ASSERT(chrBufIndex < 2*vChrBufSize) ASSERT(chrBufIndex < 2*vChrBufSize)
ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < ((srcSliceH+1)>>1)) ASSERT(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH))
ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0) ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
//FIXME replace parameters through context struct (some at least) //FIXME replace parameters through context struct (some at least)
if(!(isGray(srcFormat) || isGray(dstFormat))) if(!(isGray(srcFormat) || isGray(dstFormat)))
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer, funnyUVCode, c->srcFormat, formatConvBuffer,
c->chrMmx2Filter, c->chrMmx2FilterPos); c->chrMmx2Filter, c->chrMmx2FilterPos);
...@@ -2770,8 +2773,8 @@ i--; ...@@ -2770,8 +2773,8 @@ i--;
/* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n", /* printf("%d %d Last:%d %d LastInBuf:%d %d Index:%d %d Y:%d FSize: %d %d BSize: %d %d\n",
firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY, firstChrSrcY,firstLumSrcY,lastChrSrcY,lastLumSrcY,
lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize, lastInChrBuf,lastInLumBuf,chrBufIndex,lumBufIndex,dstY,vChrFilterSize,vLumFilterSize,
vChrBufSize, vLumBufSize); vChrBufSize, vLumBufSize);*/
*/
//Do horizontal scaling //Do horizontal scaling
while(lastInLumBuf+1 < srcSliceY + srcSliceH) while(lastInLumBuf+1 < srcSliceY + srcSliceH)
{ {
...@@ -2786,17 +2789,17 @@ i--; ...@@ -2786,17 +2789,17 @@ i--;
c->lumMmx2Filter, c->lumMmx2FilterPos); c->lumMmx2Filter, c->lumMmx2FilterPos);
lastInLumBuf++; lastInLumBuf++;
} }
while(lastInChrBuf+1 < ((srcSliceY + srcSliceH)>>1)) while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
{ {
uint8_t *src1= src[1]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[1]; uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];
uint8_t *src2= src[2]+(lastInChrBuf + 1 - (srcSliceY>>1))*srcStride[2]; uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];
chrBufIndex++; chrBufIndex++;
ASSERT(chrBufIndex < 2*vChrBufSize) ASSERT(chrBufIndex < 2*vChrBufSize)
ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) < ((srcSliceH+1)>>1)) ASSERT(lastInChrBuf + 1 - chrSrcSliceY < chrSrcSliceH)
ASSERT(lastInChrBuf + 1 - (srcSliceY>>1) >= 0) ASSERT(lastInChrBuf + 1 - chrSrcSliceY >= 0)
if(!(isGray(srcFormat) || isGray(dstFormat))) if(!(isGray(srcFormat) || isGray(dstFormat)))
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, (srcW+1)>>1, chrXInc, RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize, flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer, funnyUVCode, c->srcFormat, formatConvBuffer,
c->chrMmx2Filter, c->chrMmx2FilterPos); c->chrMmx2Filter, c->chrMmx2FilterPos);
...@@ -2823,17 +2826,17 @@ i--; ...@@ -2823,17 +2826,17 @@ i--;
{ {
int16_t *lumBuf = lumPixBuf[0]; int16_t *lumBuf = lumPixBuf[0];
int16_t *chrBuf= chrPixBuf[0]; int16_t *chrBuf= chrPixBuf[0];
RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW); RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW);
} }
else //General YV12 else //General YV12
{ {
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;
RENAME(yuv2yuvX)( RENAME(yuv2yuvX)(
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, vDest, dstW, dest, uDest, vDest, dstW, chrDstW,
lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+(dstY>>1)*vChrFilterSize*4); lumMmxFilter+dstY*vLumFilterSize*4, chrMmxFilter+chrDstY*vChrFilterSize*4);
} }
} }
else else
...@@ -2874,11 +2877,11 @@ i--; ...@@ -2874,11 +2877,11 @@ i--;
int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
if(isPlanarYUV(dstFormat)) //YV12 if(isPlanarYUV(dstFormat)) //YV12
{ {
if(dstY&1) uDest=vDest= NULL; //FIXME split functions in lumi / chromi if(dstY&1) uDest=vDest= NULL;
yuv2yuvXinC( yuv2yuvXinC(c,
vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize,
vChrFilter+(dstY>>1)*vChrFilterSize, chrSrcPtr, vChrFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
dest, uDest, vDest, dstW); dest, uDest, vDest);
} }
else else
{ {
......
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