#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 <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::placeholders;
+using namespace bmusb;
namespace {
memcpy_interleaved(dest1, dest2, src, n2);
dest1 += n2 / 2;
dest2 += n2 / 2;
- if (n2 % 1) {
+ if (n2 % 2) {
swap(dest1, dest2);
}
src = aligned_src;
assert(((limit - src) % 64) == 0);
#if __AVX2__
- const __restrict __m256i *in = (const __m256i *)src;
- __restrict __m256i *out1 = (__m256i *)dest1;
- __restrict __m256i *out2 = (__m256i *)dest2;
+ const __m256i * __restrict in = (const __m256i *)src;
+ __m256i * __restrict out1 = (__m256i *)dest1;
+ __m256i * __restrict out2 = (__m256i *)dest2;
__m256i shuffle_cw = _mm256_set_epi8(
15, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2, 0,
consumed += 64;
}
#else
- const __restrict __m128i *in = (const __m128i *)src;
- __restrict __m128i *out1 = (__m128i *)dest1;
- __restrict __m128i *out2 = (__m128i *)dest2;
+ const __m128i * __restrict in = (const __m128i *)src;
+ __m128i * __restrict out1 = (__m128i *)dest1;
+ __m128i * __restrict out2 = (__m128i *)dest2;
__m128i mask_lower_byte = _mm_set1_epi16(0x00ff);
while (in < (const __m128i *)limit) {
} // namespace
DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
- : card_index(card_index)
+ : card_index(card_index), card(card)
{
{
const char *model_name;
char buf[256];
if (card->GetModelName(&model_name) == S_OK) {
- snprintf(buf, sizeof(buf), "Card %d: %s", card_index, model_name);
+ snprintf(buf, sizeof(buf), "PCI card %d: %s", card_index, model_name);
} else {
- snprintf(buf, sizeof(buf), "Card %d: Unknown DeckLink card", card_index);
+ snprintf(buf, sizeof(buf), "PCI card %d: Unknown DeckLink card", card_index);
}
description = buf;
}
if (has_dequeue_callbacks) {
dequeue_cleanup_callback();
}
+ input->Release();
+ config->Release();
+ card->Release();
}
HRESULT STDMETHODCALLTYPE DeckLinkCapture::QueryInterface(REFIID, LPVOID *)
void DeckLinkCapture::configure_card()
{
if (video_frame_allocator == nullptr) {
- set_video_frame_allocator(new MallocFrameAllocator(FRAME_SIZE, NUM_QUEUED_VIDEO_FRAMES)); // FIXME: leak.
+ owned_video_frame_allocator.reset(new MallocFrameAllocator(FRAME_SIZE, NUM_QUEUED_VIDEO_FRAMES));
+ set_video_frame_allocator(owned_video_frame_allocator.get());
}
if (audio_frame_allocator == nullptr) {
- set_audio_frame_allocator(new MallocFrameAllocator(65536, NUM_QUEUED_AUDIO_FRAMES)); // FIXME: leak.
+ owned_audio_frame_allocator.reset(new MallocFrameAllocator(65536, NUM_QUEUED_AUDIO_FRAMES));
+ set_audio_frame_allocator(owned_audio_frame_allocator.get());
}
}