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 AOM |
| 13 | * \ingroup codecs |
| 14 | * AOM is aom's newest video compression algorithm that uses motion |
| 15 | * compensated prediction, Discrete Cosine Transform (DCT) coding of the |
| 16 | * prediction error signal and context dependent entropy coding techniques |
| 17 | * based on arithmetic principles. It features: |
| 18 | * - YUV 4:2:0 image format |
| 19 | * - Macro-block based coding (16x16 luma plus two 8x8 chroma) |
| 20 | * - 1/4 (1/8) pixel accuracy motion compensated prediction |
| 21 | * - 4x4 DCT transform |
| 22 | * - 128 level linear quantizer |
| 23 | * - In loop deblocking filter |
| 24 | * - Context-based entropy coding |
| 25 | * |
| 26 | * @{ |
| 27 | */ |
| 28 | /*!\file |
| 29 | * \brief Provides controls common to both the AOM encoder and decoder. |
| 30 | */ |
| 31 | #ifndef AOM_AOM_H_ |
| 32 | #define AOM_AOM_H_ |
| 33 | |
| 34 | #include "./aom_codec.h" |
| 35 | #include "./aom_image.h" |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
| 41 | /*!\brief Control functions |
| 42 | * |
| 43 | * The set of macros define the control functions of AOM interface |
| 44 | */ |
| 45 | enum aom_com_control_id { |
| 46 | /*!\brief pass in an external frame into decoder to be used as reference frame |
| 47 | */ |
| 48 | AOM_SET_REFERENCE = 1, |
| 49 | AOM_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */ |
| 50 | AOM_SET_POSTPROC = 3, /**< set the decoder's post processing settings */ |
| 51 | AOM_SET_DBG_COLOR_REF_FRAME = |
| 52 | 4, /**< set the reference frames to color for each macroblock */ |
| 53 | AOM_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */ |
| 54 | AOM_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */ |
| 55 | AOM_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */ |
| 56 | |
| 57 | /* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+) |
| 58 | * for its control ids. These should be migrated to something like the |
| 59 | * AOM_DECODER_CTRL_ID_START range next time we're ready to break the ABI. |
| 60 | */ |
| 61 | AV1_GET_REFERENCE = 128, /**< get a pointer to a reference frame */ |
| 62 | AOM_COMMON_CTRL_ID_MAX, |
| 63 | |
| 64 | AV1_GET_NEW_FRAME_IMAGE = 192, /**< get a pointer to the new frame */ |
| 65 | |
| 66 | AOM_DECODER_CTRL_ID_START = 256 |
| 67 | }; |
| 68 | |
| 69 | /*!\brief post process flags |
| 70 | * |
| 71 | * The set of macros define AOM decoder post processing flags |
| 72 | */ |
| 73 | enum aom_postproc_level { |
| 74 | AOM_NOFILTERING = 0, |
| 75 | AOM_DEBLOCK = 1 << 0, |
| 76 | AOM_DEMACROBLOCK = 1 << 1, |
| 77 | AOM_ADDNOISE = 1 << 2, |
| 78 | AOM_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */ |
| 79 | AOM_DEBUG_TXT_MBLK_MODES = |
| 80 | 1 << 4, /**< print macro block modes over each macro block */ |
| 81 | AOM_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */ |
| 82 | AOM_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */ |
| 83 | AOM_MFQE = 1 << 10 |
| 84 | }; |
| 85 | |
| 86 | /*!\brief post process flags |
| 87 | * |
| 88 | * This define a structure that describe the post processing settings. For |
| 89 | * the best objective measure (using the PSNR metric) set post_proc_flag |
| 90 | * to AOM_DEBLOCK and deblocking_level to 1. |
| 91 | */ |
| 92 | |
| 93 | typedef struct aom_postproc_cfg { |
| 94 | /*!\brief the types of post processing to be done, should be combination of |
| 95 | * "aom_postproc_level" */ |
| 96 | int post_proc_flag; |
| 97 | int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */ |
| 98 | int noise_level; /**< the strength of additive noise, valid range [0, 16] */ |
| 99 | } aom_postproc_cfg_t; |
| 100 | |
| 101 | /*!\brief reference frame type |
| 102 | * |
| 103 | * The set of macros define the type of AOM reference frames |
| 104 | */ |
| 105 | typedef enum aom_ref_frame_type { |
| 106 | AOM_LAST_FRAME = 1, |
| 107 | AOM_GOLD_FRAME = 2, |
| 108 | AOM_ALTR_FRAME = 4 |
| 109 | } aom_ref_frame_type_t; |
| 110 | |
| 111 | /*!\brief reference frame data struct |
| 112 | * |
| 113 | * Define the data struct to access aom reference frames. |
| 114 | */ |
| 115 | typedef struct aom_ref_frame { |
| 116 | aom_ref_frame_type_t frame_type; /**< which reference frame */ |
| 117 | aom_image_t img; /**< reference frame data in image format */ |
| 118 | } aom_ref_frame_t; |
| 119 | |
| 120 | /*!\brief AV1 specific reference frame data struct |
| 121 | * |
| 122 | * Define the data struct to access av1 reference frames. |
| 123 | */ |
| 124 | typedef struct av1_ref_frame { |
| 125 | int idx; /**< frame index to get (input) */ |
| 126 | aom_image_t img; /**< img structure to populate (output) */ |
| 127 | } av1_ref_frame_t; |
| 128 | |
| 129 | /*!\cond */ |
| 130 | /*!\brief aom decoder control function parameter type |
| 131 | * |
| 132 | * defines the data type for each of AOM decoder control function requires |
| 133 | */ |
| 134 | AOM_CTRL_USE_TYPE(AOM_SET_REFERENCE, aom_ref_frame_t *) |
| 135 | #define AOM_CTRL_AOM_SET_REFERENCE |
| 136 | AOM_CTRL_USE_TYPE(AOM_COPY_REFERENCE, aom_ref_frame_t *) |
| 137 | #define AOM_CTRL_AOM_COPY_REFERENCE |
| 138 | AOM_CTRL_USE_TYPE(AOM_SET_POSTPROC, aom_postproc_cfg_t *) |
| 139 | #define AOM_CTRL_AOM_SET_POSTPROC |
| 140 | AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_REF_FRAME, int) |
| 141 | #define AOM_CTRL_AOM_SET_DBG_COLOR_REF_FRAME |
| 142 | AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_MB_MODES, int) |
| 143 | #define AOM_CTRL_AOM_SET_DBG_COLOR_MB_MODES |
| 144 | AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_B_MODES, int) |
| 145 | #define AOM_CTRL_AOM_SET_DBG_COLOR_B_MODES |
| 146 | AOM_CTRL_USE_TYPE(AOM_SET_DBG_DISPLAY_MV, int) |
| 147 | #define AOM_CTRL_AOM_SET_DBG_DISPLAY_MV |
| 148 | AOM_CTRL_USE_TYPE(AV1_GET_REFERENCE, av1_ref_frame_t *) |
| 149 | #define AOM_CTRL_AV1_GET_REFERENCE |
| 150 | AOM_CTRL_USE_TYPE(AV1_GET_NEW_FRAME_IMAGE, aom_image_t *) |
| 151 | #define AOM_CTRL_AV1_GET_NEW_FRAME_IMAGE |
| 152 | |
| 153 | /*!\endcond */ |
| 154 | /*! @} - end defgroup aom */ |
| 155 | |
| 156 | #ifdef __cplusplus |
| 157 | } // extern "C" |
| 158 | #endif |
| 159 | |
| 160 | #endif // AOM_AOM_H_ |