xref: /aosp_15_r20/external/libaom/usage.dox (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker/*!\page usage Usage
2*77c1e3ccSAndroid Build Coastguard Worker
3*77c1e3ccSAndroid Build Coastguard Worker    The aom multi-format codec SDK provides a unified interface amongst its
4*77c1e3ccSAndroid Build Coastguard Worker    supported codecs. This abstraction allows applications using this SDK to
5*77c1e3ccSAndroid Build Coastguard Worker    easily support multiple video formats with minimal code duplication or
6*77c1e3ccSAndroid Build Coastguard Worker    "special casing." This section describes the interface common to all codecs.
7*77c1e3ccSAndroid Build Coastguard Worker    For codec-specific details, see the \ref codecs page.
8*77c1e3ccSAndroid Build Coastguard Worker
9*77c1e3ccSAndroid Build Coastguard Worker    The following sections are common to all codecs:
10*77c1e3ccSAndroid Build Coastguard Worker    - \ref usage_types
11*77c1e3ccSAndroid Build Coastguard Worker    - \ref usage_features
12*77c1e3ccSAndroid Build Coastguard Worker    - \ref usage_init
13*77c1e3ccSAndroid Build Coastguard Worker    - \ref usage_errors
14*77c1e3ccSAndroid Build Coastguard Worker
15*77c1e3ccSAndroid Build Coastguard Worker    For more information on decoder and encoder specific usage, see the
16*77c1e3ccSAndroid Build Coastguard Worker    following pages:
17*77c1e3ccSAndroid Build Coastguard Worker    \if decoder
18*77c1e3ccSAndroid Build Coastguard Worker    \li \subpage usage_decode
19*77c1e3ccSAndroid Build Coastguard Worker    \endif
20*77c1e3ccSAndroid Build Coastguard Worker    \if encoder
21*77c1e3ccSAndroid Build Coastguard Worker    \li \subpage usage_encode
22*77c1e3ccSAndroid Build Coastguard Worker    \endif
23*77c1e3ccSAndroid Build Coastguard Worker
24*77c1e3ccSAndroid Build Coastguard Worker    \section usage_types Important Data Types
25*77c1e3ccSAndroid Build Coastguard Worker    There are two important data structures to consider in this interface.
26*77c1e3ccSAndroid Build Coastguard Worker
27*77c1e3ccSAndroid Build Coastguard Worker    \subsection usage_ctxs Contexts
28*77c1e3ccSAndroid Build Coastguard Worker    A context is a storage area allocated by the calling application that the
29*77c1e3ccSAndroid Build Coastguard Worker    codec may write into to store details about a single instance of that codec.
30*77c1e3ccSAndroid Build Coastguard Worker    Most of the context is implementation specific, and thus opaque to the
31*77c1e3ccSAndroid Build Coastguard Worker    application. The context structure as seen by the application is of fixed
32*77c1e3ccSAndroid Build Coastguard Worker    size, and thus can be allocated with automatic storage or dynamically
33*77c1e3ccSAndroid Build Coastguard Worker    on the heap.
34*77c1e3ccSAndroid Build Coastguard Worker
35*77c1e3ccSAndroid Build Coastguard Worker    Most operations require an initialized codec context. Codec context
36*77c1e3ccSAndroid Build Coastguard Worker    instances are codec specific. That is, the codec to be used for the encoded
37*77c1e3ccSAndroid Build Coastguard Worker    video must be known at initialization time. See #aom_codec_ctx_t for further
38*77c1e3ccSAndroid Build Coastguard Worker    information.
39*77c1e3ccSAndroid Build Coastguard Worker
40*77c1e3ccSAndroid Build Coastguard Worker    \subsection usage_ifaces Interfaces
41*77c1e3ccSAndroid Build Coastguard Worker    A codec interface is an opaque structure that controls how function calls
42*77c1e3ccSAndroid Build Coastguard Worker    into the generic interface are dispatched to their codec-specific
43*77c1e3ccSAndroid Build Coastguard Worker    implementations. Applications \ref MUSTNOT attempt to examine or override
44*77c1e3ccSAndroid Build Coastguard Worker    this storage, as it contains internal implementation details likely to
45*77c1e3ccSAndroid Build Coastguard Worker    change from release to release.
46*77c1e3ccSAndroid Build Coastguard Worker
47*77c1e3ccSAndroid Build Coastguard Worker    Each supported codec will expose an interface structure to the application
48*77c1e3ccSAndroid Build Coastguard Worker    as an <code>extern</code> reference to a structure of the incomplete type
49*77c1e3ccSAndroid Build Coastguard Worker    #aom_codec_iface_t.
50*77c1e3ccSAndroid Build Coastguard Worker
51*77c1e3ccSAndroid Build Coastguard Worker    \section usage_features Features
52*77c1e3ccSAndroid Build Coastguard Worker    Several "features" are defined that are optionally implemented by codec
53*77c1e3ccSAndroid Build Coastguard Worker    algorithms. Indeed, the same algorithm may support different features on
54*77c1e3ccSAndroid Build Coastguard Worker    different platforms. The purpose of defining these features is that when
55*77c1e3ccSAndroid Build Coastguard Worker    they are implemented, they conform to a common interface. The features, or
56*77c1e3ccSAndroid Build Coastguard Worker    capabilities, of an algorithm can be queried from it's interface by using
57*77c1e3ccSAndroid Build Coastguard Worker    the aom_codec_get_caps() method. Attempts to invoke features not supported
58*77c1e3ccSAndroid Build Coastguard Worker    by an algorithm will generally result in #AOM_CODEC_INCAPABLE.
59*77c1e3ccSAndroid Build Coastguard Worker
60*77c1e3ccSAndroid Build Coastguard Worker    \if decoder
61*77c1e3ccSAndroid Build Coastguard Worker    Currently defined decoder features include:
62*77c1e3ccSAndroid Build Coastguard Worker    \endif
63*77c1e3ccSAndroid Build Coastguard Worker
64*77c1e3ccSAndroid Build Coastguard Worker    \section usage_init Initialization
65*77c1e3ccSAndroid Build Coastguard Worker    To initialize a codec instance, the address of the codec context
66*77c1e3ccSAndroid Build Coastguard Worker    and interface structures are passed to an initialization function. Depending
67*77c1e3ccSAndroid Build Coastguard Worker    on the \ref usage_features that the codec supports, the codec could be
68*77c1e3ccSAndroid Build Coastguard Worker    initialized in different modes.
69*77c1e3ccSAndroid Build Coastguard Worker
70*77c1e3ccSAndroid Build Coastguard Worker    To prevent cases of confusion where the ABI of the library changes,
71*77c1e3ccSAndroid Build Coastguard Worker    the ABI is versioned. The ABI version number must be passed at
72*77c1e3ccSAndroid Build Coastguard Worker    initialization time to ensure the application is using a header file that
73*77c1e3ccSAndroid Build Coastguard Worker    matches the library. The current ABI version number is stored in the
74*77c1e3ccSAndroid Build Coastguard Worker    preprocessor macros #AOM_CODEC_ABI_VERSION, #AOM_ENCODER_ABI_VERSION, and
75*77c1e3ccSAndroid Build Coastguard Worker    #AOM_DECODER_ABI_VERSION. For convenience, each initialization function has
76*77c1e3ccSAndroid Build Coastguard Worker    a wrapper macro that inserts the correct version number. These macros are
77*77c1e3ccSAndroid Build Coastguard Worker    named like the initialization methods, but without the _ver suffix.
78*77c1e3ccSAndroid Build Coastguard Worker
79*77c1e3ccSAndroid Build Coastguard Worker
80*77c1e3ccSAndroid Build Coastguard Worker    The available initialization methods are:
81*77c1e3ccSAndroid Build Coastguard Worker    \if encoder
82*77c1e3ccSAndroid Build Coastguard Worker    \li #aom_codec_enc_init (calls aom_codec_enc_init_ver())
83*77c1e3ccSAndroid Build Coastguard Worker    \endif
84*77c1e3ccSAndroid Build Coastguard Worker    \if decoder
85*77c1e3ccSAndroid Build Coastguard Worker    \li #aom_codec_dec_init (calls aom_codec_dec_init_ver())
86*77c1e3ccSAndroid Build Coastguard Worker    \endif
87*77c1e3ccSAndroid Build Coastguard Worker
88*77c1e3ccSAndroid Build Coastguard Worker
89*77c1e3ccSAndroid Build Coastguard Worker    \section usage_errors Error Handling
90*77c1e3ccSAndroid Build Coastguard Worker    Almost all codec functions return an error status of type #aom_codec_err_t.
91*77c1e3ccSAndroid Build Coastguard Worker    The semantics of how each error condition should be processed is clearly
92*77c1e3ccSAndroid Build Coastguard Worker    defined in the definitions of each enumerated value. Error values can be
93*77c1e3ccSAndroid Build Coastguard Worker    converted into ASCII strings with the aom_codec_error() and
94*77c1e3ccSAndroid Build Coastguard Worker    aom_codec_err_to_string() methods. The difference between these two methods is
95*77c1e3ccSAndroid Build Coastguard Worker    that aom_codec_error() returns the error state from an initialized context,
96*77c1e3ccSAndroid Build Coastguard Worker    whereas aom_codec_err_to_string() can be used in cases where an error occurs
97*77c1e3ccSAndroid Build Coastguard Worker    outside any context. The enumerated value returned from the last call can be
98*77c1e3ccSAndroid Build Coastguard Worker    retrieved from the <code>err</code> member of the decoder context as well.
99*77c1e3ccSAndroid Build Coastguard Worker    Finally, more detailed error information may be able to be obtained by using
100*77c1e3ccSAndroid Build Coastguard Worker    the aom_codec_error_detail() method. Not all errors produce detailed error
101*77c1e3ccSAndroid Build Coastguard Worker    information.
102*77c1e3ccSAndroid Build Coastguard Worker
103*77c1e3ccSAndroid Build Coastguard Worker    In addition to error information, the codec library's build configuration
104*77c1e3ccSAndroid Build Coastguard Worker    is available at runtime on some platforms. This information can be returned
105*77c1e3ccSAndroid Build Coastguard Worker    by calling aom_codec_build_config(), and is formatted as a base64 coded string
106*77c1e3ccSAndroid Build Coastguard Worker    (comprised of characters in the set [a-z_a-Z0-9+/]). This information is not
107*77c1e3ccSAndroid Build Coastguard Worker    useful to an application at runtime, but may be of use to aom for support.
108*77c1e3ccSAndroid Build Coastguard Worker
109*77c1e3ccSAndroid Build Coastguard Worker*/
110