[FFmpeg-cvslog] avfilter/vf_zscale: align the frame buffers

James Almer git at videolan.org
Sun Nov 17 17:37:44 EET 2024


ffmpeg | branch: release/7.1 | James Almer <jamrial at gmail.com> | Sat Nov  9 16:55:38 2024 -0300| [99f6adce60727d8e4244d4871baf3907ac545111] | committer: James Almer

avfilter/vf_zscale: align the frame buffers

Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit c8e5c684b3db1a3131af5d05a3073114bd87477a)

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

 libavfilter/vf_zscale.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index a35cd1cdf7..afd22ce6c6 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -658,7 +658,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
     return 0;
 }
 
-static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
+static int realign_frame(AVFilterLink *link, const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
 {
     AVFrame *aligned = NULL;
     int ret = 0, plane, planes;
@@ -668,17 +668,9 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int ne
     for (plane = 0; plane < planes; plane++) {
         int p = desc->comp[plane].plane;
         if ((uintptr_t)(*frame)->data[p] % ZIMG_ALIGNMENT || (*frame)->linesize[p] % ZIMG_ALIGNMENT) {
-            if (!(aligned = av_frame_alloc())) {
-                ret = AVERROR(ENOMEM);
-                goto fail;
-            }
-
-            aligned->format = (*frame)->format;
-            aligned->width  = (*frame)->width;
-            aligned->height = (*frame)->height;
-
-            if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)
-                goto fail;
+            aligned = ff_default_get_video_buffer2(link, (*frame)->width, (*frame)->height, ZIMG_ALIGNMENT);
+            if (!aligned)
+                return AVERROR(ENOMEM);
 
             if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
                 goto fail;
@@ -807,20 +799,17 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
         (s->src_format.pixel_type !=s->dst_format.pixel_type) ||
         (s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
     ){
-        out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+        out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, ZIMG_ALIGNMENT);
         if (!out) {
             ret =  AVERROR(ENOMEM);
             goto fail;
         }
 
-        if ((ret = realign_frame(odesc, &out, 0)) < 0)
-            goto fail;
-
         av_frame_copy_props(out, in);
         out->colorspace = outlink->colorspace;
         out->color_range = outlink->color_range;
 
-        if ((ret = realign_frame(desc, &in, 1)) < 0)
+        if ((ret = realign_frame(link, desc, &in, 1)) < 0)
             goto fail;
 
         snprintf(buf, sizeof(buf)-1, "%d", outlink->w);



More information about the ffmpeg-cvslog mailing list