summaryrefslogtreecommitdiff
path: root/libavcodec/evc.h
blob: 9711c760fefad2b7562487b1d021d2a71f68a5d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * EVC definitions and enums
 * Copyright (c) 2022 Dawid Kozinski <d.kozinski@samsung.com>
 *
 * 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_EVC_H
#define AVCODEC_EVC_H

// The length field that indicates the length in bytes of the following NAL unit is configured to be of 4 bytes
#define EVC_NALU_LENGTH_PREFIX_SIZE     (4)  /* byte */
#define EVC_NALU_HEADER_SIZE            (2)  /* byte */

/**
 * @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic
 *      Table 4 - NAL unit type codes and NAL unit type classes
 */
enum EVCNALUnitType {
    EVC_NOIDR_NUT            = 0,   /* Coded slice of a non-IDR picture */
    EVC_IDR_NUT              = 1,   /* Coded slice of an IDR picture */
    EVC_RSV_VCL_NUT02        = 2,
    EVC_RSV_VCL_NUT03        = 3,
    EVC_RSV_VCL_NUT04        = 4,
    EVC_RSV_VCL_NUT05        = 5,
    EVC_RSV_VCL_NUT06        = 6,
    EVC_RSV_VCL_NUT07        = 7,
    EVC_RSV_VCL_NUT08        = 8,
    EVC_RSV_VCL_NUT09        = 9,
    EVC_RSV_VCL_NUT10        = 10,
    EVC_RSV_VCL_NUT11        = 11,
    EVC_RSV_VCL_NUT12        = 12,
    EVC_RSV_VCL_NUT13        = 13,
    EVC_RSV_VCL_NUT14        = 14,
    EVC_RSV_VCL_NUT15        = 15,
    EVC_RSV_VCL_NUT16        = 16,
    EVC_RSV_VCL_NUT17        = 17,
    EVC_RSV_VCL_NUT18        = 18,
    EVC_RSV_VCL_NUT19        = 19,
    EVC_RSV_VCL_NUT20        = 20,
    EVC_RSV_VCL_NUT21        = 21,
    EVC_RSV_VCL_NUT22        = 22,
    EVC_RSV_VCL_NUT23        = 23,
    EVC_SPS_NUT              = 24,  /* Sequence parameter set */
    EVC_PPS_NUT              = 25,  /* Picture paremeter set */
    EVC_APS_NUT              = 26,  /* Adaptation parameter set */
    EVC_FD_NUT               = 27,  /* Filler data */
    EVC_SEI_NUT              = 28,  /* Supplemental enhancement information */
    EVC_RSV_NONVCL29         = 29,
    EVC_RSV_NONVCL30         = 30,
    EVC_RSV_NONVCL31         = 31,
    EVC_RSV_NONVCL32         = 32,
    EVC_RSV_NONVCL33         = 33,
    EVC_RSV_NONVCL34         = 34,
    EVC_RSV_NONVCL35         = 35,
    EVC_RSV_NONVCL36         = 36,
    EVC_RSV_NONVCL37         = 37,
    EVC_RSV_NONVCL38         = 38,
    EVC_RSV_NONVCL39         = 39,
    EVC_RSV_NONVCL40         = 40,
    EVC_RSV_NONVCL41         = 41,
    EVC_RSV_NONVCL42         = 42,
    EVC_RSV_NONVCL43         = 43,
    EVC_RSV_NONVCL44         = 44,
    EVC_RSV_NONVCL45         = 45,
    EVC_RSV_NONVCL46         = 46,
    EVC_RSV_NONVCL47         = 47,
    EVC_RSV_NONVCL48         = 48,
    EVC_RSV_NONVCL49         = 49,
    EVC_RSV_NONVCL50         = 50,
    EVC_RSV_NONVCL51         = 51,
    EVC_RSV_NONVCL52         = 52,
    EVC_RSV_NONVCL53         = 53,
    EVC_RSV_NONVCL54         = 54,
    EVC_RSV_NONVCL55         = 55,
    EVC_UNSPEC_NUT56         = 56,
    EVC_UNSPEC_NUT57         = 57,
    EVC_UNSPEC_NUT58         = 58,
    EVC_UNSPEC_NUT59         = 59,
    EVC_UNSPEC_NUT60         = 60,
    EVC_UNSPEC_NUT61         = 61,
    EVC_UNSPEC_NUT62         = 62
};

// slice type
// @see ISO_IEC_23094-1_2020 7.4.5 Slice header semantics
//
enum EVCSliceType {
    EVC_SLICE_TYPE_B = 0,
    EVC_SLICE_TYPE_P = 1,
    EVC_SLICE_TYPE_I = 2
};

enum {
    // 7.4.3.2: aps_video_parameter_set_id is u(4).
    EVC_MAX_APS_COUNT = 32,

    // 7.4.3.1: sps_seq_parameter_set_id is in [0, 15].
    EVC_MAX_SPS_COUNT = 16,

    // 7.4.3.2: pps_pic_parameter_set_id is in [0, 63].
    EVC_MAX_PPS_COUNT = 64,

    // 7.4.5: slice header slice_pic_parameter_set_id in [0, 63]
    EVC_MAX_SH_COUNT = 64,

    // E.3.2: cpb_cnt_minus1[i] is in [0, 31].
    EVC_MAX_CPB_CNT = 32,

    // A.4.1: in table A.1 the highest level allows a MaxLumaPs of 35 651 584.
    EVC_MAX_LUMA_PS = 35651584,

    EVC_MAX_NUM_REF_PICS = 21,

    EVC_MAX_NUM_RPLS = 64,

    // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
    // constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
    // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
    EVC_MAX_WIDTH  = 16888,
    EVC_MAX_HEIGHT = 16888,

    // A.4.1: table A.1 allows at most 22 tile rows for any level.
    EVC_MAX_TILE_ROWS    = 22,
    // A.4.1: table A.1 allows at most 20 tile columns for any level.
    EVC_MAX_TILE_COLUMNS = 20,

    // A.4.1: table A.1 allows at most 600 slice segments for any level.
    EVC_MAX_SLICE_SEGMENTS = 600,

    // 7.4.7.1: in the worst case (tiles_enabled_flag and
    // entropy_coding_sync_enabled_flag are both set), entry points can be
    // placed at the beginning of every Ctb row in every tile, giving an
    // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
    // Only a stream with very high resolution and perverse parameters could
    // get near that, though, so set a lower limit here with the maximum
    // possible value for 4K video (at most 135 16x16 Ctb rows).
    HEVC_MAX_ENTRY_POINT_OFFSETS = EVC_MAX_TILE_COLUMNS * 135,
};

#endif // AVCODEC_EVC_H