From ec9e782a35bd37099ef3dec7d05418e05a6a004c Mon Sep 17 00:00:00 2001 From: Maryla Date: Mon, 13 Jun 2022 11:32:20 +0200 Subject: [PATCH] sharpyuv: remove minimum image size from sharpyuv library libwebp still has a size threshold of 4 pixels in picture_csp_enc.c but the sharpyuv library itself can handle any image size. Change-Id: Ic1c78c8f8fae528395fa46a74f717f47cb13098e --- sharpyuv/sharpyuv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sharpyuv/sharpyuv.c b/sharpyuv/sharpyuv.c index a1e75303..8b3ab721 100644 --- a/sharpyuv/sharpyuv.c +++ b/sharpyuv/sharpyuv.c @@ -14,8 +14,9 @@ #include "sharpyuv/sharpyuv.h" #include -#include +#include #include +#include #include #include "src/webp/types.h" @@ -27,7 +28,6 @@ // Sharp RGB->YUV conversion static const int kNumIterations = 4; -static const int kMinDimensionIterativeConversion = 4; #define YUV_FIX 16 // fixed-point precision for RGB->YUV static const int kYuvHalf = 1 << (YUV_FIX - 1); @@ -311,6 +311,8 @@ static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr, fixed_t* target_uv = target_uv_base; const uint64_t diff_y_threshold = (uint64_t)(3.0 * w * h); int ok; + assert(w > 0); + assert(h > 0); if (best_y_base == NULL || best_uv_base == NULL || target_y_base == NULL || target_uv_base == NULL || @@ -444,8 +446,7 @@ int SharpYuvConvert(const void* r_ptr, const void* g_ptr, const int yuv_max = (1 << yuv_bit_depth) - 1; const int sfix = GetPrecisionShift(rgb_bit_depth); - if (width < kMinDimensionIterativeConversion || - height < kMinDimensionIterativeConversion || + if (width < 1 || height < 1 || width == INT_MAX || height == INT_MAX || r_ptr == NULL || g_ptr == NULL || b_ptr == NULL || y_ptr == NULL || u_ptr == NULL || v_ptr == NULL) { return 0;