Commit 6de58b49 authored by Pedro Arthur's avatar Pedro Arthur

swscale: cleanup unused code

Removed previous swscale code under '#ifndef NEW_FILTER'
and removed unused fields of SwsContext
parent 3b905b9f
...@@ -1482,7 +1482,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) ...@@ -1482,7 +1482,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
c->lumToYV12 = p010BEToY_c; c->lumToYV12 = p010BEToY_c;
break; break;
} }
if (c->alpPixBuf) { if (c->needAlpha) {
if (is16BPS(srcFormat) || isNBPS(srcFormat)) { if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
if (HAVE_BIGENDIAN == !isBE(srcFormat)) if (HAVE_BIGENDIAN == !isBE(srcFormat))
c->alpToYV12 = bswap16Y_c; c->alpToYV12 = bswap16Y_c;
......
...@@ -1513,8 +1513,8 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ ...@@ -1513,8 +1513,8 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
} }
#if CONFIG_SMALL #if CONFIG_SMALL
YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->needAlpha)
YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->needAlpha)
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1) YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1)
...@@ -1823,10 +1823,10 @@ yuv2rgb_full_1_c_template(SwsContext *c, const int16_t *buf0, ...@@ -1823,10 +1823,10 @@ yuv2rgb_full_1_c_template(SwsContext *c, const int16_t *buf0,
} }
#if CONFIG_SMALL #if CONFIG_SMALL
YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->needAlpha)
YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->needAlpha)
YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->needAlpha)
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1) YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1)
...@@ -2119,7 +2119,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2119,7 +2119,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed1 = yuv2rgba32_full_1_c; *yuv2packed1 = yuv2rgba32_full_1_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2rgba32_full_X_c; *yuv2packedX = yuv2rgba32_full_X_c;
*yuv2packed2 = yuv2rgba32_full_2_c; *yuv2packed2 = yuv2rgba32_full_2_c;
*yuv2packed1 = yuv2rgba32_full_1_c; *yuv2packed1 = yuv2rgba32_full_1_c;
...@@ -2139,7 +2139,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2139,7 +2139,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed1 = yuv2argb32_full_1_c; *yuv2packed1 = yuv2argb32_full_1_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2argb32_full_X_c; *yuv2packedX = yuv2argb32_full_X_c;
*yuv2packed2 = yuv2argb32_full_2_c; *yuv2packed2 = yuv2argb32_full_2_c;
*yuv2packed1 = yuv2argb32_full_1_c; *yuv2packed1 = yuv2argb32_full_1_c;
...@@ -2159,7 +2159,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2159,7 +2159,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed1 = yuv2bgra32_full_1_c; *yuv2packed1 = yuv2bgra32_full_1_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2bgra32_full_X_c; *yuv2packedX = yuv2bgra32_full_X_c;
*yuv2packed2 = yuv2bgra32_full_2_c; *yuv2packed2 = yuv2bgra32_full_2_c;
*yuv2packed1 = yuv2bgra32_full_1_c; *yuv2packed1 = yuv2bgra32_full_1_c;
...@@ -2179,7 +2179,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2179,7 +2179,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed1 = yuv2abgr32_full_1_c; *yuv2packed1 = yuv2abgr32_full_1_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2abgr32_full_X_c; *yuv2packedX = yuv2abgr32_full_X_c;
*yuv2packed2 = yuv2abgr32_full_2_c; *yuv2packed2 = yuv2abgr32_full_2_c;
*yuv2packed1 = yuv2abgr32_full_1_c; *yuv2packed1 = yuv2abgr32_full_1_c;
...@@ -2194,7 +2194,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2194,7 +2194,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_RGBA64LE: case AV_PIX_FMT_RGBA64LE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2rgba64le_full_X_c; *yuv2packedX = yuv2rgba64le_full_X_c;
*yuv2packed2 = yuv2rgba64le_full_2_c; *yuv2packed2 = yuv2rgba64le_full_2_c;
*yuv2packed1 = yuv2rgba64le_full_1_c; *yuv2packed1 = yuv2rgba64le_full_1_c;
...@@ -2208,7 +2208,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2208,7 +2208,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_RGBA64BE: case AV_PIX_FMT_RGBA64BE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2rgba64be_full_X_c; *yuv2packedX = yuv2rgba64be_full_X_c;
*yuv2packed2 = yuv2rgba64be_full_2_c; *yuv2packed2 = yuv2rgba64be_full_2_c;
*yuv2packed1 = yuv2rgba64be_full_1_c; *yuv2packed1 = yuv2rgba64be_full_1_c;
...@@ -2222,7 +2222,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2222,7 +2222,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_BGRA64LE: case AV_PIX_FMT_BGRA64LE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2bgra64le_full_X_c; *yuv2packedX = yuv2bgra64le_full_X_c;
*yuv2packed2 = yuv2bgra64le_full_2_c; *yuv2packed2 = yuv2bgra64le_full_2_c;
*yuv2packed1 = yuv2bgra64le_full_1_c; *yuv2packed1 = yuv2bgra64le_full_1_c;
...@@ -2236,7 +2236,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2236,7 +2236,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_BGRA64BE: case AV_PIX_FMT_BGRA64BE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packedX = yuv2bgra64be_full_X_c; *yuv2packedX = yuv2bgra64be_full_X_c;
*yuv2packed2 = yuv2bgra64be_full_2_c; *yuv2packed2 = yuv2bgra64be_full_2_c;
*yuv2packed1 = yuv2bgra64be_full_1_c; *yuv2packed1 = yuv2bgra64be_full_1_c;
...@@ -2321,7 +2321,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2321,7 +2321,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
switch (dstFormat) { switch (dstFormat) {
case AV_PIX_FMT_RGBA64LE: case AV_PIX_FMT_RGBA64LE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2rgba64le_1_c; *yuv2packed1 = yuv2rgba64le_1_c;
*yuv2packed2 = yuv2rgba64le_2_c; *yuv2packed2 = yuv2rgba64le_2_c;
*yuv2packedX = yuv2rgba64le_X_c; *yuv2packedX = yuv2rgba64le_X_c;
...@@ -2335,7 +2335,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2335,7 +2335,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_RGBA64BE: case AV_PIX_FMT_RGBA64BE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2rgba64be_1_c; *yuv2packed1 = yuv2rgba64be_1_c;
*yuv2packed2 = yuv2rgba64be_2_c; *yuv2packed2 = yuv2rgba64be_2_c;
*yuv2packedX = yuv2rgba64be_X_c; *yuv2packedX = yuv2rgba64be_X_c;
...@@ -2349,7 +2349,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2349,7 +2349,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_BGRA64LE: case AV_PIX_FMT_BGRA64LE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2bgra64le_1_c; *yuv2packed1 = yuv2bgra64le_1_c;
*yuv2packed2 = yuv2bgra64le_2_c; *yuv2packed2 = yuv2bgra64le_2_c;
*yuv2packedX = yuv2bgra64le_X_c; *yuv2packedX = yuv2bgra64le_X_c;
...@@ -2363,7 +2363,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2363,7 +2363,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
break; break;
case AV_PIX_FMT_BGRA64BE: case AV_PIX_FMT_BGRA64BE:
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2bgra64be_1_c; *yuv2packed1 = yuv2bgra64be_1_c;
*yuv2packed2 = yuv2bgra64be_2_c; *yuv2packed2 = yuv2bgra64be_2_c;
*yuv2packedX = yuv2bgra64be_X_c; *yuv2packedX = yuv2bgra64be_X_c;
...@@ -2403,7 +2403,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2403,7 +2403,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packedX = yuv2rgb32_X_c; *yuv2packedX = yuv2rgb32_X_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2rgba32_1_c; *yuv2packed1 = yuv2rgba32_1_c;
*yuv2packed2 = yuv2rgba32_2_c; *yuv2packed2 = yuv2rgba32_2_c;
*yuv2packedX = yuv2rgba32_X_c; *yuv2packedX = yuv2rgba32_X_c;
...@@ -2424,7 +2424,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, ...@@ -2424,7 +2424,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packedX = yuv2rgb32_1_X_c; *yuv2packedX = yuv2rgb32_1_X_c;
#else #else
#if CONFIG_SWSCALE_ALPHA #if CONFIG_SWSCALE_ALPHA
if (c->alpPixBuf) { if (c->needAlpha) {
*yuv2packed1 = yuv2rgba32_1_1_c; *yuv2packed1 = yuv2rgba32_1_1_c;
*yuv2packed2 = yuv2rgba32_1_2_c; *yuv2packed2 = yuv2rgba32_1_2_c;
*yuv2packedX = yuv2rgba32_1_X_c; *yuv2packedX = yuv2rgba32_1_X_c;
......
...@@ -339,13 +339,13 @@ av_cold void ff_sws_init_swscale_ppc(SwsContext *c) ...@@ -339,13 +339,13 @@ av_cold void ff_sws_init_swscale_ppc(SwsContext *c)
} }
if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) &&
dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 && dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
!c->alpPixBuf) { !c->needAlpha) {
c->yuv2planeX = yuv2planeX_altivec; c->yuv2planeX = yuv2planeX_altivec;
} }
/* The following list of supported dstFormat values should /* The following list of supported dstFormat values should
* match what's found in the body of ff_yuv2packedX_altivec() */ * match what's found in the body of ff_yuv2packedX_altivec() */
if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf) { if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->needAlpha) {
switch (c->dstFormat) { switch (c->dstFormat) {
case AV_PIX_FMT_ABGR: case AV_PIX_FMT_ABGR:
c->yuv2packedX = ff_yuv2abgr_X_altivec; c->yuv2packedX = ff_yuv2abgr_X_altivec;
......
...@@ -279,7 +279,7 @@ int ff_init_filters(SwsContext * c) ...@@ -279,7 +279,7 @@ int ff_init_filters(SwsContext * c)
if (need_lum_conv) { if (need_lum_conv) {
res = ff_init_desc_fmt_convert(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], pal); res = ff_init_desc_fmt_convert(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], pal);
if (res < 0) goto cleanup; if (res < 0) goto cleanup;
c->desc[index].alpha = c->alpPixBuf != 0; c->desc[index].alpha = c->needAlpha;
++index; ++index;
srcIdx = dstIdx; srcIdx = dstIdx;
} }
...@@ -288,7 +288,7 @@ int ff_init_filters(SwsContext * c) ...@@ -288,7 +288,7 @@ int ff_init_filters(SwsContext * c)
dstIdx = FFMAX(num_ydesc, num_cdesc); dstIdx = FFMAX(num_ydesc, num_cdesc);
res = ff_init_desc_hscale(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], c->hLumFilter, c->hLumFilterPos, c->hLumFilterSize, c->lumXInc); res = ff_init_desc_hscale(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], c->hLumFilter, c->hLumFilterPos, c->hLumFilterSize, c->lumXInc);
if (res < 0) goto cleanup; if (res < 0) goto cleanup;
c->desc[index].alpha = c->alpPixBuf != 0; c->desc[index].alpha = c->needAlpha;
++index; ++index;
......
This diff is collapsed.
...@@ -350,12 +350,6 @@ typedef struct SwsContext { ...@@ -350,12 +350,6 @@ typedef struct SwsContext {
* vertical scaler is called. * vertical scaler is called.
*/ */
//@{ //@{
int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
int16_t **chrUPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int16_t **chrVPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer. int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer. int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer.
int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source. int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
...@@ -363,6 +357,7 @@ typedef struct SwsContext { ...@@ -363,6 +357,7 @@ typedef struct SwsContext {
//@} //@}
uint8_t *formatConvBuffer; uint8_t *formatConvBuffer;
int needAlpha;
/** /**
* @name Horizontal and vertical filters. * @name Horizontal and vertical filters.
...@@ -1038,7 +1033,4 @@ void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn ...@@ -1038,7 +1033,4 @@ void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn
//number of extra lines to process //number of extra lines to process
#define MAX_LINES_AHEAD 4 #define MAX_LINES_AHEAD 4
// enable use of refactored scaler code
#define NEW_FILTER
#endif /* SWSCALE_SWSCALE_INTERNAL_H */ #endif /* SWSCALE_SWSCALE_INTERNAL_H */
...@@ -1696,69 +1696,14 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1696,69 +1696,14 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
#endif #endif
} }
// calculate buffer sizes so that they won't run out while handling these damn slices
c->vLumBufSize = c->vLumFilterSize;
c->vChrBufSize = c->vChrFilterSize;
for (i = 0; i < dstH; i++) {
int chrI = (int64_t)i * c->chrDstH / dstH;
int nextSlice = FFMAX(c->vLumFilterPos[i] + c->vLumFilterSize - 1,
((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)
<< c->chrSrcVSubSample));
nextSlice >>= c->chrSrcVSubSample;
nextSlice <<= c->chrSrcVSubSample;
if (c->vLumFilterPos[i] + c->vLumBufSize < nextSlice)
c->vLumBufSize = nextSlice - c->vLumFilterPos[i];
if (c->vChrFilterPos[chrI] + c->vChrBufSize <
(nextSlice >> c->chrSrcVSubSample))
c->vChrBufSize = (nextSlice >> c->chrSrcVSubSample) -
c->vChrFilterPos[chrI];
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
FF_ALLOCZ_OR_GOTO(c, c->dither_error[i], (c->dstW+2) * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(c, c->dither_error[i], (c->dstW+2) * sizeof(int), fail);
/* Allocate pixbufs (we use dynamic allocation because otherwise we would c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) ? 1 : 0;
* need to allocate several megabytes to handle all possible cases) */
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
FF_ALLOCZ_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
FF_ALLOCZ_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
/* Note we need at least one pixel more at the end because of the MMX code
* (just in case someone wants to replace the 4000/8000). */
/* align at 16 bytes for AltiVec */
for (i = 0; i < c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i + c->vLumBufSize],
dst_stride + 16, fail);
c->lumPixBuf[i] = c->lumPixBuf[i + c->vLumBufSize];
}
// 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate)
c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7); c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7);
c->uv_offx2 = dst_stride + 16; c->uv_offx2 = dst_stride + 16;
for (i = 0; i < c->vChrBufSize; i++) {
FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i + c->vChrBufSize],
dst_stride * 2 + 32, fail);
c->chrUPixBuf[i] = c->chrUPixBuf[i + c->vChrBufSize];
c->chrVPixBuf[i] = c->chrVPixBuf[i + c->vChrBufSize]
= c->chrUPixBuf[i] + (dst_stride >> 1) + 8;
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
for (i = 0; i < c->vLumBufSize; i++) {
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i + c->vLumBufSize],
dst_stride + 16, fail);
c->alpPixBuf[i] = c->alpPixBuf[i + c->vLumBufSize];
}
// try to avoid drawing green stuff between the right end and the stride end
for (i = 0; i < c->vChrBufSize; i++)
if(desc_dst->comp[0].depth == 16){
av_assert0(c->dstBpc > 14);
for(j=0; j<dst_stride/2+1; j++)
((int32_t*)(c->chrUPixBuf[i]))[j] = 1<<18;
} else
for(j=0; j<dst_stride+1; j++)
((int16_t*)(c->chrUPixBuf[i]))[j] = 1<<14;
av_assert0(c->chrDstH <= dstH); av_assert0(c->chrDstH <= dstH);
...@@ -2325,25 +2270,6 @@ void sws_freeContext(SwsContext *c) ...@@ -2325,25 +2270,6 @@ void sws_freeContext(SwsContext *c)
if (!c) if (!c)
return; return;
if (c->lumPixBuf) {
for (i = 0; i < c->vLumBufSize; i++)
av_freep(&c->lumPixBuf[i]);
av_freep(&c->lumPixBuf);
}
if (c->chrUPixBuf) {
for (i = 0; i < c->vChrBufSize; i++)
av_freep(&c->chrUPixBuf[i]);
av_freep(&c->chrUPixBuf);
av_freep(&c->chrVPixBuf);
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
for (i = 0; i < c->vLumBufSize; i++)
av_freep(&c->alpPixBuf[i]);
av_freep(&c->alpPixBuf);
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
av_freep(&c->dither_error[i]); av_freep(&c->dither_error[i]);
......
...@@ -218,7 +218,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS ...@@ -218,7 +218,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS
desc[0].instance = lumCtx; desc[0].instance = lumCtx;
desc[0].src = src; desc[0].src = src;
desc[0].dst = dst; desc[0].dst = dst;
desc[0].alpha = c->alpPixBuf != 0; desc[0].alpha = c->needAlpha;
if (!isGray(c->dstFormat)) { if (!isGray(c->dstFormat)) {
chrCtx = av_mallocz(sizeof(VScalerContext)); chrCtx = av_mallocz(sizeof(VScalerContext));
...@@ -239,7 +239,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS ...@@ -239,7 +239,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS
desc[0].instance = lumCtx; desc[0].instance = lumCtx;
desc[0].src = src; desc[0].src = src;
desc[0].dst = dst; desc[0].dst = dst;
desc[0].alpha = c->alpPixBuf != 0; desc[0].alpha = c->needAlpha;
} }
ff_init_vscale_pfn(c, c->yuv2plane1, c->yuv2planeX, c->yuv2nv12cX, ff_init_vscale_pfn(c, c->yuv2plane1, c->yuv2planeX, c->yuv2nv12cX,
......
...@@ -85,18 +85,12 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB ...@@ -85,18 +85,12 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
{ {
const int dstH= c->dstH; const int dstH= c->dstH;
const int flags= c->flags; const int flags= c->flags;
#ifdef NEW_FILTER
SwsPlane *lumPlane = &c->slice[c->numSlice-2].plane[0]; SwsPlane *lumPlane = &c->slice[c->numSlice-2].plane[0];
SwsPlane *chrUPlane = &c->slice[c->numSlice-2].plane[1]; SwsPlane *chrUPlane = &c->slice[c->numSlice-2].plane[1];
SwsPlane *alpPlane = &c->slice[c->numSlice-2].plane[3]; SwsPlane *alpPlane = &c->slice[c->numSlice-2].plane[3];
#else
int16_t **lumPixBuf= c->lumPixBuf; int hasAlpha = c->needAlpha;
int16_t **chrUPixBuf= c->chrUPixBuf;
int16_t **alpPixBuf= c->alpPixBuf;
const int vLumBufSize= c->vLumBufSize;
const int vChrBufSize= c->vChrBufSize;
#endif
int hasAlpha = c->alpPixBuf != NULL;
int32_t *vLumFilterPos= c->vLumFilterPos; int32_t *vLumFilterPos= c->vLumFilterPos;
int32_t *vChrFilterPos= c->vChrFilterPos; int32_t *vChrFilterPos= c->vChrFilterPos;
int16_t *vLumFilter= c->vLumFilter; int16_t *vLumFilter= c->vLumFilter;
...@@ -117,22 +111,14 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB ...@@ -117,22 +111,14 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
c->greenDither= ff_dither4[dstY&1]; c->greenDither= ff_dither4[dstY&1];
c->redDither= ff_dither8[(dstY+1)&1]; c->redDither= ff_dither8[(dstY+1)&1];
if (dstY < dstH - 2) { if (dstY < dstH - 2) {
#ifdef NEW_FILTER
const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPlane->line + firstLumSrcY - lumPlane->sliceY; const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPlane->line + firstLumSrcY - lumPlane->sliceY;
const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPlane->line + firstChrSrcY - chrUPlane->sliceY; const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPlane->line + firstChrSrcY - chrUPlane->sliceY;
const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL; const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && hasAlpha) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL;
#else
const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
#endif
int i; int i;
if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) { if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
#ifdef NEW_FILTER
const int16_t **tmpY = (const int16_t **) lumPlane->tmp; const int16_t **tmpY = (const int16_t **) lumPlane->tmp;
#else
const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
#endif
int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize); int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
for (i = 0; i < neg; i++) for (i = 0; i < neg; i++)
tmpY[i] = lumSrcPtr[neg]; tmpY[i] = lumSrcPtr[neg];
...@@ -143,11 +129,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB ...@@ -143,11 +129,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
lumSrcPtr = tmpY; lumSrcPtr = tmpY;
if (alpSrcPtr) { if (alpSrcPtr) {
#ifdef NEW_FILTER
const int16_t **tmpA = (const int16_t **) alpPlane->tmp; const int16_t **tmpA = (const int16_t **) alpPlane->tmp;
#else
const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
#endif
for (i = 0; i < neg; i++) for (i = 0; i < neg; i++)
tmpA[i] = alpSrcPtr[neg]; tmpA[i] = alpSrcPtr[neg];
for ( ; i < end; i++) for ( ; i < end; i++)
...@@ -158,11 +140,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB ...@@ -158,11 +140,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB
} }
} }
if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) { if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
#ifdef NEW_FILTER
const int16_t **tmpU = (const int16_t **) chrUPlane->tmp; const int16_t **tmpU = (const int16_t **) chrUPlane->tmp;
#else
const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
#endif
int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize); int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
for (i = 0; i < neg; i++) { for (i = 0; i < neg; i++) {
tmpU[i] = chrUSrcPtr[neg]; tmpU[i] = chrUSrcPtr[neg];
...@@ -479,7 +457,7 @@ switch(c->dstBpc){ \ ...@@ -479,7 +457,7 @@ switch(c->dstBpc){ \
switch (c->srcFormat) { switch (c->srcFormat) {
case AV_PIX_FMT_YA8: case AV_PIX_FMT_YA8:
c->lumToYV12 = ff_yuyvToY_mmx; c->lumToYV12 = ff_yuyvToY_mmx;
if (c->alpPixBuf) if (c->needAlpha)
c->alpToYV12 = ff_uyvyToY_mmx; c->alpToYV12 = ff_uyvyToY_mmx;
break; break;
case AV_PIX_FMT_YUYV422: case AV_PIX_FMT_YUYV422:
...@@ -528,7 +506,7 @@ switch(c->dstBpc){ \ ...@@ -528,7 +506,7 @@ switch(c->dstBpc){ \
switch (c->srcFormat) { switch (c->srcFormat) {
case AV_PIX_FMT_YA8: case AV_PIX_FMT_YA8:
c->lumToYV12 = ff_yuyvToY_sse2; c->lumToYV12 = ff_yuyvToY_sse2;
if (c->alpPixBuf) if (c->needAlpha)
c->alpToYV12 = ff_uyvyToY_sse2; c->alpToYV12 = ff_uyvyToY_sse2;
break; break;
case AV_PIX_FMT_YUYV422: case AV_PIX_FMT_YUYV422:
......
...@@ -348,7 +348,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, ...@@ -348,7 +348,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter,
x86_reg dstW_reg = dstW; x86_reg dstW_reg = dstW;
x86_reg uv_off = c->uv_offx2; x86_reg uv_off = c->uv_offx2;
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2PACKEDX_ACCURATE
YSCALEYUV2RGBX YSCALEYUV2RGBX
"movq %%mm2, "U_TEMP"(%0) \n\t" "movq %%mm2, "U_TEMP"(%0) \n\t"
...@@ -381,7 +381,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, ...@@ -381,7 +381,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter,
x86_reg dstW_reg = dstW; x86_reg dstW_reg = dstW;
x86_reg uv_off = c->uv_offx2; x86_reg uv_off = c->uv_offx2;
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7) YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
...@@ -410,7 +410,7 @@ static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter, ...@@ -410,7 +410,7 @@ static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter,
x86_reg dstW_reg = dstW; x86_reg dstW_reg = dstW;
x86_reg uv_off = c->uv_offx2; x86_reg uv_off = c->uv_offx2;
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
YSCALEYUV2PACKEDX YSCALEYUV2PACKEDX
YSCALEYUV2RGBX YSCALEYUV2RGBX
YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7) YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
...@@ -889,7 +889,7 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2], ...@@ -889,7 +889,7 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2],
const int16_t *buf0 = buf[0], *buf1 = buf[1], const int16_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1]; const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1];
#if ARCH_X86_64 #if ARCH_X86_64
__asm__ volatile( __asm__ volatile(
...@@ -1215,7 +1215,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, ...@@ -1215,7 +1215,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0,
if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
const int16_t *ubuf1 = ubuf[0]; const int16_t *ubuf1 = ubuf[0];
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
__asm__ volatile( __asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
...@@ -1244,7 +1244,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, ...@@ -1244,7 +1244,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0,
} }
} else { } else {
const int16_t *ubuf1 = ubuf[1]; const int16_t *ubuf1 = ubuf[1];
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
__asm__ volatile( __asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t" "mov %4, %%"REG_b" \n\t"
......
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