hardcoded decklink mode fix
This commit is contained in:
@@ -32,6 +32,10 @@ void DeckLinkInNode::configure(const nlohmann::json& params) {
|
||||
spdlog::warn("DeckLink-in: unknown mode '{}', defaulting to 1080i50", mode_str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!open_device()) {
|
||||
spdlog::error("DeckLink-in: failed to open device during configure");
|
||||
}
|
||||
}
|
||||
|
||||
void DeckLinkInNode::on_add_writer(const std::string& port_id, mxlFlowWriter writer) {
|
||||
@@ -43,9 +47,13 @@ void DeckLinkInNode::on_add_writer(const std::string& port_id, mxlFlowWriter wri
|
||||
|
||||
spdlog::info("DeckLink-in: writer added, grain_rate={}/{}", grain_rate_.numerator, grain_rate_.denominator);
|
||||
|
||||
if (!open_device()) {
|
||||
spdlog::error("DeckLink-in: failed to open device");
|
||||
return;
|
||||
if (input_ && !capturing_) {
|
||||
if (input_->StartStreams() != S_OK) {
|
||||
spdlog::error("DeckLink-in: failed to start streams");
|
||||
return;
|
||||
}
|
||||
capturing_ = true;
|
||||
spdlog::info("DeckLink-in: capture started");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,22 +115,37 @@ bool DeckLinkInNode::open_device() {
|
||||
BMDTimeScale scale = 0;
|
||||
mode->GetFrameRate(&duration, &scale);
|
||||
mode->Release();
|
||||
spdlog::info("DeckLink-in: {}x{} @ {}/{} fps", frame_width_, frame_height_, duration, scale);
|
||||
|
||||
is_interlaced_ = (display_mode_ == bmdModeHD1080i50 ||
|
||||
display_mode_ == bmdModeHD1080i5994);
|
||||
|
||||
if (is_interlaced_) {
|
||||
grain_rate_.numerator = static_cast<int32_t>(2 * scale);
|
||||
grain_rate_.denominator = static_cast<int32_t>(duration);
|
||||
} else {
|
||||
grain_rate_.numerator = static_cast<int32_t>(scale);
|
||||
grain_rate_.denominator = static_cast<int32_t>(duration);
|
||||
}
|
||||
|
||||
auto g = std::__gcd(grain_rate_.numerator, grain_rate_.denominator);
|
||||
grain_rate_.numerator /= g;
|
||||
grain_rate_.denominator /= g;
|
||||
|
||||
spdlog::info("DeckLink-in: {}x{} @ {}/{} fps, interlaced={}",
|
||||
frame_width_, frame_height_,
|
||||
grain_rate_.numerator, grain_rate_.denominator,
|
||||
is_interlaced_);
|
||||
}
|
||||
|
||||
if (input_->StartStreams() != S_OK) {
|
||||
spdlog::error("DeckLink-in: failed to start streams");
|
||||
return false;
|
||||
}
|
||||
|
||||
capturing_ = true;
|
||||
spdlog::info("DeckLink-in: capture started");
|
||||
spdlog::info("DeckLink-in: device opened, waiting for writer to start capture");
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeckLinkInNode::close_device() {
|
||||
if (input_) {
|
||||
input_->StopStreams();
|
||||
if (capturing_) {
|
||||
input_->StopStreams();
|
||||
}
|
||||
input_->DisableVideoInput();
|
||||
input_->Release();
|
||||
input_ = nullptr;
|
||||
@@ -199,6 +222,10 @@ nlohmann::json DeckLinkInNode::status() const {
|
||||
{"write_index", write_index_},
|
||||
{"capturing", capturing_.load()},
|
||||
{"has_writer", writer_.has_value()},
|
||||
{"grain_rate", {{"numerator", grain_rate_.numerator}, {"denominator", grain_rate_.denominator}}},
|
||||
{"width", frame_width_},
|
||||
{"height", frame_height_},
|
||||
{"interlaced", is_interlaced_},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
void close_device();
|
||||
|
||||
std::optional<mxlFlowWriter> writer_;
|
||||
mxlRational grain_rate_{50, 1};
|
||||
mxlRational grain_rate_{25, 1};
|
||||
uint64_t write_index_ = 0;
|
||||
uint64_t grains_written_ = 0;
|
||||
|
||||
@@ -51,11 +51,12 @@ private:
|
||||
IDeckLinkInput* input_ = nullptr;
|
||||
|
||||
std::atomic<bool> capturing_{false};
|
||||
bool is_interlaced_ = false;
|
||||
std::mutex frame_mutex_;
|
||||
void* frame_data_ = nullptr;
|
||||
long frame_row_bytes_ = 0;
|
||||
long frame_width_ = 0;
|
||||
long frame_height_ = 0;
|
||||
long frame_width_ = 1920;
|
||||
long frame_height_ = 1080;
|
||||
bool frame_ready_ = false;
|
||||
|
||||
class CaptureCallback : public IDeckLinkInputCallback {
|
||||
|
||||
@@ -201,10 +201,15 @@ void DeckLinkOutNode::process() {
|
||||
mxlFlowConfigInfo config{};
|
||||
mxlFlowReaderGetConfigInfo(*reader_, &config);
|
||||
auto grain_size = grain_info.grainSize;
|
||||
auto height = config.discrete.grainCount > 0 ? 1080 : 1080;
|
||||
auto row_bytes = grain_size / height;
|
||||
|
||||
schedule_frame(payload, 1920, height, row_bytes);
|
||||
long height = 1080;
|
||||
if (config.discrete.sliceSizes[0] > 0) {
|
||||
height = grain_size / config.discrete.sliceSizes[0];
|
||||
}
|
||||
long row_bytes = (config.discrete.sliceSizes[0] > 0) ? static_cast<long>(config.discrete.sliceSizes[0]) : (grain_size / height);
|
||||
long width = (row_bytes * 3) / 8;
|
||||
|
||||
schedule_frame(payload, width, height, row_bytes);
|
||||
|
||||
read_index_ = grain_info.index + 1;
|
||||
grains_read_++;
|
||||
@@ -221,6 +226,7 @@ nlohmann::json DeckLinkOutNode::status() const {
|
||||
{"read_index", read_index_},
|
||||
{"playing", playing_.load()},
|
||||
{"has_reader", reader_.has_value()},
|
||||
{"grain_rate", {{"numerator", grain_rate_.numerator}, {"denominator", grain_rate_.denominator}}},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user