From patchwork Sun Dec 10 15:57:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 45023 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp2458758pzf; Sun, 10 Dec 2023 08:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBcZir3YP/j9HKnUH+fJrG1y8teuOBwjQAq1lw5BolYybC6tsJStt+SkT+uLR/GVHO+ysn X-Received: by 2002:a50:d543:0:b0:551:26cc:7db3 with SMTP id f3-20020a50d543000000b0055126cc7db3mr128068edj.68.1702224880259; Sun, 10 Dec 2023 08:14:40 -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 f29-20020a50a6dd000000b0054ca02e2fb0si2916766edc.296.2023.12.10.08.14.39; Sun, 10 Dec 2023 08:14:40 -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=VLbxtYuM; 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 89E2568D11A; Sun, 10 Dec 2023 18:14:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01olkn2014.outbound.protection.outlook.com [40.92.52.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 954CF6807D3 for ; Sun, 10 Dec 2023 18:14:29 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OooiYoF9PDuveeIDObXHYFCp6ta83KcLYEA1FbCT3PsAxjB4czoM8YVEA3RFEjxrhxCXZc05l0MdsuCYGKAlWBt/vyKma4s7O3QiHytYr3Y1EUN3+XBHicHeAgyNJx07pnkVKO1gXnrW1R7ZtZiq6TbKHstgwVyCOi2iOly4Y52+USWriCxarb3NN5owks+8yWlc0imQXc6XF9hA6FSIC43Xu7wQdaX8i2zTAcXagQxuYumdt/5oVkPvLsWfAwbwh86WC5NvF+3Nr8ZoO8s0WO6NXXoodSB0NN/sCRiiH93QCbnIMDt2uAo8M0RXF71KeaIKmxDXMBUf9Rcgo1hl0Q== 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=mVVy5LTMF57cCC+vjRbBER4j7W4ZTuEBHMxLXpaqi5o=; b=K7JA2l+eMJL64NAHlZwcEAJQFOlpCEumhjiJLqvL1hITtUJaVzMJNQNqOinc5+O6njG7h7d8pUKDUBumSZbIbirojW3FH8rGzLmcpFiX372Zv5et1PTDG9zK7niv5Hb9WzldSdHaOQwlgQVovvBxRICskZC63otNuBShm5msx3aV4u6hJmJmV72rMAcaEWa62ZV9sVZ3osGIKHToCKUg9Jrpox5HoU/Z+Km+HrYoBroAuIeM4Ld+KG1I7Lr8+0pteqt3NHL8fobGlSCYdQ1D8/uURpd9o8f5vB9jbxQTHFCPQgfEb2+sIF56cQLiqdmOha3mfneJzlIGepSRc9yQgg== 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=mVVy5LTMF57cCC+vjRbBER4j7W4ZTuEBHMxLXpaqi5o=; b=VLbxtYuMKXEv6wpqGLNCpSNvTrlQIBMeUh9ePRV76pJVih6/JsVoHlYEBe1RxBmbTy35Lb3AbGGTfod2mcvh0n6kmp/tDON3LdhTZ2F5A51K1+gDW/LKvb+0+AgeUrU+jkHJ8X0qRIsLWICF57LpC+UX8OjQdCKt4dLwQzwM6JElXUR8KjBIKBT4n0i64OmYqzd/ydKks7COJeD7ku+apq4wZpZMPnIZ31oyojwUovnmgtI6Ir3or83yg7OtJ+Fxc7qihhswnDreu1UhMkCqXkrFRXftrcuoWB9OzNpjsyQWPJfRBcCrKpg7f++hYhCO7jkcpNEiKYLjtVtCgL1pSw== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by SI6PR06MB7272.apcprd06.prod.outlook.com (2603:1096:4:246::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Sun, 10 Dec 2023 15:58:16 +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 15:58:16 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Dec 2023 23:57:54 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 X-TMN: [MIXV5/4aH71Aaxb6fUXU0qjCBCJ65l0x] X-ClientProxiedBy: SI2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:4:196::10) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20231210155807.4583-1-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|SI6PR06MB7272:EE_ X-MS-Office365-Filtering-Correlation-Id: 48bbe5b9-cc43-4fd7-a2d5-08dbf998d201 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VH1ukUvLisk1NIwj0AvnK25va2Ar0/EK6NmzQAwkrQJT0aYuXTZKv3/8Ta0YQbSnQ83jJ5y8Ths1+t5GJuVAOV18BzkEGXauxflWaf1wAkuDg6ICl4t6KgNXa8qvwUON8C6BinrhgLnNYYip6i7BDX37zRdZZ8LcRJMyF+lB5Rn5M0nreQrlx7QR9EMGcPqvY9pOva/s2L+dh85Msh8GuPwC5iqb2gKsWuvu3zOm+UEU52+/2mXotRy9Cel94LMnoL1RTE1wNoDHNv9TuFzLotUQZRnXOSNrdARlmOrTWL2Fb3mQmzPPuLdPk+lUPb8YRPwFmOzZ0WMe/qJH1UkB2qjt7eUMGfwt6jopuuxn80BazXSbzTvTrS5LrFbtUdyFm2GvJLLxBW5sSzLdvXDIHg8q8BHDTBNGu/h9GymJFaJ9Th7Aq2+flGDvFTdlaD324MFPYzWnWPaYCY2Q+ytQxXN4wXPtpXa7hUJpGUzdILJZ/J5yzZgaRsHY8rIkUDohJ5HCtMLTB5AnDAMApeqmvUdREmEqEEOzMxUCz2bpfiU1IE/A9XlHdmDUdLxv07NIttvDAME62yhqiEK4QiqcN00S9LFQ/HUSJBW1OQbUIs7S25P25Zp312phLw0nFngw X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vRwI1Uh+EO6RaN18E3uWufBHb7jmiOk2pQZK4V2t8I+Ord3MQnHLMBsCvCj11bB19KCo3qWnqEasMAJbeoqEgABaWCKWkaKfjuvfxqLFiVuRaCIJt5mCjbJl3vLuLXtRENw90p6MAub06bbV/Opd/1LmM61M3dc74LJrtvqWmlFmLGd3uG2qPXnw0r+feKHYjVaqXeR3ByOABmlanoGnKjo+xM7MybNS31suzW/fFJfUyHgA5gny6OQ9ffjv9RY2jOpZRJK736YJaGT8eiKXR9giDmRHPbgqv9s7Qb/D1K2jgjZn3BW24dPy1rLXXssSAHzil6PZHzSJOO3Rv/lN98Hb7u8e1Vs4ki7ddhhZNCtVVm6hJfw9YXLO3E/VDszsv+pN3LaLVaqMPoRQbPDeaQxbsW3sELbrL0/Oyr0E0Rugny4n1Py1tKVTjUw16O4vYmADYp4+NU5zVHsJlRs0ZMtooZc++xdTKOZ8KmQqKDDHO3Uvod1tA3pkzg/NySFtSRnQHOyKf4AGEyhA8Cr03n1O2rXKDLRiaqgQuFZuS8KnmrLnY+ScDmYK/fSUneKqdNf0n/eVnE5+HifHxLwWShcklmWVbJEPwZzes4TZHrkuLnZj5alynA7pBg0dMko8CYlqiXz3c0eO7dzlBwuE0FzCxLW6FOwC8oR2pW8a7sdtfJLHAg5z+F31y+/dwkYSgNcPvT+Fh2P9chGhAcfxsv3oGFtaurJQSGth5rYB+Fv0ozgf4NM+2WC/obfzPXYTy9kCQXzwRt6wh0UKutbQC+LNmON7Oj5Wb7lkr6EvvtyXqg5WGxvgvgkK1oUu0MVRaLhN75rEVy47N4jgS2vmHHBFlAA7m2KVl8u4iTazqRT0+02tuXQGxMd+JMExoC7nxbZLzHoEREltZFGIuV8AI/gheT9/K3dfmDgONWqD379P6x2WWzOfj1O6zOsXT+YpCZSZIQ7zbm3iHk/xdv7eUehahVNC/qdCHpoENgDA/7ek2ua7Mf9YKwhWaFrncUxT4E53iRSVLaC7ZLYPspyWWZM2v2FxwSz+TJXwT9uiLvlJoyzMjgzLUTC/+AazemHI3qCXvLaWoS/4EulQKFpExb1jawsBngBOQRdLy9F69Au0htIxK8R1LY/NEMZAsVkuVg6TmL1u/5mkRw6hI6v3R4Mx/KZWGfsXpeq8zGfSiMzd3Tly+JPH1OuDccF5k1tpT4jsm2W8eNT09I1qQ5QfXFwGGHWHIC4u9wQu5uF4FZTAM3s4MAl4iwLhIk0uOW62 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48bbe5b9-cc43-4fd7-a2d5-08dbf998d201 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2023 15:58:15.9966 (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: SI6PR06MB7272 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: /QVQRfbwiGGr --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/vvc/Makefile | 4 + libavcodec/vvc/vvcdec.c | 62 ++++++++++++ libavcodec/vvc/vvcdec.h | 205 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 274 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..875ffe0a9a --- /dev/null +++ b/libavcodec/vvc/vvcdec.h @@ -0,0 +1,205 @@ +/* + * 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; + void *ref; ///< RefStruct reference, backing slice data +} SliceContext; + +typedef struct VVCFrameContext { + void *log_ctx; + + // +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 */