From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 201EF43EC7 for ; Wed, 17 Aug 2022 06:51:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1EEA368B786; Wed, 17 Aug 2022 09:51:57 +0300 (EEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5A3F68B4D0 for ; Wed, 17 Aug 2022 09:51:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660719116; x=1692255116; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=j4fScC/8nsPW0JDTrMUnvKNs5TsoDsVoqtSSBKkxN10=; b=QksWpTQ+KeDM8dP3uezeZ8Jlszjea++vH6sqlv/HRbXwoV4T7O4ksTTx Fq88ZI6DVdxHMlCBuO5EoBwA4OmE0c/5epRKh8JWns4IaHE3A/nURbC1g 84YH7CLkJjSawNNIvs6qdBfCrck2rswD5vvZVfQsjIGn1p7ijvyGIe2WL ubAegGZXuQizlaeRB94ywbUjy+bw4i/llt1mdh0taH+RMlwaWJBiaU6CT 5Cv7WrWsYhRhEmHkNmr02sfUGxQLQLJBA8fMT25zPhSyU4TNgkupfJd48 65CWP8Ux8P3RGSOQCr+UpZWgtJCpuvbsjsfJlxxXKvzRcoBjHfvnaOCX7 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10441"; a="279382693" X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="279382693" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2022 23:51:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,242,1654585200"; d="scan'208";a="583641902" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga006.jf.intel.com with ESMTP; 16 Aug 2022 23:51:47 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Aug 2022 14:49:50 +0800 Message-Id: <20220817064950.95841-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec/qsvenc_hevc: add main10sp support to hevc_qsv X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Main10sp is a combination of Main10 and one_pic_only flag. This profile encode 10bit single still picture. A option "main10sp" is added to ffmpeg-qsv. This option set MFX_PROFILE_HEVC_MAIN10 profile and MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY flag to enable main10sp in ffmpeg-qsv. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 33 +++++++++++++++++++++++++++++++-- libavcodec/qsvenc.h | 6 +++++- libavcodec/qsvenc_hevc.c | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6d73f74196..da6f1213c8 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3627,6 +3627,10 @@ range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively. @item @var{int_ref_cycle_dist} Distance between the beginnings of the intra-refresh cycles in frames. +@item @var{main10sp} +This option allows to encode 10 bit single still picture. This feature is only +supported in vpl runtime. + @item @var{max_qp_i} Maximum video quantizer scale for I frame. diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 4831640868..ab3500403e 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -185,6 +185,7 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtCodingOption3 *co3 = NULL; mfxExtHEVCTiles *exthevctiles = NULL; const char *tmp_str = NULL; + mfxExtHEVCParam *exthevcparam = NULL; if (q->co2_idx > 0) co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; @@ -195,6 +196,8 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, if (q->exthevctiles_idx > 0) exthevctiles = (mfxExtHEVCTiles *)coding_opts[q->exthevctiles_idx]; + if (q->exthevcparam_idx > 0) + exthevcparam = (mfxExtHEVCParam *)coding_opts[q->exthevcparam_idx]; av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -343,6 +346,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "NumTileColumns: %"PRIu16"; NumTileRows: %"PRIu16"\n", exthevctiles->NumTileColumns, exthevctiles->NumTileRows); } + + if (exthevcparam && + exthevcparam->GeneralConstraintFlags == MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY && + avctx->codec_id == AV_CODEC_ID_HEVC && + info->CodecProfile == MFX_PROFILE_HEVC_MAIN10) + av_log(avctx, AV_LOG_VERBOSE, "Main10sp (Main10 profile and one_pic_only flag): enable\n"); } static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, @@ -956,6 +965,18 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevctiles; } + if (avctx->codec_id == AV_CODEC_ID_HEVC && q->main10sp) { + if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 0)) { + q->param.mfx.CodecProfile = MFX_PROFILE_HEVC_MAIN10; + q->exthevcparam.Header.BufferId = MFX_EXTBUFF_HEVC_PARAM; + q->exthevcparam.Header.BufferSz = sizeof(q->exthevcparam); + q->exthevcparam.GeneralConstraintFlags = MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY; + q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevcparam; + } else + av_log(avctx, AV_LOG_WARNING, + "This version of runtime doesn't support 10bit single still picture\n"); + } + q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); q->extvsi.ColourDescriptionPresent = 0; @@ -1098,12 +1119,16 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) .Header.BufferSz = sizeof(hevc_tile_buf), }; - mfxExtBuffer *ext_buffers[6]; + mfxExtHEVCParam hevc_param_buf = { + .Header.BufferId = MFX_EXTBUFF_HEVC_PARAM, + .Header.BufferSz = sizeof(hevc_param_buf), + }; + mfxExtBuffer *ext_buffers[7]; int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; int ret, ext_buf_num = 0, extradata_offset = 0; - q->co2_idx = q->co3_idx = q->exthevctiles_idx = -1; + q->co2_idx = q->co3_idx = q->exthevctiles_idx = q->exthevcparam_idx = -1; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co; @@ -1125,6 +1150,10 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) q->exthevctiles_idx = ext_buf_num; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf; } + if (avctx->codec_id == AV_CODEC_ID_HEVC && QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 0)) { + q->exthevcparam_idx = ext_buf_num; + ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_param_buf; + } q->param.ExtParam = ext_buffers; q->param.NumExtParam = ext_buf_num; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index d35a1318f2..1df4e26583 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -138,6 +138,7 @@ typedef struct QSVEncContext { mfxExtMultiFrameControl extmfc; #endif mfxExtHEVCTiles exthevctiles; + mfxExtHEVCParam exthevcparam; mfxExtVP9Param extvp9param; #if QSV_HAVE_OPAQUE @@ -148,7 +149,7 @@ typedef struct QSVEncContext { mfxExtVideoSignalInfo extvsi; - mfxExtBuffer *extparam_internal[5 + (QSV_HAVE_MF * 2)]; + mfxExtBuffer *extparam_internal[6 + (QSV_HAVE_MF * 2)]; int nb_extparam_internal; mfxExtBuffer **extparam; @@ -235,6 +236,9 @@ typedef struct QSVEncContext { float old_i_quant_offset; float old_b_quant_factor; float old_b_quant_offset; + + int exthevcparam_idx; + int main10sp; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index e11f5dec4a..3f1a8cdf93 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -271,6 +271,9 @@ static const AVOption options[] = { { "int_ref_qp_delta", "QP difference for the refresh MBs", OFFSET(qsv.int_ref_qp_delta), AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX, VE }, { "int_ref_cycle_dist", "Distance between the beginnings of the intra-refresh cycles in frames", OFFSET(qsv.int_ref_cycle_dist), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE }, +#if QSV_ONEVPL + { "main10sp", "This option allows to encode 10 bit single still picture", OFFSET(qsv.main10sp), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, +#endif { NULL }, }; -- 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".