]> git.sesse.net Git - nageru/blobdiff - nageru/decklink_capture.cpp
Fix some overly repetitive code in PBOFrameAllocator.
[nageru] / nageru / decklink_capture.cpp
index 881e1817b1b7262f295584ac24e7f6d80fd1b65e..a09aefaaec14661bafcc3bedc5555d054fe19038 100644 (file)
@@ -21,7 +21,7 @@
 #include "bmusb/bmusb.h"
 #include "decklink_util.h"
 #include "flags.h"
-#include "memcpy_interleaved.h"
+#include "shared/memcpy_interleaved.h"
 #include "v210_converter.h"
 
 #define FRAME_SIZE (8 << 20)  // 8 MB.
@@ -254,16 +254,19 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 
                current_video_frame = video_frame_allocator->alloc_frame();
                if (current_video_frame.data != nullptr) {
-                       const uint8_t *frame_bytes;
-                       video_frame->GetBytes((void **)&frame_bytes);
+                       const uint8_t *src;
+                       video_frame->GetBytes((void **)&src);
                        size_t num_bytes = stride * height;
 
                        if (current_video_frame.interleaved) {
                                uint8_t *data = current_video_frame.data;
                                uint8_t *data2 = current_video_frame.data2;
-                               memcpy_interleaved(data, data2, frame_bytes, num_bytes);
+                               memcpy_interleaved(data, data2, src, num_bytes);
                        } else {
-                               memcpy(current_video_frame.data, frame_bytes, num_bytes);
+                               memcpy(current_video_frame.data, src, num_bytes);
+                       }
+                       if (current_video_frame.data_copy != nullptr) {
+                               memcpy(current_video_frame.data_copy, src, num_bytes);
                        }
                        current_video_frame.len += num_bytes;
 
@@ -278,11 +281,11 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 
                current_audio_frame = audio_frame_allocator->alloc_frame();
                if (current_audio_frame.data != nullptr) {
-                       const uint8_t *frame_bytes;
-                       audio_frame->GetBytes((void **)&frame_bytes);
+                       const uint8_t *src;
+                       audio_frame->GetBytes((void **)&src);
                        current_audio_frame.len = sizeof(int32_t) * 2 * num_samples;
 
-                       memcpy(current_audio_frame.data, frame_bytes, current_audio_frame.len);
+                       memcpy(current_audio_frame.data, src, current_audio_frame.len);
 
                        audio_format.bits_per_sample = 32;
                        audio_format.num_channels = 2;