]> git.sesse.net Git - nageru/blobdiff - decklink_capture.cpp
Wait for frames in render order, not QuickSync order.
[nageru] / decklink_capture.cpp
index 2519caa5ef05034b7ef136d6d769f50b10ba2aca..5e41da436ef71b0920495e38137390661f4b09fb 100644 (file)
@@ -1,25 +1,30 @@
 #include "decklink_capture.h"
 
+#include <DeckLinkAPI.h>
+#include <DeckLinkAPIConfiguration.h>
+#include <DeckLinkAPIDiscovery.h>
+#include <DeckLinkAPIModes.h>
 #include <assert.h>
+#ifdef __SSE2__
+#include <immintrin.h>
+#endif
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <cstddef>
-#ifdef __SSE2__
-#include <immintrin.h>
-#endif
+#include <chrono>
+#include <cstdint>
+#include <utility>
+#include <vector>
 
-#include <DeckLinkAPI.h>
-#include <DeckLinkAPIConfiguration.h>
-#include <DeckLinkAPIDiscovery.h>
-#include <DeckLinkAPIModes.h>
 #include "bmusb/bmusb.h"
 
 #define FRAME_SIZE (8 << 20)  // 8 MB.
 
 using namespace std;
+using namespace std::chrono;
 using namespace std::placeholders;
+using namespace bmusb;
 
 namespace {
 
@@ -58,7 +63,7 @@ size_t memcpy_interleaved_fastpath(uint8_t *dest1, uint8_t *dest2, const uint8_t
                memcpy_interleaved(dest1, dest2, src, n2);
                dest1 += n2 / 2;
                dest2 += n2 / 2;
-               if (n2 % 1) {
+               if (n2 % 2) {
                        swap(dest1, dest2);
                }
                src = aligned_src;
@@ -350,6 +355,8 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 
                        video_format.width = width;
                        video_format.height = height;
+
+                       current_video_frame.received_timestamp = steady_clock::now();
                }
        }
 
@@ -366,6 +373,8 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 
                        audio_format.bits_per_sample = 32;
                        audio_format.num_channels = 2;
+
+                       current_audio_frame.received_timestamp = steady_clock::now();
                }
        }