Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 10 | */ |
| 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 |
| 25 | extern "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 | */ |
| 36 | extern aom_codec_iface_t aom_codec_av1_dx_algo; |
| 37 | extern aom_codec_iface_t *aom_codec_av1_dx(void); |
| 38 | /*!@} - end algorithm interface member group*/ |
| 39 | |
Nathan E. Egge | c9862e0 | 2016-10-05 21:28:36 -0400 | [diff] [blame] | 40 | /** Data structure that stores bit accounting for debug |
| 41 | */ |
| 42 | typedef struct Accounting Accounting; |
| 43 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 44 | /*!\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 | */ |
| 52 | enum 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. Egge | c9862e0 | 2016-10-05 21:28:36 -0400 | [diff] [blame] | 110 | /** 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öm | a1f6432 | 2017-01-19 11:35:30 -0500 | [diff] [blame] | 118 | /** 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 122 | |
| 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öm | a1f6432 | 2017-01-19 11:35:30 -0500 | [diff] [blame] | 130 | AV1_SET_DECODE_TILE_COL, |
| 131 | |
| 132 | AOM_DECODER_CTRL_ID_MAX, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | /** Decrypt n bytes of data from input -> output, using the decrypt_state |
| 136 | * passed in AOMD_SET_DECRYPTOR. |
| 137 | */ |
| 138 | typedef 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 | */ |
| 145 | typedef 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 153 | /*!\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 | |
| 161 | AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_UPDATES, int *) |
| 162 | #define AOM_CTRL_AOMD_GET_LAST_REF_UPDATES |
| 163 | AOM_CTRL_USE_TYPE(AOMD_GET_FRAME_CORRUPTED, int *) |
| 164 | #define AOM_CTRL_AOMD_GET_FRAME_CORRUPTED |
| 165 | AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_USED, int *) |
| 166 | #define AOM_CTRL_AOMD_GET_LAST_REF_USED |
Peter Boström | a1f6432 | 2017-01-19 11:35:30 -0500 | [diff] [blame] | 167 | AOM_CTRL_USE_TYPE(AOMD_GET_LAST_QUANTIZER, int *) |
| 168 | #define AOM_CTRL_AOMD_GET_LAST_QUANTIZER |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 169 | AOM_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 |
| 173 | AOM_CTRL_USE_TYPE(AV1D_GET_DISPLAY_SIZE, int *) |
| 174 | #define AOM_CTRL_AV1D_GET_DISPLAY_SIZE |
| 175 | AOM_CTRL_USE_TYPE(AV1D_GET_BIT_DEPTH, unsigned int *) |
| 176 | #define AOM_CTRL_AV1D_GET_BIT_DEPTH |
| 177 | AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_SIZE, int *) |
| 178 | #define AOM_CTRL_AV1D_GET_FRAME_SIZE |
| 179 | AOM_CTRL_USE_TYPE(AV1_INVERT_TILE_DECODE_ORDER, int) |
| 180 | #define AOM_CTRL_AV1_INVERT_TILE_DECODE_ORDER |
Nathan E. Egge | c9862e0 | 2016-10-05 21:28:36 -0400 | [diff] [blame] | 181 | AOM_CTRL_USE_TYPE(AV1_GET_ACCOUNTING, Accounting **) |
| 182 | #define AOM_CTRL_AV1_GET_ACCOUNTING |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 183 | AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int) |
| 184 | #define AOM_CTRL_AV1_SET_DECODE_TILE_ROW |
| 185 | AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int) |
| 186 | #define AOM_CTRL_AV1_SET_DECODE_TILE_COL |
| 187 | /*!\endcond */ |
Nathan E. Egge | c9862e0 | 2016-10-05 21:28:36 -0400 | [diff] [blame] | 188 | /*! @} - end defgroup aom_decoder */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 189 | |
| 190 | #ifdef __cplusplus |
| 191 | } // extern "C" |
| 192 | #endif |
| 193 | |
| 194 | #endif // AOM_AOMDX_H_ |