summaryrefslogtreecommitdiff
path: root/libavfilter/vf_zscale.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2022-03-14 20:34:00 +0100
committerMarton Balint <cus@passwd.hu>2022-03-16 20:20:56 +0100
commitea887ef8761e44bdef9e2a3daea08a0d2dcb8fef (patch)
tree833dcae56d8be531b68ecf97bef8b77ce95e5a13 /libavfilter/vf_zscale.c
parentd5722d578e6dd713c2b81536c23151044e0eb96f (diff)
downloadffmpeg-ea887ef8761e44bdef9e2a3daea08a0d2dcb8fef.tar.gz
avfilter/vf_zscale: realign output buffer if needed
Output buffer alignment might be different to ZIMG_ALIGNMENT or it may not be aligned at all if a downstream filter (e.g. vf_pad) intentionally misaligns it. Or maybe we should unconditionally always allocate output with av_frame_get_buffer() instead of ff_get_video_buffer()? Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/vf_zscale.c')
-rw-r--r--libavfilter/vf_zscale.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index ceefc95224..2061e38bcc 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -632,7 +632,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
return 0;
}
-static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame)
+static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy)
{
AVFrame *aligned = NULL;
int ret = 0, plane, planes;
@@ -654,10 +654,10 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame)
if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0)
goto fail;
- if ((ret = av_frame_copy(aligned, *frame)) < 0)
+ if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0)
goto fail;
- if ((ret = av_frame_copy_props(aligned, *frame)) < 0)
+ if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0)
goto fail;
av_frame_free(frame);
@@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
goto fail;
}
+ if ((ret = realign_frame(odesc, &out, 0)) < 0)
+ goto fail;
+
av_frame_copy_props(out, in);
- if ((ret = realign_frame(desc, &in)) < 0)
+ if ((ret = realign_frame(desc, &in, 1)) < 0)
goto fail;
snprintf(buf, sizeof(buf)-1, "%d", outlink->w);