Move fast bilinear scaler code to the existing h[yc]scale_fast() functions.

Originally committed as revision 30098 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
This commit is contained in:
Ramiro Polla 2009-12-21 01:54:59 +00:00
parent bb53e1d188
commit a1f4b4bb6e
2 changed files with 214 additions and 214 deletions

View File

@ -261,10 +261,10 @@ typedef struct SwsContext {
const uint8_t *src1, const uint8_t *src2, const uint8_t *src1, const uint8_t *src2,
long width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler. long width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler.
void (*hyscale_fast)(struct SwsContext *c, void (*hyscale_fast)(struct SwsContext *c,
int16_t *dst, int dstWidth, int16_t *dst, long dstWidth,
const uint8_t *src, int srcW, int xInc); const uint8_t *src, int srcW, int xInc);
void (*hcscale_fast)(struct SwsContext *c, void (*hcscale_fast)(struct SwsContext *c,
int16_t *dst, int dstWidth, int16_t *dst, long dstWidth,
const uint8_t *src1, const uint8_t *src2, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc); int srcW, int xInc);

View File

@ -2259,46 +2259,15 @@ static void RENAME(lumRangeFromJpeg)(uint16_t *dst, int width)
"shrl $9, %%esi \n\t" \ "shrl $9, %%esi \n\t" \
static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst, static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src, int srcW, long dstWidth, const uint8_t *src, int srcW,
int xInc) int xInc)
{ {
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
}
// *** horizontal scale Y line to temp buffer
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
int flags, const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
int32_t av_unused *mmx2FilterPos = c->lumMmx2FilterPos;
int16_t av_unused *mmx2Filter = c->lumMmx2Filter;
int av_unused canMMX2BeUsed = c->canMMX2BeUsed;
void av_unused *mmx2FilterCode= c->lumMmx2FilterCode;
void (*toYV12)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
if (toYV12) {
toYV12(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
}
if (!c->hyscale_fast)
{
c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
} else { // fast bilinear upscale / crap downscale
#if ARCH_X86 && CONFIG_GPL #if ARCH_X86 && CONFIG_GPL
#if COMPILE_TEMPLATE_MMX2 #if COMPILE_TEMPLATE_MMX2
int32_t *mmx2FilterPos = c->lumMmx2FilterPos;
int16_t *mmx2Filter = c->lumMmx2Filter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i; int i;
#if defined(PIC) #if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave); DECLARE_ALIGNED(8, uint64_t, ebxsave);
@ -2400,8 +2369,39 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth,
} //if MMX2 can't be used } //if MMX2 can't be used
#endif #endif
#else #else
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif /* ARCH_X86 */ #endif /* ARCH_X86 */
}
// *** horizontal scale Y line to temp buffer
static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
int flags, const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal, int isAlpha)
{
void (*toYV12)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
if (toYV12) {
toYV12(formatConvBuffer, src, srcW, pal);
src= formatConvBuffer;
}
if (!c->hyscale_fast)
{
c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
} else { // fast bilinear upscale / crap downscale
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
} }
if (convertRange) if (convertRange)
@ -2409,51 +2409,15 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth,
} }
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst, static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1, long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc) const uint8_t *src2, int srcW, int xInc)
{ {
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
}
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, int flags, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos;
int16_t av_unused *mmx2Filter = c->chrMmx2Filter;
int av_unused canMMX2BeUsed = c->canMMX2BeUsed;
void av_unused *mmx2FilterCode= c->chrMmx2FilterCode;
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->chrToYV12) {
c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (!c->hcscale_fast)
{
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale
#if ARCH_X86 && CONFIG_GPL #if ARCH_X86 && CONFIG_GPL
#if COMPILE_TEMPLATE_MMX2 #if COMPILE_TEMPLATE_MMX2
int32_t *mmx2FilterPos = c->chrMmx2FilterPos;
int16_t *mmx2Filter = c->chrMmx2Filter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i; int i;
#if defined(PIC) #if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave); DECLARE_ALIGNED(8, uint64_t, ebxsave);
@ -2536,7 +2500,7 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
" jb 1b \n\t" " jb 1b \n\t"
/* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC 4.0. */ which is needed to support GCC 4.0. */
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4) #if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask), :: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
#else #else
@ -2549,8 +2513,44 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
} //if MMX2 can't be used } //if MMX2 can't be used
#endif #endif
#else #else
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc); int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif /* ARCH_X86 */ #endif /* ARCH_X86 */
}
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2,
int srcW, int xInc, int flags, const int16_t *hChrFilter,
const int16_t *hChrFilterPos, int hChrFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal)
{
src1 += c->chrSrcOffset;
src2 += c->chrSrcOffset;
if (c->chrToYV12) {
c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
src1= formatConvBuffer;
src2= formatConvBuffer+VOFW;
}
if (!c->hcscale_fast)
{
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale
c->hcscale_fast(c, dst, dstWidth, src1, src2, srcW, xInc);
} }
if (c->chrConvertRange) if (c->chrConvertRange)