kodi
video_codec.h
1 /*
2  * Copyright (C) 2017-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #ifndef C_API_ADDONINSTANCE_VIDEOCODEC_H
10 #define C_API_ADDONINSTANCE_VIDEOCODEC_H
11 
12 #include "../addon_base.h"
13 #include "inputstream/demux_packet.h"
14 #include "inputstream/stream_codec.h"
15 #include "inputstream/stream_crypto.h"
16 
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif /* __cplusplus */
21 
22  //============================================================================
25  enum VIDEOCODEC_RETVAL
26  {
28  VC_NONE = 0,
29 
31  VC_ERROR,
32 
34  VC_BUFFER,
35 
37  VC_PICTURE,
38 
40  VC_EOF,
41  };
42  //----------------------------------------------------------------------------
43 
44  //============================================================================
48  enum VIDEOCODEC_FORMAT
49  {
52  VIDEOCODEC_FORMAT_UNKNOWN = 0,
53 
55  VIDEOCODEC_FORMAT_YV12,
56 
59  VIDEOCODEC_FORMAT_I420,
60 
61  VIDEOCODEC_FORMAT_YUV420P9,
62  VIDEOCODEC_FORMAT_YUV420P10,
63  VIDEOCODEC_FORMAT_YUV420P12,
64  VIDEOCODEC_FORMAT_YUV422P9,
65  VIDEOCODEC_FORMAT_YUV422P10,
66  VIDEOCODEC_FORMAT_YUV422P12,
67  VIDEOCODEC_FORMAT_YUV444P9,
68  VIDEOCODEC_FORMAT_YUV444P10,
69  VIDEOCODEC_FORMAT_YUV444P12,
70 
72  VIDEOCODEC_FORMAT_MAXFORMATS
73  };
74  //----------------------------------------------------------------------------
75 
76  //============================================================================
80  enum VIDEOCODEC_TYPE
81  {
84  VIDEOCODEC_UNKNOWN = 0,
85 
88  VIDEOCODEC_VP8,
89 
93  VIDEOCODEC_H264,
94 
100  VIDEOCODEC_VP9,
101 
107  VIDEOCODEC_AV1,
108  };
109  //----------------------------------------------------------------------------
110 
111  //============================================================================
121  {
124 
127 
130 
133  };
134  //----------------------------------------------------------------------------
135 
136  //============================================================================
146  {
149 
152 
155  };
156  //----------------------------------------------------------------------------
157 
158  //============================================================================
165  {
168  enum VIDEOCODEC_FORMAT videoFormat;
169 
174  uint32_t flags;
175 
177  uint32_t width;
178 
180  uint32_t height;
181 
183  uint8_t* decodedData;
184 
187 
193 
199 
201  int64_t pts;
202 
208  KODI_HANDLE videoBufferHandle;
209  };
211  //----------------------------------------------------------------------------
212 
214  {
215  enum VIDEOCODEC_TYPE codec;
216  enum STREAMCODEC_PROFILE codecProfile;
217  enum VIDEOCODEC_FORMAT* videoFormats;
218  uint32_t width;
219  uint32_t height;
220  const uint8_t* extraData;
221  unsigned int extraDataSize;
222  struct STREAM_CRYPTO_SESSION cryptoSession;
223  };
224 
225  // this are properties given to the addon on create
226  // at this time we have no parameters for the addon
227  typedef struct AddonProps_VideoCodec
228  {
229  int dummy;
231 
234  {
235  KODI_HANDLE addonInstance;
236 
238  bool(__cdecl* open)(const struct AddonInstance_VideoCodec* instance,
239  struct VIDEOCODEC_INITDATA* initData);
240 
242  bool(__cdecl* reconfigure)(const struct AddonInstance_VideoCodec* instance,
243  struct VIDEOCODEC_INITDATA* initData);
244 
246  bool(__cdecl* add_data)(const struct AddonInstance_VideoCodec* instance,
247  const struct DEMUX_PACKET* packet);
248 
250  enum VIDEOCODEC_RETVAL(__cdecl* get_picture)(const struct AddonInstance_VideoCodec* instance,
251  struct VIDEOCODEC_PICTURE* picture);
252 
254  const char*(__cdecl* get_name)(const struct AddonInstance_VideoCodec* instance);
255 
257  void(__cdecl* reset)(const struct AddonInstance_VideoCodec* instance);
259 
261  {
262  KODI_HANDLE kodiInstance;
263  bool (*get_frame_buffer)(void* kodiInstance, struct VIDEOCODEC_PICTURE* picture);
264  void (*release_frame_buffer)(void* kodiInstance, void* buffer);
266 
268  {
269  struct AddonProps_VideoCodec* props;
270  struct AddonToKodiFuncTable_VideoCodec* toKodi;
271  struct KodiToAddonFuncTable_VideoCodec* toAddon;
273 
274 #ifdef __cplusplus
275 } /* extern "C" */
276 #endif /* __cplusplus */
277 
278 #endif /* !C_API_ADDONINSTANCE_VIDEOCODEC_H */
Empty and nothing defined.
Definition: video_codec.h:148
"chrominance" component V (red projection)
Definition: video_codec.h:129
Definition: video_codec.h:260
Definition: video_codec.h:164
enum VIDEOCODEC_FORMAT videoFormat
The video format declared with VIDEOCODEC_FORMAT and to be used on the addon.
Definition: video_codec.h:168
Definition: stream_crypto.h:120
uint32_t height
Picture height.
Definition: video_codec.h:180
uint32_t flags
Video coded process flags, used to perform special operations in stream calls.
Definition: video_codec.h:174
"chrominance" component U (blue projection)
Definition: video_codec.h:126
Definition: addon_base.h:267
Definition: video_codec.h:227
Definition: video_codec.h:267
"luminance" component Y (equivalent to grey scale)
Definition: video_codec.h:123
uint32_t width
Picture width.
Definition: video_codec.h:177
uint8_t * decodedData
Data to be decoded in the addon.
Definition: video_codec.h:183
VIDEOCODEC_PICTURE_FLAG
Video coded process flags, used to perform special operations in stream calls.
Definition: video_codec.h:145
VIDEOCODEC_PLANE
YUV Plane identification pointers.
Definition: video_codec.h:120
Squeeze out pictured without feeding new packets.
Definition: video_codec.h:154
Drop in decoder.
Definition: video_codec.h:151
Definition: demux_packet.h:45
The maximum value to use in a list.
Definition: video_codec.h:132
uint32_t planeOffsets[VIDEOCODEC_PICTURE_MAXPLANES]
YUV color plane calculation array.
Definition: video_codec.h:192
int64_t pts
Picture presentation time stamp (PTS).
Definition: video_codec.h:201
KODI_HANDLE videoBufferHandle
This is used to save the related handle from Kodi.
Definition: video_codec.h:208
STREAMCODEC_PROFILE
Definition: stream_codec.h:24
Definition: video_codec.h:233
Definition: video_codec.h:213
size_t decodedDataSize
Size of the data given with decodedData.
Definition: video_codec.h:186
uint32_t stride[VIDEOCODEC_PICTURE_MAXPLANES]
YUV color stride calculation array.
Definition: video_codec.h:198