Banuba SDK
conversion.hpp
1 #pragma once
2 
3 #include <bnb/types/full_image.hpp>
4 #include <bnb/utils/stdrestrict.hpp>
5 #include <functional>
6 
7 namespace bnb
8 {
9  using memory_deletter = std::function<void()>;
10 
11  full_image_t make_full_image_from_rgb_planes(
12  // clang-format off
13  const image_format& image_format,
14  const uint8_t* r_buffer, uint32_t r_row_stride, uint32_t r_pixel_stride,
15  const uint8_t* g_buffer, uint32_t g_row_stride, uint32_t g_pixel_stride,
16  const uint8_t* b_buffer, uint32_t b_row_stride, uint32_t b_pixel_stride
17  // clang-format on
18  );
19 
20  full_image_t make_full_image_from_nonplanar_bpc8_no_copy(
21  const image_format& image_format,
22  const bpc8_image_t::pixel_format_t pixel_format,
23  uint8_t* buffer,
24  uint32_t row_stride,
25  memory_deletter free_memory
26  );
27 
28  full_image_t make_full_image_from_yuv_planes(
29  // clang-format off
30  const image_format& image_format,
31  const std::vector<uint8_t>& y_buffer, uint32_t y_row_stride, uint32_t y_pixel_stride,
32  const std::vector<uint8_t>& u_buffer, uint32_t u_row_stride, uint32_t u_pixel_stride,
33  const std::vector<uint8_t>& v_buffer, uint32_t v_row_stride, uint32_t v_pixel_stride,
34  const yuv_format_t& yuv_format
35  // clang-format on
36  );
37 
38  full_image_t make_full_image_from_yuv_planes(
39  // clang-format off
40  const image_format& image_format,
41  const uint8_t* restrict y_buffer, uint32_t y_row_stride, uint32_t y_pixel_stride,
42  const uint8_t* u_buffer, uint32_t u_row_stride, uint32_t u_pixel_stride,
43  const uint8_t* v_buffer, uint32_t v_row_stride, uint32_t v_pixel_stride,
44  const yuv_format_t& yuv_format
45  // clang-format on
46  );
47 
48  full_image_t make_full_image_from_biplanar_yuv(
49  // clang-format off
50  const image_format& image_format,
51  const std::vector<uint8_t>& lumo_buffer, uint32_t lumo_row_stride,
52  const std::vector<uint8_t>& chromo_buffer, uint32_t chromo_row_stride,
53  const yuv_format_t& yuv_format
54  // clang-format on
55  );
56 
57  full_image_t make_full_image_from_biplanar_yuv(
58  // clang-format off
59  const image_format& image_format,
60  const uint8_t* restrict lumo_buffer, uint32_t lumo_row_stride,
61  const uint8_t* restrict chromo_buffer, uint32_t chromo_row_stride,
62  const yuv_format_t& yuv_format
63  // clang-format on
64  );
65 
66  full_image_t make_full_image_from_biplanar_yuv_no_copy(
67  // clang-format off
68  const image_format& image_format,
69  uint8_t* restrict lumo_buffer, uint32_t lumo_row_stride, memory_deletter free_lumo,
70  uint8_t* restrict chromo_buffer, uint32_t chromo_row_stride, memory_deletter free_chromo,
71  const yuv_format_t& yuv_format
72  // clang-format on
73  );
74 
75  full_image_t make_full_image_from_yuv_planes_no_copy(
76  // clang-format off
77  const image_format& image_format,
78  uint8_t* restrict lumo_buffer, uint32_t lumo_row_stride,
79  uint32_t lumo_pixel_stride, memory_deletter free_lumo,
80  uint8_t* restrict chromo_1_buffer, uint32_t chromo_1_row_stride, uint32_t chromo_1_pixel_stride,
81  uint8_t* restrict chromo_2_buffer, uint32_t chromo_2_row_stride, uint32_t chromo_2_pixel_stride,
82  memory_deletter free_chromo_1, memory_deletter free_chromo_2,
83  const yuv_format_t& yuv_format
84  // clang-format on
85  );
86 
87  color_plane convert_bpc8_to_y_plane(
88  const bpc8_image_t& image, uint32_t width, uint32_t height
89  );
90 
91  color_plane convert_bpc8_to_uv_plane(
92  const bpc8_image_t& image, uint32_t width, uint32_t height, bool legacy_yuv = true
93  );
94 
95  full_image_t convert_image_to_yuv(full_image_t input_image, bool legacy_yuv = true);
96 
97  color_plane convert_bgr_to_y_plane(unsigned char const* image, uint32_t width, uint32_t height);
98 
99  color_plane convert_bgr_to_uv_plane(unsigned char const* image, uint32_t width, uint32_t height);
100 } // namespace bnb
bnb::yuv_format
yuv_format
Enum class represents supported yuv formats.
Definition: full_image.hpp:291