From patchwork Wed Jan 15 07:01:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17371 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6214:1865:0:0:0:0 with SMTP id eh5csp245938qvb; Tue, 14 Jan 2020 23:01:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyXwlG6Ew/nv/NaZeoUKqV+/N2CtALCqkzoRbiytU243eEMBq5Pw0/kwoMlTxpgxIBrEJkJ X-Received: by 2002:a17:906:709:: with SMTP id y9mr26399360ejb.58.1579071666051; Tue, 14 Jan 2020 23:01:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579071666; cv=none; d=google.com; s=arc-20160816; b=nzAKLjuCsCfmIttxNc2qIl/skQz8zsOpxNCP82OwMQENDOK4YSku4WKDf9GG4c8+z0 px3lmVIQzE6R+43TXnCYXwRzKdjLg3kD2jF2LftGA/EU7kiTKwXPDuaUkp6T1fNAy43d +w1P5MjSsnG9RgKm11zsVR7HgXjT8/we6011I4fFFNbm41/NqVtN/bDewDxvo1ciuUiw 8O5BVPA5pgENxigCgiX/IWky1XlcnII/tMjfQADyVFfNZEOcysREz5GHtepkm757JGuu LLfryozMIaeImy+DUt6b5LW6RRLIrs7OoZMaRDFyybnHBxBGveblYdbHayJ2GYB0PeJY P3Tw== 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:message-id:date:to:from:delivered-to; bh=LVd2eEKG7ix1S0Z3hOoGd8w0dBtHKSdde8ny3wDx8hM=; b=uZa5FwlgsAr59XUU4G6g+gxoJpQHvLAQMHgjKVJdd5CPTu6xw12YQNPBO0918qUPnS CWb77ygeM5nTz8cDEQ/MWVFuuOPV05U1geDHTzzplQ6xdqttFwulx9LOrvGswlKP7+KS rsisuuVJ7Arf+bREiSTAgp2SzJEOyXU2KNokNaUlBsveawuInqYerzs0RBkEQa4o3eM0 vBMQx+DuC+N9cgd2LI/jWn/DwExInRrCWM+pXXfmJSEDz5G0PFTBK3f+E6+oidMccMVY GfKHdp00YOt/OnkpGPyYavQbriwDhZHJVbJVlnnXs+riev9MDZ4KiG/a9VceoggCyyqa +eNg== 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 u10si11921306edx.388.2020.01.14.23.01.05; Tue, 14 Jan 2020 23:01:06 -0800 (PST) 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 77BF268B0D7; Wed, 15 Jan 2020 09:01:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5252680052 for ; Wed, 15 Jan 2020 09:00:55 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 23:00:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="225474095" Received: from unknown (HELO icl-dev.sh.intel.com) ([10.239.158.73]) by orsmga003.jf.intel.com with ESMTP; 14 Jan 2020 23:00:52 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jan 2020 15:01:05 +0800 Message-Id: <1579071665-12454-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH 4/9] lavc/vaapi_hevc: extend parameter buffer to ParameterBufferHEVCExtension X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: n86RKXvfBmeC Content-Length: 14744 Extend ParameterBufferHEVC to ParameterBufferHEVCExtension for both VAPicture and VASlice. Pass Range Extension flags to support the decode for HEVC REXT. Signed-off-by: Linjie Fu --- libavcodec/vaapi_hevc.c | 104 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 19 deletions(-) diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index c69d63d..ee54e44 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -29,8 +29,13 @@ #include "vaapi_decode.h" typedef struct VAAPIDecodePictureHEVC { +#if VA_CHECK_VERSION(1, 2, 0) + VAPictureParameterBufferHEVCExtension pic_param; + VASliceParameterBufferHEVCExtension last_slice_param; +#else VAPictureParameterBufferHEVC pic_param; VASliceParameterBufferHEVC last_slice_param; +#endif const uint8_t *last_buffer; size_t last_size; @@ -117,11 +122,13 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, const HEVCPPS *pps = h->ps.pps; const ScalingList *scaling_list = NULL; - int err, i; + int pic_param_size, err, i; + + VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->pic_param; pic->pic.output_surface = ff_vaapi_get_surface_id(h->ref->frame); - pic->pic_param = (VAPictureParameterBufferHEVC) { + *pic_param = (VAPictureParameterBufferHEVC) { .pic_width_in_luma_samples = sps->width, .pic_height_in_luma_samples = sps->height, .log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3, @@ -188,29 +195,61 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx, }, }; - fill_vaapi_pic(&pic->pic_param.CurrPic, h->ref, 0); - fill_vaapi_reference_frames(h, &pic->pic_param); + fill_vaapi_pic(&pic_param->CurrPic, h->ref, 0); + fill_vaapi_reference_frames(h, pic_param); if (pps->tiles_enabled_flag) { - pic->pic_param.num_tile_columns_minus1 = pps->num_tile_columns - 1; - pic->pic_param.num_tile_rows_minus1 = pps->num_tile_rows - 1; + pic_param->num_tile_columns_minus1 = pps->num_tile_columns - 1; + pic_param->num_tile_rows_minus1 = pps->num_tile_rows - 1; for (i = 0; i < pps->num_tile_columns; i++) - pic->pic_param.column_width_minus1[i] = pps->column_width[i] - 1; + pic_param->column_width_minus1[i] = pps->column_width[i] - 1; for (i = 0; i < pps->num_tile_rows; i++) - pic->pic_param.row_height_minus1[i] = pps->row_height[i] - 1; + pic_param->row_height_minus1[i] = pps->row_height[i] - 1; } if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) { - pic->pic_param.st_rps_bits = h->sh.short_term_ref_pic_set_size; + pic_param->st_rps_bits = h->sh.short_term_ref_pic_set_size; } else { - pic->pic_param.st_rps_bits = 0; + pic_param->st_rps_bits = 0; + } + +#if VA_CHECK_VERSION(1, 2, 0) + if (avctx->profile == FF_PROFILE_HEVC_REXT) { + pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) { + .range_extension_pic_fields.bits = { + .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled_flag, + .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled_flag, + .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled_flag, + .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled_flag, + .extended_precision_processing_flag = sps->extended_precision_processing_flag, + .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled_flag, + .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled_flag, + .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled_flag, + .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled_flag, + .cross_component_prediction_enabled_flag = pps->cross_component_prediction_enabled_flag, + .chroma_qp_offset_list_enabled_flag = pps->chroma_qp_offset_list_enabled_flag, + }, + .diff_cu_chroma_qp_offset_depth = pps->diff_cu_chroma_qp_offset_depth, + .chroma_qp_offset_list_len_minus1 = pps->chroma_qp_offset_list_len_minus1, + .log2_sao_offset_scale_luma = pps->log2_sao_offset_scale_luma, + .log2_sao_offset_scale_chroma = pps->log2_sao_offset_scale_chroma, + .log2_max_transform_skip_block_size_minus2 = pps->log2_max_transform_skip_block_size - 2, + }; + + for (i = 0; i < 6; i++) + pic->pic_param.rext.cb_qp_offset_list[i] = pps->cb_qp_offset_list[i]; + for (i = 0; i < 6; i++) + pic->pic_param.rext.cr_qp_offset_list[i] = pps->cr_qp_offset_list[i]; } +#endif + pic_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ? + sizeof(pic->pic_param) : sizeof(VAPictureParameterBufferHEVC); err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic, VAPictureParameterBufferType, - &pic->pic_param, sizeof(pic->pic_param)); + &pic->pic_param, pic_param_size); if (err < 0) goto fail; @@ -255,12 +294,16 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx) { const HEVCContext *h = avctx->priv_data; VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private; + VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param; int ret; + int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ? + sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC); + if (pic->last_size) { - pic->last_slice_param.LongSliceFlags.fields.LastSliceOfPic = 1; + last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1; ret = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic, - &pic->last_slice_param, sizeof(pic->last_slice_param), + &pic->last_slice_param, slice_param_size, pic->last_buffer, pic->last_size); if (ret < 0) goto fail; @@ -330,7 +373,7 @@ static void fill_pred_weight_table(const HEVCContext *h, static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame) { VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private; - VAPictureParameterBufferHEVC *pp = &pic->pic_param; + VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->pic_param; uint8_t i; if (!frame) @@ -353,6 +396,10 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, const HEVCContext *h = avctx->priv_data; const SliceHeader *sh = &h->sh; VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private; + VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param; + + int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ? + sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC); int nb_list = (sh->slice_type == HEVC_SLICE_B) ? 2 : (sh->slice_type == HEVC_SLICE_I ? 0 : 1); @@ -361,7 +408,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, if (!sh->first_slice_in_pic_flag) { err = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic, - &pic->last_slice_param, sizeof(pic->last_slice_param), + &pic->last_slice_param, slice_param_size, pic->last_buffer, pic->last_size); pic->last_buffer = NULL; pic->last_size = 0; @@ -371,7 +418,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, } } - pic->last_slice_param = (VASliceParameterBufferHEVC) { + *last_slice_param = (VASliceParameterBufferHEVC) { .slice_data_size = size, .slice_data_offset = 0, .slice_data_flag = VA_SLICE_DATA_FLAG_ALL, @@ -404,16 +451,35 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, }, }; - memset(pic->last_slice_param.RefPicList, 0xFF, sizeof(pic->last_slice_param.RefPicList)); + memset(last_slice_param->RefPicList, 0xFF, sizeof(last_slice_param->RefPicList)); for (list_idx = 0; list_idx < nb_list; list_idx++) { RefPicList *rpl = &h->ref->refPicList[list_idx]; for (i = 0; i < rpl->nb_refs; i++) - pic->last_slice_param.RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]); + last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]); } - fill_pred_weight_table(h, sh, &pic->last_slice_param); + fill_pred_weight_table(h, sh, last_slice_param); + +#if VA_CHECK_VERSION(1, 2, 0) + if (avctx->profile == FF_PROFILE_HEVC_REXT) { + pic->last_slice_param.rext = (VASliceParameterBufferHEVCRext) { + .slice_ext_flags.bits = { + .cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag, + }, + }; + + 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)); + } +#endif pic->last_buffer = buffer; pic->last_size = size;