From patchwork Thu Jun 17 06:10:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28562 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp329721iol; Wed, 16 Jun 2021 23:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgnNzk4l8bKdkzOZ5Pdmr0AUp+/bGJjSKduTYQlWxYVZiMTpGiCkwrxxdobRekOYQ53Tod X-Received: by 2002:aa7:cdc8:: with SMTP id h8mr4181237edw.323.1623910342821; Wed, 16 Jun 2021 23:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910342; cv=none; d=google.com; s=arc-20160816; b=I2SdsPuz9bjxcHYarBWk/kkHr1mYQZ5MBf5hX3cUkBOuAvD+DdMtEB+mWI//uzs8QN kADBkRX2qQFqqiMforg5uCXXXI8y30WC6Jvaebtk480YIYrO+0EP/1SwPwrqfdmXY8ze ENFx3317ouHKqpiunaMYBAbL8cHUYm29/3OcIuYrrfSB+lOiSLtdn8WHRFcGVQfRTFVJ aHRnAR7da9mK6oTyQAEBW981ogXTaZgTc7WV2jnYWEx3yBmZkvgOY8/RzryEXbzrpzWA RiG5/OajteN2ZymNOmGonv+sX/chWBGb9V16IoVrmL7FteasBcLYNynYtVBFsiKoNmrF qZfA== 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:ironport-sdr :ironport-sdr:delivered-to; bh=JRvA2i8lwH+rvsXvp1d8fVa/RJrgDJUtU2HEN5BzaeQ=; b=CBwy0Nv+Iw4erel1SrPPx9G98v6M8Xg3CmmCfkcH/prJH/K1yYQrXZj+5EbeVyFHRu g63MD4uhnuablJmyPyAvJdPmxF1dsM0myGDf5Ie2j3TlQI375C3WfVGhCLXb6+UnQ5V5 SJxIeUVl6Cc5nwyy8dtDF6ufn4hKjjhpjfsRbTBIBcAYVDwkbw3Zw2HoecoHHBws2cR/ yQO9fZKMuWHZX4AlVlVkJkQ02Z9TgvtpGskS4y4Ah+ngLWGvSs7AtbWQP/9M7lw9EDyB WHmrEPYlRQiYDi4QdHKc/N5wZWlmIz35MU/UhWuTgRH41rH2LljzL6Bqnm7ioCZD7ZR9 4YTw== 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 jx19si1284595ejc.615.2021.06.16.23.12.19; Wed, 16 Jun 2021 23:12:22 -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 D8024680C28; Thu, 17 Jun 2021 09:12:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7135468094B for ; Thu, 17 Jun 2021 09:12:09 +0300 (EEST) IronPort-SDR: NRv6bMjmwSJci2ZSOkIfbsYDmnRtTrSi3CreT2zQNWqObyVKuQuLhqWdOGMtnOMswo0qDyUCn2 RecHmRpBUikg== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942557" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942557" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:07 -0700 IronPort-SDR: h+3eEpZJdSqxOlIycR/07dZiEj9AWvhKAX3mXBnfMiYAJGJMZ3W376cUgAEKYNZmIF+bUXj+rL uMLaT6wNm7MQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485176999" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:06 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:29 +0800 Message-Id: <20210617061037.20335-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/9] cbs_av1: fix incorrect data type 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: 9KmXMfKAL8IK shifted_order_hints is computed by data with int plus data with int. Switch to int8_t may lose its precision. Signed-off-by: Fei Wang --- libavcodec/cbs_av1_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 6fe6e9a4f3..956d45e132 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -355,7 +355,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, AV1_REF_FRAME_ALTREF2, AV1_REF_FRAME_ALTREF }; int8_t ref_frame_idx[AV1_REFS_PER_FRAME], used_frame[AV1_NUM_REF_FRAMES]; - int8_t shifted_order_hints[AV1_NUM_REF_FRAMES]; + int shifted_order_hints[AV1_NUM_REF_FRAMES]; int cur_frame_hint, latest_order_hint, earliest_order_hint, ref; int i, j; From patchwork Thu Jun 17 06:10:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28564 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp329828iol; Wed, 16 Jun 2021 23:12:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLzHj97U/JPzOz7h1pW1HUaMSxOfynZWeI+lYhzyk6Vvi+r6tqnrNBvngn3i6n4//TSFQk X-Received: by 2002:a17:906:dd6:: with SMTP id p22mr3542989eji.191.1623910351678; Wed, 16 Jun 2021 23:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910351; cv=none; d=google.com; s=arc-20160816; b=XlEy+qSuAsgodZkstCi+XgbD3ejc81a/jZ6IO7SSQ6Ai+0kidBppNpuDTTJmBTDztw 4yVlmxk+vTRdK2rOWqCa+ZDz/u4hBgqYFx15yboC/gRCrpwJgj3vYaAzopxk0Xc3gSSg +SGlGchBOHlEBjBdj2BC4ySObk2v+1P7IUd1I+xJplIUhw0zJiwwS7tsmvBH/McIbHkm AaWqeCgIUE5lZ7boFhxemIl6eJu15WobLsU9r2+X5kSgs3FLh8pDp5lj51vSR1KzrnXJ Gzp2DOyPQtfBLY8kInJCrdOW7xA67Fbfa0AxHK3kCFxg6WFW4JkLR6tzAKhkwAkphDxR kC1Q== 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:ironport-sdr:ironport-sdr:delivered-to; bh=TWn4LBRR0nxaKZOgkWrjhFrMRil6ja+rR9pC4RN5xBA=; b=bClwV/W/AuZCgjoenYzA6qBrIPg+FyfmkumZNjuXzqzNxKX3ou3GRp9DS2Pqa/xYbX pS+Syi9gGVTjI02/yiKahZbK13jidqrZm1Phmb/OOc7pqEb6tos5vkczWPjtCwKRHxbv fCdLKcTb1jC5PiXZdYSfCOTwWYk8eaXlat2+UVQaV19gMqtW54T98Iac9bG7NSwzxM/J 8OP6QVy+QDKiEtZf6SG5q3FHiYQAhst+fMH7UFRIAGJgMJNKR6CYfNiJf7tO726cgt3V Catb1mopNh2zQ2UqaHN94qk/aleuCwskFnMEobuXb29yabPqCAA8vJHpZUAKs7ajQSca d4Pw== 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 o17si4371785eju.179.2021.06.16.23.12.31; Wed, 16 Jun 2021 23:12: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 D94A96882FD; Thu, 17 Jun 2021 09:12:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3829468813A for ; Thu, 17 Jun 2021 09:12:11 +0300 (EEST) IronPort-SDR: vEUUgM32Jj/yBhzG3NS0aBMLt2ks2fAnQWfVBAwvzfCMrsatGk/hVXTdlLElIGH3vfTmNFXznL WoeYtvxy8S1A== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942558" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942558" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:08 -0700 IronPort-SDR: eF4UhOwHxuQS+6DGlr6T2edn2+UGu8aDZxEsV2R95aFg4/A6FmqcF95EeF0A4Y1J2B/x91ByBb HUp8Wz/tGR1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177009" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:07 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:30 +0800 Message-Id: <20210617061037.20335-2-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 2/9] avcodec/av1: extend some definitions in spec section 3 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: Rb50UfMBQN4f Signed-off-by: Fei Wang --- libavcodec/av1.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/av1.h b/libavcodec/av1.h index 0f99ae4829..951a18ecb2 100644 --- a/libavcodec/av1.h +++ b/libavcodec/av1.h @@ -114,6 +114,13 @@ enum { AV1_WARP_MODEL_TRANSLATION = 1, AV1_WARP_MODEL_ROTZOOM = 2, AV1_WARP_MODEL_AFFINE = 3, + AV1_WARP_PARAM_REDUCE_BITS = 6, + + AV1_DIV_LUT_BITS = 8, + AV1_DIV_LUT_PREC_BITS = 14, + AV1_DIV_LUT_NUM = 257, + + AV1_MAX_LOOP_FILTER = 63, }; From patchwork Thu Jun 17 06:10:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28565 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp329936iol; Wed, 16 Jun 2021 23:12:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPEdA3nAbIWLWV6RIueLB1//Cc30qg8SwcxbBh6E2XZ5uMWI5aUqCOmgclyXV6G1S8LFfj X-Received: by 2002:aa7:cac9:: with SMTP id l9mr4162678edt.373.1623910361628; Wed, 16 Jun 2021 23:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910361; cv=none; d=google.com; s=arc-20160816; b=Oyq/6pmmdI0RpIhhikKxTLb+BWPqiWDs5wyv8XgZfJcZl7epis/C3OPg8XfDal7s+1 Oe/FmYSfGRl1KnnA6ReciosGtjlFx5StoqJP5e5Rcrt2ID+rxkeyGPN4SL63eKCqSiOU mbFkB/MeNc9pavyn1LbV/9BnSZ69oCH5dH4qHd7s2FF5R27cChLh8RtCTTGcswh8IsHT co/9DZpIzFaDI6xBKDP2SP54X/mxyCLO5hMZVCTUpxRPXsuVV8xsOX690tq4VIQMzsnb qZaG/to20P/gBvdw0/7l6byb1UYM2ME4c39/a5VLnFXjFAzWQMHu1y6QdL8M/CXRzmuY yYQA== 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:ironport-sdr:ironport-sdr:delivered-to; bh=0BHF2f8Yzp/4Xrr+K5OzB+TMr027iaXmeAmfl3lqxEs=; b=AFxc4RbjUp9iQpfbDD2KkbmbXr8Aysyye7GDFnCWSBbqbH1do6CfjmmGD3moKafmve VfQnESh5hB+dlG+69N+jTXN8wggE6BwJQJLEGvNUHdjnAic3jfw8sBYAUHYRdirULeob 5/u5WHYHf9zMmi5Jvj8YwW8Bby0j/bnW5Cvq1l9fhSyNo7lahlxKuXzWowObSxg3D9u2 E4w1EFe4UYlcMXn0veVIpLl+nURmSBVRCPf+OFvSDw65PEuHUWMWJey5xa+5gtPvLOwo KOEvgnxsfg5+yQ2w6NRWufvKWgW54z0BivO1pZmjgdVdlkDB7PH4el6oeSzPhDkWkVJ2 1rIQ== 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 z14si3957229edb.332.2021.06.16.23.12.40; Wed, 16 Jun 2021 23:12:41 -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 C885E688388; Thu, 17 Jun 2021 09:12:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E0E968804D for ; Thu, 17 Jun 2021 09:12:12 +0300 (EEST) IronPort-SDR: 5/+ygaHd/9w9CkIrQGcy85kL7mCNUuZKV/dtpzJw7hVkkz45B9QcT9NEFjq/jfUTnWniNQg4HE +dbC/+StStPA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942559" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942559" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:09 -0700 IronPort-SDR: y8XlwQF3HL2sxPFoQOY4/yOv17JfvZ9gGqx5EIzoTrsofGpxfGysJzDdSj2t/F8uGKPP9Ob3X/ DTdveftTpL1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177016" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:08 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:31 +0800 Message-Id: <20210617061037.20335-3-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 3/9] avcodec/av1dec: support setup shear process 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: a2tqvY9Ke0xQ Defined in spec 7.11.3.6/7.11.3.7. Signed-off-by: Fei Wang --- libavcodec/av1dec.c | 97 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/av1dec.h | 1 + 2 files changed, 98 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 1dda0f9160..3fca17e84b 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -28,6 +28,33 @@ #include "internal.h" #include "profiles.h" +static const uint16_t div_lut[AV1_DIV_LUT_NUM] = { + 16384, 16320, 16257, 16194, 16132, 16070, 16009, 15948, 15888, 15828, 15768, + 15709, 15650, 15592, 15534, 15477, 15420, 15364, 15308, 15252, 15197, 15142, + 15087, 15033, 14980, 14926, 14873, 14821, 14769, 14717, 14665, 14614, 14564, + 14513, 14463, 14413, 14364, 14315, 14266, 14218, 14170, 14122, 14075, 14028, + 13981, 13935, 13888, 13843, 13797, 13752, 13707, 13662, 13618, 13574, 13530, + 13487, 13443, 13400, 13358, 13315, 13273, 13231, 13190, 13148, 13107, 13066, + 13026, 12985, 12945, 12906, 12866, 12827, 12788, 12749, 12710, 12672, 12633, + 12596, 12558, 12520, 12483, 12446, 12409, 12373, 12336, 12300, 12264, 12228, + 12193, 12157, 12122, 12087, 12053, 12018, 11984, 11950, 11916, 11882, 11848, + 11815, 11782, 11749, 11716, 11683, 11651, 11619, 11586, 11555, 11523, 11491, + 11460, 11429, 11398, 11367, 11336, 11305, 11275, 11245, 11215, 11185, 11155, + 11125, 11096, 11067, 11038, 11009, 10980, 10951, 10923, 10894, 10866, 10838, + 10810, 10782, 10755, 10727, 10700, 10673, 10645, 10618, 10592, 10565, 10538, + 10512, 10486, 10460, 10434, 10408, 10382, 10356, 10331, 10305, 10280, 10255, + 10230, 10205, 10180, 10156, 10131, 10107, 10082, 10058, 10034, 10010, 9986, + 9963, 9939, 9916, 9892, 9869, 9846, 9823, 9800, 9777, 9754, 9732, + 9709, 9687, 9664, 9642, 9620, 9598, 9576, 9554, 9533, 9511, 9489, + 9468, 9447, 9425, 9404, 9383, 9362, 9341, 9321, 9300, 9279, 9259, + 9239, 9218, 9198, 9178, 9158, 9138, 9118, 9098, 9079, 9059, 9039, + 9020, 9001, 8981, 8962, 8943, 8924, 8905, 8886, 8867, 8849, 8830, + 8812, 8793, 8775, 8756, 8738, 8720, 8702, 8684, 8666, 8648, 8630, + 8613, 8595, 8577, 8560, 8542, 8525, 8508, 8490, 8473, 8456, 8439, + 8422, 8405, 8389, 8372, 8355, 8339, 8322, 8306, 8289, 8273, 8257, + 8240, 8224, 8208, 8192 +}; + static uint32_t inverse_recenter(int r, uint32_t v) { if (v > 2 * r) @@ -97,6 +124,70 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx) -mx, mx + 1, r) << prec_diff) + round; } +static uint64_t round_two(uint64_t x, uint16_t n) +{ + if (n == 0) + return x; + return ((x + (1 << (n - 1))) >> n); +} + +static int64_t round_two_signed(int64_t x, uint16_t n) +{ + return ((x<0) ? -round_two(-x, n) : round_two(x, n)); +} + +/** + * Resolve divisor process. + * see spec 7.11.3.7 + */ +static int16_t resolve_divisor(uint32_t d, uint16_t *shift) +{ + int32_t e, f; + + *shift = av_log2(d); + e = d - (1 << (*shift)); + if (*shift > AV1_DIV_LUT_BITS) + f = round_two(e, *shift - AV1_DIV_LUT_BITS); + else + f = e << (AV1_DIV_LUT_BITS - (*shift)); + + *shift += AV1_DIV_LUT_PREC_BITS; + + return div_lut[f]; +} + +/** + * check if global motion params is valid. + * see spec 7.11.3.6 + */ +static uint8_t get_shear_params_valid(AV1DecContext *s, int idx) +{ + int16_t alpha, beta, gamma, delta, divf, divs; + int64_t v, w; + int32_t *param = &s->cur_frame.gm_params[idx][0]; + if (param[2] < 0) + return 0; + + alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS)); + beta = av_clip_int16(param[3]); + divf = resolve_divisor(abs(param[2]), &divs); + v = param[4] * (1 << AV1_WARPEDMODEL_PREC_BITS); + w = param[3] * param[4]; + gamma = av_clip_int16(round_two_signed((v * divf), divs)); + delta = av_clip_int16(param[5] - round_two_signed((w * divf), divs) - (1 << AV1_WARPEDMODEL_PREC_BITS)); + + alpha = round_two_signed(alpha, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + beta = round_two_signed(beta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + gamma = round_two_signed(gamma, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + delta = round_two_signed(delta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + + if ((4 * abs(alpha) + 7 * abs(beta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS) || + (4 * abs(gamma) + 4 * abs(delta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS)) + return 0; + + return 1; +} + /** * update gm type/params, since cbs already implemented part of this funcation, * so we don't need to full implement spec. @@ -144,6 +235,9 @@ static void global_motion_params(AV1DecContext *s) read_global_param(s, type, ref, 0); read_global_param(s, type, ref, 1); } + if (type <= AV1_WARP_MODEL_AFFINE) { + s->cur_frame.gm_invalid[ref] = !get_shear_params_valid(s, ref); + } } } @@ -509,6 +603,9 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s dst->spatial_id = src->spatial_id; dst->temporal_id = src->temporal_id; + memcpy(dst->gm_invalid, + src->gm_invalid, + AV1_NUM_REF_FRAMES * sizeof(uint8_t)); memcpy(dst->gm_type, src->gm_type, AV1_NUM_REF_FRAMES * sizeof(uint8_t)); diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 248a68750f..4e140588b9 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -42,6 +42,7 @@ typedef struct AV1Frame { int temporal_id; int spatial_id; + uint8_t gm_invalid[AV1_NUM_REF_FRAMES]; uint8_t gm_type[AV1_NUM_REF_FRAMES]; int32_t gm_params[AV1_NUM_REF_FRAMES][6]; From patchwork Thu Jun 17 06:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28560 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330045iol; Wed, 16 Jun 2021 23:12:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ1syhww1L0pdjEKpKHi+k+VZ6FSKlXni8Q3kIiasosnr6qN7zzwXcvGkLZxn/pTUGsNK0 X-Received: by 2002:aa7:d713:: with SMTP id t19mr4202296edq.144.1623910371846; Wed, 16 Jun 2021 23:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910371; cv=none; d=google.com; s=arc-20160816; b=0HmDFvmRgoJAjqK7sBs4tcfV6aXD8dURLOAEaq+MYc4sIF9/JnCq2JOck/m/5hrUFl dXLob8YYv+D6suc0bRdrSfaiEtnnPZ1cFbA7Vb6hLEKzMxXE4MewAr+mLsM/HZdRCX+7 GAA3epoWxzCG4ViZisrI1NP4JqHxH5JZ8oCHLIqHhD3LPM7w43ccwh53lJLBPgo7mQTf /Xef/kOFu7fy/X1KC2XP6qbJaoGwGvhv8JNrgLPt1niB9dxeKEKf/xmUmQsWN8hsHSZi /Vr4BHaQ/CM4a2Kb3cBvrWENzzuhs5NZMAzAOFgQXuQr92/TqvgDHoLJunL130rTCXum jK7A== 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:ironport-sdr:ironport-sdr:delivered-to; bh=bkVozSZ7hVmtNxG61PIGhx2/oS+J/tYDetO40/PSLeE=; b=XZiMzyrtRY4DaBJ9TzyFiN54Gric2NS5E6BWo0bT0ENH6zX8Hza+P1qGSZBZR/Twxq zMr2DtrDAmeY8bkM6ABCoYavLofyYIWt/ZuG0zciM/e4p0DzAC7Yk/U/jq8rOKMM8twh dFTAHABjAojUgsTpxsAIw+oPxI+LXM+h6wCh50jiDFWhjU9JSq415Ff1ssNDIc3jUiSf SZtw/w2UAysijB5ljk8tCAwFEJAZlO3t0bUO8wlBACU5FwTK972bEzRWlmz4IY458CXt f+qYm77UhclAt/hmK4o+d4gSPkgedrkOGwNf9QOPZuFakP98vt3K+JCc6xyfk7NruLHk Elrw== 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 p4si2592237edj.420.2021.06.16.23.12.51; Wed, 16 Jun 2021 23:12:51 -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 D92996881D0; Thu, 17 Jun 2021 09:12:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55870688081 for ; Thu, 17 Jun 2021 09:12:15 +0300 (EEST) IronPort-SDR: E0rPvh0zqaXuKMGwVvYABSX59bS6A5KUmnI682vlRZIJSDcQzlQ4RfAg2RzSbWBWovJ2rR1d1+ bujWNVpkzhwA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942562" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942562" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:10 -0700 IronPort-SDR: XKnMK+4kdbbzwLlYKjFFOv8DgfK/jyhEvzbQZ4XZBTmYzZvWRqUXeISE01ed5IBEB+1sdWNajQ jm6RYf9gwAwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177021" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:09 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:32 +0800 Message-Id: <20210617061037.20335-4-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 4/9] avcodec/av1_vaapi: add gm params valid check 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: +Fg23pocoiYs Signed-off-by: Fei Wang --- libavcodec/vaapi_av1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 16b7e35747..f577447be4 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -213,7 +213,8 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, frame_header->height_in_sbs_minus_1[i]; } for (int i = AV1_REF_FRAME_LAST; i <= AV1_REF_FRAME_ALTREF; i++) { - pic_param.wm[i - 1].wmtype = s->cur_frame.gm_type[i]; + pic_param.wm[i - 1].invalid = s->cur_frame.gm_invalid[i]; + pic_param.wm[i - 1].wmtype = s->cur_frame.gm_type[i]; for (int j = 0; j < 6; j++) pic_param.wm[i - 1].wmmat[j] = s->cur_frame.gm_params[i][j]; } From patchwork Thu Jun 17 06:10:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28568 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330285iol; Wed, 16 Jun 2021 23:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4HhOKdLl5Mst+mw1Z+tPpquaLJND+JU5NXh0BV76iYtKhlRDox4Y72n05i4qyKf+hnk7C X-Received: by 2002:a17:907:98f6:: with SMTP id ke22mr1527392ejc.533.1623910392421; Wed, 16 Jun 2021 23:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910392; cv=none; d=google.com; s=arc-20160816; b=cbZbgi3Vnx+YmmIMoNuU5UGwT+36ho9YGQiPgERwDUQE9qDWSe6KLxnZUDDe9VUcyS UtSkT1D5g2NxGQZZhfkPUX7IPzP91BLwAnJdMyOlRnrB77aNilyw4jOgzm7p728W0YJ9 R+n3CAD1Ok8eYvo7/Om5uI2hGlCbjnqN79Q0w2Qmkb0JLDwIqh+dKt6Yxi24F41DcBs+ WcGydOQxiPh5OgMtrAc4WaJfS6pCdSze+2Mr125OTmCWjZbqD0QhDQR3LRnEF37YMMT+ u8ACwOxu/e+2CYMEdTOuU8FNY/8QT3FJsy+ZGTEiyaCwIuymt6p6WHL35FfRLMJynxXP HV4g== 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:ironport-sdr:ironport-sdr:delivered-to; bh=aLwA2lVUAxkbfiLCFhcrExLJpOWJyOga98Ng6z43CjU=; b=pP2pWmSsDb2OoQhQKNd/L2Na7x1+vx8dqhQJLssOq40PJVJaWw/Snd/fKKGP5+eOxg w/96hPu5sI05uY0RtHppDEvAiPmv3b8XyQIQ8W+gfa0Ly75B57CYevHVsYd5HCCisVLb 7ariVWKtUn//hNyor9MduB5tNNL8SozZMAPHmsf3+x9qANeSBQYLcj65e/E0ZImsFx3L lGMFYQFyVPLLwXlrPhfU1QGrdF+mPrsM7wivx1TKjgYg3lUz2D1XPwGu3X6bBYE5D+eS R/FvDcJFY1fwQUKScRpl2yk1+B84Rsaly+4+aw+Zuw4ycEy3zhT0+78kz6CZ5feO5Vdh 1YMw== 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 m6si4481786edc.576.2021.06.16.23.13.11; Wed, 16 Jun 2021 23:13:12 -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 23FB86898E0; Thu, 17 Jun 2021 09:12:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C8CB6881D0 for ; Thu, 17 Jun 2021 09:12:16 +0300 (EEST) IronPort-SDR: 6ybo1FxuKGBTA0US3b7metYsIPnOyX7weEItYVVLKwc3WDhhZ3GBd/ODU95UohVKyVxOhRZMrN EE3w/AFolwPA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942564" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942564" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:11 -0700 IronPort-SDR: aURLhMQRl6iLwnauE8vmgLefOj/+DJsyiVToofV1zdh/ZFcoU2KwKXcqlnqGoIyj2tvY38K7r4 utH33WZxpouw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177026" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:10 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:33 +0800 Message-Id: <20210617061037.20335-5-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 5/9] avcodec/vaapi: increase av1 decode pool size 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: cShmA/PVTAoF For film grain clip, vaapi_av1 decoder will cache additional 8 surfaces that will be used to store frames which apply film grain. So increase the pool size by plus 8 to avoid leak of surface. Signed-off-by: Fei Wang --- libavcodec/vaapi_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 958ddf49da..665af370ed 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -577,10 +577,10 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, switch (avctx->codec_id) { case AV_CODEC_ID_H264: case AV_CODEC_ID_HEVC: + case AV_CODEC_ID_AV1: frames->initial_pool_size += 16; break; case AV_CODEC_ID_VP9: - case AV_CODEC_ID_AV1: frames->initial_pool_size += 8; break; case AV_CODEC_ID_VP8: From patchwork Thu Jun 17 06:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28563 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330599iol; Wed, 16 Jun 2021 23:13:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXQ3YncVThQqwUy+ZBaSWt/yOdmCcOtveX14QgXZ8CygwyLNU/lUq5HdTbw06h4YrqbxEQ X-Received: by 2002:a17:906:c0c7:: with SMTP id bn7mr3332785ejb.393.1623910422419; Wed, 16 Jun 2021 23:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910422; cv=none; d=google.com; s=arc-20160816; b=Mh34p83wV7c8zlS6LwbnIcEagHhT8+w9Da/BbbCKc5uUIiDocbuNLL35nCPGhIfB9+ w3XDE9YrSjAxxcW9+8Jm4SjXMCZGscSePrEjUdol5gNG5jEyGWxRPWCYJfrnCqjrxgJz hxYch+6A8LVFWPjdIodtMz+1ktor5Q/WWG0JZZDUTxz0X9aFf0ozz4p8YBo5JBQBFex1 hoSQFOYZmiCeX78H9HmH5WtRvFEy5TKAZoduoFO7DCHdBdP+1CN1U82zzYEeTLuMFcMe oGkHnshX1qwKVbqmcaS9H25xMc3Ijd/BSBgb/hXieACWo4dSuizRhAu8nlV17aYAJT+Y GVtQ== 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:ironport-sdr:ironport-sdr:delivered-to; bh=pswVKK2ik6I5+4gyjrSXM3LXnGxIybk9plEgtn2R+Qs=; b=rd5Aqp5i75F7z3rRWTbsZx3h5Gwmf671TRO48gA0OzIQr6tDjvJzzCynjtoPg7e3wP N1y6q/zY+KbCCw4FFxVsu9H4NSKuWvPIi+7OPMTJYH8Czdr+/nEi1+5PV9uLNigUI4ql VTgRldTy/MDax1m4+R/KOPgc+GJ7D2TN4WGkCOhaROZq7rU2CL0P/Y508sSugCaTRJKy /083UcjlNl6oFmAaVricYLrP5d+OGOKPtKByb57s0GV/qpOXUhYqm4I8WIjU/hHg8L/T ZIu63ZjDTo+J6ClPApELemm9epSACD184vdJ5+wqpAedPMk4OgwGYsFgZwBJ+Zk/wuvV MD/g== 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 v7si5176649edj.318.2021.06.16.23.13.41; Wed, 16 Jun 2021 23:13:42 -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 589326899A2; Thu, 17 Jun 2021 09:12:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81416688081 for ; Thu, 17 Jun 2021 09:12:18 +0300 (EEST) IronPort-SDR: 5clAT4W11yId/in+xnMkccW+m0Ky+iCawKSM4QLRErLvpeInOqqgbOiL6CKmM7WUoJTrBtLxWB iAuF9Z6+iOMQ== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942566" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942566" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:12 -0700 IronPort-SDR: E5cszs8NT/sC7hvG/J3HsN/MPYSzOTHu5ZwMs5e51+q8XM8Gw8zYjLlLORl4kS3XpE7E1ZcqPS fG2xwkiWJoNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177031" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:11 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:34 +0800 Message-Id: <20210617061037.20335-6-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 6/9] avcodec/av1dec: add display frame for film grain usage 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: FcX/SVdafeEk Make it flexible if decode frame(without apply film grain) and display frame(applied film grain) both needed when decode film grain clips. Signed-off-by: Fei Wang --- libavcodec/av1dec.c | 43 ++++++++++++++++++++++++++++++++++++++++++- libavcodec/av1dec.h | 3 +++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 3fca17e84b..af2ecb4f0c 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -569,6 +569,8 @@ static int get_pixel_format(AVCodecContext *avctx) static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f) { ff_thread_release_buffer(avctx, &f->tf); + if (f->tf_display.f->buf[0]) + ff_thread_release_buffer(avctx, &f->tf_display); av_buffer_unref(&f->hwaccel_priv_buf); f->hwaccel_picture_private = NULL; av_buffer_unref(&f->header_ref); @@ -588,6 +590,12 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s if (ret < 0) return ret; + if (src->tf_display.f->buf[0]) { + ret = ff_thread_ref_frame(&dst->tf_display, &src->tf_display); + if (ret < 0) + return ret; + } + dst->header_ref = av_buffer_ref(src->header_ref); if (!dst->header_ref) goto fail; @@ -634,9 +642,11 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { av1_frame_unref(avctx, &s->ref[i]); av_frame_free(&s->ref[i].tf.f); + av_frame_free(&s->ref[i].tf_display.f); } av1_frame_unref(avctx, &s->cur_frame); av_frame_free(&s->cur_frame.tf.f); + av_frame_free(&s->cur_frame.tf_display.f); av_buffer_unref(&s->seq_ref); av_buffer_unref(&s->header_ref); @@ -738,6 +748,13 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) "Failed to allocate reference frame buffer %d.\n", i); return AVERROR(ENOMEM); } + + s->ref[i].tf_display.f = av_frame_alloc(); + if (!s->ref[i].tf_display.f) { + av_log(avctx, AV_LOG_ERROR, + "Failed to allocate display frame buffer %d.\n", i); + return AVERROR(ENOMEM); + } } s->cur_frame.tf.f = av_frame_alloc(); @@ -747,6 +764,13 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } + s->cur_frame.tf_display.f = av_frame_alloc(); + if (!s->cur_frame.tf_display.f) { + av_log(avctx, AV_LOG_ERROR, + "Failed to allocate current display frame buffer.\n"); + return AVERROR(ENOMEM); + } + ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_AV1, avctx); if (ret < 0) return ret; @@ -819,6 +843,16 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) break; } + if (header->film_grain.apply_grain && + (avctx->pix_fmt == AV_PIX_FMT_VAAPI) && + !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN)) { + if ((ret = ff_thread_get_buffer(avctx, &f->tf_display, AV_GET_BUFFER_FLAG_REF)) < 0) + goto fail; + + f->tf_display.f->key_frame = frame->key_frame; + f->tf_display.f->pict_type = frame->pict_type; + } + if (avctx->hwaccel) { const AVHWAccel *hwaccel = avctx->hwaccel; if (hwaccel->frame_priv_data_size) { @@ -902,9 +936,16 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt, int *got_frame) { AV1DecContext *s = avctx->priv_data; - const AVFrame *srcframe = s->cur_frame.tf.f; + const AVFrame *srcframe; int ret; + /* Use tf_display as output when it is available. */ + if (s->cur_frame.tf_display.f->buf[0]) { + srcframe = s->cur_frame.tf_display.f; + } else { + srcframe= s->cur_frame.tf.f; + } + // TODO: all layers if (s->operating_point_idc && av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id) diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 4e140588b9..5af3dfc867 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -33,6 +33,9 @@ typedef struct AV1Frame { ThreadFrame tf; + /** current tf_display is only used for VA-API to apply film grain */ + ThreadFrame tf_display; + AVBufferRef *hwaccel_priv_buf; void *hwaccel_picture_private; From patchwork Thu Jun 17 06:10:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28561 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330171iol; Wed, 16 Jun 2021 23:13:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeOMs4BcSCBfeOyPP/a0TyI0ulF1PtQdJhbfnft0L5IUR/6P+9uw7HorJY3mmLoOjY17/8 X-Received: by 2002:a17:906:7d3:: with SMTP id m19mr3426401ejc.546.1623910381931; Wed, 16 Jun 2021 23:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910381; cv=none; d=google.com; s=arc-20160816; b=FWFJl+QpMGng7Qg4zj20vlmgktGl55DaFtcnPiOlvang17/Q9B9ZdBaGhVGYLljBZ4 Ju5YHz1UCvRAyYc9X4smDsDAZc//NJzHmNUtgKRKrYzm2kYT/hJzE/1pDgEOZp8vFLhr d0lA9muZe+sBoCeVPQ/3ksfVtdVANn5m11x7dmH16w2CL/yepOWxCv2Jmv9leZf1Ehb9 1Ri6QTUfpbniD81M/oVs3DtIJMQRlmmDSXjUPXUdwDnKI5JpijU18hFAb8m7Cdzpg/j5 YbfoQmX5mJyBzmr/Y87wzdt1rInFsHOMUDXMyE7/FBs3vvHiUKrq9hPI2POp6XX5gavT 6qfw== 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:ironport-sdr:ironport-sdr:delivered-to; bh=/gOZcqdnHPr6pRClQYZNb+oJzRVEW5jAeyl3cgjmKaM=; b=KOr5lVBgqc0/KD+EW0WgzI7zRdp+BndQeUp1TQH6K4aAsSyf7BQkn4WCaTGPnXf6to P6nz3U2hEkyjlIoGan3aqIhpae3kR089tGN01us3lLeHolu82lzrTMisDnLC/khEHnXy D78h/yY6x1ORILWKN9dVbDDm7JiIntG7y+R45kKI59NvNqWYhx8ShW4ywYew0oMZN1FE pkHw5uAnLz+MDE/8ktgpVMUYTCPyE4v5ioiuU3H0ZpHOCXQj3qFM4s7JIOpSrHtpq0o/ tokE2neyhgUHv43VEP3nLnp5q8LadxTc2KAqNpBZmgI3ECgKykiTTB8HyUEN36vtV6fd +b5w== 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 c13si4620989ejm.484.2021.06.16.23.13.01; Wed, 16 Jun 2021 23:13:01 -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 0685D689721; Thu, 17 Jun 2021 09:12:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E775D688081 for ; Thu, 17 Jun 2021 09:12:21 +0300 (EEST) IronPort-SDR: IdWgG4PZSMpiyAxUTV103pBAgKTBCiqBWYIbaXyFlWMt/Bt6m3jpCH9YpqFlBYJHJNeipshBCb O9QssCRnRczA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942567" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942567" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:13 -0700 IronPort-SDR: kWDxJIxhEqq5TcH+MzJm1nooFXbqinME5HJxa61BN6ODhd+G4t1R0YapeTVj4fMJceOkTlWUvi rU3XCRanEVPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177038" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:12 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:35 +0800 Message-Id: <20210617061037.20335-7-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 7/9] avcodec/av1_vaapi: set display surface when apply film grain 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: jEXY1SXsaM29 Signed-off-by: Fei Wang --- libavcodec/vaapi_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index f577447be4..81b13bb1aa 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -76,7 +76,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1, .bit_depth_idx = bit_depth_idx, .current_frame = pic->output_surface, - .current_display_picture = pic->output_surface, + .current_display_picture = apply_grain ? ff_vaapi_get_surface_id(s->cur_frame.tf_display.f) : pic->output_surface, .frame_width_minus1 = frame_header->frame_width_minus_1, .frame_height_minus1 = frame_header->frame_height_minus_1, .primary_ref_frame = frame_header->primary_ref_frame, From patchwork Thu Jun 17 06:10:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28566 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330394iol; Wed, 16 Jun 2021 23:13:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqJbSzVihzn4h/EAX8bSdOT1JWNOdQTG2vc168kYxfFfqzTgkzbZKGAgoU2ow6exG4jFtw X-Received: by 2002:a05:6402:34d5:: with SMTP id w21mr4278698edc.257.1623910402319; Wed, 16 Jun 2021 23:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910402; cv=none; d=google.com; s=arc-20160816; b=TB03TRa8Cce2zEpkn5CCeeP4c0zKa8eMqkET6PDNniHKWsu23Pe8wVMdBHLcKNqDSt OBfZ4QNn2TPFBRppLthQsBF4Zb133Tnf1cDtm276fuKQd5phQF73uLP8cvR9sni6Olem R4+8rnnIfKi+QfEfXDuLtikCdIB5z5YQ1PLk6jVPf8NS/4Pp5Kv5jilNMvn3uEW40eOF kH7eCFvbxUrDjgJw3nE5uWu+/MJJCRmw6JsKKjmqZXFibIpIivpf3nbwdmiyo/Tm1ecc vsopE7s++wqXl2llA4qQTh46za/TederE7xMWdxFYvtQWVJLrdlagc8KASx2nHdgB9Aj zm7g== 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:ironport-sdr:ironport-sdr:delivered-to; bh=YfVIkzUvXvNk9CIV/t0Htd4miK+F2WonzgeTn6YZSUY=; b=yki9+khSrOhp6CGOQmGd39V21GPXsOpj4bNHqVsyzJigIlo/S9MQzq7oBfFJtLU+6O qq+ymFL+2s5G71ubjxwcSloVcHwDMgeWI3tnTCQv1PUg6hqflyoIhY238v6cvK9d2jlz MKUYXFFwuMm9LgVkPFMqus+sWPykTk1RksmHE0wmy+MtlFEL2xST9aZ+Z8z37gZ3ZCVm XwBmZzlcxaxWUv0x4o5ic3KtuKiSfl8JkRicVgy2wVJXqsCt84E7oUKU8Lg/3W7ECHPA VXJUPxEuEHWQcnG3aIAANP9VmHV5OxoNO74CN0jqHyd5rVTTaefyfiHLDJoTY42ASHXS vI1g== 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 x7si1209211edd.288.2021.06.16.23.13.21; Wed, 16 Jun 2021 23:13:22 -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 2FAC1688342; Thu, 17 Jun 2021 09:12:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14EED68924E for ; Thu, 17 Jun 2021 09:12:22 +0300 (EEST) IronPort-SDR: ADfKQ2t0aXAAXyl7E2WOejMTvCf42x9aiSyGZA/iN+/n0SdJPxlPqkeKz/cVIy4LTMb4ycMKka BRggHB9DMQjA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942570" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942570" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:14 -0700 IronPort-SDR: S6SC6JQ1AYrkXcE1w3BQTIsVAiGeZdmtuf9o50vYQhDIQxZPReT6fDNgwesPv7l66sGnIjWIad Lg0dssyXiZMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177042" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:14 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:36 +0800 Message-Id: <20210617061037.20335-8-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 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: peWthmZOKydE 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] = From patchwork Thu Jun 17 06:10:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Wang X-Patchwork-Id: 28567 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp330494iol; Wed, 16 Jun 2021 23:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO0ZU1slslZLSYAOliDYlTCwgOYnkOv1mhO6pJnetwE+9kpw88AKKY0n9FCkgoy1OHaYd0 X-Received: by 2002:a17:906:3c0d:: with SMTP id h13mr2593763ejg.269.1623910411424; Wed, 16 Jun 2021 23:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623910411; cv=none; d=google.com; s=arc-20160816; b=lfu/if1TB5IJxj9Za6xpWM7d2YoXUq7pkdyqr1vl95y2hPEgd3Owr5x6ol9vSVheej uPQkzULcxhSze1i6QpZaRq7ryNZBNKsWW+Q2fmenq/hi2XJGSDqVlvTdO2ozLDjRW5X4 I7bmaTXdFliY92MxWft1EHN62FYb3bUwePJVk10PaHKTBPecXd2Ef5fv2YEQwlhbp68K Cd25ejSOEw3D0dNtyZBPs3U5Hz+x+wgJEfvQvfsuLeXVHN5c1KF7O6bHClUr8ZOvuSWL fCGbIMzM9x75jh1PPwwDuX3GZsr+uqWgZIC7pCpNNpMOIva0KcsQ384PM5E+UnlmMaz5 dRXA== 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:ironport-sdr:ironport-sdr:delivered-to; bh=OpfGIDCK5557UGMLGOBCZvRcpcuvXtlfavyw47RbHJw=; b=b5sK862XvbiWRTStmsJG26fe2hBvSOysC7u9woAGOzUs87VQclfnFhRxLPV7sFYU4n Hnbwlxzn27ZZfFPmM0fEg4naI/z9arqSPriqFsGKtbno/PvTSyzh4SYwMzHi2MVRPnBv /JXAweLY+fHDYZznj2CrL8kR7/VOQ5iSKz432VD20wW62tF8OaKIWq5rcxZLAu5b97vL ancwVCdDT+MQkOZTMksvV0UIuCGKXDa3jHqan7sQY2ki62bvpfXp2l1kA0ZuUuAUVITd N60mVSv8ruFKLuPrYGQrvi8p6MaESSbfop4/HB6VZ2AlrFjsNBz9tRCKPBR4UATyuBeL WXug== 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 l15si4837545ejq.530.2021.06.16.23.13.30; Wed, 16 Jun 2021 23:13: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 638BB6891F1; Thu, 17 Jun 2021 09:12:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15009689721 for ; Thu, 17 Jun 2021 09:12:22 +0300 (EEST) IronPort-SDR: O6okeu0C3tRigziysPhMWXkqP+YnhiKz+UtmtcCekvbUVveuvMIAtS5t3hY4LIsiIbU5pr4uL5 BVNk+rBqCK/Q== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="291942571" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="291942571" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 23:12:16 -0700 IronPort-SDR: LTAdEFiy0P1ZFwoKjifmN36ucTcwo6AVnjiuoWZij1fRI5d8b7MI4MjtdQZpvsKVk9D5X2nGK4 1c6UhbUmvhKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485177050" Received: from f.sh.intel.com ([10.239.159.147]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 23:12:15 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Jun 2021 14:10:37 +0800 Message-Id: <20210617061037.20335-9-fei.w.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617061037.20335-1-fei.w.wang@intel.com> References: <20210617061037.20335-1-fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH 9/9] avcodec/av1_vaapi: improve decode quality 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: DMxNVyx12+0a - quantizer delta and matrix level specific. - support loop filter delta. - support use superres. Signed-off-by: Fei Wang --- libavcodec/vaapi_av1.c | 67 ++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 6aaabed2c1..2d0f0a76ad 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -75,26 +75,35 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, memset(&pic_param, 0, sizeof(VADecPictureParameterBufferAV1)); pic_param = (VADecPictureParameterBufferAV1) { - .profile = seq->seq_profile, - .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1, - .bit_depth_idx = bit_depth_idx, - .current_frame = pic->output_surface, - .current_display_picture = apply_grain ? ff_vaapi_get_surface_id(s->cur_frame.tf_display.f) : pic->output_surface, - .frame_width_minus1 = frame_header->frame_width_minus_1, - .frame_height_minus1 = frame_header->frame_height_minus_1, - .primary_ref_frame = frame_header->primary_ref_frame, - .order_hint = frame_header->order_hint, - .tile_cols = frame_header->tile_cols, - .tile_rows = frame_header->tile_rows, - .context_update_tile_id = frame_header->context_update_tile_id, - .interp_filter = frame_header->interpolation_filter, - .filter_level[0] = frame_header->loop_filter_level[0], - .filter_level[1] = frame_header->loop_filter_level[1], - .filter_level_u = frame_header->loop_filter_level[2], - .filter_level_v = frame_header->loop_filter_level[3], - .base_qindex = frame_header->base_q_idx, - .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3, - .cdef_bits = frame_header->cdef_bits, + .profile = seq->seq_profile, + .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1, + .bit_depth_idx = bit_depth_idx, + .matrix_coefficients = seq->color_config.matrix_coefficients, + .current_frame = pic->output_surface, + .current_display_picture = apply_grain ? ff_vaapi_get_surface_id(s->cur_frame.tf_display.f) : pic->output_surface, + .frame_width_minus1 = frame_header->frame_width_minus_1, + .frame_height_minus1 = frame_header->frame_height_minus_1, + .primary_ref_frame = frame_header->primary_ref_frame, + .order_hint = frame_header->order_hint, + .tile_cols = frame_header->tile_cols, + .tile_rows = frame_header->tile_rows, + .context_update_tile_id = frame_header->context_update_tile_id, + .superres_scale_denominator = frame_header->use_superres ? + frame_header->coded_denom + AV1_SUPERRES_DENOM_MIN : + AV1_SUPERRES_NUM, + .interp_filter = frame_header->interpolation_filter, + .filter_level[0] = frame_header->loop_filter_level[0], + .filter_level[1] = frame_header->loop_filter_level[1], + .filter_level_u = frame_header->loop_filter_level[2], + .filter_level_v = frame_header->loop_filter_level[3], + .base_qindex = frame_header->base_q_idx, + .y_dc_delta_q = frame_header->delta_q_y_dc, + .u_dc_delta_q = frame_header->delta_q_u_dc, + .u_ac_delta_q = frame_header->delta_q_u_ac, + .v_dc_delta_q = frame_header->delta_q_v_dc, + .v_ac_delta_q = frame_header->delta_q_v_ac, + .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3, + .cdef_bits = frame_header->cdef_bits, .seq_info_fields.fields = { .still_picture = seq->still_picture, .use_128x128_superblock = seq->use_128x128_superblock, @@ -165,12 +174,15 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, .mode_ref_delta_update = frame_header->loop_filter_delta_update, }, .mode_control_fields.bits = { - .delta_q_present_flag = frame_header->delta_q_present, - .log2_delta_q_res = frame_header->delta_q_res, - .tx_mode = frame_header->tx_mode, - .reference_select = frame_header->reference_select, - .reduced_tx_set_used = frame_header->reduced_tx_set, - .skip_mode_present = frame_header->skip_mode_present, + .delta_q_present_flag = frame_header->delta_q_present, + .log2_delta_q_res = frame_header->delta_q_res, + .delta_lf_present_flag = frame_header->delta_lf_present, + .log2_delta_lf_res = frame_header->delta_lf_res, + .delta_lf_multi = frame_header->delta_lf_multi, + .tx_mode = frame_header->tx_mode, + .reference_select = frame_header->reference_select, + .reduced_tx_set_used = frame_header->reduced_tx_set, + .skip_mode_present = frame_header->skip_mode_present, }, .loop_restoration_fields.bits = { .yframe_restoration_type = remap_lr_type[frame_header->lr_type[0]], @@ -181,6 +193,9 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, }, .qmatrix_fields.bits = { .using_qmatrix = frame_header->using_qmatrix, + .qm_y = frame_header->qm_y, + .qm_u = frame_header->qm_u, + .qm_v = frame_header->qm_v, } };