* [FFmpeg-devel] [PATCH v2] libavutil/hwcontext_qsv: Align width and heigh when download qsv frame
@ 2022-04-02 11:59 Wenbin Chen
0 siblings, 0 replies; only message in thread
From: Wenbin Chen @ 2022-04-02 11:59 UTC (permalink / raw)
To: ffmpeg-devel
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 | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 95f8071abe..fe11e215a8 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1063,6 +1063,38 @@ 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 (dst->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->linesize[0], 16);
+ dst->height = FFALIGN(tmp_frame->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);
+ av_frame_free(&tmp_frame);
+ if (ret < 0)
+ return ret;
+ }
+
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-02 12:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02 11:59 [FFmpeg-devel] [PATCH v2] libavutil/hwcontext_qsv: Align width and heigh when download qsv frame Wenbin Chen
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