AOMedia Codec SDK: aom/aom_codec.h Source File

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_AOM_CODEC_H_
40 #define AOM_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)
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 (5 + AOM_IMAGE_ABI_VERSION)
101 typedef enum {
103 AOM_CODEC_OK,
104
106 AOM_CODEC_ERROR,
107
109 AOM_CODEC_MEM_ERROR,
110
112 AOM_CODEC_ABI_MISMATCH,
113
115 AOM_CODEC_INCAPABLE,
116
122 AOM_CODEC_UNSUP_BITSTREAM,
123
131 AOM_CODEC_UNSUP_FEATURE,
132
141 AOM_CODEC_CORRUPT_FRAME,
142
146 AOM_CODEC_INVALID_PARAM,
147
151 AOM_CODEC_LIST_END
152
153 } aom_codec_err_t;
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 int64_t aom_codec_pts_t;
182
196 typedef const struct aom_codec_iface aom_codec_iface_t;
197
203 typedef struct aom_codec_priv aom_codec_priv_t;
204
209 typedef const void *aom_codec_iter_t;
210
219 typedef struct aom_codec_ctx {
220 const char *name;
221 aom_codec_iface_t *iface;
222 aom_codec_err_t err;
223 const char *err_detail;
224 aom_codec_flags_t init_flags;
225 union {
227 const struct aom_codec_dec_cfg *dec;
229 const struct aom_codec_enc_cfg *enc;
230 const void *raw;
231 } config;
232 aom_codec_priv_t *priv;
233 } aom_codec_ctx_t;
234
239 typedef enum aom_bit_depth {
240 AOM_BITS_8 = 8,
241 AOM_BITS_10 = 10,
242 AOM_BITS_12 = 12,
243 } aom_bit_depth_t;
244
251 typedef enum aom_superblock_size {
252 AOM_SUPERBLOCK_SIZE_64X64,
253 AOM_SUPERBLOCK_SIZE_128X128,
254 AOM_SUPERBLOCK_SIZE_DYNAMIC
255 } aom_superblock_size_t;
256
257 /*
258 * Library Version Number Interface
259 *
260 * For example, see the following sample return values:
261 * aom_codec_version() (1<<16 | 2<<8 | 3)
262 * aom_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
263 * aom_codec_version_extra_str() "rc1-16-gec6a1ba"
264 */
265
276 int aom_codec_version(void);
277
279 #define aom_codec_version_major() ((aom_codec_version() >> 16) & 0xff)
280
282 #define aom_codec_version_minor() ((aom_codec_version() >> 8) & 0xff)
283
285 #define aom_codec_version_patch() ((aom_codec_version() >> 0) & 0xff)
286
296 const char *aom_codec_version_str(void);
297
305 const char *aom_codec_version_extra_str(void);
306
313 const char *aom_codec_build_config(void);
314
322 const char *aom_codec_iface_name(aom_codec_iface_t *iface);
323
334 const char *aom_codec_err_to_string(aom_codec_err_t err);
335
346 const char *aom_codec_error(aom_codec_ctx_t *ctx);
347
358 const char *aom_codec_error_detail(aom_codec_ctx_t *ctx);
359
360 /* REQUIRED FUNCTIONS
361 *
362 * The following functions are required to be implemented for all codecs.
363 * They represent the base case functionality expected of all codecs.
364 */
365
377 aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx);
378
386 aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface);
387
417 aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...);
418
426 #define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data) \
427 aom_codec_control_typechecked_##id(ctx, id, data)
435 #define AOM_CTRL_USE_TYPE(id, typ) \
436 static aom_codec_err_t aom_codec_control_typechecked_##id( \
437 aom_codec_ctx_t *, int, typ) AOM_UNUSED; \
438 static aom_codec_err_t aom_codec_control_typechecked_##id( \
439 aom_codec_ctx_t *ctx, int ctrl, typ data) { \
440 return aom_codec_control(ctx, ctrl, data); \
441 } \
442 typedef typ aom_codec_control_type_##id;
446 typedef enum ATTRIBUTE_PACKED {
447 OBU_SEQUENCE_HEADER = 1,
448 OBU_TEMPORAL_DELIMITER = 2,
449 OBU_FRAME_HEADER = 3,
450 OBU_TILE_GROUP = 4,
451 OBU_METADATA = 5,
452 OBU_FRAME = 6,
453 OBU_REDUNDANT_FRAME_HEADER = 7,
454 OBU_TILE_LIST = 8,
455 OBU_PADDING = 15,
456 } OBU_TYPE;
457
459 typedef enum {
460 OBU_METADATA_TYPE_AOM_RESERVED_0 = 0,
461 OBU_METADATA_TYPE_HDR_CLL = 1,
462 OBU_METADATA_TYPE_HDR_MDCV = 2,
463 OBU_METADATA_TYPE_SCALABILITY = 3,
464 OBU_METADATA_TYPE_ITUT_T35 = 4,
465 OBU_METADATA_TYPE_TIMECODE = 5,
466 } OBU_METADATA_TYPE;
467
472 const char *aom_obu_type_to_string(OBU_TYPE type);
473
475 #ifdef __cplusplus
476 }
477 #endif
478 #endif // AOM_AOM_AOM_CODEC_H_
aom_image.h
Describes the aom image descriptor and associated operations.
aom_codec_iface_name
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_caps_t
long aom_codec_caps_t
Codec capabilities bitfield.
Definition: aom_codec.h:163
aom_bit_depth_t
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
aom_codec_control
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id,...)
Algorithm Control.
aom_codec_flags_t
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:174
aom_codec_ctx_t
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
aom_codec_priv_t
struct aom_codec_priv aom_codec_priv_t
Codec private data structure.
Definition: aom_codec.h:203
aom_codec_error_detail
const char * aom_codec_error_detail(aom_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
aom_codec_iface_t
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:196
aom_codec_error
const char * aom_codec_error(aom_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
aom_codec_version_str
const char * aom_codec_version_str(void)
Return the version information (as a string)
aom_codec_get_caps
aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface)
Get the capabilities of an algorithm.
aom_bit_depth
aom_bit_depth
Bit depth for codecThis enumeration determines the bit depth of the codec.
Definition: aom_codec.h:239
aom_codec_err_to_string
const char * aom_codec_err_to_string(aom_codec_err_t err)
Convert error number to printable string.
OBU_TYPE
OBU_TYPE
OBU types.
Definition: aom_codec.h:447
aom_codec_pts_t
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_codec.h:181
aom_superblock_size_t
enum aom_superblock_size aom_superblock_size_t
Superblock size selection.
aom_codec_destroy
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_codec_err_t
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:101
OBU_METADATA_TYPE
OBU_METADATA_TYPE
OBU metadata types.
Definition: aom_codec.h:460
aom_codec_version
int aom_codec_version(void)
Return the version information (as an integer)
aom_superblock_size
aom_superblock_size
Superblock size selection.
Definition: aom_codec.h:251
ATTRIBUTE_PACKED
#define ATTRIBUTE_PACKED
Decorator indicating that given struct/union/enum is packed.
Definition: aom_codec.h:86
aom_codec_version_extra_str
const char * aom_codec_version_extra_str(void)
Return the version information (as a string)
aom_codec_iter_t
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:209
aom_obu_type_to_string
const char * aom_obu_type_to_string(OBU_TYPE type)
Returns string representation of OBU_TYPE.
aom_codec_build_config
const char * aom_codec_build_config(void)
Return the build configuration.
AOM_BITS_12
@ AOM_BITS_12
Definition: aom_codec.h:242
AOM_BITS_8
@ AOM_BITS_8
Definition: aom_codec.h:240
AOM_BITS_10
@ AOM_BITS_10
Definition: aom_codec.h:241
AOM_CODEC_INVALID_PARAM
@ AOM_CODEC_INVALID_PARAM
An application-supplied parameter is not valid.
Definition: aom_codec.h:146
AOM_CODEC_ERROR
@ AOM_CODEC_ERROR
Unspecified error.
Definition: aom_codec.h:106
AOM_CODEC_UNSUP_BITSTREAM
@ AOM_CODEC_UNSUP_BITSTREAM
The given bitstream is not supported.
Definition: aom_codec.h:122
AOM_CODEC_LIST_END
@ AOM_CODEC_LIST_END
An iterator reached the end of list.
Definition: aom_codec.h:151
AOM_CODEC_ABI_MISMATCH
@ AOM_CODEC_ABI_MISMATCH
ABI version mismatch.
Definition: aom_codec.h:112
AOM_CODEC_CORRUPT_FRAME
@ AOM_CODEC_CORRUPT_FRAME
The coded data for this stream is corrupt or incomplete.
Definition: aom_codec.h:141
AOM_CODEC_UNSUP_FEATURE
@ AOM_CODEC_UNSUP_FEATURE
Encoded bitstream uses an unsupported feature.
Definition: aom_codec.h:131
AOM_CODEC_MEM_ERROR
@ AOM_CODEC_MEM_ERROR
Memory operation failed.
Definition: aom_codec.h:109
AOM_CODEC_INCAPABLE
@ AOM_CODEC_INCAPABLE
Algorithm does not have required capability.
Definition: aom_codec.h:115
AOM_CODEC_OK
@ AOM_CODEC_OK
Operation completed without error.
Definition: aom_codec.h:103
AOM_SUPERBLOCK_SIZE_128X128
@ AOM_SUPERBLOCK_SIZE_128X128
Definition: aom_codec.h:253
AOM_SUPERBLOCK_SIZE_64X64
@ AOM_SUPERBLOCK_SIZE_64X64
Definition: aom_codec.h:252
AOM_SUPERBLOCK_SIZE_DYNAMIC
@ AOM_SUPERBLOCK_SIZE_DYNAMIC
Definition: aom_codec.h:254
aom_codec_ctx
Codec context structure.
Definition: aom_codec.h:219
aom_codec_ctx::name
const char * name
Definition: aom_codec.h:220
aom_codec_ctx::iface
aom_codec_iface_t * iface
Definition: aom_codec.h:221
aom_codec_ctx::dec
const struct aom_codec_dec_cfg * dec
Definition: aom_codec.h:227
aom_codec_ctx::err
aom_codec_err_t err
Definition: aom_codec.h:222
aom_codec_ctx::priv
aom_codec_priv_t * priv
Definition: aom_codec.h:232
aom_codec_ctx::config
union aom_codec_ctx::@0 config
aom_codec_ctx::init_flags
aom_codec_flags_t init_flags
Definition: aom_codec.h:224
aom_codec_ctx::err_detail
const char * err_detail
Definition: aom_codec.h:223
aom_codec_dec_cfg
Initialization Configurations.
Definition: aom_decoder.h:91
aom_codec_enc_cfg
Encoder configuration structure.
Definition: aom_encoder.h:369