diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-06-29 09:39:43 -0700 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-06-29 09:45:52 -0700 |
commit | ef1ee362b36893cd1cc1e9c7de378e9cb239b0e8 (patch) | |
tree | 22cef8fbcaf058673d151ca32ad157c2445d6d95 /libswscale/utils.c | |
parent | f68069868bd17a46f2dd80f87b712845f2fcfa56 (diff) | |
download | ffmpeg-ef1ee362b36893cd1cc1e9c7de378e9cb239b0e8.tar.gz |
swscale: implement >8bit scaling support.
This means that precision is retained when scaling between sample
formats with >8 bits per component (48bit RGB, 16bit grayscale,
9/10/16bit YUV).
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r-- | libswscale/utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 69714183d0..b7ccac94ba 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -877,8 +877,13 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) } } - FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2, fail); - if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { + // FIXME it's even nicer if bpp isn't 16, but max({src,dst}formatbpp) + 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) + 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) { 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) |