scale.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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* src,
  27. int src_stride,
  28. int src_width,
  29. int src_height,
  30. uint8* 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* src,
  37. int src_stride,
  38. int src_width,
  39. int src_height,
  40. uint16* 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* src_y,
  56. int src_stride_y,
  57. const uint8* src_u,
  58. int src_stride_u,
  59. const uint8* src_v,
  60. int src_stride_v,
  61. int src_width,
  62. int src_height,
  63. uint8* dst_y,
  64. int dst_stride_y,
  65. uint8* dst_u,
  66. int dst_stride_u,
  67. uint8* 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* src_y,
  74. int src_stride_y,
  75. const uint16* src_u,
  76. int src_stride_u,
  77. const uint16* src_v,
  78. int src_stride_v,
  79. int src_width,
  80. int src_height,
  81. uint16* dst_y,
  82. int dst_stride_y,
  83. uint16* dst_u,
  84. int dst_stride_u,
  85. uint16* dst_v,
  86. int dst_stride_v,
  87. int dst_width,
  88. int dst_height,
  89. enum FilterMode filtering);
  90. #ifdef __cplusplus
  91. // Legacy API. Deprecated.
  92. LIBYUV_API
  93. int Scale(const uint8* src_y,
  94. const uint8* src_u,
  95. const uint8* src_v,
  96. int src_stride_y,
  97. int src_stride_u,
  98. int src_stride_v,
  99. int src_width,
  100. int src_height,
  101. uint8* dst_y,
  102. uint8* dst_u,
  103. uint8* dst_v,
  104. int dst_stride_y,
  105. int dst_stride_u,
  106. int dst_stride_v,
  107. int dst_width,
  108. int dst_height,
  109. LIBYUV_BOOL interpolate);
  110. // Legacy API. Deprecated.
  111. LIBYUV_API
  112. int ScaleOffset(const uint8* src_i420,
  113. int src_width,
  114. int src_height,
  115. uint8* dst_i420,
  116. int dst_width,
  117. int dst_height,
  118. int dst_yoffset,
  119. LIBYUV_BOOL interpolate);
  120. // For testing, allow disabling of specialized scalers.
  121. LIBYUV_API
  122. void SetUseReferenceImpl(LIBYUV_BOOL use);
  123. #endif // __cplusplus
  124. #ifdef __cplusplus
  125. } // extern "C"
  126. } // namespace libyuv
  127. #endif
  128. #endif // INCLUDE_LIBYUV_SCALE_H_