From 560bf4048854b87f39dbc80fcc1c1cf1488fae93 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 22 Jan 2024 16:47:52 +0100 Subject: [PATCH] dshow: fixed nv12->uyvy chroma convert refers to GH-369 chroma from first row was used for every column \+ use ptrdiff_t vars to fix a warning for narrow type multiplication --- src/video_capture/DirectShowGrabber.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_capture/DirectShowGrabber.cpp b/src/video_capture/DirectShowGrabber.cpp index 074714417d..e616c290a5 100644 --- a/src/video_capture/DirectShowGrabber.cpp +++ b/src/video_capture/DirectShowGrabber.cpp @@ -1229,10 +1229,11 @@ void nv12_to_uyvy(int width, int height, const unsigned char *in, unsigned char *out) { const int uyvy_linesize = vc_get_linesize(width, UYVY); - for (int y = 0; y < height; ++y) { + for (ptrdiff_t y = 0; y < height; ++y) { const unsigned char *src_y = in + width * y; - const unsigned char *src_cbcr = in + width * height; - unsigned char *dst = out + y * uyvy_linesize; + const unsigned char *src_cbcr = + in + (ptrdiff_t) width * height + width * (y / 2); + unsigned char *dst = out + y * uyvy_linesize; OPTIMIZED_FOR(int x = 0; x < width / 2; ++x) {