diff mbox series

[FFmpeg-devel] avfilter/vf_frei0r: set align to 1 for frei0r frames

Message ID 20220824084439.1581-1-ffmpeg@bendys.com
State Accepted
Commit 01b9abd7716cf24d3de870fd563e118d0d71123f
Headers show
Series [FFmpeg-devel] avfilter/vf_frei0r: set align to 1 for frei0r frames | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Brendan Hack Aug. 24, 2022, 8:44 a.m. UTC
The frei0r API requires linesize to be width * 4.
Since the align property of ff_default_get_video_buffer2
specifies line alignment, not buffer alignment, the
previous value of 16 breaks this requirement for frames
whose width is a multiple of 8, but not a multiple of 16
as it adds extra padding to ensure line aligment.

Fix Trac ticket #9873
---
 libavfilter/vf_frei0r.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 1e01114b76..58fa2245bf 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -359,14 +359,17 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     Frei0rContext *s = inlink->dst->priv;
     AVFilterLink *outlink = inlink->dst->outputs[0];
-    AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
+    /* align parameter is the line alignment, not the buffer alignment.
+     * frei0r expects line size to be width*4 so we want an align of 1
+     * to ensure lines aren't padded out. */
+    AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
     if (!out)
         goto fail;
 
     av_frame_copy_props(out, in);
 
     if (in->linesize[0] != out->linesize[0]) {
-        AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
+        AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
         if (!in2)
             goto fail;
         av_frame_copy(in2, in);
@@ -481,7 +484,7 @@  static int source_config_props(AVFilterLink *outlink)
 static int source_request_frame(AVFilterLink *outlink)
 {
     Frei0rContext *s = outlink->src->priv;
-    AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 16);
+    AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, outlink->h, 1);
 
     if (!frame)
         return AVERROR(ENOMEM);