From: Wenbin Chen <wenbin.chen-at-intel.com@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] libavutil/hwcontext_qsv: Align width and heigh when download qsv frame Date: Thu, 31 Mar 2022 15:43:41 +0800 Message-ID: <20220331074341.896911-1-wenbin.chen@intel.com> (raw) The width and height for qsv frame to download need to be aligned with 16. Add the alignment operation. Now the following command works: ffmpeg -hwaccel qsv -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i \ input.yuv -vf "hwupload=extra_hw_frames=16,format=qsv,hwdownload, \ format=nv12" -f null - Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> --- libavutil/hwcontext_qsv.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 95f8071abe..1e7c065902 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1063,6 +1063,40 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if (ret < 0) return ret; + /* According to MSDK spec for mfxframeinfo, "Width must be a multiple of 16. + * Height must be a multiple of 16 for progressive frame sequence and a + * multiple of 32 otherwise.", so allign all frames to 16 before downloading. */ + if (ctx->height & 15 || dst->linesize[0] & 15) { + AVFrame *tmp_frame; + tmp_frame = av_frame_alloc(); + if (!tmp_frame) + return AVERROR(ENOMEM); + ret = av_frame_ref(tmp_frame, dst); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + av_frame_unref(dst); + + dst->width = FFALIGN(tmp_frame->width, 16); + dst->height = FFALIGN(ctx->height, 16); + dst->format = tmp_frame->format; + ret = av_frame_get_buffer(dst, 0); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + + dst->width = tmp_frame->width; + dst->height = tmp_frame->height; + ret = av_frame_copy_props(dst, tmp_frame); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + av_frame_free(&tmp_frame); + } + if (!s->session_download) { if (s->child_frames_ref) return qsv_transfer_data_child(ctx, dst, src); -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2022-03-31 7:44 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220331074341.896911-1-wenbin.chen@intel.com \ --to=wenbin.chen-at-intel.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git