WebM Codec SDK: vpx/vpx_codec.h Source File

WebM Codec SDK

vpx_codec.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
38 #ifndef VPX_VPX_CODEC_H_
39 #define VPX_VPX_CODEC_H_
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 #include "./vpx_integer.h"
46 #include "./vpx_image.h"
47
49 #ifndef DEPRECATED
50 #if defined(__GNUC__) && __GNUC__
51 #define DEPRECATED __attribute__((deprecated))
52 #elif defined(_MSC_VER)
53 #define DEPRECATED
54 #else
55 #define DEPRECATED
56 #endif
57 #endif /* DEPRECATED */
58
59 #ifndef DECLSPEC_DEPRECATED
60 #if defined(__GNUC__) && __GNUC__
61 #define DECLSPEC_DEPRECATED
62 #elif defined(_MSC_VER)
63
64 #define DECLSPEC_DEPRECATED __declspec(deprecated)
65 #else
66 #define DECLSPEC_DEPRECATED
67 #endif
68 #endif /* DECLSPEC_DEPRECATED */
69
71 #ifdef UNUSED
72 #elif defined(__GNUC__) || defined(__clang__)
73 #define UNUSED __attribute__((unused))
74 #else
75 #define UNUSED
76 #endif
77
86 #define VPX_CODEC_ABI_VERSION (3 + VPX_IMAGE_ABI_VERSION)
89 typedef enum {
90
91 VPX_CODEC_OK,
92
94 VPX_CODEC_ERROR,
95
97 VPX_CODEC_MEM_ERROR,
98
100 VPX_CODEC_ABI_MISMATCH,
101
103 VPX_CODEC_INCAPABLE,
104
110 VPX_CODEC_UNSUP_BITSTREAM,
111
119 VPX_CODEC_UNSUP_FEATURE,
120
129 VPX_CODEC_CORRUPT_FRAME,
130
134 VPX_CODEC_INVALID_PARAM,
135
139 VPX_CODEC_LIST_END
140
141 } vpx_codec_err_t;
142
151 typedef long vpx_codec_caps_t;
152 #define VPX_CODEC_CAP_DECODER 0x1
153 #define VPX_CODEC_CAP_ENCODER 0x2
162 typedef long vpx_codec_flags_t;
163
169 typedef const struct vpx_codec_iface vpx_codec_iface_t;
170
176 typedef struct vpx_codec_priv vpx_codec_priv_t;
177
182 typedef const void *vpx_codec_iter_t;
183
192 typedef struct vpx_codec_ctx {
193 const char *name;
194 vpx_codec_iface_t *iface;
195 vpx_codec_err_t err;
196 const char *err_detail;
197 vpx_codec_flags_t init_flags;
198 union {
200 const struct vpx_codec_dec_cfg *dec;
202 const struct vpx_codec_enc_cfg *enc;
203 const void *raw;
204 } config;
205 vpx_codec_priv_t *priv;
206 } vpx_codec_ctx_t;
207
212 typedef enum vpx_bit_depth {
213 VPX_BITS_8 = 8,
214 VPX_BITS_10 = 10,
215 VPX_BITS_12 = 12,
216 } vpx_bit_depth_t;
217
218 /*
219 * Library Version Number Interface
220 *
221 * For example, see the following sample return values:
222 * vpx_codec_version() (1<<16 | 2<<8 | 3)
223 * vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
224 * vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
225 */
226
237 int vpx_codec_version(void);
238 #define VPX_VERSION_MAJOR(v) \
239 ((v >> 16) & 0xff)
240 #define VPX_VERSION_MINOR(v) \
241 ((v >> 8) & 0xff)
242 #define VPX_VERSION_PATCH(v) \
243 ((v >> 0) & 0xff)
246 #define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
247
249 #define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
250
252 #define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
253
263 const char *vpx_codec_version_str(void);
264
272 const char *vpx_codec_version_extra_str(void);
273
280 const char *vpx_codec_build_config(void);
281
289 const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
290
301 const char *vpx_codec_err_to_string(vpx_codec_err_t err);
302
313 const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
314
325 const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
326
327 /* REQUIRED FUNCTIONS
328 *
329 * The following functions are required to be implemented for all codecs.
330 * They represent the base case functionality expected of all codecs.
331 */
332
344 vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
345
353 vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
354
379 vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
380 #if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
381 #define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
382 #define VPX_CTRL_USE_TYPE(id, typ)
383 #define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
384 #define VPX_CTRL_VOID(id, typ)
385
386 #else
387
396 #define vpx_codec_control(ctx, id, data) \
397 vpx_codec_control_##id(ctx, id, data)
410 #define VPX_CTRL_USE_TYPE(id, typ) \
411 static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
412 UNUSED; \
413 \
414 static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
415 int ctrl_id, typ data) { \
416 return vpx_codec_control_(ctx, ctrl_id, data); \
417 }
429 #define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
430 DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
431 vpx_codec_ctx_t *, int, typ) DEPRECATED UNUSED; \
432 \
433 DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
434 vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
435 return vpx_codec_control_(ctx, ctrl_id, data); \
436 }
448 #define VPX_CTRL_VOID(id) \
449 static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
450 UNUSED; \
451 \
452 static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
453 int ctrl_id) { \
454 return vpx_codec_control_(ctx, ctrl_id); \
455 }
457 #endif
458
460 #ifdef __cplusplus
461 }
462 #endif
463 #endif // VPX_VPX_CODEC_H_
vpx_codec_iface_name
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
vpx_codec_err_to_string
const char * vpx_codec_err_to_string(vpx_codec_err_t err)
Convert error number to printable string.
vpx_codec_ctx::init_flags
vpx_codec_flags_t init_flags
Definition: vpx_codec.h:197
VPX_CODEC_ERROR
Unspecified error.
Definition: vpx_codec.h:94
VPX_CODEC_UNSUP_BITSTREAM
The given bitstream is not supported.
Definition: vpx_codec.h:110
VPX_CODEC_MEM_ERROR
Memory operation failed.
Definition: vpx_codec.h:97
vpx_codec_enc_cfg
Encoder configuration structure.
Definition: vpx_encoder.h:285
VPX_CODEC_CORRUPT_FRAME
The coded data for this stream is corrupt or incomplete.
Definition: vpx_codec.h:129
vpx_codec_version
int vpx_codec_version(void)
Return the version information (as an integer)
VPX_CODEC_INVALID_PARAM
An application-supplied parameter is not valid.
Definition: vpx_codec.h:134
vpx_codec_version_extra_str
const char * vpx_codec_version_extra_str(void)
Return the version information (as a string)
vpx_codec_build_config
const char * vpx_codec_build_config(void)
Return the build configuration.
vpx_codec_ctx::name
const char * name
Definition: vpx_codec.h:193
vpx_bit_depth_t
enum vpx_bit_depth vpx_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
vpx_codec_get_caps
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface)
Get the capabilities of an algorithm.
VPX_CODEC_OK
Operation completed without error.
Definition: vpx_codec.h:91
vpx_codec_ctx_t
struct vpx_codec_ctx vpx_codec_ctx_t
Codec context structure.
vpx_bit_depth
vpx_bit_depth
Bit depth for codecThis enumeration determines the bit depth of the codec.
Definition: vpx_codec.h:212
vpx_codec_ctx::iface
vpx_codec_iface_t * iface
Definition: vpx_codec.h:194
vpx_image.h
Describes the vpx image descriptor and associated operations.
vpx_codec_iface_t
const struct vpx_codec_iface vpx_codec_iface_t
Codec interface structure.
Definition: vpx_codec.h:169
VPX_BITS_12
Definition: vpx_codec.h:215
vpx_codec_flags_t
long vpx_codec_flags_t
Initialization-time Feature Enabling.
Definition: vpx_codec.h:162
vpx_codec_ctx::err_detail
const char * err_detail
Definition: vpx_codec.h:196
vpx_codec_error_detail
const char * vpx_codec_error_detail(vpx_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
vpx_codec_version_str
const char * vpx_codec_version_str(void)
Return the version information (as a string)
vpx_codec_err_t
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:89
vpx_codec_priv_t
struct vpx_codec_priv vpx_codec_priv_t
Codec private data structure.
Definition: vpx_codec.h:176
VPX_CODEC_UNSUP_FEATURE
Encoded bitstream uses an unsupported feature.
Definition: vpx_codec.h:119
VPX_CODEC_ABI_MISMATCH
ABI version mismatch.
Definition: vpx_codec.h:100
vpx_codec_ctx::config
union vpx_codec_ctx::@0 config
vpx_codec_control_
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id,...)
Control algorithm.
VPX_CODEC_LIST_END
An iterator reached the end of list.
Definition: vpx_codec.h:139
vpx_codec_ctx::priv
vpx_codec_priv_t * priv
Definition: vpx_codec.h:205
vpx_codec_ctx::dec
const struct vpx_codec_dec_cfg * dec
Definition: vpx_codec.h:200
vpx_codec_destroy
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
vpx_codec_caps_t
long vpx_codec_caps_t
Codec capabilities bitfield.
Definition: vpx_codec.h:151
VPX_BITS_8
Definition: vpx_codec.h:213
VPX_CODEC_INCAPABLE
Algorithm does not have required capability.
Definition: vpx_codec.h:103
vpx_codec_ctx::err
vpx_codec_err_t err
Definition: vpx_codec.h:195
vpx_codec_error
const char * vpx_codec_error(vpx_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
vpx_codec_dec_cfg
Initialization Configurations.
Definition: vpx_decoder.h:107
VPX_BITS_10
Definition: vpx_codec.h:214
vpx_codec_iter_t
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:182
vpx_codec_ctx
Codec context structure.
Definition: vpx_codec.h:192