From: Zhao Zhili via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Zhao Zhili <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avutil/imgutils: use AV_CEIL_RSHIFT (PR #21254)
Date: Sun, 21 Dec 2025 14:06:18 -0000
Message-ID: <176632597925.60.11811881692086830865@2cb04c0e5124> (raw)
PR #21254 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21254
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21254.patch
>From 51cb9498ae15496df6c38b298c153d6b170c3dc5 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <zhilizhao@tencent.com>
Date: Sun, 21 Dec 2025 21:40:33 +0800
Subject: [PATCH] avutil/imgutils: use AV_CEIL_RSHIFT
---
libavutil/imgutils.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 681482dc08..8ff8a6be41 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -63,7 +63,7 @@ int image_get_linesize(int width, int plane,
if (width < 0)
return AVERROR(EINVAL);
s = (max_step_comp == 1 || max_step_comp == 2) ? desc->log2_chroma_w : 0;
- shifted_w = ((width + (1 << s) - 1)) >> s;
+ shifted_w = AV_CEIL_RSHIFT(width, s);
if (shifted_w && max_step > INT_MAX / shifted_w)
return AVERROR(EINVAL);
linesize = max_step * shifted_w;
@@ -133,7 +133,7 @@ int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt,
for (i = 1; i < 4 && has_plane[i]; i++) {
int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
- h = (height + (1 << s) - 1) >> s;
+ h = AV_CEIL_RSHIFT(height, s);
if (linesizes[i] > SIZE_MAX / h)
return AVERROR(EINVAL);
sizes[i] = (size_t)h * linesizes[i];
@@ -523,7 +523,7 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
for (i = 0; i < nb_planes; i++) {
int h, shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
const uint8_t *src = src_data[i];
- h = (height + (1 << shift) - 1) >> shift;
+ h = AV_CEIL_RSHIFT(height, shift);
for (j = 0; j < h; j++) {
memcpy(dst, src, linesize[i]);
@@ -646,7 +646,7 @@ int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz
size_t bytewidth = plane_line_bytes[plane];
uint8_t *data = dst_data[plane];
int chroma_div = plane == 1 || plane == 2 ? desc->log2_chroma_h : 0;
- int plane_h = ((height + ( 1 << chroma_div) - 1)) >> chroma_div;
+ int plane_h = AV_CEIL_RSHIFT(height, chroma_div);
for (; plane_h > 0; plane_h--) {
memset_bytes(data, bytewidth, &clear_block[plane][0], clear_block_size[plane]);
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-12-21 14:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176632597925.60.11811881692086830865@2cb04c0e5124 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git