aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2024-11-09 16:55:38 -0300
committerJames Almer <jamrial@gmail.com>2024-11-09 19:33:56 -0300
commitc8e5c684b3db1a3131af5d05a3073114bd87477a (patch)
treebb2a998e54a52424e50d3419f6de0339b65b30ac
parent00cf3df03f66dca44568b5b5d3e9da35d3597470 (diff)
downloadffmpeg-c8e5c684b3db1a3131af5d05a3073114bd87477a.tar.gz
avfilter/vf_zscale: align the frame buffers
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavfilter/vf_zscale.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 65e685960d..356dc152c6 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -660,7 +660,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;
@@ -670,17 +670,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;
@@ -809,20 +801,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);