X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=glwidget.cpp;h=31018d6b95d5436cddc840ab01738b1b30ded18b;hp=43517fa882cc988e9f66ca66996a9b785d18cff3;hb=96cb6414f85e0ef4d660b7bd56267303e80fcd05;hpb=12fc672ab7cb2cd7d2bbad10d1a038395a75941e diff --git a/glwidget.cpp b/glwidget.cpp index 43517fa..31018d6 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -32,6 +32,8 @@ class QMouseEvent; #include #include + +using namespace movit; using namespace std; using namespace std::placeholders; @@ -42,15 +44,15 @@ GLWidget::GLWidget(QWidget *parent) GLWidget::~GLWidget() { - global_mixer->remove_frame_ready_callback(output, this); } -void GLWidget::clean_context() +void GLWidget::shutdown() { if (resource_pool != nullptr) { makeCurrent(); resource_pool->clean_context(); } + global_mixer->remove_frame_ready_callback(output, this); } void GLWidget::initializeGL() @@ -69,9 +71,6 @@ void GLWidget::initializeGL() global_mixer->set_transition_names_updated_callback(output, [this](const vector &names){ emit transition_names_updated(names); }); - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &QWidget::customContextMenuRequested, - bind(&GLWidget::show_live_context_menu, this, _1)); } if (output >= Mixer::OUTPUT_INPUT0) { global_mixer->set_name_updated_callback(output, [this](const string &name){ @@ -80,14 +79,9 @@ void GLWidget::initializeGL() global_mixer->set_color_updated_callback(output, [this](const string &color){ emit color_updated(output, color); }); - - int signal_num = global_mixer->get_channel_signal(output); - if (signal_num != -1) { - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &QWidget::customContextMenuRequested, - bind(&GLWidget::show_preview_context_menu, this, signal_num, _1)); - } } + setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, &QWidget::customContextMenuRequested, bind(&GLWidget::show_context_menu, this, _1)); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); @@ -132,6 +126,17 @@ void GLWidget::mousePressEvent(QMouseEvent *event) emit clicked(); } +void GLWidget::show_context_menu(const QPoint &pos) +{ + if (output == Mixer::OUTPUT_LIVE) { + show_live_context_menu(pos); + } + if (output >= Mixer::OUTPUT_INPUT0) { + int signal_num = global_mixer->get_channel_signal(output); + show_preview_context_menu(signal_num, pos); + } +} + void GLWidget::show_live_context_menu(const QPoint &pos) { QPoint global_pos = mapToGlobal(pos); @@ -182,6 +187,48 @@ void GLWidget::show_preview_context_menu(unsigned signal_num, const QPoint &pos) card_submenu.setTitle("Input source"); menu.addMenu(&card_submenu); + // Note that this setting depends on which card is active. + // TODO: Consider hiding this for BGRA sources. + + QMenu interpretation_submenu; + QActionGroup interpretation_group(&interpretation_submenu); + + YCbCrInterpretation current_interpretation = global_mixer->get_input_ycbcr_interpretation(current_card); + { + QAction *action = new QAction("Auto", &interpretation_group); + action->setCheckable(true); + if (current_interpretation.ycbcr_coefficients_auto) { + action->setChecked(true); + } + action->setData(QList{"interpretation", true, YCBCR_REC_709, false}); + interpretation_submenu.addAction(action); + } + for (YCbCrLumaCoefficients ycbcr_coefficients : { YCBCR_REC_709, YCBCR_REC_601 }) { + for (bool full_range : { false, true }) { + std::string description; + if (ycbcr_coefficients == YCBCR_REC_709) { + description = "Rec. 709 (HD)"; + } else { + description = "Rec. 601 (SD)"; + } + if (full_range) { + description += ", full range (nonstandard)"; + } + QAction *action = new QAction(QString::fromStdString(description), &interpretation_group); + action->setCheckable(true); + if (!current_interpretation.ycbcr_coefficients_auto && + ycbcr_coefficients == current_interpretation.ycbcr_coefficients && + full_range == current_interpretation.full_range) { + action->setChecked(true); + } + action->setData(QList{"interpretation", false, ycbcr_coefficients, full_range}); + interpretation_submenu.addAction(action); + } + } + + interpretation_submenu.setTitle("Input interpretation"); + menu.addMenu(&interpretation_submenu); + // --- The choices in the next few options depend a lot on which card is active --- // Add a submenu for selecting video input, with an action for each input. @@ -305,6 +352,12 @@ void GLWidget::show_preview_context_menu(unsigned signal_num, const QPoint &pos) } else if (selected[0].toString() == "card") { unsigned card_index = selected[1].toUInt(nullptr); global_mixer->set_signal_mapping(signal_num, card_index); + } else if (selected[0].toString() == "interpretation") { + YCbCrInterpretation interpretation; + interpretation.ycbcr_coefficients_auto = selected[1].toBool(); + interpretation.ycbcr_coefficients = YCbCrLumaCoefficients(selected[2].toUInt(nullptr)); + interpretation.full_range = selected[3].toBool(); + global_mixer->set_input_ycbcr_interpretation(current_card, interpretation); } else { assert(false); }