From patchwork Sun Nov 12 10:35:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 44620 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp728039pzg; Sun, 12 Nov 2023 02:36:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5x1Kv7z86/C7Mw9G46uBfsHS564Alge38GCQYjTrT9UKkXPmUyGZ0goDUhSOhBzWJLpQ6 X-Received: by 2002:a17:906:13c9:b0:9d0:6108:993a with SMTP id g9-20020a17090613c900b009d06108993amr2929335ejc.36.1699785371100; Sun, 12 Nov 2023 02:36:11 -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 v5-20020a1709063bc500b009930d9d6b4csi1584547ejf.888.2023.11.12.02.36.10; Sun, 12 Nov 2023 02:36:11 -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=s2eZlJO2; 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 2714968CACA; Sun, 12 Nov 2023 12:36:07 +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-psaapc01olkn2055.outbound.protection.outlook.com [40.92.52.55]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F000F68C851 for ; Sun, 12 Nov 2023 12:35:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJzFdIulNpfS3D8+I0KXYOA0RZCqGTAb73KIMO0u5kTFCoI0zu5pP4pF1hMgvgfKDf4E8rmWa0tNiZ2v3qelqwuAU8TTTu6lCPnhTa9GKjQgWiWLQUVWVdKKQSlVco5GaE0VowLymJ4SDZdjcUIXn7oUzezbD8B9LjGjItjcnSoJP0naZ9jtknLDV9W5ASzg3cB+TnSOZjlmtMT4ao5cBK0M09PejU38YmBE4FuLnwqMN8EabFZszLfp+pShp5lYI5XYt/AP/SaG2xv1Uh8mSFgGZHyOPnIO7nPXlRNXZbfGAUO5/yparPOhqU/gdgR9kneLor0WUTif2G7BDmNC6A== 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=3LcHAW3lMrd3WAMVNE07/1xIg7fLGo9QcM0mBaofbJY=; b=BfUrixgl5Fd2hqoke9RUbawfr8EoWjcQ9+4Xj2IgpaAgjD5uWh4MdIup3B0qJb1bmXj7OBq6KvUdFFtug9d83xRl+hMO3m1hp3pmyJUwqKoOoWb2VLo/+p2kCHZJdMh8MHZdzqjjUwSh/z8uXC2yK+oxOj1aHgn6GZj2sZcQrC8+dnltV9wZtf4DapW/n81lAB4cTmW3qTFHtn1+z3FLTcKtq9eXZFrXcKk6a7jZlAy5tgAm/BGiErGzXgvEFD0epgi8Ag0Fw2ZC3aKaTOWq5byRXsdCM0V4GrR7uVB7FvVFkLQgRCiWAQuUcqwhr2czgJo8+eU9RZCkSdmUFXLboA== 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=3LcHAW3lMrd3WAMVNE07/1xIg7fLGo9QcM0mBaofbJY=; b=s2eZlJO2sKiZ26Rv3PTFVcgkJVAaCwBG2hi7qEMU1pNM+SYP8w+2JRKueeAg8UgZk3RC0+aBiz2sXzpmqfdSe/3vLwXrgDnZTNTi99yzWrQE+WoB5h0wqqllmGbeQDcVEAVVKiqpE72DaIbQF/tpGN3yzRHZfybJFIK1W4sg/EmNcNTaxWS021rIfrn5PsBCPrKerSvODrhRUSOXb7XkPX9DUgKyUnDsp3wZhfSHqykKN+n3Xa5tgEUmbK5HstITc2tEk5UKkyqY5Bmo9et5Tet3sqrhvapjMzSyJsyliZpHMXnoBTtzxboCxox+HJF8Mm8Q/IHoFEArl3HElUoOeg== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by TYSPR06MB6768.apcprd06.prod.outlook.com (2603:1096:400:475::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Sun, 12 Nov 2023 10:35:54 +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.6954.028; Sun, 12 Nov 2023 10:35:54 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2023 18:35:13 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 X-TMN: [sFHyHZyWcwEQRk3Do6ZAICaPGfe2vcAY] X-ClientProxiedBy: TYWP286CA0030.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::20) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20231112103526.11245-1-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|TYSPR06MB6768:EE_ X-MS-Office365-Filtering-Correlation-Id: b54f1516-d812-46a7-c135-08dbe36b25ac X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZywDRHzb+SnNa7hEvh2EX6/FOWV86Jn30vOQ2acZDqGX6FNbW8Qt2Dm3hFAz3J4lId86GL50P0HnzbeYNUm6l8W2cl5uYJVGwuey7Bn0DfmfPDpIhozSA9ZWNJSQvwsxyD2R9UoIkiATC5YgVtLeFlB8TesqrHTS7IoUNHhoNTeQ0SOd3rO87XOZMNoqZoJ8qH4mR0czLBrPpwgn0gni1WiRsM3CXiKsMDGQ4dVAoZ7S9m68M+Q6okdGnswfozCS2rz6U12Y2pU8+VN/G5SZPSAB7wbHyQQw5Rm0NaATsYGmsY+32Nea43pw56HgkgN2uClaJS/6Ubl0yMdcbyCmdeptfr3iiBgfKxVY9OFd0fJvqGEzQ/ojEGWhfw+v6/WDvCIYlt4QxWcPTARcJQd1DbkSqpWRNjZ9T2XLA0hOknzGEQWO+CjjP9lGAawsxa7uLNKXvUUz0ALbieHnQZgpiDXBEgxlP15via1ojdg5nV/eTAmE2ORSXaWRZi1x2mNkdp8ccmZKN+Y/p8yP00L6yl0VrkKvlWolG9GlXhesoqR7wJOVGE6B0qWEBTyFbd2FzVs8j+ItUJv7jp8JBrBqhKa1U4LvOk2tkefjRy7Hue0wczJlaUvI7rErtC7AGa9n X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w4fiVvGT/J5BxjCWfBU+x2GWkR4pHiIkhW9XWdCgwAHBLjOwhFC0PAmQOzKyMG1NbpBx8Jqx4GIVr7RFB1j7zFHdlobfhdkvXP/iFDuxj/YvgQT0ycZ1n53rgdOfz3TwqXCvGlxLcgnIg0w7vesH1AQM1/a4oVQNmz/unitKetLHJd6GAJMLKv49KzMz8y+pYWyWn3bmxx8px7CrA9dFj6n4VEOdg8W43naA4Yl+fi4pfaUa7HPGfR1rk3SDRoZRJnk+WDou94mhmxesZ4llckPd6iRK7AKHgS7ptBhVnZRy5ghjEuZHe/wWi6oX5N39awlVlkchFnwORkvX2lCjUlgpqRw83zYuvM8J2SFo7fF2jVcXNrLfZSGlfrAWCkqQAWs64wVcBDzrDdcxxgALCBeW8SmTPjqVbQm9lmDEzpQK/pf7xny8ryRLqaRwwH0DrzFvtCUOfA8C9qztw13NPsxoLbd2CEbKRI/ENh3t8ZzflzeB00X43Hv7ybBGwtAYpWXdjLQJwjqJ1IyT5cgecTBxIaEswDNZLBLduMb+I1LnrrrMdbapr2ozSUMkC3aLUZ4sLH1kiv9Ojgezedx599/ftLELH6PbLUp8h/oQtijaQj3a4eNd5/+pYVGGBb9RRC28/WvG0/G8F2jpWNathYv2PubcAtY87twXAdFSlnvvK5LE70CEzoTkPxt/07/c9hL3mYicsakxQuOr7b9FsVsOUHF3t05Z7sV16n4MJFxv/WGZb82h6iF4qN+YXFnzOcoH5S66AwTQZf2JTvLUFoC7zyym65qWTH65TVcAlDdH5V3tR+cGb/MdlZjIvCd8ZIM1knsvrgQpqGEJE0U4KMXY+VqzCAlZKcs7ZEgO+GbEYqlZglURR6n4mXLsPJ4SMKcRCsVrf1HzB17R1NcqG+indo7YSgWZAEc/s3sMbHP9f4KdBHjofF6hXfzfyc0fdXYA17HJ0EPkwn3pt1JUd3LcDZFWCAVJKxt/fy8fxxZxMQEz+RkqoL2gj8L5Kjuu2MZDVsA+/VaMZk1dwwQMD2WnaibfNNnAHEweMOW5+/ENOGPaDTtJ4lbp8iXteZRvRsZvg73VlirK71Xj0i1lxgpWJjrQK3BAVovaMUNowBvPVQJYhBTZJ5GdSSb/GLxh298ogL5cdEADNQn/KHBN+faFk6B9rZMkoqAZkvrbXcvhC0BmwPGlkR1eu4EH4PllWnxBPV1ImnSc/hGBEqbqUDnJzEu7VFLrRlfqs6HlroiHRWUddhrdAKPF1woEX4B3 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b54f1516-d812-46a7-c135-08dbe36b25ac X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2023 10:35:54.0213 (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: TYSPR06MB6768 Subject: [FFmpeg-devel] [PATCH v5 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: gjFVS5noMsz8 --- 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..3c591ce875 --- /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 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..2823faee75 --- /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_VVCDEC_H +#define AVCODEC_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_VVCDEC_H */