From patchwork Mon Jul 5 08:26:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28779 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp3945443ios; Mon, 5 Jul 2021 01:30:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLxxQY2ZruhLQsDYKlRGemRSGfpQMC3DVxMPpIX969788iPKbAfKjlQbwZ+KKakfYmqZoe X-Received: by 2002:a05:6402:487:: with SMTP id k7mr14738337edv.315.1625473827722; Mon, 05 Jul 2021 01:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625473827; cv=none; d=google.com; s=arc-20160816; b=zm8cgePIt0BvHJaem7g06+VVkHux7tL5Q0SQ27reYFVWxjKSnNm/TkaRoU0BaYtnuc +CETOdrWihNYw6HWTGkTZj3Qp55H7gGwYABv934HOaO2KVQlU60fPmqe74/THEU6DwEg o23yruWQFmapNC/ECztXg4YD22YBtStKMh9AoG/BvPUrrU6nCiKKDnn7U45IwQPM2nzK w7F3QjpqPVV4RM9OtkVFSXb+gp7y0ALj/6oNTVq1qb8JksyP1lIV5VKohpwTtMcQ676E w8fvWzhZ/HUuUHCh5y+rYrUjlTlUy5Od+EfUYLbU9sl3Z/cAfg3asncQRn9/A4xYZynM gf6Q== 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=vXk0aSyP7qWpysIlqBMjyu4GWva7S44nzu77p3kNqWY790hZES/WgBMIv7ymDuwlKr MDQrPaavtLwbaxQaVFAI8/FIrmjS5g4iGKz+3yyWCFpSGM9PZSHt2NbY0nqrWoNnaYXT W/Me+xScEYfAZInkABSi9mEdOWLgFG8kBmDtlKUmyf5Q5x8HxGZAaYr4j/9XYSZ0qzVB qClEPdaX5Hjt+/uoSMFmTMykpijQrwfU0viMgkha6yPwxxlsN5817+7UddAw9JRWNU6J D/sTJAaYG6tiBcZAfS+bYQGOUxEZJ9atu12HTv9a9wgPyVFSnxRBQpOXhxo5theG51Yj feRA== 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 c16si11465186edw.370.2021.07.05.01.30.27; Mon, 05 Jul 2021 01:30:27 -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 443A668A716; Mon, 5 Jul 2021 11:29:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2C5868A6D2 for ; Mon, 5 Jul 2021 11:29:03 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10035"; a="230662737" X-IronPort-AV: E=Sophos;i="5.83,325,1616482800"; d="scan'208";a="230662737" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2021 01:28:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,325,1616482800"; d="scan'208";a="496045736" Received: from f.sh.intel.com ([10.239.159.147]) by fmsmga002.fm.intel.com with ESMTP; 05 Jul 2021 01:28:51 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Jul 2021 16:26:42 +0800 Message-Id: <20210705082643.28259-8-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210705082643.28259-1-fei.w.wang@intel.com> References: <20210705082643.28259-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH v3 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: HRi/fqKyhiHB 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] =