blob: e14ace44d04c437e748733d72c7bacefe57cd9ec [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 */
James Zerne1cbb132018-08-22 14:10:36 -070021#ifndef AOM_AOM_AOMDX_H_
22#define AOM_AOM_AOMDX_H_
Yaowu Xuf883b422016-08-30 14:01:10 -070023
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Include controls common to both the encoder and decoder */
Tom Finegandd3e2a52018-05-23 14:33:09 -070029#include "aom/aom.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070030
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
Nathan E. Egge1e412752017-05-04 21:09:39 -040044#ifndef AOM_INSPECTION_H_
Nathan E. Egge2cf03b12017-02-22 16:19:59 -050045/** Callback that inspects decoder frame data.
46 */
47typedef void (*aom_inspect_cb)(void *decoder, void *ctx);
Jim Bankoski8aced4b2018-10-01 13:03:41 -070048
Nathan E. Egge1e412752017-05-04 21:09:39 -040049#endif
Nathan E. Egge2cf03b12017-02-22 16:19:59 -050050
51/*!\brief Structure to hold inspection callback and context.
52 *
53 * Defines a structure to hold the inspection callback function and calling
54 * context.
55 */
56typedef struct aom_inspect_init {
57 /*! Inspection callback. */
58 aom_inspect_cb inspect_cb;
59
60 /*! Inspection context. */
61 void *inspect_ctx;
62} aom_inspect_init;
63
Jim Bankoski8aced4b2018-10-01 13:03:41 -070064/*!\brief Structure to collect a buffer index when inspecting.
65 *
66 * Defines a structure to hold the buffer and return an index
67 * when calling decode from inspect. This enables us to decode
68 * non showable sub frames.
69 */
70typedef struct {
71 /*! Pointer for new position in compressed buffer after decoding 1 OBU. */
72 const unsigned char *buf;
73 /*! Index into reference buffer array to see result of decoding 1 OBU. */
74 int idx;
75} Av1DecodeReturn;
76
Yunqing Wang265d15d2018-05-31 14:59:03 -070077/*!\brief Structure to hold a tile's start address and size in the bitstream.
78 *
79 * Defines a structure to hold a tile's start address and size in the bitstream.
80 */
81typedef struct aom_tile_data {
82 /*! Tile data size. */
83 size_t coded_tile_data_size;
84 /*! Tile's start address. */
Yunqing Wangcd28b202018-06-06 11:53:23 -070085 const void *coded_tile_data;
Yunqing Wang3f9c1e22018-06-16 16:48:15 -070086 /*! Extra size information. */
87 size_t extra_size;
Yunqing Wang265d15d2018-05-31 14:59:03 -070088} aom_tile_data;
89
Yunqing Wang93b18f32018-06-08 21:08:29 -070090/*!\brief Structure to hold the external reference frame pointer.
91 *
92 * Define a structure to hold the external reference frame pointer.
93 */
94typedef struct av1_ext_ref_frame {
95 /*! Start pointer of external references. */
96 aom_image_t *img;
97 /*! Number of available external references. */
98 int num;
99} av1_ext_ref_frame_t;
100
Yaowu Xuf883b422016-08-30 14:01:10 -0700101/*!\enum aom_dec_control_id
102 * \brief AOM decoder control functions
103 *
104 * This set of macros define the control functions available for the AOM
105 * decoder interface.
106 *
107 * \sa #aom_codec_control
108 */
109enum aom_dec_control_id {
110 /** control function to get info on which reference frames were updated
111 * by the last decode
112 */
113 AOMD_GET_LAST_REF_UPDATES = AOM_DECODER_CTRL_ID_START,
114
115 /** check if the indicated frame is corrupted */
116 AOMD_GET_FRAME_CORRUPTED,
117
118 /** control function to get info on which reference frames were used
119 * by the last decode
120 */
121 AOMD_GET_LAST_REF_USED,
122
Yaowu Xuf883b422016-08-30 14:01:10 -0700123 /** control function to get the dimensions that the current frame is decoded
124 * at. This may be different to the intended display size for the frame as
125 * specified in the wrapper or frame header (see AV1D_GET_DISPLAY_SIZE). */
126 AV1D_GET_FRAME_SIZE,
127
128 /** control function to get the current frame's intended display dimensions
129 * (as specified in the wrapper or frame header). This may be different to
130 * the decoded dimensions of this frame (see AV1D_GET_FRAME_SIZE). */
131 AV1D_GET_DISPLAY_SIZE,
132
133 /** control function to get the bit depth of the stream. */
134 AV1D_GET_BIT_DEPTH,
135
Yunqing Wang3dd5e3e2018-07-11 13:22:59 -0700136 /** control function to get the image format of the stream. */
137 AV1D_GET_IMG_FORMAT,
138
Yunqing Wangd74f5682018-07-12 14:34:56 -0700139 /** control function to get the size of the tile. */
140 AV1D_GET_TILE_SIZE,
141
Yaowu Xuf883b422016-08-30 14:01:10 -0700142 /** control function to set the byte alignment of the planes in the reference
143 * buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
144 * legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
145 * follows Y plane, and V plane directly follows U plane. Default value is 0.
146 */
147 AV1_SET_BYTE_ALIGNMENT,
148
149 /** control function to invert the decoding order to from right to left. The
150 * function is used in a test to confirm the decoding independence of tile
151 * columns. The function may be used in application where this order
152 * of decoding is desired.
153 *
154 * TODO(yaowu): Rework the unit test that uses this control, and in a future
155 * release, this test-only control shall be removed.
156 */
157 AV1_INVERT_TILE_DECODE_ORDER,
158
159 /** control function to set the skip loop filter flag. Valid values are
160 * integers. The decoder will skip the loop filter when its value is set to
161 * nonzero. If the loop filter is skipped the decoder may accumulate decode
162 * artifacts. The default value is 0.
163 */
164 AV1_SET_SKIP_LOOP_FILTER,
165
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400166 /** control function to retrieve a pointer to the Accounting struct. When
167 * compiled without --enable-accounting, this returns AOM_CODEC_INCAPABLE.
168 * If called before a frame has been decoded, this returns AOM_CODEC_ERROR.
169 * The caller should ensure that AOM_CODEC_OK is returned before attempting
170 * to dereference the Accounting pointer.
171 */
172 AV1_GET_ACCOUNTING,
173
Peter Boströma1f64322017-01-19 11:35:30 -0500174 /** control function to get last decoded frame quantizer. Returned value uses
175 * internal quantizer scale defined by the codec.
176 */
177 AOMD_GET_LAST_QUANTIZER,
Yaowu Xuf883b422016-08-30 14:01:10 -0700178
179 /** control function to set the range of tile decoding. A value that is
180 * greater and equal to zero indicates only the specific row/column is
181 * decoded. A value that is -1 indicates the whole row/column is decoded.
182 * A special case is both values are -1 that means the whole frame is
183 * decoded.
184 */
185 AV1_SET_DECODE_TILE_ROW,
Peter Boströma1f64322017-01-19 11:35:30 -0500186 AV1_SET_DECODE_TILE_COL,
Yunqing Wang8ae64a92018-01-12 12:26:44 -0800187 /** control function to set the tile coding mode. A value that is equal to
188 * zero indicates the tiles are coded in normal tile mode. A value that is
189 * 1 indicates the tiles are coded in large-scale tile mode.
190 */
191 AV1_SET_TILE_MODE,
Yunqing Wang3f9c1e22018-06-16 16:48:15 -0700192 /** control function to get the frame header information of an encoded frame
193 * in the bitstream. This provides a way to access a frame's header data.
194 */
195 AV1D_GET_FRAME_HEADER_INFO,
Yunqing Wang265d15d2018-05-31 14:59:03 -0700196 /** control function to get the start address and size of a tile in the coded
197 * bitstream. This provides a way to access a specific tile's bitstream data.
198 */
199 AV1D_GET_TILE_DATA,
Yunqing Wang93b18f32018-06-08 21:08:29 -0700200 /** control function to set the external references' pointers in the decoder.
201 * This is used while decoding the tile list OBU in large-scale tile coding
202 * mode.
203 */
204 AV1D_SET_EXT_REF_PTR,
Yunqing Wangfcd71662018-06-06 12:08:31 -0700205 /** control function to enable the ext-tile software debug and testing code in
206 * the decoder.
207 */
208 AV1D_EXT_TILE_DEBUG,
Peter Boströma1f64322017-01-19 11:35:30 -0500209
Deepa K G966c44e2018-06-22 17:41:12 +0530210 /** control function to enable the row based multi-threading of decoding. A
211 * value that is equal to 1 indicates that row based multi-threading is
212 * enabled.
213 */
214 AV1D_SET_ROW_MT,
215
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400216 /** control function to indicate whether bitstream is in Annex-B format. */
217 AV1D_SET_IS_ANNEXB,
218
Frank Bossend8f457a2018-04-30 21:44:12 -0400219 /** control function to indicate which operating point to use. A scalable
220 * stream may define multiple operating points, each of which defines a
221 * set of temporal and spatial layers to be processed. The operating point
Wan-Teh Changf372b852018-05-15 11:31:58 -0700222 * index may take a value between 0 and operating_points_cnt_minus_1 (which
223 * is at most 31).
Frank Bossend8f457a2018-04-30 21:44:12 -0400224 */
225 AV1D_SET_OPERATING_POINT,
226
David Barkerfb356012018-06-07 13:34:44 +0100227 /** control function to indicate whether to output one frame per temporal
228 * unit (the default), or one frame per spatial layer.
229 * In a scalable stream, each temporal unit corresponds to a single "frame"
230 * of video, and within a temporal unit there may be multiple spatial layers
231 * with different versions of that frame.
232 * For video playback, only the highest-quality version (within the
233 * selected operating point) is needed, but for some use cases it is useful
234 * to have access to multiple versions of a frame when they are available.
235 */
236 AV1D_SET_OUTPUT_ALL_LAYERS,
237
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500238 /** control function to set an aom_inspect_cb callback that is invoked each
239 * time a frame is decoded. When compiled without --enable-inspection, this
240 * returns AOM_CODEC_INCAPABLE.
241 */
242 AV1_SET_INSPECTION_CALLBACK,
243
Yaowu Xu6fa40062018-09-13 18:26:09 -0700244 /** control function to set the skip film grain flag. Valid values are
245 * integers. The decoder will skip the film grain when its value is set to
246 * nonzero. The default value is 0.
247 */
248 AV1D_SET_SKIP_FILM_GRAIN,
249
Peter Boströma1f64322017-01-19 11:35:30 -0500250 AOM_DECODER_CTRL_ID_MAX,
Yaowu Xuf883b422016-08-30 14:01:10 -0700251};
252
Yaowu Xuf883b422016-08-30 14:01:10 -0700253/*!\cond */
254/*!\brief AOM decoder control function parameter type
255 *
256 * Defines the data types that AOMD control functions take. Note that
257 * additional common controls are defined in aom.h
258 *
259 */
260
261AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_UPDATES, int *)
262#define AOM_CTRL_AOMD_GET_LAST_REF_UPDATES
263AOM_CTRL_USE_TYPE(AOMD_GET_FRAME_CORRUPTED, int *)
264#define AOM_CTRL_AOMD_GET_FRAME_CORRUPTED
265AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_USED, int *)
266#define AOM_CTRL_AOMD_GET_LAST_REF_USED
Peter Boströma1f64322017-01-19 11:35:30 -0500267AOM_CTRL_USE_TYPE(AOMD_GET_LAST_QUANTIZER, int *)
268#define AOM_CTRL_AOMD_GET_LAST_QUANTIZER
Yaowu Xuf883b422016-08-30 14:01:10 -0700269AOM_CTRL_USE_TYPE(AV1D_GET_DISPLAY_SIZE, int *)
270#define AOM_CTRL_AV1D_GET_DISPLAY_SIZE
271AOM_CTRL_USE_TYPE(AV1D_GET_BIT_DEPTH, unsigned int *)
272#define AOM_CTRL_AV1D_GET_BIT_DEPTH
Yunqing Wang3dd5e3e2018-07-11 13:22:59 -0700273AOM_CTRL_USE_TYPE(AV1D_GET_IMG_FORMAT, aom_img_fmt_t *)
274#define AOM_CTRL_AV1D_GET_IMG_FORMAT
Yunqing Wangd74f5682018-07-12 14:34:56 -0700275AOM_CTRL_USE_TYPE(AV1D_GET_TILE_SIZE, unsigned int *)
276#define AOM_CTRL_AV1D_GET_TILE_SIZE
Yaowu Xuf883b422016-08-30 14:01:10 -0700277AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_SIZE, int *)
278#define AOM_CTRL_AV1D_GET_FRAME_SIZE
279AOM_CTRL_USE_TYPE(AV1_INVERT_TILE_DECODE_ORDER, int)
280#define AOM_CTRL_AV1_INVERT_TILE_DECODE_ORDER
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400281AOM_CTRL_USE_TYPE(AV1_GET_ACCOUNTING, Accounting **)
282#define AOM_CTRL_AV1_GET_ACCOUNTING
Yaowu Xuf883b422016-08-30 14:01:10 -0700283AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int)
284#define AOM_CTRL_AV1_SET_DECODE_TILE_ROW
285AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int)
286#define AOM_CTRL_AV1_SET_DECODE_TILE_COL
Yunqing Wang8ae64a92018-01-12 12:26:44 -0800287AOM_CTRL_USE_TYPE(AV1_SET_TILE_MODE, unsigned int)
288#define AOM_CTRL_AV1_SET_TILE_MODE
Yunqing Wang3f9c1e22018-06-16 16:48:15 -0700289AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_HEADER_INFO, aom_tile_data *)
290#define AOM_CTRL_AV1D_GET_FRAME_HEADER_INFO
Yunqing Wang265d15d2018-05-31 14:59:03 -0700291AOM_CTRL_USE_TYPE(AV1D_GET_TILE_DATA, aom_tile_data *)
292#define AOM_CTRL_AV1D_GET_TILE_DATA
Yunqing Wang93b18f32018-06-08 21:08:29 -0700293AOM_CTRL_USE_TYPE(AV1D_SET_EXT_REF_PTR, av1_ext_ref_frame_t *)
294#define AOM_CTRL_AV1D_SET_EXT_REF_PTR
Yunqing Wangfcd71662018-06-06 12:08:31 -0700295AOM_CTRL_USE_TYPE(AV1D_EXT_TILE_DEBUG, unsigned int)
296#define AOM_CTRL_AV1D_EXT_TILE_DEBUG
Deepa K G966c44e2018-06-22 17:41:12 +0530297AOM_CTRL_USE_TYPE(AV1D_SET_ROW_MT, unsigned int)
298#define AOM_CTRL_AV1D_SET_ROW_MT
Yaowu Xu6fa40062018-09-13 18:26:09 -0700299AOM_CTRL_USE_TYPE(AV1D_SET_SKIP_FILM_GRAIN, int)
300#define AOM_CTRL_AV1D_SET_SKIP_FILM_GRAIN
Soo-Chul Han29c46fb2018-03-23 16:02:00 -0400301AOM_CTRL_USE_TYPE(AV1D_SET_IS_ANNEXB, unsigned int)
302#define AOM_CTRL_AV1D_SET_IS_ANNEXB
Frank Bossend8f457a2018-04-30 21:44:12 -0400303AOM_CTRL_USE_TYPE(AV1D_SET_OPERATING_POINT, int)
304#define AOM_CTRL_AV1D_SET_OPERATING_POINT
David Barkerfb356012018-06-07 13:34:44 +0100305AOM_CTRL_USE_TYPE(AV1D_SET_OUTPUT_ALL_LAYERS, int)
306#define AOM_CTRL_AV1D_SET_OUTPUT_ALL_LAYERS
Nathan E. Egge2cf03b12017-02-22 16:19:59 -0500307AOM_CTRL_USE_TYPE(AV1_SET_INSPECTION_CALLBACK, aom_inspect_init *)
308#define AOM_CTRL_AV1_SET_INSPECTION_CALLBACK
Yaowu Xuf883b422016-08-30 14:01:10 -0700309/*!\endcond */
Nathan E. Eggec9862e02016-10-05 21:28:36 -0400310/*! @} - end defgroup aom_decoder */
Yaowu Xuf883b422016-08-30 14:01:10 -0700311
312#ifdef __cplusplus
313} // extern "C"
314#endif
315
James Zerne1cbb132018-08-22 14:10:36 -0700316#endif // AOM_AOM_AOMDX_H_