decklink-out: non-blocking frame pool, skip late frames instead of realign, 5 preroll frames
This commit is contained in:
@@ -157,7 +157,7 @@ bool DeckLinkOutNode::open_device() {
|
|||||||
is_interlaced_);
|
is_interlaced_);
|
||||||
}
|
}
|
||||||
|
|
||||||
preroll_frames_ = 3;
|
preroll_frames_ = 5;
|
||||||
for (int i = 0; i < preroll_frames_; ++i) {
|
for (int i = 0; i < preroll_frames_; ++i) {
|
||||||
IDeckLinkMutableVideoFrame* frame = nullptr;
|
IDeckLinkMutableVideoFrame* frame = nullptr;
|
||||||
int32_t out_row_bytes = out_width_ * 16 / 6;
|
int32_t out_row_bytes = out_width_ * 16 / 6;
|
||||||
@@ -239,8 +239,8 @@ void DeckLinkOutNode::schedule_frame(void* mxl_payload, long width, long height,
|
|||||||
|
|
||||||
IDeckLinkMutableVideoFrame* frame = nullptr;
|
IDeckLinkMutableVideoFrame* frame = nullptr;
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(frame_pool_mutex_);
|
std::lock_guard<std::mutex> lock(frame_pool_mutex_);
|
||||||
if (frame_pool_cv_.wait_for(lock, std::chrono::milliseconds(100), [this] { return !frame_pool_.empty(); })) {
|
if (!frame_pool_.empty()) {
|
||||||
frame = frame_pool_.back();
|
frame = frame_pool_.back();
|
||||||
frame_pool_.pop_back();
|
frame_pool_.pop_back();
|
||||||
}
|
}
|
||||||
@@ -295,16 +295,18 @@ void DeckLinkOutNode::process() {
|
|||||||
uint8_t* payload = nullptr;
|
uint8_t* payload = nullptr;
|
||||||
auto status = mxlFlowReaderGetGrain(*reader_, source_index, 5000000ULL, &grain_info, &payload);
|
auto status = mxlFlowReaderGetGrain(*reader_, source_index, 5000000ULL, &grain_info, &payload);
|
||||||
if (status != MXL_STATUS_OK) {
|
if (status != MXL_STATUS_OK) {
|
||||||
if (status == MXL_ERR_OUT_OF_RANGE_TOO_LATE || status == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) {
|
if (status == MXL_ERR_OUT_OF_RANGE_TOO_LATE) {
|
||||||
auto now = mxlGetTime();
|
auto now = mxlGetTime();
|
||||||
auto current_index = mxlTimestampToIndex(&flow_rate_, now);
|
auto current_index = mxlTimestampToIndex(&flow_rate_, now);
|
||||||
spdlog::warn("DeckLink-out: realigned from {} to {}", source_index, current_index - 2);
|
spdlog::warn("DeckLink-out: grain too late, skipping to index {}", current_index - 2);
|
||||||
source_index = current_index - 2;
|
source_index = current_index - 2;
|
||||||
|
|
||||||
status = mxlFlowReaderGetGrain(*reader_, source_index, 5000000ULL, &grain_info, &payload);
|
status = mxlFlowReaderGetGrain(*reader_, source_index, 5000000ULL, &grain_info, &payload);
|
||||||
if (status != MXL_STATUS_OK) {
|
if (status != MXL_STATUS_OK) {
|
||||||
|
grains_read_++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (status == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -320,7 +322,6 @@ void DeckLinkOutNode::process() {
|
|||||||
|
|
||||||
schedule_frame(payload, src_width, src_height, src_row_bytes);
|
schedule_frame(payload, src_width, src_height, src_row_bytes);
|
||||||
|
|
||||||
read_index_ = source_index + 1;
|
|
||||||
grains_read_++;
|
grains_read_++;
|
||||||
|
|
||||||
if (grains_read_ == 1) {
|
if (grains_read_ == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user