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 EA4FC42952 for ; Thu, 6 Oct 2022 07:38:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EDB3B68BBA7; Thu, 6 Oct 2022 10:38:11 +0300 (EEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E131768BBA5 for ; Thu, 6 Oct 2022 10:38:04 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665041890; x=1696577890; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=YyAHGYzBmXCjpNky0GKh/umuXVSgB6Y4D2OA/20CYJQ=; b=c4cbHybf6yMrOyhJ3iJVaqr6jXBM0w41evVagEPTqBYvIDXJxqAl++x8 XCFUmNOBGTQoVBwgCwnSIjdCKvDi1tjAD9U09ZRO9IsY3xNbO0c7I90aw QbLCeKIVtwlhYLGMvwZfM0oNVHlUpuHcavcNC01PRI7QSrFFdz8w1PwrT 2U5o1jvFPs3q9ypMRxtQNWP7ZWkxMOWbbAgaAjWIl1CpcTmDunFYFzhYu QBDbtepV4S5gX+Z+CVut25pHwu+AFMfjPnZWMLr1zkf9Mf+qeoiI8OwuI Cy/JtHSyGePF5OX4vvNrWby+NSgSPn6w5jKzV8fqFmVPlPJVqTBhraAKI A==; X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="300974387" X-IronPort-AV: E=Sophos;i="5.95,163,1661842800"; d="scan'208";a="300974387" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2022 00:38:01 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="687318979" X-IronPort-AV: E=Sophos;i="5.95,163,1661842800"; d="scan'208";a="687318979" Received: from xhh-dg164.sh.intel.com ([10.238.5.169]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2022 00:38:00 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Oct 2022 15:35:34 +0800 Message-Id: <20221006073538.27710-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221006073538.27710-1-haihao.xiang@intel.com> References: <20221006073538.27710-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH 2/6] lavc/qsv: specify Shift for each format too 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 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: From: Haihao Xiang Signed-off-by: Haihao Xiang --- libavcodec/qsv.c | 9 ++++++++- libavcodec/qsv_internal.h | 2 +- libavcodec/qsvenc.c | 6 ++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 51aac16695..4e11b33a7d 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -217,35 +217,42 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc) return AV_PIX_FMT_NONE; } -int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) +int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc, uint16_t *shift) { switch (format) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVJ420P: case AV_PIX_FMT_NV12: *fourcc = MFX_FOURCC_NV12; + *shift = 0; return AV_PIX_FMT_NV12; case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_P010: *fourcc = MFX_FOURCC_P010; + *shift = 1; return AV_PIX_FMT_P010; case AV_PIX_FMT_X2RGB10: *fourcc = MFX_FOURCC_A2RGB10; + *shift = 1; return AV_PIX_FMT_X2RGB10; case AV_PIX_FMT_BGRA: *fourcc = MFX_FOURCC_RGB4; + *shift = 0; return AV_PIX_FMT_BGRA; #if CONFIG_VAAPI case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUYV422: *fourcc = MFX_FOURCC_YUY2; + *shift = 0; return AV_PIX_FMT_YUYV422; case AV_PIX_FMT_YUV422P10: case AV_PIX_FMT_Y210: *fourcc = MFX_FOURCC_Y210; + *shift = 1; return AV_PIX_FMT_Y210; case AV_PIX_FMT_VUYX: *fourcc = MFX_FOURCC_AYUV; + *shift = 0; return AV_PIX_FMT_VUYX; #endif default: diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index f914956596..f95e23c5e8 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -132,7 +132,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id); enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc); -int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc); +int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc, uint16_t *shift); enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type); enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct); diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 398fa6ff22..dc5479d0f3 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -553,7 +553,7 @@ static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q) if (!desc) return AVERROR_BUG; - ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); + ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC, &q->param.mfx.FrameInfo.Shift); if (ret < 0) return AVERROR_BUG; @@ -567,7 +567,6 @@ static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q) !desc->log2_chroma_w + !desc->log2_chroma_h; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; - q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16); q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 16); @@ -653,7 +652,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) if (!desc) return AVERROR_BUG; - ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); + ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC, &q->param.mfx.FrameInfo.Shift); if (ret < 0) return AVERROR_BUG; @@ -667,7 +666,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) !desc->log2_chroma_w + !desc->log2_chroma_h; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; - q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; // If the minor version is greater than or equal to 19, // then can use the same alignment settings as H.264 for HEVC -- 2.17.1 _______________________________________________ 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".