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:
parent
bb53e1d188
commit
a1f4b4bb6e
@ -261,10 +261,10 @@ typedef struct SwsContext {
|
||||
const uint8_t *src1, const uint8_t *src2,
|
||||
long width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler.
|
||||
void (*hyscale_fast)(struct SwsContext *c,
|
||||
int16_t *dst, int dstWidth,
|
||||
int16_t *dst, long dstWidth,
|
||||
const uint8_t *src, int srcW, int xInc);
|
||||
void (*hcscale_fast)(struct SwsContext *c,
|
||||
int16_t *dst, int dstWidth,
|
||||
int16_t *dst, long dstWidth,
|
||||
const uint8_t *src1, const uint8_t *src2,
|
||||
int srcW, int xInc);
|
||||
|
||||
|
@ -2259,46 +2259,15 @@ static void RENAME(lumRangeFromJpeg)(uint16_t *dst, int width)
|
||||
"shrl $9, %%esi \n\t" \
|
||||
|
||||
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 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 COMPILE_TEMPLATE_MMX2
|
||||
int32_t *mmx2FilterPos = c->lumMmx2FilterPos;
|
||||
int16_t *mmx2Filter = c->lumMmx2Filter;
|
||||
int canMMX2BeUsed = c->canMMX2BeUsed;
|
||||
void *mmx2FilterCode= c->lumMmx2FilterCode;
|
||||
int i;
|
||||
#if defined(PIC)
|
||||
DECLARE_ALIGNED(8, uint64_t, ebxsave);
|
||||
@ -2400,60 +2369,55 @@ static inline void RENAME(hyscale)(SwsContext *c, uint16_t *dst, long dstWidth,
|
||||
} //if MMX2 can't be used
|
||||
#endif
|
||||
#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 */
|
||||
}
|
||||
|
||||
// *** 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)
|
||||
convertRange(dst, dstWidth);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 COMPILE_TEMPLATE_MMX2
|
||||
int32_t *mmx2FilterPos = c->chrMmx2FilterPos;
|
||||
int16_t *mmx2Filter = c->chrMmx2Filter;
|
||||
int canMMX2BeUsed = c->canMMX2BeUsed;
|
||||
void *mmx2FilterCode= c->chrMmx2FilterCode;
|
||||
int i;
|
||||
#if defined(PIC)
|
||||
DECLARE_ALIGNED(8, uint64_t, ebxsave);
|
||||
@ -2549,10 +2513,46 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
|
||||
} //if MMX2 can't be used
|
||||
#endif
|
||||
#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 */
|
||||
}
|
||||
|
||||
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)
|
||||
c->chrConvertRange(dst, dstWidth);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user