From patchwork Wed Jul 28 08:15:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29081 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp5254846ios; Wed, 28 Jul 2021 01:16:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+yQ1EzBoaAEQJvJKY2uDAtH85oWZyF+SvOwDJlLsQIThgDDbK0LfpyfgQDkNS5UyklWUm X-Received: by 2002:a17:906:4889:: with SMTP id v9mr25663234ejq.269.1627460190740; Wed, 28 Jul 2021 01:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627460190; cv=none; d=google.com; s=arc-20160816; b=QuW0nos0fyuqlwnNNG77Lf0978sQJUo11Q3cOR4u2XNv4iHvuETLVyhGaEO9djUQj5 niP/AFKDdwDbNJnYIm4mUGHjTx5Uc6gaS0sXzrfmun3UlTuK8qKWk3OkpxsxS0TBUiSB 5ThgnruarfimbOVtOI88ks/Hdpaq1d9QiU/ALnTSjk8wgSdQ/wfEGuolgCGuVnKI/zmP 34F5oP8fYi5WRoZ/piJ0XBQso/p9DJG+UbZjDLLUBAaRw1yS23OGr/1W5wYtXtcMsPkM LaamyiAcUO87uMglYTwFYOH6VQ2Bbu1XypS8TDHOQ4wxp4X/r30lFW+3kY0J5UrhK+dk PexQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=BQB8k45rntRTVDtKL7NL2EGzJ656gV2Y7hZ0jjGuxkA=; b=eVMZGIOLJ5Ow3E5TA5cpsNGHFEVQh29mGcxEC9N6KyVH1MG2Jd21Ebi+mBN/rDhEVk /lZFr2i5f8YquBgRwAAFs1FvtWhfey8ptJCm/1uiRS4ugNa1IZ82EdJUnC8VrVHVF6RG Hy9HhrzWam2WV67xfSwLf5smjd7ds1/y9vTickkHTL8LEiKZO8wl/o3tJlmsMmp+G6O2 n1FDdp9L5zIpPqyoLm9Z1ZU65vD83ol7Hv8i5OavC7fI5h8G7Z+iwwoLhjPNJjzEpmon fDCMID9QYHF8M8GeZKj3gtQInVXIayYsL1HuE4wn3zHPXFKcQ9EA0jCn6lLMtYzkcC2z Owzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l1si5334527edw.438.2021.07.28.01.16.30; Wed, 28 Jul 2021 01:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 293B7688128; Wed, 28 Jul 2021 11:16:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B86F68A03A for ; Wed, 28 Jul 2021 11:16:19 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212601800" X-IronPort-AV: E=Sophos;i="5.84,275,1620716400"; d="scan'208";a="212601800" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 01:16:17 -0700 X-IronPort-AV: E=Sophos;i="5.84,275,1620716400"; d="scan'208";a="456412043" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 01:16:16 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Jul 2021 16:15:47 +0800 Message-Id: <20210728081547.26105-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210728081547.26105-1-haihao.xiang@intel.com> References: <20210728081547.26105-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH 2/2] lavc/qsvenc: pass the color properties to the SDK 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 Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dBmJGTA+zll3 Otherwise the color properties won't be encoded into the bitstream header --- libavcodec/qsvenc.c | 18 ++++++++++++++++++ libavcodec/qsvenc.h | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f6fa759447..e7e65ebfcf 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -805,6 +805,24 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } #endif + q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); + q->extvsi.ColourDescriptionPresent = 0; + + if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + avctx->color_trc != AVCOL_TRC_UNSPECIFIED || + avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { + q->extvsi.ColourDescriptionPresent = 1; + q->extvsi.ColourPrimaries = avctx->color_primaries; + q->extvsi.TransferCharacteristics = avctx->color_trc; + q->extvsi.MatrixCoefficients = avctx->colorspace; + } + + if (q->extvsi.VideoFullRange || q->extvsi.ColourDescriptionPresent) { + q->extvsi.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO; + q->extvsi.Header.BufferSz = sizeof(q->extvsi); + q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvsi; + } + if (!check_enc_param(avctx,q)) { av_log(avctx, AV_LOG_ERROR, "some encoding parameters are not supported by the QSV " diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 6d305f87dd..fc8a14143e 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -139,7 +139,9 @@ typedef struct QSVEncContext { mfxFrameSurface1 **opaque_surfaces; AVBufferRef *opaque_alloc_buf; - mfxExtBuffer *extparam_internal[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + (QSV_HAVE_MF * 2)]; + mfxExtVideoSignalInfo extvsi; + + mfxExtBuffer *extparam_internal[3 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + (QSV_HAVE_MF * 2)]; int nb_extparam_internal; mfxExtBuffer **extparam;