Created
May 24, 2019 16:00
-
-
Save j0sh/6b5d52d51c09bcf321c3b77c0468af9b to your computer and use it in GitHub Desktop.
Revisions
-
j0sh created this gist
May 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ From 5db9543bdf466a7894e5532c10618e42c162da83 Mon Sep 17 00:00:00 2001 From: Josh Allmann <[email protected]> Date: Fri, 24 May 2019 15:30:32 +0000 Subject: [PATCH] lavfi/vf_scale_cuda: Reset frame size after acquiring from hwframe. The first frame is scaled correctly, and subsequent frames are over-scaled / cropped since the frame data is reset with the hwframe after each invocation of the scaler. The hwframe-allocated frame has a width/height that is 32-bit aligned. The scaler uses this aligned width / height as its target, leading to "over-scaling" and then cropping of the result. To generate a broken test sample: ffmpeg -hwaccel cuvid -c:v h264_cuvid -i <input> -an \ -lavfi scale_cuda=w=426:h=240 -c:v h264_nvenc <output> --- libavfilter/vf_scale_cuda.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index 6b1ef2bb6f..13eb3ad24c 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -489,6 +489,8 @@ static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in) av_frame_move_ref(out, s->frame); av_frame_move_ref(s->frame, s->tmp_frame); + s->frame->width = s->planes_out[0].width; + s->frame->height= s->planes_out[0].height; ret = av_frame_copy_props(out, in); if (ret < 0) -- 2.17.1