diff --git a/post_processing_stages/post_processing_stage.cpp b/post_processing_stages/post_processing_stage.cpp index 3bab5ad8..d0014bf4 100644 --- a/post_processing_stages/post_processing_stage.cpp +++ b/post_processing_stages/post_processing_stage.cpp @@ -44,7 +44,12 @@ void PostProcessingStage::Teardown() std::vector PostProcessingStage::Yuv420ToRgb(const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info) { std::vector output(dst_info.height * dst_info.stride); + Yuv420ToRgb(output.data(), src, src_info, dst_info); + return output; +} +void PostProcessingStage::Yuv420ToRgb(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info) +{ assert(src_info.width >= dst_info.width && src_info.height >= dst_info.height); int off_x = ((src_info.width - dst_info.width) / 2) & ~1, off_y = ((src_info.height - dst_info.height) / 2) & ~1; int src_Y_size = src_info.height * src_info.stride, src_U_size = (src_info.height / 2) * (src_info.stride / 2); @@ -59,7 +64,7 @@ std::vector PostProcessingStage::Yuv420ToRgb(const uint8_t *src, Stream const uint8_t *src_U = src + src_Y_size + ((y + off_y) / 2) * (src_info.stride / 2) + off_x / 2; const uint8_t *src_V = src_U + src_U_size; const uint8_t *src_Y1 = src_Y0 + src_info.stride; - uint8_t *dst0 = &output[y * dst_info.stride]; + uint8_t *dst0 = &dst[y * dst_info.stride]; uint8_t *dst1 = dst0 + dst_info.stride; unsigned int x = 0; @@ -213,7 +218,7 @@ std::vector PostProcessingStage::Yuv420ToRgb(const uint8_t *src, Stream const uint8_t *src_Y0 = src + (y + off_y) * src_info.stride + off_x; const uint8_t *src_U = src + src_Y_size + ((y + off_y) / 2) * (src_info.stride / 2) + off_x / 2; const uint8_t *src_V = src_U + src_U_size; - uint8_t *dst0 = &output[y * dst_info.stride]; + uint8_t *dst0 = &dst[y * dst_info.stride]; unsigned int x = 0; for (; x < dst_info.width; x++) @@ -240,8 +245,6 @@ std::vector PostProcessingStage::Yuv420ToRgb(const uint8_t *src, Stream *(dst0++) = B0; } } - - return output; } static std::map &stages() diff --git a/post_processing_stages/post_processing_stage.hpp b/post_processing_stages/post_processing_stage.hpp index 687afbec..81071f3d 100644 --- a/post_processing_stages/post_processing_stage.hpp +++ b/post_processing_stages/post_processing_stage.hpp @@ -56,6 +56,7 @@ class PostProcessingStage // Convert YUV420 image to RGB. We crop from the centre of the image if the src // image is larger than the destination. static std::vector Yuv420ToRgb(const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info); + static void Yuv420ToRgb(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info) protected: // Helper to calculate the execution time of any callable object and return it in as a std::chrono::duration.