[FFmpeg-cvslog] avutil/frame: fix setting plane_padding

James Almer git at videolan.org
Fri Nov 22 16:13:32 EET 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sat Nov 16 13:12:50 2024 -0300| [ea91d978e3be77de42f4b93194a286108de5720f] | committer: James Almer

avutil/frame: fix setting plane_padding

STRIDE_ALIGN is a lavc define and is not necessarely 32. And align may be <= 0 at the
point plane_padding is being set.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea91d978e3be77de42f4b93194a286108de5720f
---

 libavutil/frame.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index f42f310023..093853b173 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -174,7 +174,7 @@ static int get_video_buffer(AVFrame *frame, int align)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
     int ret, padded_height;
-    int plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align);
+    int plane_padding;
     ptrdiff_t linesizes[4];
     size_t total_size, sizes[4];
 
@@ -184,10 +184,11 @@ static int get_video_buffer(AVFrame *frame, int align)
     if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0)
         return ret;
 
-    if (!frame->linesize[0]) {
-        if (align <= 0)
-            align = ALIGN;
+    if (align <= 0)
+        align = ALIGN;
+    plane_padding = FFMAX(ALIGN, align);
 
+    if (!frame->linesize[0]) {
         for (int i = 1; i <= align; i += i) {
             ret = av_image_fill_linesizes(frame->linesize, frame->format,
                                           FFALIGN(frame->width, i));



More information about the ffmpeg-cvslog mailing list