vp9_alt_ref_aq.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file in the root of the source tree. An additional
  6. * intellectual property rights grant can be found in the file PATENTS.
  7. * All contributing project authors may be found in the AUTHORS file in
  8. * the root of the source tree.
  9. */
  10. /*
  11. * \file vp9_alt_ref_aq.h
  12. *
  13. * This file contains public interface for setting up adaptive segmentation
  14. * for altref frames. Go to alt_ref_aq_private.h for implmentation details.
  15. */
  16. #ifndef VP9_ENCODER_VP9_ALT_REF_AQ_H_
  17. #define VP9_ENCODER_VP9_ALT_REF_AQ_H_
  18. #include "vpx/vpx_integer.h"
  19. // Where to disable segmentation
  20. #define ALT_REF_AQ_LOW_BITRATE_BOUNDARY 150
  21. // Last frame always has overall quality = 0,
  22. // so it is questionable if I can process it
  23. #define ALT_REF_AQ_APPLY_TO_LAST_FRAME 1
  24. // If I should try to compare gain
  25. // against segmentation overhead
  26. #define ALT_REF_AQ_PROTECT_GAIN 0
  27. // Threshold to disable segmentation
  28. #define ALT_REF_AQ_PROTECT_GAIN_THRESH 0.5
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. // Simple structure for storing images
  33. struct MATX_8U {
  34. int rows;
  35. int cols;
  36. int stride;
  37. uint8_t *data;
  38. };
  39. struct VP9_COMP;
  40. struct ALT_REF_AQ;
  41. /*!\brief Constructor
  42. *
  43. * \return Instance of the class
  44. */
  45. struct ALT_REF_AQ *vp9_alt_ref_aq_create();
  46. /*!\brief Upload segmentation_map to self object
  47. *
  48. * \param self Instance of the class
  49. * \param segmentation_map Segmentation map to upload
  50. */
  51. void vp9_alt_ref_aq_upload_map(struct ALT_REF_AQ *const self,
  52. const struct MATX_8U *segmentation_map);
  53. /*!\brief Return pointer to the altref segmentation map
  54. *
  55. * \param self Instance of the class
  56. * \param segmentation_overhead Segmentation overhead in bytes
  57. * \param bandwidth Current frame bandwidth in bytes
  58. *
  59. * \return Boolean value to disable segmentation
  60. */
  61. int vp9_alt_ref_aq_disable_if(const struct ALT_REF_AQ *self,
  62. int segmentation_overhead, int bandwidth);
  63. /*!\brief Set number of segments
  64. *
  65. * It is used for delta quantizer computations
  66. * and thus it can be larger than
  67. * maximum value of the segmentation map
  68. *
  69. * \param self Instance of the class
  70. * \param nsegments Maximum number of segments
  71. */
  72. void vp9_alt_ref_aq_set_nsegments(struct ALT_REF_AQ *const self, int nsegments);
  73. /*!\brief Set up LOOKAHEAD_AQ segmentation mode
  74. *
  75. * Set up segmentation mode to LOOKAHEAD_AQ
  76. * (expected future frames prediction
  77. * quality refering to the current frame).
  78. *
  79. * \param self Instance of the class
  80. * \param cpi Encoder context
  81. */
  82. void vp9_alt_ref_aq_setup_mode(struct ALT_REF_AQ *const self,
  83. struct VP9_COMP *const cpi);
  84. /*!\brief Set up LOOKAHEAD_AQ segmentation map and delta quantizers
  85. *
  86. * \param self Instance of the class
  87. * \param cpi Encoder context
  88. */
  89. void vp9_alt_ref_aq_setup_map(struct ALT_REF_AQ *const self,
  90. struct VP9_COMP *const cpi);
  91. /*!\brief Restore main segmentation map mode and reset the class variables
  92. *
  93. * \param self Instance of the class
  94. * \param cpi Encoder context
  95. */
  96. void vp9_alt_ref_aq_unset_all(struct ALT_REF_AQ *const self,
  97. struct VP9_COMP *const cpi);
  98. /*!\brief Destructor
  99. *
  100. * \param self Instance of the class
  101. */
  102. void vp9_alt_ref_aq_destroy(struct ALT_REF_AQ *const self);
  103. #ifdef __cplusplus
  104. } // extern "C"
  105. #endif
  106. #endif // VP9_ENCODER_VP9_ALT_REF_AQ_H_