summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0490c42)
This fixes an issue where auto white balance would be completely off if
any signals were remapped out of the default. It means you no longer can
duplicate a signal and have different white balance on it, but that seems
narrow enough that one could use manual white balance for that (I can't
really imagine what the use case would be).
if (fabs(new_frame->neutral_color.r - last_received_neutral_color[card_index].r) > 1e-3 ||
fabs(new_frame->neutral_color.g - last_received_neutral_color[card_index].g) > 1e-3 ||
fabs(new_frame->neutral_color.b - last_received_neutral_color[card_index].b) > 1e-3) {
if (fabs(new_frame->neutral_color.r - last_received_neutral_color[card_index].r) > 1e-3 ||
fabs(new_frame->neutral_color.g - last_received_neutral_color[card_index].g) > 1e-3 ||
fabs(new_frame->neutral_color.b - last_received_neutral_color[card_index].b) > 1e-3) {
- theme->set_wb_for_signal(card_index, new_frame->neutral_color.r, new_frame->neutral_color.g, new_frame->neutral_color.b);
+ theme->set_wb_for_card(card_index, new_frame->neutral_color.r, new_frame->neutral_color.g, new_frame->neutral_color.b);
last_received_neutral_color[card_index] = new_frame->neutral_color;
}
if (new_frame->frame->data_copy != nullptr && mjpeg_encoder->should_encode_mjpeg_for_card(card_index)) {
last_received_neutral_color[card_index] = new_frame->neutral_color;
}
if (new_frame->frame->data_copy != nullptr && mjpeg_encoder->should_encode_mjpeg_for_card(card_index)) {
- RGBTriplet neutral_color = theme->get_white_balance_for_signal(card_index);
+ RGBTriplet neutral_color = theme->get_white_balance_for_card(card_index);
mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset, move(raw_audio[card_index]), neutral_color);
}
mjpeg_encoder->upload_frame(pts_int, card_index, new_frame->frame, new_frame->video_format, new_frame->y_offset, new_frame->cbcr_offset, move(raw_audio[card_index]), neutral_color);
}
-int find_signal_to_connect(lua_State *L, const Block *block)
+int find_card_to_connect(lua_State *L, const Block *block)
- if (block->signal_type_to_connect == Block::CONNECT_SIGNAL) {
- return block->signal_to_connect;
+ if (block->signal_type_to_connect == Block::CONNECT_CARD) {
+ return block->card_to_connect;
#ifdef HAVE_CEF
} else if (block->signal_type_to_connect == Block::CONNECT_CEF) {
return block->cef_to_connect->get_card_index();
#ifdef HAVE_CEF
} else if (block->signal_type_to_connect == Block::CONNECT_CEF) {
return block->cef_to_connect->get_card_index();
// based on the current state of the signals.
InputStateInfo info(input_state);
for (Block *block : blocks) {
// based on the current state of the signals.
InputStateInfo info(input_state);
for (Block *block : blocks) {
- if (block->is_input && block->signal_type_to_connect == Block::CONNECT_SIGNAL) {
+ if (block->is_input && block->signal_type_to_connect == Block::CONNECT_CARD) {
EffectType chosen_type = current_type(block);
assert(chosen_type == LIVE_INPUT_YCBCR || chosen_type == LIVE_INPUT_YCBCR_WITH_DEINTERLACE);
EffectType chosen_type = current_type(block);
assert(chosen_type == LIVE_INPUT_YCBCR || chosen_type == LIVE_INPUT_YCBCR_WITH_DEINTERLACE);
- if (info.last_interlaced[block->signal_to_connect]) {
+ if (info.last_interlaced[block->card_to_connect]) {
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR_WITH_DEINTERLACE);
} else {
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR);
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR_WITH_DEINTERLACE);
} else {
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR);
chosen_type == LIVE_INPUT_YCBCR_WITH_DEINTERLACE ||
chosen_type == LIVE_INPUT_YCBCR_PLANAR ||
chosen_type == LIVE_INPUT_BGRA);
chosen_type == LIVE_INPUT_YCBCR_WITH_DEINTERLACE ||
chosen_type == LIVE_INPUT_YCBCR_PLANAR ||
chosen_type == LIVE_INPUT_BGRA);
- int signal = find_signal_to_connect(L, input);
- RGBTriplet wb = theme->get_white_balance_for_signal(signal);
+ int card_idx = find_card_to_connect(L, input);
+ RGBTriplet wb = theme->get_white_balance_for_card(card_idx);
if (fabs(wb.r - 1.0) < 1e-3 && fabs(wb.g - 1.0) < 1e-3 && fabs(wb.b - 1.0) < 1e-3) {
// Neutral white balance.
block->currently_chosen_alternative = find_index_of(block, IDENTITY_EFFECT);
if (fabs(wb.r - 1.0) < 1e-3 && fabs(wb.g - 1.0) < 1e-3 && fabs(wb.b - 1.0) < 1e-3) {
// Neutral white balance.
block->currently_chosen_alternative = find_index_of(block, IDENTITY_EFFECT);
const Scene::Instantiation &instantiation = chains[chain_idx];
EffectChain *effect_chain = instantiation.chain.get();
const Scene::Instantiation &instantiation = chains[chain_idx];
EffectChain *effect_chain = instantiation.chain.get();
- map<LiveInputWrapper *, int> signals_to_connect;
+ map<LiveInputWrapper *, int> cards_to_connect;
map<ImageInput *, string> images_to_select;
map<pair<Effect *, string>, int> int_to_set;
map<pair<Effect *, string>, float> float_to_set;
map<ImageInput *, string> images_to_select;
map<pair<Effect *, string>, int> int_to_set;
map<pair<Effect *, string>, float> float_to_set;
chosen_type == LIVE_INPUT_YCBCR_PLANAR ||
chosen_type == LIVE_INPUT_BGRA) {
LiveInputWrapper *input = index_and_input.second;
chosen_type == LIVE_INPUT_YCBCR_PLANAR ||
chosen_type == LIVE_INPUT_BGRA) {
LiveInputWrapper *input = index_and_input.second;
- signals_to_connect.emplace(input, find_signal_to_connect(L, block));
+ cards_to_connect.emplace(input, find_card_to_connect(L, block));
}
}
for (const auto &index_and_input : instantiation.image_inputs) {
}
}
for (const auto &index_and_input : instantiation.image_inputs) {
- auto setup_chain = [L, theme, signals_to_connect, images_to_select, int_to_set, float_to_set, vec3_to_set, vec4_to_set, input_state]{
+ auto setup_chain = [L, theme, cards_to_connect, images_to_select, int_to_set, float_to_set, vec3_to_set, vec4_to_set, input_state]{
lock_guard<mutex> lock(theme->m);
lock_guard<mutex> lock(theme->m);
- // Set up state, including connecting signals.
- for (const auto &input_and_signal : signals_to_connect) {
- LiveInputWrapper *input = input_and_signal.first;
- input->connect_signal_raw(input_and_signal.second, input_state);
+ // Set up state, including connecting cards.
+ for (const auto &input_and_card : cards_to_connect) {
+ LiveInputWrapper *input = input_and_card.first;
+ input->connect_card(input_and_card.second, input_state);
}
for (const auto &input_and_filename : images_to_select) {
input_and_filename.first->switch_image(input_and_filename.second);
}
for (const auto &input_and_filename : images_to_select) {
input_and_filename.first->switch_image(input_and_filename.second);
if (lua_isnumber(L, idx)) {
Theme *theme = get_theme_updata(L);
int signal_idx = luaL_checknumber(L, idx);
if (lua_isnumber(L, idx)) {
Theme *theme = get_theme_updata(L);
int signal_idx = luaL_checknumber(L, idx);
- block->signal_type_to_connect = Block::CONNECT_SIGNAL;
- block->signal_to_connect = theme->map_signal_to_card(signal_idx); // FIXME: Assigning a card to something named about signals.
+ block->signal_type_to_connect = Block::CONNECT_CARD;
+ block->card_to_connect = theme->map_signal_to_card(signal_idx);
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR); // Will be changed to deinterlaced at get_chain() time if needed.
return true;
#ifdef HAVE_CEF
block->currently_chosen_alternative = find_index_of(block, LIVE_INPUT_YCBCR); // Will be changed to deinterlaced at get_chain() time if needed.
return true;
#ifdef HAVE_CEF
// For LIVE_INPUT* only. We can't just always populate signal_to_connect,
// since when we set this, CEF and video signals may not have numbers yet.
// FIXME: Perhaps it would be simpler if they just did?
// For LIVE_INPUT* only. We can't just always populate signal_to_connect,
// since when we set this, CEF and video signals may not have numbers yet.
// FIXME: Perhaps it would be simpler if they just did?
- enum { CONNECT_NONE, CONNECT_SIGNAL, CONNECT_CEF, CONNECT_VIDEO } signal_type_to_connect = CONNECT_NONE;
- int signal_to_connect = 0; // For CONNECT_SIGNAL.
+ enum { CONNECT_NONE, CONNECT_CARD, CONNECT_CEF, CONNECT_VIDEO } signal_type_to_connect = CONNECT_NONE;
+ int card_to_connect = 0; // For CONNECT_CARD.
#ifdef HAVE_CEF
CEFCapture *cef_to_connect = nullptr; // For CONNECT_CEF.
#endif
#ifdef HAVE_CEF
CEFCapture *cef_to_connect = nullptr; // For CONNECT_CEF.
#endif
}
int card_idx = theme->map_signal_to_card(signal_num);
}
int card_idx = theme->map_signal_to_card(signal_num);
- connect_signal_raw(card_idx, *theme->input_state);
+ connect_card(card_idx, *theme->input_state);
-void LiveInputWrapper::connect_signal_raw(int card_idx, const InputState &input_state)
+void LiveInputWrapper::connect_card(int card_idx, const InputState &input_state)
{
BufferedFrame first_frame = input_state.buffered_frames[card_idx][0];
if (first_frame.frame == nullptr) {
{
BufferedFrame first_frame = input_state.buffered_frames[card_idx][0];
if (first_frame.frame == nullptr) {
// each FFmpeg or CEF input, so we'll do it here.
if (video_signal_connections.count(effect_chain)) {
for (const VideoSignalConnection &conn : video_signal_connections[effect_chain]) {
// each FFmpeg or CEF input, so we'll do it here.
if (video_signal_connections.count(effect_chain)) {
for (const VideoSignalConnection &conn : video_signal_connections[effect_chain]) {
- conn.wrapper->connect_signal_raw(conn.source->get_card_index(), input_state);
+ conn.wrapper->connect_card(conn.source->get_card_index(), input_state);
}
}
#ifdef HAVE_CEF
if (html_signal_connections.count(effect_chain)) {
for (const CEFSignalConnection &conn : html_signal_connections[effect_chain]) {
}
}
#ifdef HAVE_CEF
if (html_signal_connections.count(effect_chain)) {
for (const CEFSignalConnection &conn : html_signal_connections[effect_chain]) {
- conn.wrapper->connect_signal_raw(conn.source->get_card_index(), input_state);
+ conn.wrapper->connect_card(conn.source->get_card_index(), input_state);
lock_guard<mutex> lock(m);
if (signal != -1) {
lock_guard<mutex> lock(m);
if (signal != -1) {
- white_balance_for_signal[signal] = RGBTriplet{ r, g, b };
+ int card_idx = map_signal_to_card(signal);
+ white_balance_for_card[card_idx] = RGBTriplet{ r, g, b };
}
call_lua_wb_callback(channel, r, g, b);
}
}
call_lua_wb_callback(channel, r, g, b);
}
-void Theme::set_wb_for_signal(int signal, float r, float g, float b)
+void Theme::set_wb_for_card(int card_idx, float r, float g, float b)
{
lock_guard<mutex> lock(m);
{
lock_guard<mutex> lock(m);
- white_balance_for_signal[signal] = RGBTriplet{ r, g, b };
+ white_balance_for_card[card_idx] = RGBTriplet{ r, g, b };
for (const auto &channel_and_signal : channel_signals) {
for (const auto &channel_and_signal : channel_signals) {
- if (channel_and_signal.second == signal) {
+ if (map_signal_to_card(channel_and_signal.second) == card_idx) {
call_lua_wb_callback(channel_and_signal.first, r, g, b);
}
}
call_lua_wb_callback(channel_and_signal.first, r, g, b);
}
}
assert(lua_gettop(L) == 0);
}
assert(lua_gettop(L) == 0);
}
-RGBTriplet Theme::get_white_balance_for_signal(int signal)
+RGBTriplet Theme::get_white_balance_for_card(int card_idx)
- if (white_balance_for_signal.count(signal)) {
- return white_balance_for_signal[signal];
+ if (white_balance_for_card.count(card_idx)) {
+ return white_balance_for_card[card_idx];
} else {
return RGBTriplet{ 1.0, 1.0, 1.0 };
}
} else {
return RGBTriplet{ 1.0, 1.0, 1.0 };
}
int map_channel_to_signal(unsigned channel);
bool get_supports_set_wb(unsigned channel);
void set_wb(unsigned channel, float r, float g, float b);
int map_channel_to_signal(unsigned channel);
bool get_supports_set_wb(unsigned channel);
void set_wb(unsigned channel, float r, float g, float b);
- void set_wb_for_signal(int signal, float r, float g, float b);
- movit::RGBTriplet get_white_balance_for_signal(int signal);
+ void set_wb_for_card(int card_idx, float r, float g, float b);
+ movit::RGBTriplet get_white_balance_for_card(int card_idx);
std::string get_channel_color(unsigned channel);
std::string get_channel_color(unsigned channel);
- std::unordered_map<int, movit::RGBTriplet> white_balance_for_signal;
+ std::unordered_map<int, movit::RGBTriplet> white_balance_for_card;
std::vector<std::string> get_transition_names(float t);
std::vector<std::string> get_transition_names(float t);
LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace, bool user_connectable);
bool connect_signal(int signal_num); // Must be called with the theme's <m> lock held, since it accesses theme->input_state. Returns false on error.
LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bmusb::PixelFormat pixel_format, bool override_bounce, bool deinterlace, bool user_connectable);
bool connect_signal(int signal_num); // Must be called with the theme's <m> lock held, since it accesses theme->input_state. Returns false on error.
- void connect_signal_raw(int signal_num, const InputState &input_state);
+ void connect_card(int signal_num, const InputState &input_state);
movit::Effect *get_effect() const
{
if (deinterlace) {
movit::Effect *get_effect() const
{
if (deinterlace) {