Decklink in #4
@@ -142,16 +142,20 @@ private:
|
|||||||
IDeckLinkAudioInputPacket* /*audio_packet*/) override
|
IDeckLinkAudioInputPacket* /*audio_packet*/) override
|
||||||
{
|
{
|
||||||
if (!video_frame) return S_OK;
|
if (!video_frame) return S_OK;
|
||||||
|
|
||||||
|
IDeckLinkVideoBuffer* buf = nullptr;
|
||||||
|
if (video_frame->QueryInterface(IID_IDeckLinkVideoBuffer, (void**)&buf) != S_OK)
|
||||||
|
return S_OK;
|
||||||
|
buf->StartAccess(bmdBufferAccessRead);
|
||||||
void* src = nullptr;
|
void* src = nullptr;
|
||||||
video_frame->GetBytes(&src);
|
buf->GetBytes(&src);
|
||||||
if (!src) return S_OK;
|
|
||||||
|
|
||||||
const uint32_t row_bytes = static_cast<uint32_t>(video_frame->GetRowBytes());
|
if (src) {
|
||||||
const int fw = static_cast<int>(video_frame->GetWidth());
|
const uint32_t row_bytes = static_cast<uint32_t>(video_frame->GetRowBytes());
|
||||||
const int fh = static_cast<int>(video_frame->GetHeight());
|
const int fw = static_cast<int>(video_frame->GetWidth());
|
||||||
const size_t sz = static_cast<size_t>(row_bytes) * static_cast<size_t>(fh);
|
const int fh = static_cast<int>(video_frame->GetHeight());
|
||||||
|
const size_t sz = static_cast<size_t>(row_bytes) * static_cast<size_t>(fh);
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lk(owner.mutex);
|
std::lock_guard<std::mutex> lk(owner.mutex);
|
||||||
if (owner.frame_buffer.size() < sz) owner.frame_buffer.resize(sz);
|
if (owner.frame_buffer.size() < sz) owner.frame_buffer.resize(sz);
|
||||||
std::memcpy(owner.frame_buffer.data(), src, sz);
|
std::memcpy(owner.frame_buffer.data(), src, sz);
|
||||||
@@ -160,7 +164,10 @@ private:
|
|||||||
owner.frame_height = fh;
|
owner.frame_height = fh;
|
||||||
owner.frame_ready = true;
|
owner.frame_ready = true;
|
||||||
}
|
}
|
||||||
owner.frame_cv.notify_one();
|
|
||||||
|
buf->EndAccess(bmdBufferAccessRead);
|
||||||
|
buf->Release();
|
||||||
|
if (src) owner.frame_cv.notify_one();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user