Add support for receiving all video types

This commit is contained in:
Naoto Kondo
2020-05-03 08:25:57 +09:00
parent a64a654d8a
commit 002597146e

View File

@@ -105,12 +105,14 @@ PYBIND11_MODULE(NDIlib, m) {
.def_property( .def_property(
"data", "data",
[](const NDIlib_video_frame_v2_t &self) { [](const NDIlib_video_frame_v2_t &self) {
auto buffer_info = int r = self.yres;
py::buffer_info(self.p_data, sizeof(uint8_t), int c = self.xres;
py::format_descriptor<uint8_t>::format(), 3, size_t b1 = self.line_stride_in_bytes;
{self.yres, self.xres, 4}, size_t b2 = c > 0 ? b1 / c : 0;
{sizeof(uint8_t) * self.xres * 4, size_t b3 = sizeof(uint8_t);
sizeof(uint8_t) * 4, sizeof(uint8_t)}); auto buffer_info = py::buffer_info(
self.p_data, b3, py::format_descriptor<uint8_t>::format(), 3,
{r, c, int(b2)}, {b1, b2, b3});
return py::array(buffer_info); return py::array(buffer_info);
}, },
[](NDIlib_video_frame_v2_t &self, const py::array_t<uint8_t> &array) { [](NDIlib_video_frame_v2_t &self, const py::array_t<uint8_t> &array) {