diff mbox

[FFmpeg-devel] libavfilter/vf_scale_cuda: fix frame dimensions

Message ID 1557351171-11114-1-git-send-email-svechnikov66@gmail.com
State New
Headers show

Commit Message

Sergey Svechnikov May 8, 2019, 9:32 p.m. UTC
AVHWFramesContext has aligned width and height.
When initializing a new AVFrame, it receives these aligned values (in av_hwframe_get_buffer), which leads to incorrect scaling.
The resulting frames are cropped either horizontally or vertically.
As a fix we can overwrite the dimensions to original values right after av_hwframe_get_buffer.
More info, samples and reproduction steps are here https://github.com/Svechnikov/ffmpeg-scale-cuda-problem
---
 libavfilter/vf_scale_cuda.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index c97a802..ef1bd82 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -463,6 +463,9 @@  static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
     if (ret < 0)
         return ret;
 
+    s->tmp_frame->width = s->planes_out[0].width;
+    s->tmp_frame->height = s->planes_out[0].height;
+
     av_frame_move_ref(out, s->frame);
     av_frame_move_ref(s->frame, s->tmp_frame);