H.264 Codec for ESP32-S3
Loading...
Searching...
No Matches
codec_def.h
Go to the documentation of this file.
1/*!
2 * \copy
3 * Copyright (c) 2013, Cisco Systems
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#ifndef WELS_VIDEO_CODEC_DEFINITION_H__
34#define WELS_VIDEO_CODEC_DEFINITION_H__
35#include <stdint.h>
36/**
37 * @file codec_def.h
38*/
39
40/**
41* @brief Enumerate the type of video format
42*/
43typedef enum {
44 videoFormatRGB = 1, ///< rgb color formats
52
53 videoFormatYUY2 = 20, ///< yuv color formats
56 videoFormatI420 = 23, ///< the same as IYUV
58 videoFormatInternal = 25, ///< only used in SVC decoder testbed
59
60 videoFormatNV12 = 26, ///< new format for output by DXVA decoding
61
62 videoFormatVFlip = 0x80000000
63} EVideoFormatType;
64
65/**
66* @brief Enumerate video frame type
67*/
68typedef enum {
69 videoFrameTypeInvalid = -1, ///< encoder not ready or parameters are invalidate
70 videoFrameTypeIDR = 0, ///< IDR frame in H.264
71 videoFrameTypeI = 1, ///< I frame type
72 videoFrameTypeP = 2, ///< P frame type
73 videoFrameTypeSKIP = 3, ///< skip the frame based encoder kernel
74 videoFrameTypeIPMixed = 4, ///< a frame where I and P slices are mixing, not supported yet
75} EVideoFrameType;
76
77/**
78* @brief Enumerate return type
79*/
80typedef enum {
81 cmResultSuccess, ///< successful
82 cmInitParaError, ///< parameters are invalid
84 cmMallocMemeError, ///< malloc a memory error
85 cmInitExpected, ///< initial action is expected
87} CM_RETURN;
88
89/**
90* @brief Enumulate the nal unit type
91*/
98 NAL_SLICE_IDR = 5, ///< ref_idc != 0
99 NAL_SEI = 6, ///< ref_idc == 0
101 NAL_PPS = 8
102 ///< ref_idc == 0 for 6,9,10,11,12
104
105/**
106* @brief NRI: eNalRefIdc
107*/
114
115#define IS_PARAMETER_SET_NAL(eNalRefIdc, eNalType) \
116((eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == (NAL_SPS|NAL_PPS) || eNalType == NAL_SPS) )
117
118#define IS_IDR_NAL(eNalRefIdc, eNalType) \
119((eNalRefIdc == NAL_PRIORITY_HIGHEST) && (eNalType == NAL_SLICE_IDR) )
120
121#define FRAME_NUM_PARAM_SET (-1)
122#define FRAME_NUM_IDR 0
123
124/**
125 * @brief eDeblockingIdc
126 */
127enum {
132#define DEBLOCKING_OFFSET (6)
133#define DEBLOCKING_OFFSET_MINUS (-6)
134
135/* Error Tools definition */
136typedef unsigned short ERR_TOOL;
137
138/**
139 @brief to do
140*/
141enum {
142 ET_NONE = 0x00, ///< NONE Error Tools
143 ET_IP_SCALE = 0x01, ///< IP Scalable
144 ET_FMO = 0x02, ///< Flexible Macroblock Ordering
145 ET_IR_R1 = 0x04, ///< Intra Refresh in predifined 2% MB
146 ET_IR_R2 = 0x08, ///< Intra Refresh in predifined 5% MB
147 ET_IR_R3 = 0x10, ///< Intra Refresh in predifined 10% MB
148 ET_FEC_HALF = 0x20, ///< Forward Error Correction in 50% redundency mode
149 ET_FEC_FULL = 0x40, ///< Forward Error Correction in 100% redundency mode
150 ET_RFS = 0x80 ///< Reference Frame Selection
152
153/**
154* @brief Information of coded Slice(=NAL)(s)
155*/
156typedef struct SliceInformation {
157 unsigned char *pBufferOfSlices; ///< base buffer of coded slice(s)
158 int32_t iCodedSliceCount; ///< number of coded slices
159 uint32_t *pLengthOfSlices; ///< array of slices length accordingly by number of slice
160 int32_t iFecType; ///< FEC type[0, 50%FEC, 100%FEC]
161 unsigned char uiSliceIdx; ///< index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0]
162 unsigned char uiSliceCount; ///< count number of slice in frame [FMO: 2-8; No FMO: 1]
163 char iFrameIndex; ///< index of frame[-1, .., idr_interval-1]
164 unsigned char uiNalRefIdc; ///< NRI, priority level of slice(NAL)
165 unsigned char uiNalType; ///< NAL type
166 unsigned char
167 uiContainingFinalNal; ///< whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
168} SliceInfo, *PSliceInfo;
169
170/**
171* @brief thresholds of the initial, maximal and minimal rate
172*/
173typedef struct {
174 int32_t iWidth; ///< frame width
175 int32_t iHeight; ///< frame height
176 int32_t iThresholdOfInitRate; ///< threshold of initial rate
177 int32_t iThresholdOfMaxRate; ///< threshold of maximal rate
178 int32_t iThresholdOfMinRate; ///< threshold of minimal rate
179 int32_t iMinThresholdFrameRate; ///< min frame rate min
180 int32_t iSkipFrameRate; ///< skip to frame rate min
181 int32_t iSkipFrameStep; ///< how many frames to skip
182} SRateThresholds, *PRateThresholds;
183
184/**
185* @brief Structure for decoder memery
186*/
187typedef struct TagSysMemBuffer {
188 int32_t iWidth; ///< width of decoded pic for display
189 int32_t iHeight; ///< height of decoded pic for display
190 int32_t iFormat; ///< type is "EVideoFormatType"
191 int32_t iStride[2]; ///< stride of 2 component
192} SSysMEMBuffer;
193
194/**
195* @brief Buffer info
196*/
197typedef struct TagBufferInfo {
198 int32_t iBufferStatus; ///< 0: one frame data is not ready; 1: one frame data is ready
199 unsigned long long uiInBsTimeStamp; ///< input BS timestamp
200 unsigned long long uiOutYuvTimeStamp; ///< output YUV timestamp, when bufferstatus is 1
201 union {
202 SSysMEMBuffer sSystemBuffer; ///< memory info for one picture
203 } UsrData; ///< output buffer info
204 unsigned char *pDst[3]; //point to picture YUV data
205} SBufferInfo;
206
207
208/**
209* @brief In a GOP, multiple of the key frame number, derived from
210* the number of layers(index or array below)
211*/
212static const char kiKeyNumMultiple[] = {
213 1, 1, 2, 4, 8, 16,
214};
215
216#endif//WELS_VIDEO_CODEC_DEFINITION_H__
ENalPriority
NRI: eNalRefIdc.
Definition: codec_def.h:108
@ NAL_PRIORITY_HIGH
Definition: codec_def.h:111
@ NAL_PRIORITY_HIGHEST
Definition: codec_def.h:112
@ NAL_PRIORITY_LOW
Definition: codec_def.h:110
@ NAL_PRIORITY_DISPOSABLE
Definition: codec_def.h:109
ENalUnitType
Enumulate the nal unit type.
Definition: codec_def.h:92
@ NAL_SLICE_DPB
Definition: codec_def.h:96
@ NAL_SLICE
Definition: codec_def.h:94
@ NAL_SLICE_DPA
Definition: codec_def.h:95
@ NAL_UNKNOWN
Definition: codec_def.h:93
@ NAL_SEI
ref_idc == 0
Definition: codec_def.h:99
@ NAL_SLICE_IDR
ref_idc != 0
Definition: codec_def.h:98
@ NAL_PPS
ref_idc == 0 for 6,9,10,11,12
Definition: codec_def.h:101
@ NAL_SPS
Definition: codec_def.h:100
@ NAL_SLICE_DPC
Definition: codec_def.h:97
@ videoFrameTypeIPMixed
a frame where I and P slices are mixing, not supported yet
Definition: codec_def.h:74
@ videoFrameTypeP
P frame type.
Definition: codec_def.h:72
@ videoFrameTypeSKIP
skip the frame based encoder kernel
Definition: codec_def.h:73
@ videoFrameTypeI
I frame type.
Definition: codec_def.h:71
@ videoFrameTypeInvalid
encoder not ready or parameters are invalidate
Definition: codec_def.h:69
@ videoFrameTypeIDR
IDR frame in H.264.
Definition: codec_def.h:70
unsigned short ERR_TOOL
Definition: codec_def.h:136
@ DEBLOCKING_IDC_2
Definition: codec_def.h:130
@ DEBLOCKING_IDC_0
Definition: codec_def.h:128
@ DEBLOCKING_IDC_1
Definition: codec_def.h:129
@ ET_NONE
NONE Error Tools.
Definition: codec_def.h:142
@ ET_FMO
Flexible Macroblock Ordering.
Definition: codec_def.h:144
@ ET_IP_SCALE
IP Scalable.
Definition: codec_def.h:143
@ ET_IR_R1
Intra Refresh in predifined 2% MB.
Definition: codec_def.h:145
@ ET_IR_R2
Intra Refresh in predifined 5% MB.
Definition: codec_def.h:146
@ ET_FEC_FULL
Forward Error Correction in 100% redundency mode.
Definition: codec_def.h:149
@ ET_IR_R3
Intra Refresh in predifined 10% MB.
Definition: codec_def.h:147
@ ET_FEC_HALF
Forward Error Correction in 50% redundency mode.
Definition: codec_def.h:148
@ ET_RFS
Reference Frame Selection.
Definition: codec_def.h:150
@ cmUnsupportedData
Definition: codec_def.h:86
@ cmUnknownReason
Definition: codec_def.h:83
@ cmResultSuccess
successful
Definition: codec_def.h:81
@ cmMallocMemeError
malloc a memory error
Definition: codec_def.h:84
@ cmInitExpected
initial action is expected
Definition: codec_def.h:85
@ cmInitParaError
parameters are invalid
Definition: codec_def.h:82
@ videoFormatRGB555
Definition: codec_def.h:46
@ videoFormatI420
the same as IYUV
Definition: codec_def.h:56
@ videoFormatRGB565
Definition: codec_def.h:47
@ videoFormatUYVY
Definition: codec_def.h:55
@ videoFormatRGBA
Definition: codec_def.h:45
@ videoFormatBGR
Definition: codec_def.h:48
@ videoFormatARGB
Definition: codec_def.h:51
@ videoFormatYV12
Definition: codec_def.h:57
@ videoFormatABGR
Definition: codec_def.h:50
@ videoFormatYVYU
Definition: codec_def.h:54
@ videoFormatBGRA
Definition: codec_def.h:49
@ videoFormatYUY2
yuv color formats
Definition: codec_def.h:53
@ videoFormatNV12
new format for output by DXVA decoding
Definition: codec_def.h:60
@ videoFormatInternal
only used in SVC decoder testbed
Definition: codec_def.h:58
@ videoFormatRGB
rgb color formats
Definition: codec_def.h:44
@ videoFormatVFlip
Definition: codec_def.h:62
int32_t iThresholdOfMinRate
threshold of minimal rate
Definition: codec_def.h:178
int32_t iThresholdOfMaxRate
threshold of maximal rate
Definition: codec_def.h:177
int32_t iMinThresholdFrameRate
min frame rate min
Definition: codec_def.h:179
int32_t iThresholdOfInitRate
threshold of initial rate
Definition: codec_def.h:176
int32_t iSkipFrameRate
skip to frame rate min
Definition: codec_def.h:180
int32_t iSkipFrameStep
how many frames to skip
Definition: codec_def.h:181
int32_t iWidth
frame width
Definition: codec_def.h:174
int32_t iHeight
frame height
Definition: codec_def.h:175
Information of coded Slice(=NAL)(s)
Definition: codec_def.h:156
unsigned char uiContainingFinalNal
whether final NAL is involved in buffer of coded slices, flag used in Pause feature in T27
Definition: codec_def.h:167
char iFrameIndex
index of frame[-1, .., idr_interval-1]
Definition: codec_def.h:163
unsigned char uiNalType
NAL type.
Definition: codec_def.h:165
unsigned char uiSliceIdx
index of slice in frame [FMO: 0,..,uiSliceCount-1; No FMO: 0]
Definition: codec_def.h:161
uint32_t * pLengthOfSlices
array of slices length accordingly by number of slice
Definition: codec_def.h:159
unsigned char uiSliceCount
count number of slice in frame [FMO: 2-8; No FMO: 1]
Definition: codec_def.h:162
int32_t iCodedSliceCount
number of coded slices
Definition: codec_def.h:158
unsigned char * pBufferOfSlices
base buffer of coded slice(s)
Definition: codec_def.h:157
unsigned char uiNalRefIdc
NRI, priority level of slice(NAL)
Definition: codec_def.h:164
int32_t iFecType
FEC type[0, 50FEC, 100FEC].
Definition: codec_def.h:160
Buffer info.
Definition: codec_def.h:197
unsigned char * pDst[3]
Definition: codec_def.h:204
SSysMEMBuffer sSystemBuffer
memory info for one picture
Definition: codec_def.h:202
unsigned long long uiInBsTimeStamp
input BS timestamp
Definition: codec_def.h:199
unsigned long long uiOutYuvTimeStamp
output YUV timestamp, when bufferstatus is 1
Definition: codec_def.h:200
int32_t iBufferStatus
0: one frame data is not ready; 1: one frame data is ready
Definition: codec_def.h:198
Structure for decoder memery.
Definition: codec_def.h:187
int32_t iStride[2]
stride of 2 component
Definition: codec_def.h:191
int32_t iWidth
width of decoded pic for display
Definition: codec_def.h:188
int32_t iFormat
type is "EVideoFormatType"
Definition: codec_def.h:190
int32_t iHeight
height of decoded pic for display
Definition: codec_def.h:189