]> git.sesse.net Git - bmusb/commitdiff
Fix v4l2proxy when stride != width * 2.
authorSteinar H. Gunderson <steinar+naguru@gunderson.no>
Mon, 6 Apr 2020 17:12:28 +0000 (19:12 +0200)
committerBigscreen user <sesse@bigscreen.party.solskogen.no>
Mon, 6 Apr 2020 17:16:02 +0000 (19:16 +0200)
This is only for cleanness, since stride == width * 2 for all 8-bit
modes that we know of. Also fixes an overrun for non-SSE2.

v4l2proxy.cpp

index 3cb3bc0af137c197aee90bfd473f830e03c338aa..4e0b36b3d1b40da41fbe07d10afc3abb67613ce1 100644 (file)
@@ -69,7 +69,7 @@ void frame_callback(uint16_t timecode,
                uint8_t *origptr = video_frame.data + video_offset + video_format.extra_lines_top * video_format.stride;
 #if __SSE2__
                __m128i *ptr = (__m128i *)origptr;
-               for (unsigned i = 0; i < video_format.width * video_format.height / 8; ++i) {
+               for (unsigned i = 0; i < video_format.stride * video_format.height / 16; ++i) {
                        __m128i val = _mm_loadu_si128(ptr);
                        val = _mm_slli_epi16(val, 8) | _mm_srli_epi16(val, 8);
                        _mm_storeu_si128(ptr, val);
@@ -77,7 +77,7 @@ void frame_callback(uint16_t timecode,
                }
 #else
                uint8_t *ptr = origptr;
-               for (unsigned i = 0; i < video_format.width * video_format.height; ++i) {
+               for (unsigned i = 0; i < video_format.stride * video_format.height / 4; ++i) {
                        swap(ptr[0], ptr[1]);
                        swap(ptr[2], ptr[3]);
                        ptr += 4;