Removed previous swscale code under '#ifndef NEW_FILTER' and removed unused fields of SwsContext
Unified · Split
| @@ -1482,7 +1482,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) · 1481 unmodified lines | ||
| 1482 | 1482 | c->lumToYV12 = p010BEToY_c; |
| 1483 | 1483 | break; |
| 1484 | 1484 | } |
| 1485 | − if (c->alpPixBuf) { | |
| 1485 | + if (c->needAlpha) { | |
| 1486 | 1486 | if (is16BPS(srcFormat) || isNBPS(srcFormat)) { |
| 1487 | 1487 | if (HAVE_BIGENDIAN == !isBE(srcFormat)) |
| 1488 | 1488 | c->alpToYV12 = bswap16Y_c; |
| @@ -1513,8 +1513,8 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \ · 1512 unmodified lines | ||
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | #if CONFIG_SMALL |
| 1516 | −YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1517 | −YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1516 | +YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1517 | +YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1518 | 1518 | #else |
| 1519 | 1519 | #if CONFIG_SWSCALE_ALPHA |
| 1520 | 1520 | 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, · 302 unmodified lines | ||
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | 1825 | #if CONFIG_SMALL |
| 1826 | −YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1827 | −YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1828 | −YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1829 | −YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1826 | +YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1827 | +YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1828 | +YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1829 | +YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->needAlpha) | |
| 1830 | 1830 | #else |
| 1831 | 1831 | #if CONFIG_SWSCALE_ALPHA |
| 1832 | 1832 | 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, · 286 unmodified lines | ||
| 2119 | 2119 | *yuv2packed1 = yuv2rgba32_full_1_c; |
| 2120 | 2120 | #else |
| 2121 | 2121 | #if CONFIG_SWSCALE_ALPHA |
| 2122 | − if (c->alpPixBuf) { | |
| 2122 | + if (c->needAlpha) { | |
| 2123 | 2123 | *yuv2packedX = yuv2rgba32_full_X_c; |
| 2124 | 2124 | *yuv2packed2 = yuv2rgba32_full_2_c; |
| 2125 | 2125 | *yuv2packed1 = yuv2rgba32_full_1_c; |
| @@ -2139,7 +2139,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 13 unmodified lines | ||
| 2139 | 2139 | *yuv2packed1 = yuv2argb32_full_1_c; |
| 2140 | 2140 | #else |
| 2141 | 2141 | #if CONFIG_SWSCALE_ALPHA |
| 2142 | − if (c->alpPixBuf) { | |
| 2142 | + if (c->needAlpha) { | |
| 2143 | 2143 | *yuv2packedX = yuv2argb32_full_X_c; |
| 2144 | 2144 | *yuv2packed2 = yuv2argb32_full_2_c; |
| 2145 | 2145 | *yuv2packed1 = yuv2argb32_full_1_c; |
| @@ -2159,7 +2159,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 13 unmodified lines | ||
| 2159 | 2159 | *yuv2packed1 = yuv2bgra32_full_1_c; |
| 2160 | 2160 | #else |
| 2161 | 2161 | #if CONFIG_SWSCALE_ALPHA |
| 2162 | − if (c->alpPixBuf) { | |
| 2162 | + if (c->needAlpha) { | |
| 2163 | 2163 | *yuv2packedX = yuv2bgra32_full_X_c; |
| 2164 | 2164 | *yuv2packed2 = yuv2bgra32_full_2_c; |
| 2165 | 2165 | *yuv2packed1 = yuv2bgra32_full_1_c; |
| @@ -2179,7 +2179,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 13 unmodified lines | ||
| 2179 | 2179 | *yuv2packed1 = yuv2abgr32_full_1_c; |
| 2180 | 2180 | #else |
| 2181 | 2181 | #if CONFIG_SWSCALE_ALPHA |
| 2182 | − if (c->alpPixBuf) { | |
| 2182 | + if (c->needAlpha) { | |
| 2183 | 2183 | *yuv2packedX = yuv2abgr32_full_X_c; |
| 2184 | 2184 | *yuv2packed2 = yuv2abgr32_full_2_c; |
| 2185 | 2185 | *yuv2packed1 = yuv2abgr32_full_1_c; |
| @@ -2194,7 +2194,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 8 unmodified lines | ||
| 2194 | 2194 | break; |
| 2195 | 2195 | case AV_PIX_FMT_RGBA64LE: |
| 2196 | 2196 | #if CONFIG_SWSCALE_ALPHA |
| 2197 | − if (c->alpPixBuf) { | |
| 2197 | + if (c->needAlpha) { | |
| 2198 | 2198 | *yuv2packedX = yuv2rgba64le_full_X_c; |
| 2199 | 2199 | *yuv2packed2 = yuv2rgba64le_full_2_c; |
| 2200 | 2200 | *yuv2packed1 = yuv2rgba64le_full_1_c; |
| @@ -2208,7 +2208,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2208 | 2208 | break; |
| 2209 | 2209 | case AV_PIX_FMT_RGBA64BE: |
| 2210 | 2210 | #if CONFIG_SWSCALE_ALPHA |
| 2211 | − if (c->alpPixBuf) { | |
| 2211 | + if (c->needAlpha) { | |
| 2212 | 2212 | *yuv2packedX = yuv2rgba64be_full_X_c; |
| 2213 | 2213 | *yuv2packed2 = yuv2rgba64be_full_2_c; |
| 2214 | 2214 | *yuv2packed1 = yuv2rgba64be_full_1_c; |
| @@ -2222,7 +2222,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2222 | 2222 | break; |
| 2223 | 2223 | case AV_PIX_FMT_BGRA64LE: |
| 2224 | 2224 | #if CONFIG_SWSCALE_ALPHA |
| 2225 | − if (c->alpPixBuf) { | |
| 2225 | + if (c->needAlpha) { | |
| 2226 | 2226 | *yuv2packedX = yuv2bgra64le_full_X_c; |
| 2227 | 2227 | *yuv2packed2 = yuv2bgra64le_full_2_c; |
| 2228 | 2228 | *yuv2packed1 = yuv2bgra64le_full_1_c; |
| @@ -2236,7 +2236,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2236 | 2236 | break; |
| 2237 | 2237 | case AV_PIX_FMT_BGRA64BE: |
| 2238 | 2238 | #if CONFIG_SWSCALE_ALPHA |
| 2239 | − if (c->alpPixBuf) { | |
| 2239 | + if (c->needAlpha) { | |
| 2240 | 2240 | *yuv2packedX = yuv2bgra64be_full_X_c; |
| 2241 | 2241 | *yuv2packed2 = yuv2bgra64be_full_2_c; |
| 2242 | 2242 | *yuv2packed1 = yuv2bgra64be_full_1_c; |
| @@ -2321,7 +2321,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 78 unmodified lines | ||
| 2321 | 2321 | switch (dstFormat) { |
| 2322 | 2322 | case AV_PIX_FMT_RGBA64LE: |
| 2323 | 2323 | #if CONFIG_SWSCALE_ALPHA |
| 2324 | − if (c->alpPixBuf) { | |
| 2324 | + if (c->needAlpha) { | |
| 2325 | 2325 | *yuv2packed1 = yuv2rgba64le_1_c; |
| 2326 | 2326 | *yuv2packed2 = yuv2rgba64le_2_c; |
| 2327 | 2327 | *yuv2packedX = yuv2rgba64le_X_c; |
| @@ -2335,7 +2335,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2335 | 2335 | break; |
| 2336 | 2336 | case AV_PIX_FMT_RGBA64BE: |
| 2337 | 2337 | #if CONFIG_SWSCALE_ALPHA |
| 2338 | − if (c->alpPixBuf) { | |
| 2338 | + if (c->needAlpha) { | |
| 2339 | 2339 | *yuv2packed1 = yuv2rgba64be_1_c; |
| 2340 | 2340 | *yuv2packed2 = yuv2rgba64be_2_c; |
| 2341 | 2341 | *yuv2packedX = yuv2rgba64be_X_c; |
| @@ -2349,7 +2349,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2349 | 2349 | break; |
| 2350 | 2350 | case AV_PIX_FMT_BGRA64LE: |
| 2351 | 2351 | #if CONFIG_SWSCALE_ALPHA |
| 2352 | − if (c->alpPixBuf) { | |
| 2352 | + if (c->needAlpha) { | |
| 2353 | 2353 | *yuv2packed1 = yuv2bgra64le_1_c; |
| 2354 | 2354 | *yuv2packed2 = yuv2bgra64le_2_c; |
| 2355 | 2355 | *yuv2packedX = yuv2bgra64le_X_c; |
| @@ -2363,7 +2363,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 7 unmodified lines | ||
| 2363 | 2363 | break; |
| 2364 | 2364 | case AV_PIX_FMT_BGRA64BE: |
| 2365 | 2365 | #if CONFIG_SWSCALE_ALPHA |
| 2366 | − if (c->alpPixBuf) { | |
| 2366 | + if (c->needAlpha) { | |
| 2367 | 2367 | *yuv2packed1 = yuv2bgra64be_1_c; |
| 2368 | 2368 | *yuv2packed2 = yuv2bgra64be_2_c; |
| 2369 | 2369 | *yuv2packedX = yuv2bgra64be_X_c; |
| @@ -2403,7 +2403,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 33 unmodified lines | ||
| 2403 | 2403 | *yuv2packedX = yuv2rgb32_X_c; |
| 2404 | 2404 | #else |
| 2405 | 2405 | #if CONFIG_SWSCALE_ALPHA |
| 2406 | − if (c->alpPixBuf) { | |
| 2406 | + if (c->needAlpha) { | |
| 2407 | 2407 | *yuv2packed1 = yuv2rgba32_1_c; |
| 2408 | 2408 | *yuv2packed2 = yuv2rgba32_2_c; |
| 2409 | 2409 | *yuv2packedX = yuv2rgba32_X_c; |
| @@ -2424,7 +2424,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, · 14 unmodified lines | ||
| 2424 | 2424 | *yuv2packedX = yuv2rgb32_1_X_c; |
| 2425 | 2425 | #else |
| 2426 | 2426 | #if CONFIG_SWSCALE_ALPHA |
| 2427 | − if (c->alpPixBuf) { | |
| 2427 | + if (c->needAlpha) { | |
| 2428 | 2428 | *yuv2packed1 = yuv2rgba32_1_1_c; |
| 2429 | 2429 | *yuv2packed2 = yuv2rgba32_1_2_c; |
| 2430 | 2430 | *yuv2packedX = yuv2rgba32_1_X_c; |
| @@ -339,13 +339,13 @@ av_cold void ff_sws_init_swscale_ppc(SwsContext *c) · 338 unmodified lines | ||
| 339 | 339 | } |
| 340 | 340 | if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && |
| 341 | 341 | dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 && |
| 342 | − !c->alpPixBuf) { | |
| 342 | + !c->needAlpha) { | |
| 343 | 343 | c->yuv2planeX = yuv2planeX_altivec; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /* The following list of supported dstFormat values should |
| 347 | 347 | * match what's found in the body of ff_yuv2packedX_altivec() */ |
| 348 | − if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf) { | |
| 348 | + if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->needAlpha) { | |
| 349 | 349 | switch (c->dstFormat) { |
| 350 | 350 | case AV_PIX_FMT_ABGR: |
| 351 | 351 | c->yuv2packedX = ff_yuv2abgr_X_altivec; |
| @@ -279,7 +279,7 @@ int ff_init_filters(SwsContext * c) · 278 unmodified lines | ||
| 279 | 279 | if (need_lum_conv) { |
| 280 | 280 | res = ff_init_desc_fmt_convert(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], pal); |
| 281 | 281 | if (res < 0) goto cleanup; |
| 282 | − c->desc[index].alpha = c->alpPixBuf != 0; | |
| 282 | + c->desc[index].alpha = c->needAlpha; | |
| 283 | 283 | ++index; |
| 284 | 284 | srcIdx = dstIdx; |
| 285 | 285 | } |
| @@ -288,7 +288,7 @@ int ff_init_filters(SwsContext * c) · 2 unmodified lines | ||
| 288 | 288 | dstIdx = FFMAX(num_ydesc, num_cdesc); |
| 289 | 289 | res = ff_init_desc_hscale(&c->desc[index], &c->slice[srcIdx], &c->slice[dstIdx], c->hLumFilter, c->hLumFilterPos, c->hLumFilterSize, c->lumXInc); |
| 290 | 290 | if (res < 0) goto cleanup; |
| 291 | − c->desc[index].alpha = c->alpPixBuf != 0; | |
| 291 | + c->desc[index].alpha = c->needAlpha; | |
| 292 | 292 | |
| 293 | 293 | |
| 294 | 294 | ++index; |
| @@ -52,24 +52,6 @@ DECLARE_ALIGNED(8, static const uint8_t, sws_pb_64)[8] = { · 51 unmodified lines | ||
| 52 | 52 | 64, 64, 64, 64, 64, 64, 64, 64 |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | −#ifndef NEW_FILTER | |
| 56 | −static void gamma_convert(uint8_t * src[], int width, uint16_t *gamma) | |
| 57 | −{ | |
| 58 | − int i; | |
| 59 | − uint16_t *src1 = (uint16_t*)src[0]; | |
| 60 | − | |
| 61 | − for (i = 0; i < width; ++i) { | |
| 62 | − uint16_t r = AV_RL16(src1 + i*4 + 0); | |
| 63 | − uint16_t g = AV_RL16(src1 + i*4 + 1); | |
| 64 | − uint16_t b = AV_RL16(src1 + i*4 + 2); | |
| 65 | − | |
| 66 | − AV_WL16(src1 + i*4 + 0, gamma[r]); | |
| 67 | − AV_WL16(src1 + i*4 + 1, gamma[g]); | |
| 68 | − AV_WL16(src1 + i*4 + 2, gamma[b]); | |
| 69 | − } | |
| 70 | −} | |
| 71 | −#endif | |
| 72 | − | |
| 73 | 55 | static av_always_inline void fillPlane(uint8_t *plane, int stride, int width, |
| 74 | 56 | int height, int y, uint8_t val) |
| 75 | 57 | { |
| @@ -240,79 +222,6 @@ static void lumRangeFromJpeg16_c(int16_t *_dst, int width) · 164 unmodified lines | ||
| 240 | 222 | dst[i] = (dst[i]*(14071/4) + (33561947<<4)/4)>>12; |
| 241 | 223 | } |
| 242 | 224 | |
| 243 | −#ifndef NEW_FILTER | |
| 244 | −// *** horizontal scale Y line to temp buffer | |
| 245 | −static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth, | |
| 246 | − const uint8_t *src_in[4], | |
| 247 | − int srcW, int xInc, | |
| 248 | − const int16_t *hLumFilter, | |
| 249 | − const int32_t *hLumFilterPos, | |
| 250 | − int hLumFilterSize, | |
| 251 | − uint8_t *formatConvBuffer, | |
| 252 | − uint32_t *pal, int isAlpha) | |
| 253 | −{ | |
| 254 | − void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) = | |
| 255 | − isAlpha ? c->alpToYV12 : c->lumToYV12; | |
| 256 | − void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; | |
| 257 | − const uint8_t *src = src_in[isAlpha ? 3 : 0]; | |
| 258 | − | |
| 259 | − if (toYV12) { | |
| 260 | − toYV12(formatConvBuffer, src, src_in[1], src_in[2], srcW, pal); | |
| 261 | − src = formatConvBuffer; | |
| 262 | − } else if (c->readLumPlanar && !isAlpha) { | |
| 263 | − c->readLumPlanar(formatConvBuffer, src_in, srcW, c->input_rgb2yuv_table); | |
| 264 | − src = formatConvBuffer; | |
| 265 | − } else if (c->readAlpPlanar && isAlpha) { | |
| 266 | − c->readAlpPlanar(formatConvBuffer, src_in, srcW, NULL); | |
| 267 | − src = formatConvBuffer; | |
| 268 | − } | |
| 269 | − | |
| 270 | − if (!c->hyscale_fast) { | |
| 271 | − c->hyScale(c, dst, dstWidth, src, hLumFilter, | |
| 272 | − hLumFilterPos, hLumFilterSize); | |
| 273 | − } else { // fast bilinear upscale / crap downscale | |
| 274 | − c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc); | |
| 275 | − } | |
| 276 | − | |
| 277 | − if (convertRange) | |
| 278 | − convertRange(dst, dstWidth); | |
| 279 | −} | |
| 280 | − | |
| 281 | −static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, | |
| 282 | − int16_t *dst2, int dstWidth, | |
| 283 | − const uint8_t *src_in[4], | |
| 284 | − int srcW, int xInc, | |
| 285 | − const int16_t *hChrFilter, | |
| 286 | − const int32_t *hChrFilterPos, | |
| 287 | − int hChrFilterSize, | |
| 288 | − uint8_t *formatConvBuffer, uint32_t *pal) | |
| 289 | −{ | |
| 290 | − const uint8_t *src1 = src_in[1], *src2 = src_in[2]; | |
| 291 | − if (c->chrToYV12) { | |
| 292 | − uint8_t *buf2 = formatConvBuffer + | |
| 293 | − FFALIGN(srcW*2+78, 16); | |
| 294 | − c->chrToYV12(formatConvBuffer, buf2, src_in[0], src1, src2, srcW, pal); | |
| 295 | − src1= formatConvBuffer; | |
| 296 | − src2= buf2; | |
| 297 | − } else if (c->readChrPlanar) { | |
| 298 | − uint8_t *buf2 = formatConvBuffer + | |
| 299 | − FFALIGN(srcW*2+78, 16); | |
| 300 | − c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW, c->input_rgb2yuv_table); | |
| 301 | − src1 = formatConvBuffer; | |
| 302 | − src2 = buf2; | |
| 303 | − } | |
| 304 | − | |
| 305 | − if (!c->hcscale_fast) { | |
| 306 | − c->hcScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize); | |
| 307 | − c->hcScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize); | |
| 308 | − } else { // fast bilinear upscale / crap downscale | |
| 309 | − c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc); | |
| 310 | − } | |
| 311 | − | |
| 312 | − if (c->chrConvertRange) | |
| 313 | − c->chrConvertRange(dst1, dst2, dstWidth); | |
| 314 | −} | |
| 315 | −#endif /* NEW_FILTER */ | |
| 316 | 225 | |
| 317 | 226 | #define DEBUG_SWSCALE_BUFFERS 0 |
| 318 | 227 | #define DEBUG_BUFFERS(...) \ |
| @@ -325,46 +234,17 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 6 unmodified lines | ||
| 325 | 234 | { |
| 326 | 235 | /* load a few things into local vars to make the code more readable? |
| 327 | 236 | * and faster */ |
| 328 | −#ifndef NEW_FILTER | |
| 329 | − const int srcW = c->srcW; | |
| 330 | −#endif | |
| 331 | 237 | const int dstW = c->dstW; |
| 332 | 238 | const int dstH = c->dstH; |
| 333 | −#ifndef NEW_FILTER | |
| 334 | − const int chrDstW = c->chrDstW; | |
| 335 | − const int chrSrcW = c->chrSrcW; | |
| 336 | − const int lumXInc = c->lumXInc; | |
| 337 | − const int chrXInc = c->chrXInc; | |
| 338 | −#endif | |
| 239 | + | |
| 339 | 240 | const enum AVPixelFormat dstFormat = c->dstFormat; |
| 340 | 241 | const int flags = c->flags; |
| 341 | 242 | int32_t *vLumFilterPos = c->vLumFilterPos; |
| 342 | 243 | int32_t *vChrFilterPos = c->vChrFilterPos; |
| 343 | −#ifndef NEW_FILTER | |
| 344 | − int32_t *hLumFilterPos = c->hLumFilterPos; | |
| 345 | − int32_t *hChrFilterPos = c->hChrFilterPos; | |
| 346 | − int16_t *hLumFilter = c->hLumFilter; | |
| 347 | − int16_t *hChrFilter = c->hChrFilter; | |
| 348 | − int32_t *lumMmxFilter = c->lumMmxFilter; | |
| 349 | − int32_t *chrMmxFilter = c->chrMmxFilter; | |
| 350 | −#endif | |
| 244 | + | |
| 351 | 245 | const int vLumFilterSize = c->vLumFilterSize; |
| 352 | 246 | const int vChrFilterSize = c->vChrFilterSize; |
| 353 | −#ifndef NEW_FILTER | |
| 354 | − const int hLumFilterSize = c->hLumFilterSize; | |
| 355 | − const int hChrFilterSize = c->hChrFilterSize; | |
| 356 | − int16_t **lumPixBuf = c->lumPixBuf; | |
| 357 | − int16_t **chrUPixBuf = c->chrUPixBuf; | |
| 358 | − int16_t **chrVPixBuf = c->chrVPixBuf; | |
| 359 | −#endif | |
| 360 | − int16_t **alpPixBuf = c->alpPixBuf; | |
| 361 | − const int vLumBufSize = c->vLumBufSize; | |
| 362 | − const int vChrBufSize = c->vChrBufSize; | |
| 363 | −#ifndef NEW_FILTER | |
| 364 | − uint8_t *formatConvBuffer = c->formatConvBuffer; | |
| 365 | − uint32_t *pal = c->pal_yuv; | |
| 366 | − int perform_gamma = c->is_internal_gamma; | |
| 367 | −#endif | |
| 247 | + | |
| 368 | 248 | yuv2planar1_fn yuv2plane1 = c->yuv2plane1; |
| 369 | 249 | yuv2planarX_fn yuv2planeX = c->yuv2planeX; |
| 370 | 250 | yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX; |
| @@ -385,7 +265,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 14 unmodified lines | ||
| 385 | 265 | int lastInLumBuf = c->lastInLumBuf; |
| 386 | 266 | int lastInChrBuf = c->lastInChrBuf; |
| 387 | 267 | |
| 388 | −#ifdef NEW_FILTER | |
| 268 | + | |
| 389 | 269 | int lumStart = 0; |
| 390 | 270 | int lumEnd = c->descIndex[0]; |
| 391 | 271 | int chrStart = lumEnd; |
| @@ -397,15 +277,12 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 5 unmodified lines | ||
| 397 | 277 | SwsSlice *vout_slice = &c->slice[c->numSlice-1]; |
| 398 | 278 | SwsFilterDescriptor *desc = c->desc; |
| 399 | 279 | |
| 280 | + | |
| 281 | + int needAlpha = c->needAlpha; | |
| 282 | + | |
| 400 | 283 | int hasLumHoles = 1; |
| 401 | 284 | int hasChrHoles = 1; |
| 402 | −#endif | |
| 403 | 285 | |
| 404 | −#ifndef NEW_FILTER | |
| 405 | − if (!usePal(c->srcFormat)) { | |
| 406 | − pal = c->input_rgb2yuv_table; | |
| 407 | − } | |
| 408 | −#endif | |
| 409 | 286 | |
| 410 | 287 | if (isPacked(c->srcFormat)) { |
| 411 | 288 | src[0] = |
| @@ -427,8 +304,8 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 15 unmodified lines | ||
| 427 | 304 | dst[2], dstStride[2], dst[3], dstStride[3]); |
| 428 | 305 | DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n", |
| 429 | 306 | srcSliceY, srcSliceH, dstY, dstH); |
| 430 | − DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", | |
| 431 | − vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); | |
| 307 | + DEBUG_BUFFERS("vLumFilterSize: %d vChrFilterSize: %d\n", | |
| 308 | + vLumFilterSize, vChrFilterSize); | |
| 432 | 309 | |
| 433 | 310 | if (dstStride[0]&15 || dstStride[1]&15 || |
| 434 | 311 | dstStride[2]&15 || dstStride[3]&15) { |
| @@ -470,7 +347,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 35 unmodified lines | ||
| 470 | 347 | } |
| 471 | 348 | lastDstY = dstY; |
| 472 | 349 | |
| 473 | −#ifdef NEW_FILTER | |
| 474 | 350 | ff_init_vscale_pfn(c, yuv2plane1, yuv2planeX, yuv2nv12cX, |
| 475 | 351 | yuv2packed1, yuv2packed2, yuv2packedX, yuv2anyX, c->use_mmx_vfilter); |
| 476 | 352 | |
| @@ -492,18 +368,9 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 15 unmodified lines | ||
| 492 | 368 | hout_slice->plane[3].sliceH = 0; |
| 493 | 369 | hout_slice->width = dstW; |
| 494 | 370 | } |
| 495 | −#endif | |
| 496 | 371 | |
| 497 | 372 | for (; dstY < dstH; dstY++) { |
| 498 | 373 | const int chrDstY = dstY >> c->chrDstVSubSample; |
| 499 | −#ifndef NEW_FILTER | |
| 500 | − uint8_t *dest[4] = { | |
| 501 | − dst[0] + dstStride[0] * dstY, | |
| 502 | − dst[1] + dstStride[1] * chrDstY, | |
| 503 | − dst[2] + dstStride[2] * chrDstY, | |
| 504 | − (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, | |
| 505 | − }; | |
| 506 | −#endif | |
| 507 | 374 | int use_mmx_vfilter= c->use_mmx_vfilter; |
| 508 | 375 | |
| 509 | 376 | // First line needed as input |
| @@ -517,14 +384,13 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 7 unmodified lines | ||
| 517 | 384 | int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1; |
| 518 | 385 | int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1; |
| 519 | 386 | int enough_lines; |
| 520 | −#ifdef NEW_FILTER | |
| 387 | + | |
| 521 | 388 | int i; |
| 522 | 389 | int posY, cPosY, firstPosY, lastPosY, firstCPosY, lastCPosY; |
| 523 | −#endif | |
| 524 | 390 | |
| 525 | 391 | // handle holes (FAST_BILINEAR & weird filters) |
| 526 | 392 | if (firstLumSrcY > lastInLumBuf) { |
| 527 | −#ifdef NEW_FILTER | |
| 393 | + | |
| 528 | 394 | hasLumHoles = lastInLumBuf != firstLumSrcY - 1; |
| 529 | 395 | if (hasLumHoles) { |
| 530 | 396 | hout_slice->plane[0].sliceY = firstLumSrcY; |
| @@ -532,11 +398,11 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 1 unmodified line | ||
| 532 | 398 | hout_slice->plane[0].sliceH = |
| 533 | 399 | hout_slice->plane[3].sliceH = 0; |
| 534 | 400 | } |
| 535 | −#endif | |
| 401 | + | |
| 536 | 402 | lastInLumBuf = firstLumSrcY - 1; |
| 537 | 403 | } |
| 538 | 404 | if (firstChrSrcY > lastInChrBuf) { |
| 539 | −#ifdef NEW_FILTER | |
| 405 | + | |
| 540 | 406 | hasChrHoles = lastInChrBuf != firstChrSrcY - 1; |
| 541 | 407 | if (hasChrHoles) { |
| 542 | 408 | hout_slice->plane[1].sliceY = firstChrSrcY; |
| @@ -544,11 +410,11 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 1 unmodified line | ||
| 544 | 410 | hout_slice->plane[1].sliceH = |
| 545 | 411 | hout_slice->plane[2].sliceH = 0; |
| 546 | 412 | } |
| 547 | −#endif | |
| 413 | + | |
| 548 | 414 | lastInChrBuf = firstChrSrcY - 1; |
| 549 | 415 | } |
| 550 | − av_assert0(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1); | |
| 551 | − av_assert0(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1); | |
| 416 | + av_assert0(firstLumSrcY >= lastInLumBuf - vLumFilterSize + 1); | |
| 417 | + av_assert0(firstChrSrcY >= lastInChrBuf - vChrFilterSize + 1); | |
| 552 | 418 | |
| 553 | 419 | DEBUG_BUFFERS("dstY: %d\n", dstY); |
| 554 | 420 | DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n", |
| @@ -567,7 +433,6 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 12 unmodified lines | ||
| 567 | 433 | lastLumSrcY, lastChrSrcY); |
| 568 | 434 | } |
| 569 | 435 | |
| 570 | −#ifdef NEW_FILTER | |
| 571 | 436 | posY = hout_slice->plane[0].sliceY + hout_slice->plane[0].sliceH; |
| 572 | 437 | if (posY <= lastLumSrcY && !hasLumHoles) { |
| 573 | 438 | firstPosY = FFMAX(firstLumSrcY, posY); |
| @@ -604,62 +469,11 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 30 unmodified lines | ||
| 604 | 469 | chrBufIndex += lastChrSrcY - lastInChrBuf; |
| 605 | 470 | lastInChrBuf = lastChrSrcY; |
| 606 | 471 | |
| 607 | −#else | |
| 608 | − // Do horizontal scaling | |
| 609 | − while (lastInLumBuf < lastLumSrcY) { | |
| 610 | − const uint8_t *src1[4] = { | |
| 611 | − src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0], | |
| 612 | − src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1], | |
| 613 | − src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2], | |
| 614 | − src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3], | |
| 615 | − }; | |
| 616 | − lumBufIndex++; | |
| 617 | − av_assert0(lumBufIndex < 2 * vLumBufSize); | |
| 618 | − av_assert0(lastInLumBuf + 1 - srcSliceY < srcSliceH); | |
| 619 | − av_assert0(lastInLumBuf + 1 - srcSliceY >= 0); | |
| 620 | − | |
| 621 | − if (perform_gamma) | |
| 622 | − gamma_convert((uint8_t **)src1, srcW, c->inv_gamma); | |
| 623 | − | |
| 624 | − hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc, | |
| 625 | − hLumFilter, hLumFilterPos, hLumFilterSize, | |
| 626 | − formatConvBuffer, pal, 0); | |
| 627 | − if (CONFIG_SWSCALE_ALPHA && alpPixBuf) | |
| 628 | − hyscale(c, alpPixBuf[lumBufIndex], dstW, src1, srcW, | |
| 629 | − lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, | |
| 630 | − formatConvBuffer, pal, 1); | |
| 631 | − lastInLumBuf++; | |
| 632 | − DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n", | |
| 633 | − lumBufIndex, lastInLumBuf); | |
| 634 | − } | |
| 635 | − while (lastInChrBuf < lastChrSrcY) { | |
| 636 | − const uint8_t *src1[4] = { | |
| 637 | − src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0], | |
| 638 | − src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1], | |
| 639 | − src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2], | |
| 640 | − src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3], | |
| 641 | − }; | |
| 642 | − chrBufIndex++; | |
| 643 | − av_assert0(chrBufIndex < 2 * vChrBufSize); | |
| 644 | − av_assert0(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH)); | |
| 645 | − av_assert0(lastInChrBuf + 1 - chrSrcSliceY >= 0); | |
| 646 | − // FIXME replace parameters through context struct (some at least) | |
| 647 | − | |
| 648 | − if (c->needs_hcscale) | |
| 649 | − hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex], | |
| 650 | − chrDstW, src1, chrSrcW, chrXInc, | |
| 651 | − hChrFilter, hChrFilterPos, hChrFilterSize, | |
| 652 | − formatConvBuffer, pal); | |
| 653 | − lastInChrBuf++; | |
| 654 | − DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n", | |
| 655 | − chrBufIndex, lastInChrBuf); | |
| 656 | − } | |
| 657 | −#endif | |
| 658 | 472 | // wrap buf index around to stay inside the ring buffer |
| 659 | − if (lumBufIndex >= vLumBufSize) | |
| 660 | − lumBufIndex -= vLumBufSize; | |
| 661 | − if (chrBufIndex >= vChrBufSize) | |
| 662 | − chrBufIndex -= vChrBufSize; | |
| 473 | + if (lumBufIndex >= vLumFilterSize) | |
| 474 | + lumBufIndex -= vLumFilterSize; | |
| 475 | + if (chrBufIndex >= vChrFilterSize) | |
| 476 | + chrBufIndex -= vChrFilterSize; | |
| 663 | 477 | if (!enough_lines) |
| 664 | 478 | break; // we can't output a dstY line so let's try with the next slice |
| 665 | 479 | |
| @@ -682,119 +496,11 @@ static int swscale(SwsContext *c, const uint8_t *src[], · 16 unmodified lines | ||
| 682 | 496 | } |
| 683 | 497 | |
| 684 | 498 | { |
| 685 | −#ifdef NEW_FILTER | |
| 686 | 499 | for (i = vStart; i < vEnd; ++i) |
| 687 | 500 | desc[i].process(c, &desc[i], dstY, 1); |
| 688 | −#else | |
| 689 | − const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
| 690 | − const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
| 691 | − const int16_t **chrVSrcPtr = (const int16_t **)(void*) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
| 692 | − const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? | |
| 693 | − (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; | |
| 694 | − int16_t *vLumFilter = c->vLumFilter; | |
| 695 | − int16_t *vChrFilter = c->vChrFilter; | |
| 696 | − | |
| 697 | − if (isPlanarYUV(dstFormat) || | |
| 698 | − (isGray(dstFormat) && !isALPHA(dstFormat))) { // YV12 like | |
| 699 | − const int chrSkipMask = (1 << c->chrDstVSubSample) - 1; | |
| 700 | − | |
| 701 | − vLumFilter += dstY * vLumFilterSize; | |
| 702 | − vChrFilter += chrDstY * vChrFilterSize; | |
| 703 | − | |
| 704 | −// av_assert0(use_mmx_vfilter != ( | |
| 705 | −// yuv2planeX == yuv2planeX_10BE_c | |
| 706 | −// || yuv2planeX == yuv2planeX_10LE_c | |
| 707 | −// || yuv2planeX == yuv2planeX_9BE_c | |
| 708 | −// || yuv2planeX == yuv2planeX_9LE_c | |
| 709 | −// || yuv2planeX == yuv2planeX_16BE_c | |
| 710 | −// || yuv2planeX == yuv2planeX_16LE_c | |
| 711 | −// || yuv2planeX == yuv2planeX_8_c) || !ARCH_X86); | |
| 712 | − | |
| 713 | − if(use_mmx_vfilter){ | |
| 714 | − vLumFilter= (int16_t *)c->lumMmxFilter; | |
| 715 | − vChrFilter= (int16_t *)c->chrMmxFilter; | |
| 716 | − } | |
| 717 | − | |
| 718 | − if (vLumFilterSize == 1) { | |
| 719 | − yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0); | |
| 720 | − } else { | |
| 721 | − yuv2planeX(vLumFilter, vLumFilterSize, | |
| 722 | − lumSrcPtr, dest[0], | |
| 723 | − dstW, c->lumDither8, 0); | |
| 724 | − } | |
| 725 | − | |
| 726 | − if (!((dstY & chrSkipMask) || isGray(dstFormat))) { | |
| 727 | − if (yuv2nv12cX) { | |
| 728 | − yuv2nv12cX(c, vChrFilter, | |
| 729 | − vChrFilterSize, chrUSrcPtr, chrVSrcPtr, | |
| 730 | − dest[1], chrDstW); | |
| 731 | − } else if (vChrFilterSize == 1) { | |
| 732 | − yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0); | |
| 733 | − yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3); | |
| 734 | − } else { | |
| 735 | − yuv2planeX(vChrFilter, | |
| 736 | − vChrFilterSize, chrUSrcPtr, dest[1], | |
| 737 | − chrDstW, c->chrDither8, 0); | |
| 738 | − yuv2planeX(vChrFilter, | |
| 739 | − vChrFilterSize, chrVSrcPtr, dest[2], | |
| 740 | − chrDstW, c->chrDither8, use_mmx_vfilter ? (c->uv_offx2 >> 1) : 3); | |
| 741 | − } | |
| 742 | − } | |
| 743 | − | |
| 744 | − if (CONFIG_SWSCALE_ALPHA && alpPixBuf) { | |
| 745 | − if(use_mmx_vfilter){ | |
| 746 | − vLumFilter= (int16_t *)c->alpMmxFilter; | |
| 747 | − } | |
| 748 | − if (vLumFilterSize == 1) { | |
| 749 | − yuv2plane1(alpSrcPtr[0], dest[3], dstW, | |
| 750 | − c->lumDither8, 0); | |
| 751 | − } else { | |
| 752 | − yuv2planeX(vLumFilter, | |
| 753 | − vLumFilterSize, alpSrcPtr, dest[3], | |
| 754 | − dstW, c->lumDither8, 0); | |
| 755 | − } | |
| 756 | − } | |
| 757 | − } else if (yuv2packedX) { | |
| 758 | − av_assert1(lumSrcPtr + vLumFilterSize - 1 < (const int16_t **)lumPixBuf + vLumBufSize * 2); | |
| 759 | − av_assert1(chrUSrcPtr + vChrFilterSize - 1 < (const int16_t **)chrUPixBuf + vChrBufSize * 2); | |
| 760 | − if (c->yuv2packed1 && vLumFilterSize == 1 && | |
| 761 | − vChrFilterSize <= 2) { // unscaled RGB | |
| 762 | − int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1]; | |
| 763 | − yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr, | |
| 764 | − alpPixBuf ? *alpSrcPtr : NULL, | |
| 765 | − dest[0], dstW, chrAlpha, dstY); | |
| 766 | − } else if (c->yuv2packed2 && vLumFilterSize == 2 && | |
| 767 | − vChrFilterSize == 2) { // bilinear upscale RGB | |
| 768 | − int lumAlpha = vLumFilter[2 * dstY + 1]; | |
| 769 | − int chrAlpha = vChrFilter[2 * dstY + 1]; | |
| 770 | − lumMmxFilter[2] = | |
| 771 | − lumMmxFilter[3] = vLumFilter[2 * dstY] * 0x10001; | |
| 772 | − chrMmxFilter[2] = | |
| 773 | − chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001; | |
| 774 | − yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr, | |
| 775 | − alpPixBuf ? alpSrcPtr : NULL, | |
| 776 | − dest[0], dstW, lumAlpha, chrAlpha, dstY); | |
| 777 | − } else { // general RGB | |
| 778 | − yuv2packedX(c, vLumFilter + dstY * vLumFilterSize, | |
| 779 | − lumSrcPtr, vLumFilterSize, | |
| 780 | − vChrFilter + dstY * vChrFilterSize, | |
| 781 | − chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |
| 782 | − alpSrcPtr, dest[0], dstW, dstY); | |
| 783 | − } | |
| 784 | − } else { | |
| 785 | − av_assert1(!yuv2packed1 && !yuv2packed2); | |
| 786 | − yuv2anyX(c, vLumFilter + dstY * vLumFilterSize, | |
| 787 | − lumSrcPtr, vLumFilterSize, | |
| 788 | − vChrFilter + dstY * vChrFilterSize, | |
| 789 | − chrUSrcPtr, chrVSrcPtr, vChrFilterSize, | |
| 790 | − alpSrcPtr, dest, dstW, dstY); | |
| 791 | − } | |
| 792 | − if (perform_gamma) | |
| 793 | − gamma_convert(dest, dstW, c->gamma); | |
| 794 | −#endif | |
| 795 | 501 | } |
| 796 | 502 | } |
| 797 | − if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) { | |
| 503 | + if (isPlanar(dstFormat) && isALPHA(dstFormat) && !needAlpha) { | |
| 798 | 504 | int length = dstW; |
| 799 | 505 | int height = dstY - lastDstY; |
| 800 | 506 | |
| @@ -350,12 +350,6 @@ typedef struct SwsContext { · 349 unmodified lines | ||
| 350 | 350 | * vertical scaler is called. |
| 351 | 351 | */ |
| 352 | 352 | //@{ |
| 353 | − int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler. | |
| 354 | − int16_t **chrUPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler. | |
| 355 | − int16_t **chrVPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler. | |
| 356 | − int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler. | |
| 357 | − int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer. | |
| 358 | − int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer. | |
| 359 | 353 | int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer. |
| 360 | 354 | int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer. |
| 361 | 355 | int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source. |
| @@ -363,6 +357,7 @@ typedef struct SwsContext { · 1 unmodified line | ||
| 363 | 357 | //@} |
| 364 | 358 | |
| 365 | 359 | uint8_t *formatConvBuffer; |
| 360 | + int needAlpha; | |
| 366 | 361 | |
| 367 | 362 | /** |
| 368 | 363 | * @name Horizontal and vertical filters. |
| @@ -1038,7 +1033,4 @@ void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn · 669 unmodified lines | ||
| 1038 | 1033 | //number of extra lines to process |
| 1039 | 1034 | #define MAX_LINES_AHEAD 4 |
| 1040 | 1035 | |
| 1041 | −// enable use of refactored scaler code | |
| 1042 | −#define NEW_FILTER | |
| 1043 | − | |
| 1044 | 1036 | #endif /* SWSCALE_SWSCALE_INTERNAL_H */ |
| @@ -1696,69 +1696,14 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, · 1695 unmodified lines | ||
| 1696 | 1696 | #endif |
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | − // calculate buffer sizes so that they won't run out while handling these damn slices | |
| 1700 | − c->vLumBufSize = c->vLumFilterSize; | |
| 1701 | − c->vChrBufSize = c->vChrFilterSize; | |
| 1702 | − for (i = 0; i < dstH; i++) { | |
| 1703 | − int chrI = (int64_t)i * c->chrDstH / dstH; | |
| 1704 | − int nextSlice = FFMAX(c->vLumFilterPos[i] + c->vLumFilterSize - 1, | |
| 1705 | − ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1) | |
| 1706 | − << c->chrSrcVSubSample)); | |
| 1707 | − | |
| 1708 | − nextSlice >>= c->chrSrcVSubSample; | |
| 1709 | − nextSlice <<= c->chrSrcVSubSample; | |
| 1710 | − if (c->vLumFilterPos[i] + c->vLumBufSize < nextSlice) | |
| 1711 | − c->vLumBufSize = nextSlice - c->vLumFilterPos[i]; | |
| 1712 | − if (c->vChrFilterPos[chrI] + c->vChrBufSize < | |
| 1713 | − (nextSlice >> c->chrSrcVSubSample)) | |
| 1714 | − c->vChrBufSize = (nextSlice >> c->chrSrcVSubSample) - | |
| 1715 | − c->vChrFilterPos[chrI]; | |
| 1716 | − } | |
| 1717 | − | |
| 1718 | 1699 | for (i = 0; i < 4; i++) |
| 1719 | 1700 | FF_ALLOCZ_OR_GOTO(c, c->dither_error[i], (c->dstW+2) * sizeof(int), fail); |
| 1720 | 1701 | |
| 1721 | − /* Allocate pixbufs (we use dynamic allocation because otherwise we would | |
| 1722 | − * need to allocate several megabytes to handle all possible cases) */ | |
| 1723 | − FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail); | |
| 1724 | − FF_ALLOCZ_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); | |
| 1725 | − FF_ALLOCZ_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail); | |
| 1726 | − if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) | |
| 1727 | − FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail); | |
| 1728 | − /* Note we need at least one pixel more at the end because of the MMX code | |
| 1729 | − * (just in case someone wants to replace the 4000/8000). */ | |
| 1730 | − /* align at 16 bytes for AltiVec */ | |
| 1731 | − for (i = 0; i < c->vLumBufSize; i++) { | |
| 1732 | − FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i + c->vLumBufSize], | |
| 1733 | − dst_stride + 16, fail); | |
| 1734 | − c->lumPixBuf[i] = c->lumPixBuf[i + c->vLumBufSize]; | |
| 1735 | − } | |
| 1702 | + c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) ? 1 : 0; | |
| 1703 | + | |
| 1736 | 1704 | // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) |
| 1737 | 1705 | c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7); |
| 1738 | 1706 | c->uv_offx2 = dst_stride + 16; |
| 1739 | − for (i = 0; i < c->vChrBufSize; i++) { | |
| 1740 | − FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i + c->vChrBufSize], | |
| 1741 | − dst_stride * 2 + 32, fail); | |
| 1742 | − c->chrUPixBuf[i] = c->chrUPixBuf[i + c->vChrBufSize]; | |
| 1743 | − c->chrVPixBuf[i] = c->chrVPixBuf[i + c->vChrBufSize] | |
| 1744 | − = c->chrUPixBuf[i] + (dst_stride >> 1) + 8; | |
| 1745 | − } | |
| 1746 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) | |
| 1747 | − for (i = 0; i < c->vLumBufSize; i++) { | |
| 1748 | − FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i + c->vLumBufSize], | |
| 1749 | − dst_stride + 16, fail); | |
| 1750 | − c->alpPixBuf[i] = c->alpPixBuf[i + c->vLumBufSize]; | |
| 1751 | − } | |
| 1752 | − | |
| 1753 | − // try to avoid drawing green stuff between the right end and the stride end | |
| 1754 | − for (i = 0; i < c->vChrBufSize; i++) | |
| 1755 | − if(desc_dst->comp[0].depth == 16){ | |
| 1756 | − av_assert0(c->dstBpc > 14); | |
| 1757 | − for(j=0; j<dst_stride/2+1; j++) | |
| 1758 | − ((int32_t*)(c->chrUPixBuf[i]))[j] = 1<<18; | |
| 1759 | − } else | |
| 1760 | − for(j=0; j<dst_stride+1; j++) | |
| 1761 | − ((int16_t*)(c->chrUPixBuf[i]))[j] = 1<<14; | |
| 1762 | 1707 | |
| 1763 | 1708 | av_assert0(c->chrDstH <= dstH); |
| 1764 | 1709 | |
| @@ -2325,25 +2270,6 @@ void sws_freeContext(SwsContext *c) · 560 unmodified lines | ||
| 2325 | 2270 | if (!c) |
| 2326 | 2271 | return; |
| 2327 | 2272 | |
| 2328 | − if (c->lumPixBuf) { | |
| 2329 | − for (i = 0; i < c->vLumBufSize; i++) | |
| 2330 | − av_freep(&c->lumPixBuf[i]); | |
| 2331 | − av_freep(&c->lumPixBuf); | |
| 2332 | − } | |
| 2333 | − | |
| 2334 | − if (c->chrUPixBuf) { | |
| 2335 | − for (i = 0; i < c->vChrBufSize; i++) | |
| 2336 | − av_freep(&c->chrUPixBuf[i]); | |
| 2337 | − av_freep(&c->chrUPixBuf); | |
| 2338 | − av_freep(&c->chrVPixBuf); | |
| 2339 | − } | |
| 2340 | − | |
| 2341 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 2342 | − for (i = 0; i < c->vLumBufSize; i++) | |
| 2343 | − av_freep(&c->alpPixBuf[i]); | |
| 2344 | − av_freep(&c->alpPixBuf); | |
| 2345 | − } | |
| 2346 | − | |
| 2347 | 2273 | for (i = 0; i < 4; i++) |
| 2348 | 2274 | av_freep(&c->dither_error[i]); |
| 2349 | 2275 | |
| @@ -218,7 +218,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS · 217 unmodified lines | ||
| 218 | 218 | desc[0].instance = lumCtx; |
| 219 | 219 | desc[0].src = src; |
| 220 | 220 | desc[0].dst = dst; |
| 221 | − desc[0].alpha = c->alpPixBuf != 0; | |
| 221 | + desc[0].alpha = c->needAlpha; | |
| 222 | 222 | |
| 223 | 223 | if (!isGray(c->dstFormat)) { |
| 224 | 224 | chrCtx = av_mallocz(sizeof(VScalerContext)); |
| @@ -239,7 +239,7 @@ int ff_init_vscale(SwsContext *c, SwsFilterDescriptor *desc, SwsSlice *src, SwsS · 14 unmodified lines | ||
| 239 | 239 | desc[0].instance = lumCtx; |
| 240 | 240 | desc[0].src = src; |
| 241 | 241 | desc[0].dst = dst; |
| 242 | − desc[0].alpha = c->alpPixBuf != 0; | |
| 242 | + desc[0].alpha = c->needAlpha; | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | 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 · 84 unmodified lines | ||
| 85 | 85 | { |
| 86 | 86 | const int dstH= c->dstH; |
| 87 | 87 | const int flags= c->flags; |
| 88 | −#ifdef NEW_FILTER | |
| 88 | + | |
| 89 | 89 | SwsPlane *lumPlane = &c->slice[c->numSlice-2].plane[0]; |
| 90 | 90 | SwsPlane *chrUPlane = &c->slice[c->numSlice-2].plane[1]; |
| 91 | 91 | SwsPlane *alpPlane = &c->slice[c->numSlice-2].plane[3]; |
| 92 | −#else | |
| 93 | − int16_t **lumPixBuf= c->lumPixBuf; | |
| 94 | − int16_t **chrUPixBuf= c->chrUPixBuf; | |
| 95 | − int16_t **alpPixBuf= c->alpPixBuf; | |
| 96 | − const int vLumBufSize= c->vLumBufSize; | |
| 97 | − const int vChrBufSize= c->vChrBufSize; | |
| 98 | −#endif | |
| 99 | − int hasAlpha = c->alpPixBuf != NULL; | |
| 92 | + | |
| 93 | + int hasAlpha = c->needAlpha; | |
| 100 | 94 | int32_t *vLumFilterPos= c->vLumFilterPos; |
| 101 | 95 | int32_t *vChrFilterPos= c->vChrFilterPos; |
| 102 | 96 | int16_t *vLumFilter= c->vLumFilter; |
| @@ -117,22 +111,14 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB · 14 unmodified lines | ||
| 117 | 111 | c->greenDither= ff_dither4[dstY&1]; |
| 118 | 112 | c->redDither= ff_dither8[(dstY+1)&1]; |
| 119 | 113 | if (dstY < dstH - 2) { |
| 120 | −#ifdef NEW_FILTER | |
| 121 | 114 | const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPlane->line + firstLumSrcY - lumPlane->sliceY; |
| 122 | 115 | const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPlane->line + firstChrSrcY - chrUPlane->sliceY; |
| 123 | − const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL; | |
| 124 | −#else | |
| 125 | − const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; | |
| 126 | − const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; | |
| 127 | − const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; | |
| 128 | −#endif | |
| 116 | + const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && hasAlpha) ? (const int16_t **)(void*) alpPlane->line + firstLumSrcY - alpPlane->sliceY : NULL; | |
| 117 | + | |
| 129 | 118 | int i; |
| 130 | 119 | if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) { |
| 131 | −#ifdef NEW_FILTER | |
| 132 | 120 | const int16_t **tmpY = (const int16_t **) lumPlane->tmp; |
| 133 | −#else | |
| 134 | − const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize; | |
| 135 | −#endif | |
| 121 | + | |
| 136 | 122 | int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize); |
| 137 | 123 | for (i = 0; i < neg; i++) |
| 138 | 124 | tmpY[i] = lumSrcPtr[neg]; |
| @@ -143,11 +129,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB · 4 unmodified lines | ||
| 143 | 129 | lumSrcPtr = tmpY; |
| 144 | 130 | |
| 145 | 131 | if (alpSrcPtr) { |
| 146 | −#ifdef NEW_FILTER | |
| 147 | 132 | const int16_t **tmpA = (const int16_t **) alpPlane->tmp; |
| 148 | −#else | |
| 149 | − const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize; | |
| 150 | −#endif | |
| 151 | 133 | for (i = 0; i < neg; i++) |
| 152 | 134 | tmpA[i] = alpSrcPtr[neg]; |
| 153 | 135 | for ( ; i < end; i++) |
| @@ -158,11 +140,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrB · 4 unmodified lines | ||
| 158 | 140 | } |
| 159 | 141 | } |
| 160 | 142 | if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) { |
| 161 | −#ifdef NEW_FILTER | |
| 162 | 143 | const int16_t **tmpU = (const int16_t **) chrUPlane->tmp; |
| 163 | −#else | |
| 164 | − const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize; | |
| 165 | −#endif | |
| 166 | 144 | int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize); |
| 167 | 145 | for (i = 0; i < neg; i++) { |
| 168 | 146 | tmpU[i] = chrUSrcPtr[neg]; |
| @@ -479,7 +457,7 @@ switch(c->dstBpc){ \ · 310 unmodified lines | ||
| 479 | 457 | switch (c->srcFormat) { |
| 480 | 458 | case AV_PIX_FMT_YA8: |
| 481 | 459 | c->lumToYV12 = ff_yuyvToY_mmx; |
| 482 | − if (c->alpPixBuf) | |
| 460 | + if (c->needAlpha) | |
| 483 | 461 | c->alpToYV12 = ff_uyvyToY_mmx; |
| 484 | 462 | break; |
| 485 | 463 | case AV_PIX_FMT_YUYV422: |
| @@ -528,7 +506,7 @@ switch(c->dstBpc){ \ · 42 unmodified lines | ||
| 528 | 506 | switch (c->srcFormat) { |
| 529 | 507 | case AV_PIX_FMT_YA8: |
| 530 | 508 | c->lumToYV12 = ff_yuyvToY_sse2; |
| 531 | − if (c->alpPixBuf) | |
| 509 | + if (c->needAlpha) | |
| 532 | 510 | c->alpToYV12 = ff_uyvyToY_sse2; |
| 533 | 511 | break; |
| 534 | 512 | case AV_PIX_FMT_YUYV422: |
| @@ -348,7 +348,7 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, · 347 unmodified lines | ||
| 348 | 348 | x86_reg dstW_reg = dstW; |
| 349 | 349 | x86_reg uv_off = c->uv_offx2; |
| 350 | 350 | |
| 351 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 351 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 352 | 352 | YSCALEYUV2PACKEDX_ACCURATE |
| 353 | 353 | YSCALEYUV2RGBX |
| 354 | 354 | "movq %%mm2, "U_TEMP"(%0) \n\t" |
| @@ -381,7 +381,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, · 26 unmodified lines | ||
| 381 | 381 | x86_reg dstW_reg = dstW; |
| 382 | 382 | x86_reg uv_off = c->uv_offx2; |
| 383 | 383 | |
| 384 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 384 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 385 | 385 | YSCALEYUV2PACKEDX |
| 386 | 386 | YSCALEYUV2RGBX |
| 387 | 387 | 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, · 22 unmodified lines | ||
| 410 | 410 | x86_reg dstW_reg = dstW; |
| 411 | 411 | x86_reg uv_off = c->uv_offx2; |
| 412 | 412 | |
| 413 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 413 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 414 | 414 | YSCALEYUV2PACKEDX |
| 415 | 415 | YSCALEYUV2RGBX |
| 416 | 416 | 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], · 472 unmodified lines | ||
| 889 | 889 | const int16_t *buf0 = buf[0], *buf1 = buf[1], |
| 890 | 890 | *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; |
| 891 | 891 | |
| 892 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 892 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 893 | 893 | const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1]; |
| 894 | 894 | #if ARCH_X86_64 |
| 895 | 895 | __asm__ volatile( |
| @@ -1215,7 +1215,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, · 319 unmodified lines | ||
| 1215 | 1215 | |
| 1216 | 1216 | if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster |
| 1217 | 1217 | const int16_t *ubuf1 = ubuf[0]; |
| 1218 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 1218 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 1219 | 1219 | __asm__ volatile( |
| 1220 | 1220 | "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" |
| 1221 | 1221 | "mov %4, %%"REG_b" \n\t" |
| @@ -1244,7 +1244,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, · 22 unmodified lines | ||
| 1244 | 1244 | } |
| 1245 | 1245 | } else { |
| 1246 | 1246 | const int16_t *ubuf1 = ubuf[1]; |
| 1247 | − if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { | |
| 1247 | + if (CONFIG_SWSCALE_ALPHA && c->needAlpha) { | |
| 1248 | 1248 | __asm__ volatile( |
| 1249 | 1249 | "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" |
| 1250 | 1250 | "mov %4, %%"REG_b" \n\t" |