From 229dbd80fd1290e97018ae2953d74fc3985a54f8 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Thu, 19 Dec 2024 00:27:43 +0100 Subject: [PATCH] reuse code for get_subsampled_size() --- libheif/common_utils.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libheif/common_utils.cc b/libheif/common_utils.cc index 649738527a..188810b1dd 100644 --- a/libheif/common_utils.cc +++ b/libheif/common_utils.cc @@ -87,6 +87,7 @@ uint32_t get_subsampled_size_h(uint32_t width, } } + uint32_t get_subsampled_size_v(uint32_t height, heif_channel channel, heif_chroma chroma, @@ -112,25 +113,14 @@ uint32_t get_subsampled_size_v(uint32_t height, } } + void get_subsampled_size(uint32_t width, uint32_t height, heif_channel channel, heif_chroma chroma, uint32_t* subsampled_width, uint32_t* subsampled_height) { - if (channel == heif_channel_Cb || - channel == heif_channel_Cr) { - uint8_t chromaSubH = chroma_h_subsampling(chroma); - uint8_t chromaSubV = chroma_v_subsampling(chroma); - - // NOLINTNEXTLINE(clang-analyzer-core.DivideZero) - *subsampled_width = (width + chromaSubH - 1) / chromaSubH; - // NOLINTNEXTLINE(clang-analyzer-core.DivideZero) - *subsampled_height = (height + chromaSubV - 1) / chromaSubV; - } - else { - *subsampled_width = width; - *subsampled_height = height; - } + *subsampled_width = get_subsampled_size_h(width, channel, chroma, scaling_mode::round_up); + *subsampled_height = get_subsampled_size_v(height, channel, chroma, scaling_mode::round_up); }