blob: 2a00ecb38f949093c61205a7da5fbd6d0cfe608a [file] [log] [blame]
Yaowu Xuf883b422016-08-30 14:01:10 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuf883b422016-08-30 14:01:10 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Yaowu Xuf883b422016-08-30 14:01:10 -070010 */
11
12/*!\defgroup aom_decoder AOMedia AOM/AV1 Decoder
13 * \ingroup aom
14 *
15 * @{
16 */
17/*!\file
18 * \brief Provides definitions for using AOM or AV1 within the aom Decoder
19 * interface.
20 */
21#ifndef AOM_AOMDX_H_
22#define AOM_AOMDX_H_
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Include controls common to both the encoder and decoder */
29#include "./aom.h"
30
31/*!\name Algorithm interface for AV1
32 *
33 * This interface provides the capability to decode AV1 streams.
34 * @{
35 */
36extern aom_codec_iface_t aom_codec_av1_dx_algo;
37extern aom_codec_iface_t *aom_codec_av1_dx(void);
38/*!@} - end algorithm interface member group*/
39
Nathan E. Eggec9862e02016-10-05 21:28:36 -040040/** Data structure that stores bit accounting for debug
41 */
42typedef struct Accounting Accounting;
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044/*!\enum aom_dec_control_id
45 * \brief AOM decoder control functions
46 *
47 * This set of macros define the control functions available for the AOM
48 * decoder interface.
49 *
50 * \sa #aom_codec_control
51 */
52enum aom_dec_control_id {
53 /** control function to get info on which reference frames were updated
54 * by the last decode
55 */
56 AOMD_GET_LAST_REF_UPDATES = AOM_DECODER_CTRL_ID_START,
57
58 /** check if the indicated frame is corrupted */
59 AOMD_GET_FRAME_CORRUPTED,
60
61 /** control function to get info on which reference frames were used
62 * by the last decode
63 */
64 AOMD_GET_LAST_REF_USED,
65
66 /** decryption function to decrypt encoded buffer data immediately
67 * before decoding. Takes a aom_decrypt_init, which contains
68 * a callback function and opaque context pointer.
69 */
70 AOMD_SET_DECRYPTOR,
71 // AOMD_SET_DECRYPTOR = AOMD_SET_DECRYPTOR,
72
73 /** control function to get the dimensions that the current frame is decoded
74 * at. This may be different to the intended display size for the frame as
75 * specified in the wrapper or frame header (see AV1D_GET_DISPLAY_SIZE). */
76 AV1D_GET_FRAME_SIZE,
77
78 /** control function to get the current frame's intended display dimensions
79 * (as specified in the wrapper or frame header). This may be different to
80 * the decoded dimensions of this frame (see AV1D_GET_FRAME_SIZE). */
81 AV1D_GET_DISPLAY_SIZE,
82
83 /** control function to get the bit depth of the stream. */
84 AV1D_GET_BIT_DEPTH,
85
86 /** control function to set the byte alignment of the planes in the reference
87 * buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
88 * legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
89 * follows Y plane, and V plane directly follows U plane. Default value is 0.
90 */
91 AV1_SET_BYTE_ALIGNMENT,
92
93 /** control function to invert the decoding order to from right to left. The
94 * function is used in a test to confirm the decoding independence of tile
95 * columns. The function may be used in application where this order
96 * of decoding is desired.
97 *
98 * TODO(yaowu): Rework the unit test that uses this control, and in a future
99 * release, this test-only control shall be removed.
100 */
101 AV1_INVERT_TILE_DECODE_ORDER,
102
103 /** control function to set the skip loop filter flag. Valid values are
104 * integers. The decoder will skip the loop filter when its value is set to
105 * nonzero. If the loop filter is skipped the decoder may accumulate decode
106 * artifacts. The default value is 0.
107 */
108 AV1_SET_SKIP_LOOP_FILTER,
109
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400110 /** control function to retrieve a pointer to the Accounting struct. When
111 * compiled without --enable-accounting, this returns AOM_CODEC_INCAPABLE.
112 * If called before a frame has been decoded, this returns AOM_CODEC_ERROR.
113 * The caller should ensure that AOM_CODEC_OK is returned before attempting
114 * to dereference the Accounting pointer.
115 */
116 AV1_GET_ACCOUNTING,
117
Peter Boströma1f64322017-01-19 11:35:30 -0500118 /** control function to get last decoded frame quantizer. Returned value uses
119 * internal quantizer scale defined by the codec.
120 */
121 AOMD_GET_LAST_QUANTIZER,
Yaowu Xuf883b422016-08-30 14:01:10 -0700122
123 /** control function to set the range of tile decoding. A value that is
124 * greater and equal to zero indicates only the specific row/column is
125 * decoded. A value that is -1 indicates the whole row/column is decoded.
126 * A special case is both values are -1 that means the whole frame is
127 * decoded.
128 */
129 AV1_SET_DECODE_TILE_ROW,
Peter Boströma1f64322017-01-19 11:35:30 -0500130 AV1_SET_DECODE_TILE_COL,
131
132 AOM_DECODER_CTRL_ID_MAX,
Yaowu Xuf883b422016-08-30 14:01:10 -0700133};
134
135/** Decrypt n bytes of data from input -> output, using the decrypt_state
136 * passed in AOMD_SET_DECRYPTOR.
137 */
138typedef void (*aom_decrypt_cb)(void *decrypt_state, const unsigned char *input,
139 unsigned char *output, int count);
140
141/*!\brief Structure to hold decryption state
142 *
143 * Defines a structure to hold the decryption state and access function.
144 */
145typedef struct aom_decrypt_init {
146 /*! Decrypt callback. */
147 aom_decrypt_cb decrypt_cb;
148
149 /*! Decryption state. */
150 void *decrypt_state;
151} aom_decrypt_init;
152
Yaowu Xuf883b422016-08-30 14:01:10 -0700153/*!\cond */
154/*!\brief AOM decoder control function parameter type
155 *
156 * Defines the data types that AOMD control functions take. Note that
157 * additional common controls are defined in aom.h
158 *
159 */
160
161AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_UPDATES, int *)
162#define AOM_CTRL_AOMD_GET_LAST_REF_UPDATES
163AOM_CTRL_USE_TYPE(AOMD_GET_FRAME_CORRUPTED, int *)
164#define AOM_CTRL_AOMD_GET_FRAME_CORRUPTED
165AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_USED, int *)
166#define AOM_CTRL_AOMD_GET_LAST_REF_USED
Peter Boströma1f64322017-01-19 11:35:30 -0500167AOM_CTRL_USE_TYPE(AOMD_GET_LAST_QUANTIZER, int *)
168#define AOM_CTRL_AOMD_GET_LAST_QUANTIZER
Yaowu Xuf883b422016-08-30 14:01:10 -0700169AOM_CTRL_USE_TYPE(AOMD_SET_DECRYPTOR, aom_decrypt_init *)
170#define AOM_CTRL_AOMD_SET_DECRYPTOR
171// AOM_CTRL_USE_TYPE(AOMD_SET_DECRYPTOR, aom_decrypt_init *)
172//#define AOM_CTRL_AOMD_SET_DECRYPTOR
173AOM_CTRL_USE_TYPE(AV1D_GET_DISPLAY_SIZE, int *)
174#define AOM_CTRL_AV1D_GET_DISPLAY_SIZE
175AOM_CTRL_USE_TYPE(AV1D_GET_BIT_DEPTH, unsigned int *)
176#define AOM_CTRL_AV1D_GET_BIT_DEPTH
177AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_SIZE, int *)
178#define AOM_CTRL_AV1D_GET_FRAME_SIZE
179AOM_CTRL_USE_TYPE(AV1_INVERT_TILE_DECODE_ORDER, int)
180#define AOM_CTRL_AV1_INVERT_TILE_DECODE_ORDER
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400181AOM_CTRL_USE_TYPE(AV1_GET_ACCOUNTING, Accounting **)
182#define AOM_CTRL_AV1_GET_ACCOUNTING
Yaowu Xuf883b422016-08-30 14:01:10 -0700183AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int)
184#define AOM_CTRL_AV1_SET_DECODE_TILE_ROW
185AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int)
186#define AOM_CTRL_AV1_SET_DECODE_TILE_COL
187/*!\endcond */
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400188/*! @} - end defgroup aom_decoder */
Yaowu Xuf883b422016-08-30 14:01:10 -0700189
190#ifdef __cplusplus
191} // extern "C"
192#endif
193
194#endif // AOM_AOMDX_H_