aom.h 5.3 KB

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