Commit d03c61d5 authored by ramiro's avatar ramiro

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

git-svn-id: file:///var/local/repositories/mplayer/trunk/libswscale@30098 b3059339-0415-0410-9bf9-f77b7e298cf2
parent 1f13448e
...@@ -261,10 +261,10 @@ typedef struct SwsContext { ...@@ -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);
......
...@@ -2259,46 +2259,15 @@ static void RENAME(lumRangeFromJpeg)(uint16_t *dst, int width) ...@@ -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,60 +2369,55 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, ...@@ -2400,60 +2369,55 @@ 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);
#endif /* ARCH_X86 */
}
if (convertRange)
convertRange(dst, dstWidth);
}
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int i; int i;
unsigned int xpos=0; unsigned int xpos=0;
for (i=0;i<dstWidth;i++) { for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16; register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9; register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha); dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*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; xpos+=xInc;
} }
#endif /* ARCH_X86 */
} }
inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src1, const uint8_t *src2, // *** horizontal scale Y line to temp buffer
int srcW, int xInc, int flags, const int16_t *hChrFilter, static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth, const uint8_t *src, int srcW, int xInc,
const int16_t *hChrFilterPos, int hChrFilterSize, int flags, const int16_t *hLumFilter,
const int16_t *hLumFilterPos, int hLumFilterSize,
enum PixelFormat srcFormat, uint8_t *formatConvBuffer, enum PixelFormat srcFormat, uint8_t *formatConvBuffer,
uint32_t *pal) uint32_t *pal, int isAlpha)
{ {
int32_t av_unused *mmx2FilterPos = c->chrMmx2FilterPos; void (*toYV12)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12;
int16_t av_unused *mmx2Filter = c->chrMmx2Filter; void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
int av_unused canMMX2BeUsed = c->canMMX2BeUsed;
void av_unused *mmx2FilterCode= c->chrMmx2FilterCode;
src1 += c->chrSrcOffset; src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
src2 += c->chrSrcOffset;
if (c->chrToYV12) { if (toYV12) {
c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); toYV12(formatConvBuffer, src, srcW, pal);
src1= formatConvBuffer; src= formatConvBuffer;
src2= formatConvBuffer+VOFW;
} }
if (!c->hcscale_fast) if (!c->hyscale_fast)
{ {
c->hScale(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); c->hScale(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);
c->hScale(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize);
} else { // fast bilinear upscale / crap downscale } else { // fast bilinear upscale / crap downscale
c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
}
if (convertRange)
convertRange(dst, dstWidth);
}
static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#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, ...@@ -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, ...@@ -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)
......
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