X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=v4l2proxy.cpp;h=4e0b36b3d1b40da41fbe07d10afc3abb67613ce1;hb=7d282bf25e6b11c1e594164cdccb56460a34b42d;hp=2bb40aae484ae2a7f57547bf6aebacc2329ab775;hpb=92bbe6548d1681d7cfae66e1c42f9770f3eec857;p=bmusb diff --git a/v4l2proxy.cpp b/v4l2proxy.cpp index 2bb40aa..4e0b36b 100644 --- a/v4l2proxy.cpp +++ b/v4l2proxy.cpp @@ -18,7 +18,9 @@ #if __SSE2__ #include #endif +#include +using namespace std; using namespace bmusb; BMUSBCapture *usb; @@ -67,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); @@ -75,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;