scale.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright 2011 The LibYuv Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef INCLUDE_LIBYUV_SCALE_H_
  11. #define INCLUDE_LIBYUV_SCALE_H_
  12. #include "libyuv/basic_types.h"
  13. #ifdef __cplusplus
  14. namespace libyuv {
  15. extern "C" {
  16. #endif
  17. // Supported filtering.
  18. typedef enum FilterMode {
  19. kFilterNone = 0, // Point sample; Fastest.
  20. kFilterLinear = 1, // Filter horizontally only.
  21. kFilterBilinear = 2, // Faster than box, but lower quality scaling down.
  22. kFilterBox = 3 // Highest quality.
  23. } FilterModeEnum;
  24. // Scale a YUV plane.
  25. LIBYUV_API
  26. void ScalePlane(const uint8_t* src,
  27. int src_stride,
  28. int src_width,
  29. int src_height,
  30. uint8_t* dst,
  31. int dst_stride,
  32. int dst_width,
  33. int dst_height,
  34. enum FilterMode filtering);
  35. LIBYUV_API
  36. void ScalePlane_16(const uint16_t* src,
  37. int src_stride,
  38. int src_width,
  39. int src_height,
  40. uint16_t* dst,
  41. int dst_stride,
  42. int dst_width,
  43. int dst_height,
  44. enum FilterMode filtering);
  45. // Scales a YUV 4:2:0 image from the src width and height to the
  46. // dst width and height.
  47. // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
  48. // used. This produces basic (blocky) quality at the fastest speed.
  49. // If filtering is kFilterBilinear, interpolation is used to produce a better
  50. // quality image, at the expense of speed.
  51. // If filtering is kFilterBox, averaging is used to produce ever better
  52. // quality image, at further expense of speed.
  53. // Returns 0 if successful.
  54. LIBYUV_API
  55. int I420Scale(const uint8_t* src_y,
  56. int src_stride_y,
  57. const uint8_t* src_u,
  58. int src_stride_u,
  59. const uint8_t* src_v,
  60. int src_stride_v,
  61. int src_width,
  62. int src_height,
  63. uint8_t* dst_y,
  64. int dst_stride_y,
  65. uint8_t* dst_u,
  66. int dst_stride_u,
  67. uint8_t* dst_v,
  68. int dst_stride_v,
  69. int dst_width,
  70. int dst_height,
  71. enum FilterMode filtering);
  72. LIBYUV_API
  73. int I420Scale_16(const uint16_t* src_y,
  74. int src_stride_y,
  75. const uint16_t* src_u,
  76. int src_stride_u,
  77. const uint16_t* src_v,
  78. int src_stride_v,
  79. int src_width,
  80. int src_height,
  81. uint16_t* dst_y,
  82. int dst_stride_y,
  83. uint16_t* dst_u,
  84. int dst_stride_u,
  85. uint16_t* dst_v,
  86. int dst_stride_v,
  87. int dst_width,
  88. int dst_height,
  89. enum FilterMode filtering);
  90. // Scales a YUV 4:4:4 image from the src width and height to the
  91. // dst width and height.
  92. // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
  93. // used. This produces basic (blocky) quality at the fastest speed.
  94. // If filtering is kFilterBilinear, interpolation is used to produce a better
  95. // quality image, at the expense of speed.
  96. // If filtering is kFilterBox, averaging is used to produce ever better
  97. // quality image, at further expense of speed.
  98. // Returns 0 if successful.
  99. LIBYUV_API
  100. int I444Scale(const uint8_t* src_y,
  101. int src_stride_y,
  102. const uint8_t* src_u,
  103. int src_stride_u,
  104. const uint8_t* src_v,
  105. int src_stride_v,
  106. int src_width,
  107. int src_height,
  108. uint8_t* dst_y,
  109. int dst_stride_y,
  110. uint8_t* dst_u,
  111. int dst_stride_u,
  112. uint8_t* dst_v,
  113. int dst_stride_v,
  114. int dst_width,
  115. int dst_height,
  116. enum FilterMode filtering);
  117. LIBYUV_API
  118. int I444Scale_16(const uint16_t* src_y,
  119. int src_stride_y,
  120. const uint16_t* src_u,
  121. int src_stride_u,
  122. const uint16_t* src_v,
  123. int src_stride_v,
  124. int src_width,
  125. int src_height,
  126. uint16_t* dst_y,
  127. int dst_stride_y,
  128. uint16_t* dst_u,
  129. int dst_stride_u,
  130. uint16_t* dst_v,
  131. int dst_stride_v,
  132. int dst_width,
  133. int dst_height,
  134. enum FilterMode filtering);
  135. #ifdef __cplusplus
  136. // Legacy API. Deprecated.
  137. LIBYUV_API
  138. int Scale(const uint8_t* src_y,
  139. const uint8_t* src_u,
  140. const uint8_t* src_v,
  141. int src_stride_y,
  142. int src_stride_u,
  143. int src_stride_v,
  144. int src_width,
  145. int src_height,
  146. uint8_t* dst_y,
  147. uint8_t* dst_u,
  148. uint8_t* dst_v,
  149. int dst_stride_y,
  150. int dst_stride_u,
  151. int dst_stride_v,
  152. int dst_width,
  153. int dst_height,
  154. LIBYUV_BOOL interpolate);
  155. // For testing, allow disabling of specialized scalers.
  156. LIBYUV_API
  157. void SetUseReferenceImpl(LIBYUV_BOOL use);
  158. #endif // __cplusplus
  159. #ifdef __cplusplus
  160. } // extern "C"
  161. } // namespace libyuv
  162. #endif
  163. #endif // INCLUDE_LIBYUV_SCALE_H_