From patchwork Sun Dec 10 12:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 44996 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp2365052pzf; Sun, 10 Dec 2023 04:53:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IESgI9Nb1LRIMighRvxaOOHVmzr9SzSpJOX79YTnIaQHBWy+eZ+dr4c58tMlc/O/XVKxqTM X-Received: by 2002:a05:600c:2d84:b0:40c:31f6:1dae with SMTP id i4-20020a05600c2d8400b0040c31f61daemr698421wmg.69.1702212817307; Sun, 10 Dec 2023 04:53:37 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v14-20020a056402348e00b0054c8bc2a8a7si2814039edc.193.2023.12.10.04.53.36; Sun, 10 Dec 2023 04:53:37 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=VnTzGBJk; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 90BC368D0BC; Sun, 10 Dec 2023 14:53:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (unknown [40.92.53.57]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B605368CEB1 for ; Sun, 10 Dec 2023 14:53:25 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b3C3OqnzK3i3z4fpBHbY5k1faH/ZwCt1aHBYpEYiSBs2nfg03i8dTl/bsot2+vWa0zd11J6BAFT4psUCtHeD1zFzSvI7/TLWvwU7YJGCxFvffdoWLPZYKuK+OrpR7cWDd8W4rPasRxxSV8nSxcF3CevQzvx4kKUsaQIU1AF26scR7DToHuz3bFB2SoTGXM56ykhzj8BdFlvBMkc8xa0p8ojXzhrblwkeOyHLkDq0RKcjiseVIov23DLBZk5mPr1hI60nHdSZaBq+E/D19fpaqyeGMsfwe2+6Zfq8PF+U4I4HTThcIX+Eri/9hVR+myTfzCHVYUrxN6Gvo/iZwG0XRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z3j2wH+z1wUJM7Wwpc1azXnssr9VB6QCBvbs/XaM1Kc=; b=LPD2ojEprSod1tNlGfjJ03os/pTT6ONtlxiDBi4WcYYGr4YhtGZhB22fcWN6lDoTs1jueTo7jGxXg5lRjEEfM4sWQYS8U+MZblqtxwZeWSZHdBCdlqSohYeS2EO5p6W7bz/JZ9G45rcXw6gGUW5Yrl66+pEZJ4X6l10qNSY7ApFbOiFVdTY3jBwXdQu00r++0CmyplKIbORo9Cc7Us23Thla7wDPMxuWpodTcEmbgp75kw9BB0qgYYaF/McoRW6mGuAsW5oTTw6beBMVNzl8lf0NVh0XxrL7/H2jEVkP3dlfy+j24ivC832AekXv9BPC2ZOAQMg+Ia7/msHsaqdxhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z3j2wH+z1wUJM7Wwpc1azXnssr9VB6QCBvbs/XaM1Kc=; b=VnTzGBJkpyllzhynE0mEDVuKB8SSiTzmzj1PJfphuX5snvbNZJYdpHfML/oOypXiuSVEQv+utPUpSy7zSHPLO3p6fRFdnv8ci3Nv1dEJPBeqMVr2fBBA9hxWcjUBRteH2DXquXMZ7pvG1YoLVGxIcSA3Y0cqsEVSuudFQB8FdF+l1gAn7M8axw7rouodpSM38MDr9cXrqFedfH9VAkUr9fp/5dVC/9w1a6/89FoEDPPCgNgqhMfbmRSMK+q0wjH9yJn5d9Dlj4qW8CQ4TMxBzFndvDm41Fli/9aKFPvsk3AaYKLKJChdW9bDVmkmC7KAM03R38knxQ/L6xtUx0gp+Q== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by SEZPR06MB7644.apcprd06.prod.outlook.com (2603:1096:101:249::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.30; Sun, 10 Dec 2023 12:53:22 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::80b3:be24:949c:e49f]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::80b3:be24:949c:e49f%4]) with mapi id 15.20.7068.030; Sun, 10 Dec 2023 12:53:21 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Dec 2023 20:52:55 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 X-TMN: [aJVVEPrLNVIHSmTlkZcgTpLKR5U7debM] X-ClientProxiedBy: TY2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:404:a6::19) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20231210125308.1838-1-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|SEZPR06MB7644:EE_ X-MS-Office365-Filtering-Correlation-Id: 980acb5e-49f0-4f13-07d2-08dbf97efcf8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: omJYiNGY9803Kj93seiv89oO7/HgXenOlXTNBlIMSqUJe0azHImynfKD2NnL//QiS6ywpcpPU2lfGPGW6Af5qXhI4OOVj8lrbaU3qsfDE3E/0AoFVBU2vipR02r9PXMmQ5QeLSOMcXAPId/HGtG8LrLSi0cxd/3U5afjT7yCsKjL5XLkj8w4nO1ZcL1P9IEvJ9FeOhsDTP7etvhf6wl0yIKVR/fDFztYMR3d7HTqStfdq33TPO7C13vDxt4j6/yMv1pHzNI1eJPiGWJ+oxFpiUwxOL9hcSUxQ2UIGX+OEUhBOIkYKpHyQrzVi8HhijM9BNruk29pqqOy2ap5b8pxuA4M/NGdjL2HINr9UC6axqefGmFX60IpvyubjFQdvKcG729Go3yww+fwPrfZssQrBK1/gLRNAR+5dvzX/PUnub+sukXrdDb14oDY9dVzsvmGjXBJ8e5lS2+yt6EuHeR/yMXnXai2VfLTF7WxQ7ryh5whIri1dwaxjGIcYodScS61Hnv5Qtdf6LcglX2Vv3wiYMWZITm0WR/pvaE4oGKrsokkwKusdVl271Xp5cAN6/hWkn9YEz1P0c/Mj24tzcj2zvJSB7g98CV8+0zSN0mtwm/0wdrv6PSAD3B4M/uIDbv1 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GYWc+TNRr/bkbprUEOD5Gl9cFQBbELBTmx5+Q+9aWT5Is4YLqOAyuUhqpjN9R//QAhRL7bXsDzWBVEXV4AOjuf14IwOYGWEkzYIAeGoL5gxeCWvqHo5qFXIYmtIuSHMklzwFrlZmzoKdrN5JpmHC8tbUSOPjBdnn0pfvcvDc1623Vr9c2JUh074aCD8h3IE3ikCk8kmBrcTXnGxXVeLQdt4qg8oJsSpoeeXGPkMP3HbZbxv8mnuHy1bf1izjGGWzPqFqUzkJyci9Kx9VPIxfm1UwYv/G5NyRzwYGZBABVL/5/clJc5wtxOPV953HlujqI2t0iQti9JzC6BZcNRX8A0vCqd6pSQ6fj6FMUg9TiLxgHTf3NYNVM3xw8/WxJRNEp72KPGu2ZL8i9QwyzQrbMak/0kSHmoqeo5h6kPti2Hq+O2hJ11TUd9eqfE79AaDaHe19AIb+jsYSrdCCmFz7JMans7me3e95Z7TBHberujOy6RO+iKfJqmzVWZYL2NL4VSNafbvuk0WcuA2eSb1m3K7ZrfdoLS+WIgR4hIz5jJIlC6igXDxkCNaJ6UNH2DTRrTb/fXSUE+6d991uraJv0C8bEjSZiy767MAtyrWmyE7NRF021W6AAhwqpbtldUY5qSTa/LEB/Yh5LAS0J5o6wOKrJhjd53B9cQ7qMqVGmrUCen8tc2G6CaUSzhpeB5INpGPqX3LAAhBZjf46KGngXSJqrDf+640RKijIxyFlqIV2jHwjHHQjCUWugDR5nsojFXKe1UxLBiTzNsi65y1m2tPSQY5/TLpE5re4BvlJkRWwBLdLhYlgO9ypoY1nhGQUG7aTrDowDYwMVHcCFNPr7jvees/srUnNms4jl5DEctt3SqV/+G1bkBPuX3kQooQDa8M+/dYYVvyzAckK7RPoGCQII4bQT2YoTYSi36sSkwc8aaGmigxYQNEiKJj9Hpl3/Tp25Lu3kPGy4mhu692dNdwVP/ObqSOM6uW2PEMCJQ7U353vsEVJBB0d6JTdYUNDNyoY52zYaCSzL5kR0ltqtEeXZcMOdBPshSTeC90K/W6PCMJtalqeuCTEJvuFvsF8rks8RvpLcIzzikY/ooXB7WFs3JG0yPFWkiOJSl9ltJ1upSJZXQanetURcuawDwlXiQJV2rZK3pzVkxXuKEArM6wokCxnyYrmiqJX7m++ZSvh1rgV807rvliJz76DF/fZoQI73VgTPD+YQinV3ZbJHkd7SIh2ZNHomj5iaZwSPaVQvAW9ekXizI+E3B5sfyzu X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 980acb5e-49f0-4f13-07d2-08dbf97efcf8 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2023 12:53:21.2234 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB7644 Subject: [FFmpeg-devel] [PATCH v7 01/14] vvcdec: add vvc decoder stub 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: Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1yltzVDOYYTt --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/vvc/Makefile | 4 + libavcodec/vvc/vvcdec.c | 62 ++++++++++++ libavcodec/vvc/vvcdec.h | 204 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 273 insertions(+) create mode 100644 libavcodec/vvc/Makefile create mode 100644 libavcodec/vvc/vvcdec.c create mode 100644 libavcodec/vvc/vvcdec.h diff --git a/configure b/configure index 46d7a5cf0e..770cbb2f8e 100755 --- a/configure +++ b/configure @@ -3013,6 +3013,7 @@ vp6f_decoder_select="vp6_decoder" vp7_decoder_select="h264pred videodsp vp8dsp" vp8_decoder_select="h264pred videodsp vp8dsp" vp9_decoder_select="videodsp vp9_parser vp9_superframe_split_bsf" +vvc_decoder_select="cabac golomb videodsp" wcmv_decoder_select="inflate_wrapper" webp_decoder_select="vp8_decoder exif" wmalossless_decoder_select="llauddsp" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 57d57f3ab5..aba849f408 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -64,6 +64,7 @@ OBJS = ac3_parser.o \ xiph.o \ # subsystems +include $(SRC_PATH)/libavcodec/vvc/Makefile OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio_sample_rates.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 2662adb754..6c5aa6b44b 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -389,6 +389,7 @@ extern const FFCodec ff_vp9_rkmpp_decoder; extern const FFCodec ff_vp9_v4l2m2m_decoder; extern const FFCodec ff_vqa_decoder; extern const FFCodec ff_vqc_decoder; +extern const FFCodec ff_vvc_decoder; extern const FFCodec ff_wbmp_decoder; extern const FFCodec ff_wbmp_encoder; extern const FFCodec ff_webp_decoder; diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile new file mode 100644 index 0000000000..bd14dbc1df --- /dev/null +++ b/libavcodec/vvc/Makefile @@ -0,0 +1,4 @@ +clean:: + $(RM) $(CLEANSUFFIXES:%=libavcodec/vvc/%) + +OBJS-$(CONFIG_VVC_DECODER) += vvc/vvcdec.o \ diff --git a/libavcodec/vvc/vvcdec.c b/libavcodec/vvc/vvcdec.c new file mode 100644 index 0000000000..4ea20624be --- /dev/null +++ b/libavcodec/vvc/vvcdec.c @@ -0,0 +1,62 @@ +/* + * VVC video decoder + * + * Copyright (C) 2021 Nuo Mi + * Copyright (C) 2022 Xu Mu + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "libavcodec/codec_internal.h" +#include "libavcodec/profiles.h" + +#include "vvcdec.h" + +static int vvc_decode_frame(AVCodecContext *avctx, AVFrame *output, + int *got_output, AVPacket *avpkt) +{ + return avpkt->size; +} + +static av_cold void vvc_decode_flush(AVCodecContext *avctx) +{ +} + +static av_cold int vvc_decode_free(AVCodecContext *avctx) +{ + return 0; +} + +static av_cold int vvc_decode_init(AVCodecContext *avctx) +{ + return 0; +} + +const FFCodec ff_vvc_decoder = { + .p.name = "vvc", + .p.long_name = NULL_IF_CONFIG_SMALL("VVC (Versatile Video Coding)"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VVC, + .priv_data_size = sizeof(VVCContext), + .init = vvc_decode_init, + .close = vvc_decode_free, + FF_CODEC_DECODE_CB(vvc_decode_frame), + .flush = vvc_decode_flush, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, + .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_AUTO_THREADS, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles), +}; diff --git a/libavcodec/vvc/vvcdec.h b/libavcodec/vvc/vvcdec.h new file mode 100644 index 0000000000..720d585fd4 --- /dev/null +++ b/libavcodec/vvc/vvcdec.h @@ -0,0 +1,204 @@ +/* + * VVC video decoder + * + * Copyright (C) 2021 Nuo Mi + * Copyright (C) 2022 Xu Mu + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VVC_VVCDEC_H +#define AVCODEC_VVC_VVCDEC_H + +#include "libavcodec/vvc.h" + +#define LUMA 0 +#define CHROMA 1 +#define CB 1 +#define CR 2 +#define JCBCR 3 + +#define MIN_TU_LOG2 2 ///< MinTbLog2SizeY +#define MIN_PU_LOG2 2 + +#define L0 0 +#define L1 1 + +typedef struct RefPicList { + struct VVCFrame *ref[VVC_MAX_REF_ENTRIES]; + int list[VVC_MAX_REF_ENTRIES]; + int isLongTerm[VVC_MAX_REF_ENTRIES]; + int nb_refs; +} RefPicList; + +typedef struct RefPicListTab { + RefPicList refPicList[2]; +} RefPicListTab; + +typedef struct VVCFrame { + struct AVFrame *frame; + + struct MvField *tab_dmvr_mvf; ///< RefStruct reference + RefPicListTab **rpl_tab; ///< RefStruct reference + RefPicListTab *rpl; ///< RefStruct reference + int nb_rpl_elems; + + int ctb_count; + + int poc; + + struct VVCFrame *collocated_ref; + + struct FrameProgress *progress; ///< RefStruct reference + + /** + * A sequence counter, so that old frames are output first + * after a POC reset + */ + uint16_t sequence; + /** + * A combination of VVC_FRAME_FLAG_* + */ + uint8_t flags; +} VVCFrame; + +typedef struct SliceContext { + int slice_idx; + struct EntryPoint *eps; + int nb_eps; + RefPicList *rpl; +} SliceContext; + +typedef struct VVCFrameContext { + struct AVCodecContext *avctx; + + // +1 for the current frame + VVCFrame DPB[VVC_MAX_DPB_SIZE + 1]; + + struct AVFrame *frame; + struct AVFrame *output_frame; + + SliceContext **slices; + int nb_slices; + int nb_slices_allocated; + + VVCFrame *ref; + + struct VVCFrameThread *ft; + + uint64_t decode_order; + + struct FFRefStructPool *tab_dmvr_mvf_pool; + struct FFRefStructPool *rpl_tab_pool; + + struct FFRefStructPool *cu_pool; + struct FFRefStructPool *tu_pool; + + struct { + int16_t *slice_idx; + + int *cb_pos_x[2]; ///< CbPosX[][][] + int *cb_pos_y[2]; ///< CbPosY[][][] + uint8_t *cb_width[2]; ///< CbWidth[][][] + uint8_t *cb_height[2]; ///< CbHeight[][][] + uint8_t *cqt_depth[2]; ///< CqtDepth[][][] + int8_t *qp[VVC_MAX_SAMPLE_ARRAYS]; + + uint8_t *skip; ///< CuSkipFlag[][] + uint8_t *ispmf; ///< intra_sub_partitions_mode_flag + uint8_t *msm[2]; ///< MttSplitMode[][][] in 32 pixels + uint8_t *imf; ///< IntraMipFlag[][] + uint8_t *imtf; ///< intra_mip_transposed_flag[][] + uint8_t *imm; ///< intra_mip_mode[][] + uint8_t *ipm; ///< IntraPredModeY[][] + uint8_t *cpm[2]; ///< CuPredMode[][][] + uint8_t *msf; ///< MergeSubblockFlag[][] + uint8_t *iaf; ///< InterAffineFlag[][] + uint8_t *mmi; ///< MotionModelIdc[][] + struct Mv *cp_mv[2]; ///< CpMvLX[][][][MAX_CONTROL_POINTS]; + struct MvField *mvf; ///< MvDmvrL0, MvDmvrL1 + + uint8_t *tu_coded_flag[VVC_MAX_SAMPLE_ARRAYS]; ///< tu_y_coded_flag[][], tu_cb_coded_flag[][], tu_cr_coded_flag[][] + uint8_t *tu_joint_cbcr_residual_flag; ///< tu_joint_cbcr_residual_flag[][] + int *tb_pos_x0[2]; + int *tb_pos_y0[2]; + uint8_t *tb_width[2]; + uint8_t *tb_height[2]; + uint8_t *pcmf[2]; + + uint8_t *horizontal_bs[VVC_MAX_SAMPLE_ARRAYS]; + uint8_t *vertical_bs[VVC_MAX_SAMPLE_ARRAYS]; + uint8_t *horizontal_p; ///< horizontal maxFilterLengthPs for luma + uint8_t *horizontal_q; ///< horizontal maxFilterLengthQs for luma + uint8_t *vertical_p; ///< vertical maxFilterLengthPs for luma + uint8_t *vertical_q; ///< vertical maxFilterLengthQs for luma + + uint8_t *sao_pixel_buffer_h[VVC_MAX_SAMPLE_ARRAYS]; + uint8_t *sao_pixel_buffer_v[VVC_MAX_SAMPLE_ARRAYS]; + uint8_t *alf_pixel_buffer_h[VVC_MAX_SAMPLE_ARRAYS][2]; + uint8_t *alf_pixel_buffer_v[VVC_MAX_SAMPLE_ARRAYS][2]; + + int *coeffs; + struct CTU *ctus; + + //used in arrays_init only + int ctu_count; + int ctu_size; + int pic_size_in_min_cb; + int pic_size_in_min_pu; + int pic_size_in_min_tu; + int ctu_width; + int ctu_height; + int width; + int height; + int chroma_format_idc; + int pixel_shift; + int bs_width; + int bs_height; + } tab; +} VVCFrameContext; + +typedef struct VVCContext { + struct AVCodecContext *avctx; + + int temporal_id; ///< temporal_id_plus1 - 1 + int poc_tid0; + + int eos; ///< current packet contains an EOS/EOB NAL + int last_eos; ///< last packet contains an EOS/EOB NAL + + enum VVCNALUnitType vcl_unit_type; + int no_output_before_recovery_flag; ///< NoOutputBeforeRecoveryFlag + int gdr_recovery_point_poc; ///< recoveryPointPocVal + + /** + * Sequence counters for decoded and output frames, so that old + * frames are output first after a POC reset + */ + uint16_t seq_decode; + uint16_t seq_output; + + struct AVExecutor *executor; + + VVCFrameContext *fcs; + int nb_fcs; + + uint64_t nb_frames; ///< processed frames + int nb_delayed; ///< delayed frames +} VVCContext ; + +#endif /* AVCODEC_VVC_VVCDEC_H */