Skip to content

Commit

Permalink
reuse code for get_subsampled_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Dec 18, 2024
1 parent 32ea2d7 commit 229dbd8
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions libheif/common_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}


Expand Down

0 comments on commit 229dbd8

Please sign in to comment.