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); }