From e87a501e7d03ac68b58520108fe24ad9d0b36765 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 25 Sep 2016 16:23:20 +0200 Subject: [PATCH] swscale: Update bitdepth range check Make sure the scaling functions for the 9-15bits are used for 9-15bits bit depths correctly. --- libswscale/swscale.c | 6 +++--- libswscale/swscale_internal.h | 2 +- libswscale/x86/swscale.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 131980855c..142c79c14a 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -731,7 +731,7 @@ static av_cold void sws_init_swscale(SwsContext *c) ff_sws_init_input_funcs(c); if (c->srcBpc == 8) { - if (c->dstBpc <= 10) { + if (c->dstBpc <= 15) { c->hyScale = c->hcScale = hScale8To15_c; if (c->flags & SWS_FAST_BILINEAR) { c->hyscale_fast = hyscale_fast_c; @@ -741,12 +741,12 @@ static av_cold void sws_init_swscale(SwsContext *c) c->hyScale = c->hcScale = hScale8To19_c; } } else { - c->hyScale = c->hcScale = c->dstBpc > 10 ? hScale16To19_c + c->hyScale = c->hcScale = c->dstBpc > 15 ? hScale16To19_c : hScale16To15_c; } if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { - if (c->dstBpc <= 10) { + if (c->dstBpc <= 15) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_c; c->chrConvertRange = chrRangeFromJpeg_c; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 84f8dd339f..625bd864a4 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -569,7 +569,7 @@ static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); av_assert0(desc); - return desc->comp[0].depth == 9 || desc->comp[0].depth == 10; + return desc->comp[0].depth >= 9 && desc->comp[0].depth <= 15; } static av_always_inline int isBE(enum AVPixelFormat pix_fmt) diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index ec774678d5..48b5b49ce8 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -316,16 +316,16 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c) #define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \ if (c->srcBpc == 8) { \ - hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \ + hscalefn = c->dstBpc <= 15 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \ ff_hscale8to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 9) { \ - hscalefn = c->dstBpc <= 10 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \ + hscalefn = c->dstBpc <= 15 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \ ff_hscale9to19_ ## filtersize ## _ ## opt1; \ } else if (c->srcBpc == 10) { \ - hscalefn = c->dstBpc <= 10 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ + hscalefn = c->dstBpc <= 15 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ ff_hscale10to19_ ## filtersize ## _ ## opt1; \ - } else /* c->srcBpc == 16 */ { \ - hscalefn = c->dstBpc <= 10 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ + } else if (c->srcBpc == 16) { \ + hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ ff_hscale16to19_ ## filtersize ## _ ## opt1; \ } \ } while (0) @@ -340,14 +340,14 @@ switch(c->dstBpc){ \ case 16: do_16_case; break; \ case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ - default: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ + case 8: if (condition_8bit) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ } #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ switch(c->dstBpc){ \ case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ - default: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ + case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ } #define case_rgb(x, X, opt) \ case AV_PIX_FMT_ ## X: \