X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fdecklink_capture.cpp;h=e239ec964f6f70d17fc13c24494ead77e7d726b4;hb=HEAD;hp=eefb537cd1b3409d9f51593b1432e9360ff534b4;hpb=3e4002cd9c16df872b4f4fd67816814a3696403a;p=nageru diff --git a/nageru/decklink_capture.cpp b/nageru/decklink_capture.cpp index eefb537..90d86b1 100644 --- a/nageru/decklink_capture.cpp +++ b/nageru/decklink_capture.cpp @@ -1,10 +1,16 @@ #include "decklink_capture.h" +#include "defs.h" #include #include #include #include +#include +#include #include +#include +#include +#include #ifdef __SSE2__ #include #endif @@ -24,8 +30,6 @@ #include "shared/memcpy_interleaved.h" #include "v210_converter.h" -#define FRAME_SIZE (8 << 20) // 8 MB. - using namespace std; using namespace std::chrono; using namespace std::placeholders; @@ -246,13 +250,20 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( const int stride = video_frame->GetRowBytes(); const BMDPixelFormat format = video_frame->GetPixelFormat(); assert(format == pixel_format_to_bmd(current_pixel_format)); - if (global_flags.ten_bit_input) { + if (global_flags.bit_depth > 8) { assert(stride == int(v210Converter::get_v210_stride(width))); } else { assert(stride == width * 2); } - current_video_frame = video_frame_allocator->create_frame(width, height, stride); + if (width * stride > FRAME_SIZE) { + // TODO: If we had an OpenGL context here, calling create_frame() + // would be completely fine. + fprintf(stderr, "Card %u: Captured frame %d x %d (stride %d) would be larger than supported frame size (%d > %d), skipping.\n", + card_index, width, height, stride, width * stride, FRAME_SIZE); + } else { + current_video_frame = video_frame_allocator->create_frame(width, height, stride); + } if (current_video_frame.data != nullptr) { const uint8_t *src; video_frame->GetBytes((void **)&src); @@ -350,14 +361,12 @@ void DeckLinkCapture::stop_dequeue_thread() fprintf(stderr, "StopStreams failed with error 0x%x\n", result); abort(); } - if (input->DisableVideoInput() != S_OK) { - fprintf(stderr, "Failed to disable video input for card %d\n", card_index); - exit(1); - } - if (input->DisableAudioInput() != S_OK) { - fprintf(stderr, "Failed to disable audio input for card %d\n", card_index); - exit(1); - } + + // We could call DisableVideoInput() and DisableAudioInput() here, + // but they seem to be taking a really long time, and we only do this + // during shutdown anyway (except when switching to output mode, + // where DeckLinkOutput does the disabling), so StopStreams() will suffice. + running = false; }