yuv_rgb_std.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // Copyright 2016 Adrien Descamps
  2. // Distributed under BSD 3-Clause License
  3. // Provide optimized functions to convert images from 8bits yuv420 to rgb24 format
  4. // There are a few slightly different variations of the YCbCr color space with different parameters that
  5. // change the conversion matrix.
  6. // The three most common YCbCr color space, defined by BT.601, BT.709 and JPEG standard are implemented here.
  7. // See the respective standards for details
  8. // The matrix values used are derived from http://www.equasys.de/colorconversion.html
  9. // YUV420 is stored as three separate channels, with U and V (Cb and Cr) subsampled by a 2 factor
  10. // For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This
  11. // is suboptimal for image quality, but by far the fastest method.
  12. // For all methods, width and height should be even, if not, the last row/column of the result image won't be affected.
  13. // For sse methods, if the width if not divisible by 32, the last (width%32) pixels of each line won't be affected.
  14. /*#include <stdint.h>*/
  15. #include "yuv_rgb_common.h"
  16. // yuv to rgb, standard c implementation
  17. void yuv420_rgb565_std(
  18. uint32_t width, uint32_t height,
  19. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  20. uint8_t *rgb, uint32_t rgb_stride,
  21. YCbCrType yuv_type);
  22. void yuv420_rgb24_std(
  23. uint32_t width, uint32_t height,
  24. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  25. uint8_t *rgb, uint32_t rgb_stride,
  26. YCbCrType yuv_type);
  27. void yuv420_rgba_std(
  28. uint32_t width, uint32_t height,
  29. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  30. uint8_t *rgb, uint32_t rgb_stride,
  31. YCbCrType yuv_type);
  32. void yuv420_bgra_std(
  33. uint32_t width, uint32_t height,
  34. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  35. uint8_t *rgb, uint32_t rgb_stride,
  36. YCbCrType yuv_type);
  37. void yuv420_argb_std(
  38. uint32_t width, uint32_t height,
  39. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  40. uint8_t *rgb, uint32_t rgb_stride,
  41. YCbCrType yuv_type);
  42. void yuv420_abgr_std(
  43. uint32_t width, uint32_t height,
  44. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  45. uint8_t *rgb, uint32_t rgb_stride,
  46. YCbCrType yuv_type);
  47. void yuv422_rgb565_std(
  48. uint32_t width, uint32_t height,
  49. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  50. uint8_t *rgb, uint32_t rgb_stride,
  51. YCbCrType yuv_type);
  52. void yuv422_rgb24_std(
  53. uint32_t width, uint32_t height,
  54. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  55. uint8_t *rgb, uint32_t rgb_stride,
  56. YCbCrType yuv_type);
  57. void yuv422_rgba_std(
  58. uint32_t width, uint32_t height,
  59. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  60. uint8_t *rgb, uint32_t rgb_stride,
  61. YCbCrType yuv_type);
  62. void yuv422_bgra_std(
  63. uint32_t width, uint32_t height,
  64. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  65. uint8_t *rgb, uint32_t rgb_stride,
  66. YCbCrType yuv_type);
  67. void yuv422_argb_std(
  68. uint32_t width, uint32_t height,
  69. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  70. uint8_t *rgb, uint32_t rgb_stride,
  71. YCbCrType yuv_type);
  72. void yuv422_abgr_std(
  73. uint32_t width, uint32_t height,
  74. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  75. uint8_t *rgb, uint32_t rgb_stride,
  76. YCbCrType yuv_type);
  77. void yuvnv12_rgb565_std(
  78. uint32_t width, uint32_t height,
  79. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  80. uint8_t *rgb, uint32_t rgb_stride,
  81. YCbCrType yuv_type);
  82. void yuvnv12_rgb24_std(
  83. uint32_t width, uint32_t height,
  84. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  85. uint8_t *rgb, uint32_t rgb_stride,
  86. YCbCrType yuv_type);
  87. void yuvnv12_rgba_std(
  88. uint32_t width, uint32_t height,
  89. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  90. uint8_t *rgb, uint32_t rgb_stride,
  91. YCbCrType yuv_type);
  92. void yuvnv12_bgra_std(
  93. uint32_t width, uint32_t height,
  94. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  95. uint8_t *rgb, uint32_t rgb_stride,
  96. YCbCrType yuv_type);
  97. void yuvnv12_argb_std(
  98. uint32_t width, uint32_t height,
  99. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  100. uint8_t *rgb, uint32_t rgb_stride,
  101. YCbCrType yuv_type);
  102. void yuvnv12_abgr_std(
  103. uint32_t width, uint32_t height,
  104. const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  105. uint8_t *rgb, uint32_t rgb_stride,
  106. YCbCrType yuv_type);
  107. void yuvp010_xbgr2101010_std(
  108. uint32_t width, uint32_t height,
  109. const uint16_t *y, const uint16_t *u, const uint16_t *v, uint32_t y_stride, uint32_t uv_stride,
  110. uint8_t *rgb, uint32_t rgb_stride,
  111. YCbCrType yuv_type);
  112. // rgb to yuv, standard c implementation
  113. void rgb24_yuv420_std(
  114. uint32_t width, uint32_t height,
  115. const uint8_t *rgb, uint32_t rgb_stride,
  116. uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
  117. YCbCrType yuv_type);