From 5b65e558cfa4c4762395ecef16d43b52f0358f4a Mon Sep 17 00:00:00 2001 From: marcel303 Date: Thu, 1 Sep 2022 10:35:41 +0100 Subject: [PATCH] vfxgraph-webcam: Compile fix when SSE is not available. --- vfxGraph/vfxNodes/macWebcam.mm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/vfxGraph/vfxNodes/macWebcam.mm b/vfxGraph/vfxNodes/macWebcam.mm index 4b68b01f5..db9e40abf 100644 --- a/vfxGraph/vfxNodes/macWebcam.mm +++ b/vfxGraph/vfxNodes/macWebcam.mm @@ -35,6 +35,12 @@ #import #include +#ifdef __SSE2__ + #define USE_SSE 1 +#else + #define USE_SSE 0 +#endif + @interface MacWebcamImpl : NSObject @property (assign) AVCaptureSession * session; @property (assign) AVCaptureDevice * device; @@ -242,6 +248,8 @@ - (void)shutContext } } +#if USE_SSE == 1 + static __m128i swizzle(const __m128i src) { __m128i srcL = _mm_unpacklo_epi8(src, _mm_setzero_si128()); @@ -256,6 +264,8 @@ static __m128i swizzle(const __m128i src) return _mm_packus_epi16(srcL, srcH); } +#endif + - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection @@ -284,7 +294,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput uint64_t t1 = g_TimerRT.TimeUS_get(); -#if 1 +#if USE_SSE == 1 for (int y = 0; y < sy; ++y) { const uint8_t * __restrict srcPtr = baseAddress + y * bytesPerRow; @@ -383,12 +393,20 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput , pitch(0) , data(nullptr) { +#if USE_SSE == 1 data = (uint8_t*)_mm_malloc(sx * sy * 4, 16); +#else + data = (uint8_t*)malloc(sx * sy * 4); +#endif } MacWebcamImage::~MacWebcamImage() { +#if USE_SSE == 1 _mm_free(data); +#else + free(data); +#endif data = nullptr; }