]> git.sesse.net Git - nageru/blobdiff - decklink_capture.cpp
Set num_levels correctly on the input format.
[nageru] / decklink_capture.cpp
index a0e890fcbcdd4fdc7c8bbb55e8212e8039980192..21a4e791a747459ed1a4dee6d81cbc5ced55a680 100644 (file)
@@ -335,31 +335,33 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
                if (current_video_frame.data != nullptr) {
                        const uint8_t *frame_bytes;
                        video_frame->GetBytes((void **)&frame_bytes);
+                       size_t num_bytes = stride * height;
 
-                       uint8_t *data = current_video_frame.data;
-                       uint8_t *data2 = current_video_frame.data2;
-                       size_t num_bytes = width * height * 2;
+                       if (current_video_frame.interleaved) {
+                               uint8_t *data = current_video_frame.data;
+                               uint8_t *data2 = current_video_frame.data2;
 #ifdef __SSE2__
-                       size_t consumed = memcpy_interleaved_fastpath(data, data2, frame_bytes, num_bytes);
-                       frame_bytes += consumed;
-                       data += consumed / 2;
-                       data2 += consumed / 2;
-                       if (num_bytes % 2) {
-                               swap(data, data2);
-                       }
-                       current_video_frame.len += consumed;
-                       num_bytes -= consumed;
+                               size_t consumed = memcpy_interleaved_fastpath(data, data2, frame_bytes, num_bytes);
+                               frame_bytes += consumed;
+                               data += consumed / 2;
+                               data2 += consumed / 2;
+                               if (num_bytes % 2) {
+                                       swap(data, data2);
+                               }
+                               current_video_frame.len += consumed;
+                               num_bytes -= consumed;
 #endif
 
-                       if (num_bytes > 0) {
-                               memcpy_interleaved(data, data2, frame_bytes, num_bytes);
+                               if (num_bytes > 0) {
+                                       memcpy_interleaved(data, data2, frame_bytes, num_bytes);
+                               }
+                       } else {
+                               memcpy(current_video_frame.data, frame_bytes, num_bytes);
                        }
                        current_video_frame.len += num_bytes;
 
                        video_format.width = width;
                        video_format.height = height;
-
-                       current_video_frame.received_timestamp = now;
                }
        }
 
@@ -376,11 +378,12 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 
                        audio_format.bits_per_sample = 32;
                        audio_format.num_channels = 2;
-
-                       current_audio_frame.received_timestamp = now;
                }
        }
 
+       current_video_frame.received_timestamp = now;
+       current_audio_frame.received_timestamp = now;
+
        if (current_video_frame.data != nullptr || current_audio_frame.data != nullptr) {
                // TODO: Put into a queue and put into a dequeue thread, if the
                // BlackMagic drivers don't already do that for us?