3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef _EXYNOS_VIDEO_API_H_
19 #define _EXYNOS_VIDEO_API_H_
21 #include "exynos_v4l2.h"
24 #define VIDEO_BUFFER_MAX_PLANES 3
26 typedef enum _ExynosVideoBoolType {
29 } ExynosVideoBoolType;
31 typedef enum _ExynosVideoErrorType {
33 VIDEO_ERROR_BADPARAM = -1,
34 VIDEO_ERROR_OPENFAIL = -2,
35 VIDEO_ERROR_NOMEM = -3,
36 VIDEO_ERROR_APIFAIL = -4,
37 VIDEO_ERROR_MAPFAIL = -5,
38 VIDEO_ERROR_NOBUFFERS = -6,
39 VIDEO_ERROR_POLL = -7,
40 VIDEO_ERROR_DQBUF_EIO = -8,
41 } ExynosVideoErrorType;
43 typedef enum _ExynosVideoCodingType {
44 VIDEO_CODING_UNKNOWN = 0,
53 VIDEO_CODING_RESERVED,
54 } ExynosVideoCodingType;
56 typedef enum _ExynosVideoColorFormatType {
57 VIDEO_COLORFORMAT_UNKNOWN = 0,
58 VIDEO_COLORFORMAT_NV12,
59 VIDEO_COLORFORMAT_NV21,
60 VIDEO_COLORFORMAT_NV12_TILED,
61 VIDEO_COLORFORMAT_RESERVED,
62 } ExynosVideoColorFormatType;
64 typedef enum _ExynosVideoFrameType {
65 VIDEO_FRAME_NOT_CODED = 0,
71 } ExynosVideoFrameType;
73 typedef enum _ExynosVideoFrameStatusType {
74 VIDEO_FRAME_STATUS_UNKNOWN = 0,
75 VIDEO_FRAME_STATUS_DECODING_ONLY,
76 VIDEO_FRAME_STATUS_DISPLAY_DECODING,
77 VIDEO_FRAME_STATUS_DISPLAY_ONLY,
78 VIDEO_FRAME_STATUS_DECODING_FINISHED,
79 VIDEO_FRAME_STATUS_CHANGE_RESOL,
80 } ExynosVideoFrameStatusType;
82 typedef enum _ExynosVideoFrameSkipMode {
83 VIDEO_FRAME_SKIP_DISABLED = 0,
84 VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT,
85 VIDEO_FRAME_SKIP_MODE_BUF_LIMIT,
86 } ExynosVideoFrameSkipMode;
88 typedef struct _ExynosVideoRect {
95 typedef struct _ExynosVideoGeometry {
96 unsigned int nFrameWidth;
97 unsigned int nFrameHeight;
98 unsigned int nSizeImage;
99 ExynosVideoRect cropRect;
100 ExynosVideoCodingType eCompressionFormat;
101 ExynosVideoColorFormatType eColorFormat;
102 } ExynosVideoGeometry;
104 typedef struct _ExynosVideoPlane {
106 unsigned int allocSize;
107 unsigned int dataSize;
108 unsigned long offset;
113 typedef struct _ExynosVideoBuffer {
114 ExynosVideoPlane planes[VIDEO_BUFFER_MAX_PLANES];
115 ExynosVideoGeometry *pGeometry;
116 ExynosVideoFrameStatusType displayStatus;
117 ExynosVideoFrameType frameType;
118 ExynosVideoBoolType bQueued;
119 ExynosVideoBoolType bRegistered;
123 typedef struct _ExynosVideoFramePacking{
125 unsigned int arrangement_id;
126 int arrangement_cancel_flag;
127 unsigned char arrangement_type;
128 int quincunx_sampling_flag;
129 unsigned char content_interpretation_type;
130 int spatial_flipping_flag;
131 int frame0_flipped_flag;
132 int field_views_flag;
133 int current_frame_is_frame0_flag;
134 unsigned char frame0_grid_pos_x;
135 unsigned char frame0_grid_pos_y;
136 unsigned char frame1_grid_pos_x;
137 unsigned char frame1_grid_pos_y;
138 } ExynosVideoFramePacking;
140 typedef struct _ExynosVideoEncInitParam{
141 /* Initial parameters */
142 ExynosVideoFrameSkipMode FrameSkip; /* [IN] frame skip mode */
145 }ExynosVideoEncInitParam;
147 typedef struct _ExynosVideoEncCommonParam{
148 /* common parameters */
149 int SourceWidth; /* [IN] width of video to be encoded */
150 int SourceHeight; /* [IN] height of video to be encoded */
151 int IDRPeriod; /* [IN] GOP number(interval of I-frame) */
152 int SliceMode; /* [IN] Multi slice mode */
153 int RandomIntraMBRefresh; /* [IN] cyclic intra refresh */
154 int EnableFRMRateControl; /* [IN] frame based rate control enable */
155 int EnableMBRateControl; /* [IN] Enable macroblock-level rate control */
156 int Bitrate; /* [IN] rate control parameter(bit rate) */
157 int FrameQp; /* [IN] The quantization parameter of the frame */
158 int FrameQp_P; /* [IN] The quantization parameter of the P frame */
159 int QSCodeMax; /* [IN] Maximum Quantization value */
160 int QSCodeMin; /* [IN] Minimum Quantization value */
161 int CBRPeriodRf; /* [IN] Reaction coefficient parameter for rate control */
162 int PadControlOn; /* [IN] Enable padding control */
163 int LumaPadVal; /* [IN] Luma pel value used to fill padding area */
164 int CbPadVal; /* [IN] CB pel value used to fill padding area */
165 int CrPadVal; /* [IN] CR pel value used to fill padding area */
166 int FrameMap; /* [IN] Encoding input mode(tile mode or linear mode) */
167 }ExynosVideoEncCommonParam;
169 typedef struct _ExynosVideoEncH264Param{
170 /* H.264 specific parameters */
171 int ProfileIDC; /* [IN] profile */
172 int LevelIDC; /* [IN] level */
173 int FrameQp_B; /* [IN] The quantization parameter of the B frame */
174 int FrameRate; /* [IN] rate control parameter(frame rate) */
175 int SliceArgument; /* [IN] MB number or byte number */
176 int NumberBFrames; /* [IN] The number of consecutive B frame inserted */
177 int NumberReferenceFrames; /* [IN] The number of reference pictures used */
178 int NumberRefForPframes; /* [IN] The number of reference pictures used for encoding P pictures */
179 int LoopFilterDisable; /* [IN] disable the loop filter */
180 int LoopFilterAlphaC0Offset; /* [IN] Alpha & C0 offset for H.264 loop filter */
181 int LoopFilterBetaOffset; /* [IN] Beta offset for H.264 loop filter */
182 int SymbolMode; /* [IN] The mode of entropy coding(CABAC, CAVLC) */
183 int PictureInterlace; /* [IN] Enables the interlace mode */
184 int Transform8x8Mode; /* [IN] Allow 8x8 transform(This is allowed only for high profile) */
185 int DarkDisable; /* [IN] Disable adaptive rate control on dark region */
186 int SmoothDisable; /* [IN] Disable adaptive rate control on smooth region */
187 int StaticDisable; /* [IN] Disable adaptive rate control on static region */
188 int ActivityDisable; /* [IN] Disable adaptive rate control on high activity region */
189 } ExynosVideoEncH264Param;
191 typedef struct _ExynosVideoEncMpeg4Param {
192 /* MPEG4 specific parameters */
193 int ProfileIDC; /* [IN] profile */
194 int LevelIDC; /* [IN] level */
195 int FrameQp_B; /* [IN] The quantization parameter of the B frame */
196 int TimeIncreamentRes; /* [IN] frame rate */
197 int VopTimeIncreament; /* [IN] frame rate */
198 int SliceArgument; /* [IN] MB number or byte number */
199 int NumberBFrames; /* [IN] The number of consecutive B frame inserted */
200 int DisableQpelME; /* [IN] disable quarter-pixel motion estimation */
201 } ExynosVideoEncMpeg4Param;
203 typedef struct _ExynosVideoEncH263Param {
204 /* H.263 specific parameters */
205 int FrameRate; /* [IN] rate control parameter(frame rate) */
206 } ExynosVideoEncH263Param;
208 typedef union _ExynosVideoEncCodecParam {
209 ExynosVideoEncH264Param h264;
210 ExynosVideoEncMpeg4Param mpeg4;
211 ExynosVideoEncH263Param h263;
212 } ExynosVideoEncCodecParam;
214 typedef struct _ExynosVideoEncParam {
215 ExynosVideoCodingType eCompressionFormat;
216 ExynosVideoEncInitParam initParam;
217 ExynosVideoEncCommonParam commonParam;
218 ExynosVideoEncCodecParam codecParam;
219 } ExynosVideoEncParam;
221 typedef struct _ExynosVideoDecOps {
224 void * (*Init)(int nMemoryType);
225 ExynosVideoErrorType (*Finalize)(void *pHandle);
227 /* Add new ops at the end of structure, no order change */
228 ExynosVideoErrorType (*Set_FrameTag)(void *pHandle, int frameTag);
229 int (*Get_FrameTag)(void *pHandle);
230 int (*Get_ActualBufferCount)(void *pHandle);
231 ExynosVideoErrorType (*Set_DisplayDelay)(void *pHandle, int delay);
232 ExynosVideoErrorType (*Enable_PackedPB)(void *pHandle);
233 ExynosVideoErrorType (*Enable_LoopFilter)(void *pHandle);
234 ExynosVideoErrorType (*Enable_SliceMode)(void *pHandle);
235 ExynosVideoErrorType (*Enable_SEIParsing)(void *pHandle);
236 ExynosVideoErrorType (*Get_FramePackingInfo)(void *pHandle, ExynosVideoFramePacking *pFramepacking);
237 ExynosVideoErrorType (*Set_ImmediateDisplay)(void *pHandle);
238 ExynosVideoErrorType (*Enable_DecodeWait)(void *pHandle);
241 typedef struct _ExynosVideoEncOps {
243 void * (*Init)(int nMemoryType);
244 ExynosVideoErrorType (*Finalize)(void *pHandle);
246 /* Add new ops at the end of structure, no order change */
247 ExynosVideoErrorType (*Set_EncParam)(void *pHandle, ExynosVideoEncParam*encParam);
248 ExynosVideoErrorType (*Set_FrameTag)(void *pHandle, int frameTag);
249 int (*Get_FrameTag)(void *pHandle);
250 ExynosVideoErrorType (*Set_FrameType)(void *pHandle, int frameType);
251 ExynosVideoErrorType (*Set_FrameRate)(void *pHandle, int frameRate);
252 ExynosVideoErrorType (*Set_BitRate)(void *pHandle, int bitRate);
253 ExynosVideoErrorType (*Set_FrameSkip)(void *pHandle, int frameSkip);
254 ExynosVideoErrorType (*Set_IDRPeriod)(void *pHandle, int period);
255 ExynosVideoErrorType (*Enable_PrependSpsPpsToIdr)(void *pHandle);
258 typedef struct _ExynosVideoDecBufferOps {
261 /* Add new ops at the end of structure, no order change */
262 ExynosVideoErrorType (*Enable_Cacheable)(void *pHandle);
263 ExynosVideoErrorType (*Set_Shareable)(void *pHandle);
264 ExynosVideoErrorType (*Get_Buffer)(void *pHandle, int nIndex, ExynosVideoBuffer **pBuffer);
265 ExynosVideoErrorType (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
266 ExynosVideoErrorType (*Get_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
267 ExynosVideoErrorType (*Setup)(void *pHandle, unsigned int nBufferCount);
268 ExynosVideoErrorType (*Run)(void *pHandle);
269 ExynosVideoErrorType (*Stop)(void *pHandle);
270 ExynosVideoErrorType (*Enqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int dataSize[], int nPlanes, void *pPrivate);
271 ExynosVideoErrorType (*Enqueue_All)(void *pHandle);
272 ExynosVideoBuffer * (*Dequeue)(void *pHandle);
273 ExynosVideoErrorType (*Register)(void *pHandle, ExynosVideoPlane *planes, int nPlanes);
274 ExynosVideoErrorType (*Clear_RegisteredBuffer)(void *pHandle);
275 ExynosVideoErrorType (*Clear_Queue)(void *pHandle);
276 ExynosVideoErrorType (*Cleanup)(void *pHandle);
277 } ExynosVideoDecBufferOps;
279 typedef struct _ExynosVideoEncBufferOps {
282 /* Add new ops at the end of structure, no order change */
283 ExynosVideoErrorType (*Enable_Cacheable)(void *pHandle);
284 ExynosVideoErrorType (*Set_Shareable)(void *pHandle);
285 ExynosVideoErrorType (*Get_Buffer)(void *pHandle, int nIndex, ExynosVideoBuffer **pBuffer);
286 ExynosVideoErrorType (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
287 ExynosVideoErrorType (*Get_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
288 ExynosVideoErrorType (*Setup)(void *pHandle, unsigned int nBufferCount);
289 ExynosVideoErrorType (*Run)(void *pHandle);
290 ExynosVideoErrorType (*Stop)(void *pHandle);
291 ExynosVideoErrorType (*Enqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int dataSize[], int nPlanes, void *pPrivate);
292 ExynosVideoErrorType (*Enqueue_All)(void *pHandle);
293 ExynosVideoBuffer * (*Dequeue)(void *pHandle);
294 ExynosVideoErrorType (*Register)(void *pHandle, ExynosVideoPlane *planes, int nPlanes);
295 ExynosVideoErrorType (*Clear_RegisteredBuffer)(void *pHandle);
296 ExynosVideoErrorType (*Clear_Queue)(void *pHandle);
297 } ExynosVideoEncBufferOps;
299 int Exynos_Video_Register_Decoder(
300 ExynosVideoDecOps *pDecOps,
301 ExynosVideoDecBufferOps *pInbufOps,
302 ExynosVideoDecBufferOps *pOutbufOps);
304 int Exynos_Video_Register_Encoder(
305 ExynosVideoEncOps *pEncOps,
306 ExynosVideoEncBufferOps *pInbufOps,
307 ExynosVideoEncBufferOps *pOutbufOps);
309 #endif /* _EXYNOS_VIDEO_API_H_ */