From patchwork Tue Oct 12 08:24:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 31074 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp4528597ioa; Tue, 12 Oct 2021 01:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpGzZuSAidTxTU0wezH3rkf3Uozm+6u2FSDu4HcD/7iX18PAfi4HGM8L8u4Q5mNcELroYH X-Received: by 2002:a50:be82:: with SMTP id b2mr47841548edk.56.1634027251646; Tue, 12 Oct 2021 01:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634027251; cv=none; d=google.com; s=arc-20160816; b=WmTJYgYPxAD3QmGVamhVYFx9l0aUuuS479SzNfhtBX16XQ37/MgaD3eCQoIwBRu986 RuGFGmsSfWX15erqX2CJPoF4/vT18R72Tq+CNKY7pUXjYsQ8gswpoqZpWdjQEWTIAdmN TkvgLdLMaZWEeW5b/M5MBIVbp/qjPhCXhSjV9nub5oO8i71tn7Uo19M9hqz8NnPrhPQH 0q2PGyQ9/NWWMS1IUk+6C0kHDeAC2wIOVtAIgXUHQY0OmPrME9jOD2eQ0h9kQbjdNEVg 68aN5T5yf2KI9aHi1pmerbynqyKWGbEl5JDQQjcIj0WDStS/QxxzUz74zJ2Q/22+07jk 09HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=pLZ0NLflyXGAlQe3FnpJy82At4eHZ9zik0loTeAJ7IE=; b=nC93ZYwfb5k/MNX0bDFxDd/pVAu7G7yGQG9b8HqnNITQkWK/X0ey251++sEFFnL88f ziVVzFqPjp62sMEAwaDePWcJXGxtLt6k+anlQa+QRpRHgPX6c+fKFDcSxFMHren6tj7r d3Pks5WZ6H9pUlEhw2QHL/n67XONZJfynS8DwMGxGpFeYfwJqW475iluj/0/AJ6eB6vF tz2eKVdyZOebjUbke+S79HvCU4lKDr3ykA20teHkQ94teVjhCtBbjTnTqzJIv3sNA70k QeRPRYDKCFU6T+/BG5bgR2YGIInpB+GrIVZoEwjSXEKGdtGUlgP9V+MKRiz7Dv5MBZf3 Iy6Q== 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 x12si6380742edr.120.2021.10.12.01.27.31; Tue, 12 Oct 2021 01:27:31 -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 B558768A943; Tue, 12 Oct 2021 11:26:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B80CF68A906 for ; Tue, 12 Oct 2021 11:26:27 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="225852123" X-IronPort-AV: E=Sophos;i="5.85,367,1624345200"; d="scan'208";a="225852123" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2021 01:26:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,367,1624345200"; d="scan'208";a="524139886" Received: from t.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 12 Oct 2021 01:26:17 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Oct 2021 16:24:03 +0800 Message-Id: <20211012082404.31639-8-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012082404.31639-1-fei.w.wang@intel.com> References: <20211012082404.31639-1-fei.w.wang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 8/9] avcodec/av1_vaapi: enable segmentation features 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: Fei Wang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: J5V23kNshLtd Signed-off-by: Fei Wang --- libavcodec/vaapi_av1.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 26476c7738..c57d1b898a 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -126,6 +126,9 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, int err = 0; int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; uint8_t remap_lr_type[4] = {AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ}; + uint8_t segmentation_feature_signed[AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0}; + uint8_t segmentation_feature_max[AV1_SEG_LVL_MAX] = {255, AV1_MAX_LOOP_FILTER, + AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, 7 , 0 , 0 }; bit_depth_idx = vaapi_av1_get_bit_depth_idx(avctx); if (bit_depth_idx < 0) @@ -293,6 +296,17 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, for (int j = 0; j < 6; j++) pic_param.wm[i - 1].wmmat[j] = s->cur_frame.gm_params[i][j]; } + for (int i = 0; i < AV1_MAX_SEGMENTS; i++) { + for (int j = 0; j < AV1_SEG_LVL_MAX; j++) { + pic_param.seg_info.feature_mask[i] |= (frame_header->feature_enabled[i][j] << j); + if (segmentation_feature_signed[j]) + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + -segmentation_feature_max[j], segmentation_feature_max[j]); + else + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + 0, segmentation_feature_max[j]); + } + } if (apply_grain) { for (int i = 0; i < film_grain->num_y_points; i++) { pic_param.film_grain_info.point_y_value[i] =