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 31EE2429CE for ; Fri, 10 Jun 2022 12:58:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B93368B7BF; Fri, 10 Jun 2022 15:58:52 +0300 (EEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 186E168B62E for ; Fri, 10 Jun 2022 15:58:44 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654865930; x=1686401930; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=eX3Ug+5ttrTexyHj5p3BRBSnNfKSUyQyquqKAwGGwv4=; b=gOcAuSH3+pfVP4VcoAszFx4t4MZTlqDZsUnVZToO7Ij4D/At6duLDLBJ cTPTDF0gWBBx/j+6wY+vro5Kh67N7tkv1b3oaTH3u19qUiIrXHlpK4Q04 gH49yZ7k/FGEIEobtdzMooUd4E5n3mjeSRqwXF9BGkDulaRj4Ic0Zx4Jl MZ+eca6lESvFIy1fcML+oVXfbxxorqAJbN0Bo6bbV6w/5Mjvfn+I3Sh2Y 4fzxSh6ktvxC8S538NC/6gt86QTPzIdPEpySKp4k0pm9srFBZNMDE/Z2e QPVAmNi6xuZW9rv/RP1Cd/q05dGuqGhec+WmxHHSNQVHqlODinoscLEsV Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="339373722" X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="339373722" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 05:54:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,290,1647327600"; d="scan'208";a="724958944" Received: from t.sh.intel.com ([10.239.159.147]) by fmsmga001.fm.intel.com with ESMTP; 10 Jun 2022 05:54:32 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Jun 2022 20:47:47 +0800 Message-Id: <20220610124747.2767836-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way 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: Xu Guangxin , Linjie Fu , Fei Wang 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: Xu Guangxin For range extension, the luma/chroma offset is larger than 8 bits, we need fill the 16 bits version. Signed-off-by: Xu Guangxin Signed-off-by: Linjie Fu Signed-off-by: Fei Wang --- update: 1. Add some warning log. libavcodec/vaapi_hevc.c | 55 +++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index 9083331c45..d82975979a 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -322,11 +322,20 @@ fail: return ret; } -static void fill_pred_weight_table(const HEVCContext *h, +static void fill_pred_weight_table(AVCodecContext *avctx, + const HEVCContext *h, const SliceHeader *sh, VASliceParameterBufferHEVC *slice_param) { int i; +#if VA_CHECK_VERSION(1, 2, 0) + int is_rext = avctx->profile >= FF_PROFILE_HEVC_REXT; +#else + int is_rext = 0; + if (avctx->profile >= FF_PROFILE_HEVC_REXT) + av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI 1.2.0 " + "or above, which can support REXT related setting correctly.\n"); +#endif memset(slice_param->delta_luma_weight_l0, 0, sizeof(slice_param->delta_luma_weight_l0)); memset(slice_param->delta_luma_weight_l1, 0, sizeof(slice_param->delta_luma_weight_l1)); @@ -353,21 +362,25 @@ static void fill_pred_weight_table(const HEVCContext *h, for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) { slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 << sh->luma_log2_weight_denom); - slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i]; slice_param->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom); slice_param->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom); - slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0]; - slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1]; + if (!is_rext) { + slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i]; + slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0]; + slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1]; + } } if (sh->slice_type == HEVC_SLICE_B) { for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) { slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom); - slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i]; slice_param->delta_chroma_weight_l1[i][0] = sh->chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom); slice_param->delta_chroma_weight_l1[i][1] = sh->chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom); - slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0]; - slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1]; + if (!is_rext) { + slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i]; + slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0]; + slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1]; + } } } } @@ -462,7 +475,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]); } - fill_pred_weight_table(h, sh, last_slice_param); + fill_pred_weight_table(avctx, h, sh, last_slice_param); #if VA_CHECK_VERSION(1, 2, 0) if (avctx->profile == FF_PROFILE_HEVC_REXT) { @@ -471,15 +484,25 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, .cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag, }, }; + for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) { + pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i]; + pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0]; + pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1]; + } + + for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) { + pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i]; + pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0]; + pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1]; + } - memcpy(pic->last_slice_param.rext.luma_offset_l0, pic->last_slice_param.base.luma_offset_l0, - sizeof(pic->last_slice_param.base.luma_offset_l0)); - memcpy(pic->last_slice_param.rext.luma_offset_l1, pic->last_slice_param.base.luma_offset_l1, - sizeof(pic->last_slice_param.base.luma_offset_l1)); - memcpy(pic->last_slice_param.rext.ChromaOffsetL0, pic->last_slice_param.base.ChromaOffsetL0, - sizeof(pic->last_slice_param.base.ChromaOffsetL0)); - memcpy(pic->last_slice_param.rext.ChromaOffsetL1, pic->last_slice_param.base.ChromaOffsetL1, - sizeof(pic->last_slice_param.base.ChromaOffsetL1)); + if (sh->slice_type == HEVC_SLICE_B) { + for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) { + pic->last_slice_param.rext.luma_offset_l1[i] = sh->luma_offset_l1[i]; + pic->last_slice_param.rext.ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0]; + pic->last_slice_param.rext.ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1]; + } + } } #endif -- 2.25.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".