From patchwork Fri Jul 9 03:32:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28875 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp270803ios; Thu, 8 Jul 2021 20:36:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPrOWCFG2wnuT66L2jVIVH1yiLsxqNx/OJ4biuxkpY/qeBw0QPDtG7WY/6c+9jm+KuqqLH X-Received: by 2002:a17:907:c0f:: with SMTP id ga15mr33840352ejc.228.1625801771081; Thu, 08 Jul 2021 20:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625801771; cv=none; d=google.com; s=arc-20160816; b=L/R1V1hTZvPdmnQu/T2DPtWOBmQidbgZS/HV31xonjvEdW+xrqQ23/kmt+w3r9054e WSB6PgpZqqaQWSHnS8xnfvwv4qjVfeCIaolyATvf2/8eDVE9ugv5DLEAIa6rEwjPonQL yPoOCce/KVpEruCT9gvtegYsMQtJ7bGlebaCudyebfWCFmTEEmkAAEkj8i/sfC8TGVKa vkEqLtR42a43Mf5hYHguVV8QKigdKMGz2DU+pkCryS8si/AMfO8U7Mt76Lr/yjYQaylp tz+bff+I2VY/D+GyLFlNThDynHYSY508xOcXic+CpeyUWPmjj8ODLXICX+HwrI7c94wD jDNw== 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=YfVIkzUvXvNk9CIV/t0Htd4miK+F2WonzgeTn6YZSUY=; b=JRzv74/CLP1I0j8DGUnP4oPODfcp2p8LlhJyd8YG9AdBW8DQwq44W74+5qurTv1COx DSBayDxWTBXcG+JCljBF4Oo/ZSXwaAgECoBw5cBUkbO3JJbnSHvigU8Rg6lWxVseDmeb smk7Uka0mfEv3ePh76BdJojXS9Kv5pNMcKFe8wsSrAJrLS1tCwKj8MbvolZ9xD98y7+y 3lkLDhz/eK/r9aC36nrQkRHy4sB3CTzlM4EJZkmMS7+FjaVu2TtL8E6kbMY94nrNsoDt +MS2fr4CoPB6U44LjKjEZeD/ExfA0wW3hWC3xn3gtWuNAt3KmzsEU3g2dYxBWHuHVEqg PTjg== 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 ox14si3011117ejb.694.2021.07.08.20.36.10; Thu, 08 Jul 2021 20:36:11 -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 6CEB368A62A; Fri, 9 Jul 2021 06:35:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A17B468A571 for ; Fri, 9 Jul 2021 06:35:10 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10039"; a="196814916" X-IronPort-AV: E=Sophos;i="5.84,225,1620716400"; d="scan'208";a="196814916" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2021 20:34:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,225,1620716400"; d="scan'208";a="461973684" Received: from f.sh.intel.com ([10.239.159.147]) by fmsmga008.fm.intel.com with ESMTP; 08 Jul 2021 20:34:58 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Jul 2021 11:32:28 +0800 Message-Id: <20210709033229.19125-8-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210709033229.19125-1-fei.w.wang@intel.com> References: <20210709033229.19125-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qtZ/h1YqtQZM 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 81b13bb1aa..6aaabed2c1 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -63,6 +63,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 }; pic->output_surface = vaapi_av1_surface_id(&s->cur_frame); @@ -218,6 +221,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] =