AOMedia Codec SDK
aom_codec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
39 #ifndef AOM_AOM_CODEC_H_
40 #define AOM_AOM_CODEC_H_
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "aom/aom_image.h"
47 #include "aom/aom_integer.h"
48 
50 #ifndef AOM_DEPRECATED
51 #if defined(__GNUC__) && __GNUC__
52 #define AOM_DEPRECATED __attribute__((deprecated))
53 #elif defined(_MSC_VER)
54 #define AOM_DEPRECATED
55 #else
56 #define AOM_DEPRECATED
57 #endif
58 #endif /* AOM_DEPRECATED */
59 
60 #ifndef AOM_DECLSPEC_DEPRECATED
61 #if defined(__GNUC__) && __GNUC__
62 #define AOM_DECLSPEC_DEPRECATED
63 #elif defined(_MSC_VER)
64 
65 #define AOM_DECLSPEC_DEPRECATED __declspec(deprecated)
66 #else
67 #define AOM_DECLSPEC_DEPRECATED
68 #endif
69 #endif /* AOM_DECLSPEC_DEPRECATED */
70 
72 #ifdef AOM_UNUSED
73 #elif defined(__GNUC__) || defined(__clang__)
74 #define AOM_UNUSED __attribute__((unused))
75 #else
76 #define AOM_UNUSED
77 #endif
78 
80 #ifndef ATTRIBUTE_PACKED
81 #if defined(__GNUC__) && __GNUC__
82 #define ATTRIBUTE_PACKED __attribute__((packed))
83 #elif defined(_MSC_VER)
84 #define ATTRIBUTE_PACKED
85 #else
86 #define ATTRIBUTE_PACKED
87 #endif
88 #endif /* ATTRIBUTE_PACKED */
89 
98 #define AOM_CODEC_ABI_VERSION (3 + AOM_IMAGE_ABI_VERSION)
101 typedef enum {
102 
104 
107 
110 
113 
116 
123 
132 
142 
147 
152 
154 
163 typedef long aom_codec_caps_t;
164 #define AOM_CODEC_CAP_DECODER 0x1
165 #define AOM_CODEC_CAP_ENCODER 0x2
174 typedef long aom_codec_flags_t;
175 
181 typedef const struct aom_codec_iface aom_codec_iface_t;
182 
188 typedef struct aom_codec_priv aom_codec_priv_t;
189 
194 typedef const void *aom_codec_iter_t;
195 
204 typedef struct aom_codec_ctx {
205  const char *name;
208  const char *err_detail;
210  union {
212  const struct aom_codec_dec_cfg *dec;
214  const struct aom_codec_enc_cfg *enc;
215  const void *raw;
216  } config;
219 
224 typedef enum aom_bit_depth {
226  AOM_BITS_10 = 10,
227  AOM_BITS_12 = 12,
229 
236 typedef enum aom_superblock_size {
241 
242 /*
243  * Library Version Number Interface
244  *
245  * For example, see the following sample return values:
246  * aom_codec_version() (1<<16 | 2<<8 | 3)
247  * aom_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
248  * aom_codec_version_extra_str() "rc1-16-gec6a1ba"
249  */
250 
261 int aom_codec_version(void);
262 #define AOM_VERSION_MAJOR(v) \
263  ((v >> 16) & 0xff)
264 #define AOM_VERSION_MINOR(v) \
265  ((v >> 8) & 0xff)
266 #define AOM_VERSION_PATCH(v) \
267  ((v >> 0) & 0xff)
270 #define aom_codec_version_major() ((aom_codec_version() >> 16) & 0xff)
271 
273 #define aom_codec_version_minor() ((aom_codec_version() >> 8) & 0xff)
274 
276 #define aom_codec_version_patch() ((aom_codec_version() >> 0) & 0xff)
277 
287 const char *aom_codec_version_str(void);
288 
296 const char *aom_codec_version_extra_str(void);
297 
304 const char *aom_codec_build_config(void);
305 
313 const char *aom_codec_iface_name(aom_codec_iface_t *iface);
314 
326 
337 const char *aom_codec_error(aom_codec_ctx_t *ctx);
338 
349 const char *aom_codec_error_detail(aom_codec_ctx_t *ctx);
350 
351 /* REQUIRED FUNCTIONS
352  *
353  * The following functions are required to be implemented for all codecs.
354  * They represent the base case functionality expected of all codecs.
355  */
356 
369 
378 
403 aom_codec_err_t aom_codec_control_(aom_codec_ctx_t *ctx, int ctrl_id, ...);
404 #if defined(AOM_DISABLE_CTRL_TYPECHECKS) && AOM_DISABLE_CTRL_TYPECHECKS
405 #define aom_codec_control(ctx, id, data) aom_codec_control_(ctx, id, data)
406 #define AOM_CTRL_USE_TYPE(id, typ)
407 #define AOM_CTRL_USE_TYPE_DEPRECATED(id, typ)
408 #define AOM_CTRL_VOID(id, typ)
409 
410 #else
411 
420 #define aom_codec_control(ctx, id, data) \
421  aom_codec_control_##id(ctx, id, data)
434 #define AOM_CTRL_USE_TYPE(id, typ) \
435  static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *, int, typ) \
436  AOM_UNUSED; \
437  \
438  static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *ctx, \
439  int ctrl_id, typ data) { \
440  return aom_codec_control_(ctx, ctrl_id, data); \
441  }
453 #define AOM_CTRL_USE_TYPE_DEPRECATED(id, typ) \
454  AOM_DECLSPEC_DEPRECATED static aom_codec_err_t aom_codec_control_##id( \
455  aom_codec_ctx_t *, int, typ) AOM_DEPRECATED AOM_UNUSED; \
456  \
457  AOM_DECLSPEC_DEPRECATED static aom_codec_err_t aom_codec_control_##id( \
458  aom_codec_ctx_t *ctx, int ctrl_id, typ data) { \
459  return aom_codec_control_(ctx, ctrl_id, data); \
460  }
472 #define AOM_CTRL_VOID(id) \
473  static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *, int) \
474  AOM_UNUSED; \
475  \
476  static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *ctx, \
477  int ctrl_id) { \
478  return aom_codec_control_(ctx, ctrl_id); \
479  }
481 #endif
482 
484 typedef enum ATTRIBUTE_PACKED {
485  OBU_SEQUENCE_HEADER = 1,
486  OBU_TEMPORAL_DELIMITER = 2,
487  OBU_FRAME_HEADER = 3,
488  OBU_TILE_GROUP = 4,
489  OBU_METADATA = 5,
490  OBU_FRAME = 6,
491  OBU_REDUNDANT_FRAME_HEADER = 7,
492  OBU_TILE_LIST = 8,
493  OBU_PADDING = 15,
494 } OBU_TYPE;
495 
497 typedef enum {
498  OBU_METADATA_TYPE_AOM_RESERVED_0 = 0,
499  OBU_METADATA_TYPE_HDR_CLL = 1,
500  OBU_METADATA_TYPE_HDR_MDCV = 2,
501  OBU_METADATA_TYPE_SCALABILITY = 3,
502  OBU_METADATA_TYPE_ITUT_T35 = 4,
503  OBU_METADATA_TYPE_TIMECODE = 5,
505 
510 const char *aom_obu_type_to_string(OBU_TYPE type);
511 
517 typedef struct cfg_options {
522  unsigned int ext_partition;
523 } cfg_options_t;
524 
526 #ifdef __cplusplus
527 }
528 #endif
529 #endif // AOM_AOM_CODEC_H_
union aom_codec_ctx::@0 config
Operation completed without error.
Definition: aom_codec.h:103
Encoded bitstream uses an unsupported feature.
Definition: aom_codec.h:131
The coded data for this stream is corrupt or incomplete.
Definition: aom_codec.h:141
Encoder configuration structure.
Definition: aom_encoder.h:237
aom_codec_err_t err
Definition: aom_codec.h:207
const char * name
Definition: aom_codec.h:205
Describes the aom image descriptor and associated operations.
aom_codec_iface_t * iface
Definition: aom_codec.h:206
Codec context structure.
Definition: aom_codec.h:204
aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface)
Get the capabilities of an algorithm.
const char * err_detail
Definition: aom_codec.h:208
aom_codec_err_t aom_codec_control_(aom_codec_ctx_t *ctx, int ctrl_id,...)
Control algorithm.
struct cfg_options cfg_options_t
Config Options.
OBU_METADATA_TYPE
OBU metadata types.
Definition: aom_codec.h:522
Definition: aom_codec.h:225
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:181
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_priv_t * priv
Definition: aom_codec.h:217
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
Config Options.
Definition: aom_codec.h:542
const char * aom_codec_err_to_string(aom_codec_err_t err)
Convert error number to printable string.
Algorithm does not have required capability.
Definition: aom_codec.h:115
Memory operation failed.
Definition: aom_codec.h:109
Definition: aom_codec.h:227
enum aom_superblock_size aom_superblock_size_t
Superblock size selection.
ABI version mismatch.
Definition: aom_codec.h:112
const char * aom_obu_type_to_string(OBU_TYPE type)
Returns string representation of OBU_TYPE.
Unspecified error.
Definition: aom_codec.h:106
aom_superblock_size
Superblock size selection.
Definition: aom_codec.h:236
Initialization Configurations.
Definition: aom_decoder.h:103
An iterator reached the end of list.
Definition: aom_codec.h:151
OBU_TYPE
OBU types.
Definition: aom_codec.h:509
int aom_codec_version(void)
Return the version information (as an integer)
const char * aom_codec_build_config(void)
Return the build configuration.
The given bitstream is not supported.
Definition: aom_codec.h:122
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
const char * aom_codec_version_str(void)
Return the version information (as a string)
Definition: aom_codec.h:237
#define ATTRIBUTE_PACKED
Decorator indicating that given struct/union/enum is packed.
Definition: aom_codec.h:86
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:174
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
Definition: aom_codec.h:238
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
const char * aom_codec_error(aom_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
struct aom_codec_priv aom_codec_priv_t
Codec private data structure.
Definition: aom_codec.h:188
unsigned int ext_partition
Reflects if ext_partition should be enabled.
Definition: aom_codec.h:547
aom_codec_flags_t init_flags
Definition: aom_codec.h:209
const struct aom_codec_dec_cfg * dec
Definition: aom_codec.h:212
Definition: aom_codec.h:226
An application-supplied parameter is not valid.
Definition: aom_codec.h:146
const char * aom_codec_error_detail(aom_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
long aom_codec_caps_t
Codec capabilities bitfield.
Definition: aom_codec.h:163
Definition: aom_codec.h:239
const char * aom_codec_version_extra_str(void)
Return the version information (as a string)
aom_bit_depth
Bit depth for codecThis enumeration determines the bit depth of the codec.
Definition: aom_codec.h:224