Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Wenbin Chen <wenbin.chen-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc
Date: Wed, 30 Mar 2022 14:43:49 +0800
Message-ID: <20220330064349.850881-2-wenbin.chen@intel.com> (raw)
In-Reply-To: <20220330064349.850881-1-wenbin.chen@intel.com>

Qsv encoder only support input P010 and nv12 format directly from system
memory. For other format, we need to upload frame to device memory and
input qsv format to encoder. Now add other system memory format support
to qsv encoder.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvenc.c      | 30 ++++--------------------------
 libavcodec/qsvenc_hevc.c |  2 ++
 2 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 55ce3d2499..eb94ab0650 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1606,32 +1606,10 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
         else if (frame->repeat_pict == 4)
             qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
 
-        qf->surface.Data.PitchLow  = qf->frame->linesize[0];
-        qf->surface.Data.Y         = qf->frame->data[0];
-        qf->surface.Data.UV        = qf->frame->data[1];
-
-        /* The SDK checks Data.V when using system memory for VP9 encoding */
-        switch (frame->format) {
-        case AV_PIX_FMT_NV12:
-            qf->surface.Data.V     = qf->surface.Data.UV + 1;
-            break;
-
-        case AV_PIX_FMT_P010:
-            qf->surface.Data.V     = qf->surface.Data.UV + 2;
-            break;
-
-        case AV_PIX_FMT_X2RGB10:
-        case AV_PIX_FMT_BGRA:
-            qf->surface.Data.B         = qf->frame->data[0];
-            qf->surface.Data.G         = qf->frame->data[0] + 1;
-            qf->surface.Data.R         = qf->frame->data[0] + 2;
-            qf->surface.Data.A         = qf->frame->data[0] + 3;
-            break;
-
-        default:
-            /* should not reach here */
-            av_assert0(0);
-            break;
+        ret = ff_qsv_map_frame_to_surface(qf->frame, &qf->surface);
+        if (ret < 0) {
+            av_log(q->avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
+            return AVERROR(EINVAL);
         }
     }
     qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 5c1571f62f..1814774655 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -303,6 +303,8 @@ const FFCodec ff_hevc_qsv_encoder = {
     .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
                                                     AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_YUYV422,
+                                                    AV_PIX_FMT_Y210,
                                                     AV_PIX_FMT_QSV,
 #if QSV_VERSION_ATLEAST(1, 17)
                                                     AV_PIX_FMT_BGRA,
-- 
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-30  6:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30  6:43 [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Wenbin Chen
2022-03-30  6:43 ` Wenbin Chen [this message]
2022-04-02  9:01 ` Xiang, Haihao
2022-04-02  9:26   ` Chen, Wenbin

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=20220330064349.850881-2-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