diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-08-02 15:42:35 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-08-12 11:54:25 -0700 |
commit | 28c1115a915e4e198bfb6bd39909b2d1327c1454 (patch) | |
tree | 3c39829d2a10105f780da17c7a7593cab35887b8 /libswscale/utils.c | |
parent | b2c087871dafc7d030b2d48457ddff597dfd4925 (diff) | |
download | ffmpeg-28c1115a915e4e198bfb6bd39909b2d1327c1454.tar.gz |
swscale: use 15-bit intermediates for 9/10-bit scaling.
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r-- | libswscale/utils.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 525a370e7c..2b52199a35 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -853,12 +853,18 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - c->scalingBpp = FFMAX(av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1, - av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1) >= 8 ? 16 : 8; - if (c->scalingBpp == 16) + c->srcBpc = 1 + av_pix_fmt_descriptors[srcFormat].comp[0].depth_minus1; + if (c->srcBpc < 8) + c->srcBpc = 8; + c->dstBpc = 1 + av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1; + if (c->dstBpc < 8) + c->dstBpc = 8; + if (c->dstBpc == 16) dst_stride <<= 1; - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2 * c->scalingBpp >> 3, fail); - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->scalingBpp == 8) { + FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, + FFALIGN(srcW, 16) * 2 * FFALIGN(c->srcBpc, 8) >> 3, + fail); + if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2 && c->srcBpc == 8 && c->dstBpc <= 10) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { if (flags&SWS_PRINT_INFO) @@ -1011,8 +1017,8 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) 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) - c->uv_off_px = dst_stride_px + 64 / c->scalingBpp; + // 64 / (c->dstBpc & ~7) is the same as 16 / sizeof(scaling_intermediate) + c->uv_off_px = dst_stride_px + 64 / (c->dstBpc &~ 7); c->uv_off_byte = 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); |