blob: 9a95d17efd3ea2b4a004504547ddb6644b2b9a10 [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 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
38extern "C" {
39#endif
40
41/*!\brief Control functions
42 *
43 * The set of macros define the control functions of AOM interface
44 */
45enum aom_com_control_id {
46 /*!\brief pass in an external frame into decoder to be used as reference frame
47 */
Thomas Daede497d1952017-08-08 17:33:06 -070048 AOM_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
Yaowu Xuf883b422016-08-30 14:01:10 -070049 AOM_SET_DBG_COLOR_REF_FRAME =
50 4, /**< set the reference frames to color for each macroblock */
51 AOM_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
52 AOM_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */
53 AOM_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */
54
55 /* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
56 * for its control ids. These should be migrated to something like the
57 * AOM_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
58 */
59 AV1_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
Thomas Daede497d1952017-08-08 17:33:06 -070060 AV1_SET_REFERENCE = 129, /**< write a frame into a reference buffer */
61 AV1_COPY_REFERENCE =
62 130, /**< get a copy of reference frame from the decoder */
Yaowu Xuf883b422016-08-30 14:01:10 -070063 AOM_COMMON_CTRL_ID_MAX,
64
65 AV1_GET_NEW_FRAME_IMAGE = 192, /**< get a pointer to the new frame */
Yunqing Wang20a336d2018-04-25 10:19:53 -070066 AV1_COPY_NEW_FRAME_IMAGE =
67 193, /**< copy the new frame to an external buffer */
Yaowu Xuf883b422016-08-30 14:01:10 -070068
69 AOM_DECODER_CTRL_ID_START = 256
70};
71
72/*!\brief post process flags
73 *
74 * The set of macros define AOM decoder post processing flags
75 */
76enum aom_postproc_level {
77 AOM_NOFILTERING = 0,
78 AOM_DEBLOCK = 1 << 0,
79 AOM_DEMACROBLOCK = 1 << 1,
80 AOM_ADDNOISE = 1 << 2,
81 AOM_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */
82 AOM_DEBUG_TXT_MBLK_MODES =
83 1 << 4, /**< print macro block modes over each macro block */
84 AOM_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */
85 AOM_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */
86 AOM_MFQE = 1 << 10
87};
88
89/*!\brief post process flags
90 *
91 * This define a structure that describe the post processing settings. For
92 * the best objective measure (using the PSNR metric) set post_proc_flag
93 * to AOM_DEBLOCK and deblocking_level to 1.
94 */
95
96typedef struct aom_postproc_cfg {
97 /*!\brief the types of post processing to be done, should be combination of
98 * "aom_postproc_level" */
99 int post_proc_flag;
100 int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
101 int noise_level; /**< the strength of additive noise, valid range [0, 16] */
102} aom_postproc_cfg_t;
103
Yaowu Xuf883b422016-08-30 14:01:10 -0700104/*!\brief AV1 specific reference frame data struct
105 *
106 * Define the data struct to access av1 reference frames.
107 */
108typedef struct av1_ref_frame {
Yunqing Wang4450c762018-04-24 13:49:25 -0700109 int idx; /**< frame index to get (input) */
110 int use_external_ref; /**< Directly use external ref buffer(decoder only) */
111 aom_image_t img; /**< img structure to populate (output) */
Yaowu Xuf883b422016-08-30 14:01:10 -0700112} av1_ref_frame_t;
113
114/*!\cond */
115/*!\brief aom decoder control function parameter type
116 *
117 * defines the data type for each of AOM decoder control function requires
118 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700119AOM_CTRL_USE_TYPE(AOM_SET_POSTPROC, aom_postproc_cfg_t *)
120#define AOM_CTRL_AOM_SET_POSTPROC
121AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_REF_FRAME, int)
122#define AOM_CTRL_AOM_SET_DBG_COLOR_REF_FRAME
123AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_MB_MODES, int)
124#define AOM_CTRL_AOM_SET_DBG_COLOR_MB_MODES
125AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_B_MODES, int)
126#define AOM_CTRL_AOM_SET_DBG_COLOR_B_MODES
127AOM_CTRL_USE_TYPE(AOM_SET_DBG_DISPLAY_MV, int)
128#define AOM_CTRL_AOM_SET_DBG_DISPLAY_MV
129AOM_CTRL_USE_TYPE(AV1_GET_REFERENCE, av1_ref_frame_t *)
130#define AOM_CTRL_AV1_GET_REFERENCE
Thomas Daede497d1952017-08-08 17:33:06 -0700131AOM_CTRL_USE_TYPE(AV1_SET_REFERENCE, av1_ref_frame_t *)
132#define AOM_CTRL_AV1_SET_REFERENCE
133AOM_CTRL_USE_TYPE(AV1_COPY_REFERENCE, av1_ref_frame_t *)
134#define AOM_CTRL_AV1_COPY_REFERENCE
Yaowu Xuf883b422016-08-30 14:01:10 -0700135AOM_CTRL_USE_TYPE(AV1_GET_NEW_FRAME_IMAGE, aom_image_t *)
136#define AOM_CTRL_AV1_GET_NEW_FRAME_IMAGE
Yunqing Wang20a336d2018-04-25 10:19:53 -0700137AOM_CTRL_USE_TYPE(AV1_COPY_NEW_FRAME_IMAGE, aom_image_t *)
138#define AOM_CTRL_AV1_COPY_NEW_FRAME_IMAGE
Yaowu Xuf883b422016-08-30 14:01:10 -0700139
140/*!\endcond */
141/*! @} - end defgroup aom */
142
143#ifdef __cplusplus
144} // extern "C"
145#endif
146
147#endif // AOM_AOM_H_