AOMedia AV1 Codec
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 
13 // Internal implementation details
15 //
16 // There are two levels of interfaces used to access the AOM codec: the
17 // aom_codec_iface and the aom_codec_ctx.
18 //
19 // 1. aom_codec_iface_t
20 // (Related files: aom/aom_codec.h, aom/src/aom_codec.c,
21 // aom/internal/aom_codec_internal.h, av1/av1_cx_iface.c,
22 // av1/av1_dx_iface.c)
23 //
24 // Used to initialize the codec context, which contains the configuration for
25 // for modifying the encoder/decoder during run-time. See the other
26 // documentation in this header file for more details. For the most part,
27 // users will call helper functions, such as aom_codec_iface_name,
28 // aom_codec_get_caps, etc., to interact with it.
29 //
30 // The main purpose of the aom_codec_iface_t is to provide a way to generate
31 // a default codec config, find out what capabilities the implementation has,
32 // and create an aom_codec_ctx_t (which is actually used to interact with the
33 // codec).
34 //
35 // Note that the implementations for the AV1 algorithm are located in
36 // av1/av1_cx_iface.c and av1/av1_dx_iface.c
37 //
38 //
39 // 2. aom_codec_ctx_t
40 // (Related files: aom/aom_codec.h, av1/av1_cx_iface.c, av1/av1_dx_iface.c,
41 // aom/aomcx.h, aom/aomdx.h, aom/src/aom_encoder.c, aom/src/aom_decoder.c)
42 //
43 // The actual interface between user code and the codec. It stores the name
44 // of the codec, a pointer back to the aom_codec_iface_t that initialized it,
45 // initialization flags, a config for either encoder or the decoder, and a
46 // pointer to internal data.
47 //
48 // The codec is configured / queried through calls to aom_codec_control,
49 // which takes a control ID (listed in aomcx.h and aomdx.h) and a parameter.
50 // In the case of "getter" control IDs, the parameter is modified to have
51 // the requested value; in the case of "setter" control IDs, the codec's
52 // configuration is changed based on the parameter. Note that a aom_codec_err_t
53 // is returned, which indicates if the operation was successful or not.
54 //
55 // Note that for the encoder, the aom_codec_alg_priv_t points to the
56 // the aom_codec_alg_priv structure in av1/av1_cx_iface.c, and for the decoder,
57 // the struct in av1/av1_dx_iface.c. Variables such as AV1_COMP cpi are stored
58 // here and also used in the core algorithm.
59 //
60 // At the end, aom_codec_destroy should be called for each initialized
61 // aom_codec_ctx_t.
62 
93 #ifndef AOM_AOM_AOM_CODEC_H_
94 #define AOM_AOM_AOM_CODEC_H_
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100 #include "aom/aom_image.h"
101 #include "aom/aom_integer.h"
102 
104 #ifndef AOM_DEPRECATED
105 #if defined(__GNUC__) && __GNUC__
106 #define AOM_DEPRECATED __attribute__((deprecated))
107 #elif defined(_MSC_VER)
108 #define AOM_DEPRECATED
109 #else
110 #define AOM_DEPRECATED
111 #endif
112 #endif /* AOM_DEPRECATED */
113 
114 #ifndef AOM_DECLSPEC_DEPRECATED
115 #if defined(__GNUC__) && __GNUC__
116 #define AOM_DECLSPEC_DEPRECATED
117 #elif defined(_MSC_VER)
119 #define AOM_DECLSPEC_DEPRECATED __declspec(deprecated)
120 #else
121 #define AOM_DECLSPEC_DEPRECATED
122 #endif
123 #endif /* AOM_DECLSPEC_DEPRECATED */
124 
126 #ifdef AOM_UNUSED
127 #elif defined(__GNUC__) || defined(__clang__)
128 #define AOM_UNUSED __attribute__((unused))
129 #else
130 #define AOM_UNUSED
131 #endif
132 
134 #ifndef ATTRIBUTE_PACKED
135 #if defined(__GNUC__) && __GNUC__
136 #define ATTRIBUTE_PACKED __attribute__((packed))
137 #elif defined(_MSC_VER)
138 #define ATTRIBUTE_PACKED
139 #else
140 #define ATTRIBUTE_PACKED
141 #endif
142 #endif /* ATTRIBUTE_PACKED */
143 
152 #define AOM_CODEC_ABI_VERSION (7 + AOM_IMAGE_ABI_VERSION)
155 typedef enum {
158 
161 
164 
167 
170 
177 
186 
196 
201 
206 
208 
217 typedef long aom_codec_caps_t;
218 #define AOM_CODEC_CAP_DECODER 0x1
219 #define AOM_CODEC_CAP_ENCODER 0x2
228 typedef long aom_codec_flags_t;
229 
235 typedef int64_t aom_codec_pts_t;
236 
254 typedef const struct aom_codec_iface aom_codec_iface_t;
255 
261 typedef struct aom_codec_priv aom_codec_priv_t;
262 
270 typedef uint32_t aom_codec_frame_flags_t;
271 #define AOM_FRAME_IS_KEY 0x1u
274 #define AOM_FRAME_IS_DROPPABLE 0x2u
276 #define AOM_FRAME_IS_INTRAONLY 0x10u
278 #define AOM_FRAME_IS_SWITCH 0x20u
280 #define AOM_FRAME_IS_ERROR_RESILIENT 0x40u
282 #define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80u
283 
288 typedef const void *aom_codec_iter_t;
289 
298 typedef struct aom_codec_ctx {
299  const char *name;
302  const char *err_detail;
304  union {
306  const struct aom_codec_dec_cfg *dec;
308  const struct aom_codec_enc_cfg *enc;
309  const void *raw;
310  } config;
313 
318 typedef enum aom_bit_depth {
320  AOM_BITS_10 = 10,
321  AOM_BITS_12 = 12,
323 
330 typedef enum aom_superblock_size {
335 
336 /*
337  * Library Version Number Interface
338  *
339  * For example, see the following sample return values:
340  * aom_codec_version() (1<<16 | 2<<8 | 3)
341  * aom_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
342  * aom_codec_version_extra_str() "rc1-16-gec6a1ba"
343  */
344 
354 
356 #define aom_codec_version_major() ((aom_codec_version() >> 16) & 0xff)
357 
359 #define aom_codec_version_minor() ((aom_codec_version() >> 8) & 0xff)
360 
362 #define aom_codec_version_patch() ((aom_codec_version() >> 0) & 0xff)
363 
371 const char *aom_codec_version_str(void);
372 
379 const char *aom_codec_version_extra_str(void);
380 
387 const char *aom_codec_build_config(void);
388 
397 
409 
420 const char *aom_codec_error(const aom_codec_ctx_t *ctx);
421 
434 const char *aom_codec_error_detail(const aom_codec_ctx_t *ctx);
435 
436 /* REQUIRED FUNCTIONS
437  *
438  * The following functions are required to be implemented for all codecs.
439  * They represent the base case functionality expected of all codecs.
440  */
441 
456 
465 
497 
516  const char *value);
517 
525 #define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data) \
526  aom_codec_control_typechecked_##id(ctx, id, data)
534 #define AOM_CTRL_USE_TYPE(id, typ) \
535  static aom_codec_err_t aom_codec_control_typechecked_##id( \
536  aom_codec_ctx_t *, int, typ) AOM_UNUSED; \
537  static aom_codec_err_t aom_codec_control_typechecked_##id( \
538  aom_codec_ctx_t *ctx, int ctrl, typ data) { \
539  return aom_codec_control(ctx, ctrl, data); \
540  } \
541  typedef typ aom_codec_control_type_##id;
545 typedef enum ATTRIBUTE_PACKED {
546  OBU_SEQUENCE_HEADER = 1,
547  OBU_TEMPORAL_DELIMITER = 2,
548  OBU_FRAME_HEADER = 3,
549  OBU_TILE_GROUP = 4,
550  OBU_METADATA = 5,
551  OBU_FRAME = 6,
552  OBU_REDUNDANT_FRAME_HEADER = 7,
553  OBU_TILE_LIST = 8,
554  OBU_PADDING = 15,
555 } OBU_TYPE;
556 
558 typedef enum {
559  OBU_METADATA_TYPE_AOM_RESERVED_0 = 0,
560  OBU_METADATA_TYPE_HDR_CLL = 1,
561  OBU_METADATA_TYPE_HDR_MDCV = 2,
562  OBU_METADATA_TYPE_SCALABILITY = 3,
563  OBU_METADATA_TYPE_ITUT_T35 = 4,
564  OBU_METADATA_TYPE_TIMECODE = 5,
566 
571 const char *aom_obu_type_to_string(OBU_TYPE type);
572 
574 #ifdef __cplusplus
575 }
576 #endif
577 #endif // AOM_AOM_AOM_CODEC_H_
Describes the aom image descriptor and associated operations.
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
long aom_codec_caps_t
Codec capabilities bitfield.
Definition: aom_codec.h:217
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id,...)
Algorithm Control.
long aom_codec_flags_t
Initialization-time Feature Enabling.
Definition: aom_codec.h:228
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
struct aom_codec_priv aom_codec_priv_t
Codec private data structure.
Definition: aom_codec.h:261
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition: aom_codec.h:254
const char * aom_codec_version_str(void)
Return the version information (as a string)
aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface)
Get the capabilities of an algorithm.
aom_bit_depth
Bit depth for codecThis enumeration determines the bit depth of the codec.
Definition: aom_codec.h:318
const char * aom_codec_error_detail(const aom_codec_ctx_t *ctx)
Retrieve detailed error information for codec context.
const char * aom_codec_err_to_string(aom_codec_err_t err)
Convert error number to printable string.
OBU_TYPE
OBU types.
Definition: aom_codec.h:546
aom_codec_err_t aom_codec_set_option(aom_codec_ctx_t *ctx, const char *name, const char *value)
Key & Value API.
int64_t aom_codec_pts_t
Time Stamp Type.
Definition: aom_codec.h:235
enum aom_superblock_size aom_superblock_size_t
Superblock size selection.
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:155
OBU_METADATA_TYPE
OBU metadata types.
Definition: aom_codec.h:559
int aom_codec_version(void)
Return the version information (as an integer)
const char * aom_codec_error(const aom_codec_ctx_t *ctx)
Retrieve error synopsis for codec context.
aom_superblock_size
Superblock size selection.
Definition: aom_codec.h:330
#define ATTRIBUTE_PACKED
Decorator indicating that given struct/union/enum is packed.
Definition: aom_codec.h:140
const char * aom_codec_version_extra_str(void)
Return the version information (as a string)
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:288
const char * aom_obu_type_to_string(OBU_TYPE type)
Returns string representation of OBU_TYPE.
const char * aom_codec_build_config(void)
Return the build configuration.
uint32_t aom_codec_frame_flags_t
Compressed Frame Flags.
Definition: aom_codec.h:270
@ AOM_BITS_12
Definition: aom_codec.h:321
@ AOM_BITS_8
Definition: aom_codec.h:319
@ AOM_BITS_10
Definition: aom_codec.h:320
@ AOM_CODEC_INVALID_PARAM
An application-supplied parameter is not valid.
Definition: aom_codec.h:200
@ AOM_CODEC_ERROR
Unspecified error.
Definition: aom_codec.h:160
@ AOM_CODEC_UNSUP_BITSTREAM
The given bitstream is not supported.
Definition: aom_codec.h:176
@ AOM_CODEC_LIST_END
An iterator reached the end of list.
Definition: aom_codec.h:205
@ AOM_CODEC_ABI_MISMATCH
ABI version mismatch.
Definition: aom_codec.h:166
@ AOM_CODEC_CORRUPT_FRAME
The coded data for this stream is corrupt or incomplete.
Definition: aom_codec.h:195
@ AOM_CODEC_UNSUP_FEATURE
Encoded bitstream uses an unsupported feature.
Definition: aom_codec.h:185
@ AOM_CODEC_MEM_ERROR
Memory operation failed.
Definition: aom_codec.h:163
@ AOM_CODEC_INCAPABLE
Algorithm does not have required capability.
Definition: aom_codec.h:169
@ AOM_CODEC_OK
Operation completed without error.
Definition: aom_codec.h:157
@ AOM_SUPERBLOCK_SIZE_128X128
Definition: aom_codec.h:332
@ AOM_SUPERBLOCK_SIZE_64X64
Definition: aom_codec.h:331
@ AOM_SUPERBLOCK_SIZE_DYNAMIC
Definition: aom_codec.h:333
Codec context structure.
Definition: aom_codec.h:298
const char * name
Definition: aom_codec.h:299
aom_codec_iface_t * iface
Definition: aom_codec.h:300
const struct aom_codec_dec_cfg * dec
Definition: aom_codec.h:306
aom_codec_err_t err
Definition: aom_codec.h:301
aom_codec_priv_t * priv
Definition: aom_codec.h:311
union aom_codec_ctx::@0 config
aom_codec_flags_t init_flags
Definition: aom_codec.h:303
const char * err_detail
Definition: aom_codec.h:302
Initialization Configurations.
Definition: aom_decoder.h:91
Encoder configuration structure.
Definition: aom_encoder.h:385