本文整理汇总了C++中mlt::Filter类的典型用法代码示例。如果您正苦于以下问题:C++ Filter类的具体用法?C++ Filter怎么用?C++ Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
Frei0rColoradjWidget::Frei0rColoradjWidget(Mlt::Filter filter, bool setDefaults, QWidget *parent) :
QWidget(parent),
ui(new Ui::Frei0rColoradjWidget),
m_filter(filter)
{
ui->setupUi(this);
ui->keepLumaCheckBox->hide();
m_defaultAction = 0.5;
m_defaultLuma = false;
m_defaultRGB = QColor::fromRgbF(0.5, 0.5, 0.5);
if (setDefaults) {
ui->modeComboBox->setCurrentIndex(2 * m_defaultAction);
ui->keepLumaCheckBox->setChecked(m_defaultLuma);
ui->wheel->setColor(m_defaultRGB);
m_filter.set(kParamAction, m_defaultAction);
m_filter.set(kParamKeepLuma, m_defaultLuma? 1 : 0);
m_filter.set(kParamRed, m_defaultRGB.redF());
m_filter.set(kParamGreen, m_defaultRGB.greenF());
m_filter.set(kParamBlue, m_defaultRGB.blueF());
ui->preset->saveDefaultPreset(m_filter);
} else {
ui->modeComboBox->setCurrentIndex(2 * filter.get_double(kParamAction));
ui->keepLumaCheckBox->setChecked(filter.get_int(kParamKeepLuma));
ui->wheel->setColor(QColor::fromRgbF(filter.get_double(kParamRed),
filter.get_double(kParamGreen),
filter.get_double(kParamBlue)));
}
ui->preset->loadPresets();
m_filter.set(kParamLumaFormula,
(MLT.profile().colorspace() == 709? kLumaFormula709 : kLumaFormula601));
}
示例2: add
void AttachedFiltersModel::add(QmlMetadata* meta)
{
if (!meta->allowMultiple()) {
for (int i = 0; i < m_metaList.count(); i++) {
const QmlMetadata* attachedMeta = m_metaList[i];
if (attachedMeta && meta->uniqueId() == attachedMeta->uniqueId()) {
emit duplicateAddFailed(i);
return;
}
}
}
int insertIndex = -1;
int mltIndex = -1;
Mlt::Filter* filter = new Mlt::Filter(MLT.profile(), meta->mlt_service().toUtf8().constData());
if (filter->is_valid()) {
if (!meta->objectName().isEmpty())
filter->set(kShotcutFilterProperty, meta->objectName().toUtf8().constData());
// Put the filter after the last filter that is greater than or equal
// in sort order.
insertIndex = 0;
for (int i = m_metaList.count() - 1; i >= 0; i--) {
if (!sortIsLess(m_metaList[i], meta)) {
insertIndex = i + 1;
break;
}
}
// Calculate the MLT index for the new filter.
if (m_mltIndexMap.count() == 0) {
mltIndex = m_producer->filter_count();
} else if (insertIndex == 0) {
mltIndex = m_mltIndexMap[0];
} else {
mltIndex = m_mltIndexMap[insertIndex -1] + 1;
}
beginInsertRows(QModelIndex(), insertIndex, insertIndex);
if (MLT.isSeekable())
MLT.pause();
m_event->block();
m_producer->attach(*filter);
m_producer->move_filter(m_producer->filter_count() - 1, mltIndex);
m_event->unblock();
// Adjust MLT index map for indices that just changed.
for (int i = 0; i < m_mltIndexMap.count(); i++) {
if (m_mltIndexMap[i] >= mltIndex) {
m_mltIndexMap[i] = m_mltIndexMap[i] + 1;
}
}
m_mltIndexMap.insert(insertIndex, mltIndex);
m_metaList.insert(insertIndex, meta);
endInsertRows();
emit changed();
}
else qWarning() << "Failed to load filter" << meta->mlt_service();
delete filter;
}
示例3: enableEffects
bool EffectManager::enableEffects(const QList <int> &effectIndexes, bool disable, bool rememberState)
{
int ct = 0;
bool success = false;
Mlt::Filter *filter = m_producer.filter(ct);
while (filter) {
if (effectIndexes.isEmpty() || effectIndexes.contains(filter->get_int("kdenlive_ix"))) {
//m_producer.lock();
if (rememberState) {
if (disable && filter->get_int("disable") == 0) {
filter->set("auto_disable", 1);
filter->set("disable", (int) disable);
} else if (!disable && filter->get_int("auto_disable") == 1) {
filter->set("disable", (char*) NULL);
filter->set("auto_disable", (char*) NULL);
}
} else {
filter->set("disable", (int) disable);
}
success = true;
//m_producer.unlock();
}
delete filter;
ct++;
filter = m_producer.filter(ct);
}
return success;
}
示例4: remove
void AttachedFiltersModel::remove(int row)
{
Mlt::Filter* filter = filterForRow(row);
if (filter && filter->is_valid()) {
beginRemoveRows(QModelIndex(), row, row);
MLT.pause();
m_producer->detach(*filter);
m_rows--;
endRemoveRows();
emit changed();
}
delete filter;
}
示例5: setData
bool AttachedFiltersModel::setData(const QModelIndex& index, const QVariant& , int role)
{
if (role == Qt::CheckStateRole) {
Mlt::Filter* filter = getFilter(index.row());
if (filter && filter->is_valid()) {
filter->set("disable", !filter->get_int("disable"));
emit changed();
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 0));
}
delete filter;
return true;
}
return false;
}
示例6: calculateRows
void AttachedFiltersModel::calculateRows()
{
m_rows =-0;
if (MLT.isPlaylist()) return;
if (m_producer && m_producer->is_valid()) {
int n = m_producer->filter_count();
while (n--) {
Mlt::Filter* filter = m_producer->filter(n);
if (filter && filter->is_valid() && !filter->get_int("_loader"))
m_rows++;
delete filter;
}
}
}
示例7: setData
bool AttachedFiltersModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
if (role == Qt::CheckStateRole) {
Mlt::Filter* filter = filterForRow(index.row());
if (filter && filter->is_valid()) {
double speed = MLT.producer()->get_speed();
MLT.pause();
filter->set("disable", !filter->get_int("disable"));
MLT.play(speed);
emit changed();
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 0));
}
delete filter;
return true;
}
return false;
}
示例8: changed
Mlt::Filter *AttachedFiltersModel::add(const QString& mlt_service, const QString& shotcutName)
{
Mlt::Filter* filter = new Mlt::Filter(MLT.profile(), mlt_service.toUtf8().constData());
if (filter->is_valid()) {
if (!shotcutName.isEmpty())
filter->set("shotcut:filter", shotcutName.toUtf8().constData());
int count = rowCount();
beginInsertRows(QModelIndex(), count, count);
MLT.pause();
m_producer->attach(*filter);
m_rows++;
endInsertRows();
emit changed();
}
else qWarning() << "Failed to load filter" << mlt_service;
return filter;
}
示例9: duplicateFilters
void BinController::duplicateFilters(Mlt::Producer original, Mlt::Producer clone)
{
Mlt::Service clipService(original.get_service());
Mlt::Service dupService(clone.get_service());
//delete original;
//delete clone;
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
// Only duplicate Kdenlive filters, and skip the fade in effects
//fprintf(stderr, "CHKNG FILTER: %s\n", filter->get("kdenlive_id"));
if (filter->is_valid()/* && strcmp(filter->get("kdenlive_id"), "") && strcmp(filter->get("kdenlive_id"), "fadein") && strcmp(filter->get("kdenlive_id"), "fade_from_black")*/) {
// looks like there is no easy way to duplicate a filter,
// so we will create a new one and duplicate its properties
Mlt::Filter *dup = new Mlt::Filter(*original.profile(), filter->get("mlt_service"));
if (dup && dup->is_valid()) {
Mlt::Properties entries(filter->get_properties());
for (int i = 0; i < entries.count(); ++i) {
dup->set(entries.get_name(i), entries.get(i));
}
dupService.attach(*dup);
}
}
ct++;
filter = clipService.filter(ct);
}
}
示例10: data
QVariant AttachedFiltersModel::data(const QModelIndex &index, int role) const
{
if ( !m_producer || !m_producer->is_valid()
|| index.row() >= m_producer->filter_count())
return QVariant();
switch (role ) {
case Qt::DisplayRole: {
QVariant result;
Mlt::Filter* filter = filterForRow(index.row());
if (filter && filter->is_valid()) {
// Relabel by QML UI
QmlMetadata* meta = MAIN.filtersDock()->qmlMetadataForService(filter);
if (meta)
result = meta->name();
// Fallback is raw mlt_service name
else if (filter->get("mlt_service"))
result = QString::fromUtf8(filter->get("mlt_service"));
}
// Relabel for widgets UIs
if (result == "movit.blur" || result == "boxblur")
result = tr("Blur");
else if (result == "movit.lift_gamma_gain" || result == "frei0r.coloradj_RGB")
result = tr("Color Grading");
else if (result == "crop")
result = tr("Crop");
else if (result == "movit.glow" || result == "frei0r.glow")
result = tr("Glow");
else if (result == "movit.mirror" || result == "mirror")
result = tr("Mirror");
else if (result == "webvfx")
result = tr("Overlay HTML");
else if (result == "movit.sharpen" || result == "frei0r.sharpness")
result = tr("Sharpen");
else if (result == "movit.white_balance" || result == "frei0r.colgate")
result = tr("White Balance");
else if (result == "sox" && filter->get("use_peak"))
result = tr("Normalize");
delete filter;
return result;
}
case Qt::CheckStateRole: {
Mlt::Filter* filter = filterForRow(index.row());
QVariant result = Qt::Unchecked;
if (filter && filter->is_valid() && !filter->get_int("disable"))
result = Qt::Checked;
delete filter;
return result;
}
break;
default:
break;
}
return QVariant();
}
示例11: reset
void AttachedFiltersModel::reset(Mlt::Producer* producer)
{
beginResetModel();
m_event.reset();
if (producer && producer->is_valid())
m_producer.reset(new Mlt::Producer(producer));
else if (MLT.isClip())
m_producer.reset(new Mlt::Producer(MLT.producer()));
else
m_producer.reset();
m_metaList.clear();
m_mltIndexMap.clear();
if (m_producer && m_producer->is_valid()) {
Mlt::Event* event = m_producer->listen("service-changed", this, (mlt_listener)AttachedFiltersModel::producerChanged);
m_event.reset(event);
int count = m_producer->filter_count();
for (int i = 0; i < count; i++) {
Mlt::Filter* filter = m_producer->filter(i);
if (filter && filter->is_valid() && !filter->get_int("_loader")) {
QmlMetadata* newMeta = MAIN.filterController()->metadataForService(filter);
int newIndex = m_metaList.count();
for (int j = newIndex - 1; j >= 0; j--) {
const QmlMetadata* prevMeta = m_metaList[j];
if (sortIsLess(prevMeta, newMeta)) {
newIndex = j;
} else {
break;
}
}
m_metaList.insert(newIndex, newMeta);
m_mltIndexMap.insert(newIndex, i);
}
delete filter;
}
}
endResetModel();
emit trackTitleChanged();
emit isProducerSelectedChanged();
emit readyChanged();
}
示例12: indexForRow
int AttachedFiltersModel::indexForRow(int row) const
{
int result = -1;
if (m_producer && m_producer->is_valid()) {
int count = m_producer->filter_count();
int j = 0;
for (int i = 0; i < count; i++) {
Mlt::Filter* filter = m_producer->filter(i);
if (filter && filter->is_valid() && !filter->get_int("_loader")) {
if (j == row) {
result = i;
break;
}
j++;
}
delete filter;
}
}
return result;
}
示例13: f
MovitColorFilter::MovitColorFilter(Mlt::Filter filter, bool setDefaults, QWidget *parent) :
QWidget(parent),
ui(new Ui::MovitColorFilter),
m_filter(filter)
{
ui->setupUi(this);
Mlt::Filter f(MLT.profile(), "movit.lift_gamma_gain");
m_liftDefault = QColor::fromRgbF(f.get_double("lift_r"),
f.get_double("lift_g"),
f.get_double("lift_b"));
m_gammaDefault = QColor::fromRgbF(f.get_double("gamma_r") / GAMMA_FACTOR,
f.get_double("gamma_g") / GAMMA_FACTOR,
f.get_double("gamma_b") / GAMMA_FACTOR);
m_gainDefault = QColor::fromRgbF(f.get_double("gain_r") / GAIN_FACTOR,
f.get_double("gain_g") / GAIN_FACTOR,
f.get_double("gain_b") / GAIN_FACTOR);
if (setDefaults) {
ui->liftWheel->setColor(m_liftDefault);
ui->gammaWheel->setColor(m_gammaDefault);
ui->gainWheel->setColor(m_gainDefault);
ui->preset->saveDefaultPreset(m_filter);
} else {
ui->liftWheel->setColor(QColor::fromRgbF(filter.get_double("lift_r"),
filter.get_double("lift_g"),
filter.get_double("lift_b")));
ui->gammaWheel->setColor(QColor::fromRgbF(filter.get_double("gamma_r") / GAMMA_FACTOR,
filter.get_double("gamma_g") / GAMMA_FACTOR,
filter.get_double("gamma_b") / GAMMA_FACTOR));
ui->gainWheel->setColor(QColor::fromRgbF(filter.get_double("gain_r") / GAIN_FACTOR,
filter.get_double("gain_g") / GAIN_FACTOR,
filter.get_double("gain_b") / GAIN_FACTOR));
}
ui->preset->loadPresets();
}
示例14: removeEffect
bool EffectManager::removeEffect(int effectIndex, bool updateIndex)
{
m_producer.lock();
int ct = 0;
bool success = false;
Mlt::Filter *filter = m_producer.filter(ct);
QList <Mlt::Filter *> filters;
while (filter) {
filters << filter;
if ((effectIndex == -1 && strcmp(filter->get("kdenlive_id"), "")) || filter->get_int("kdenlive_ix") == effectIndex) {
if (m_producer.detach(*filter) == 0) {
success = true;
}
} else if (updateIndex) {
// Adjust the other effects index
if (filter->get_int("kdenlive_ix") > effectIndex) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
} else ct++;
filter = m_producer.filter(ct);
}
m_producer.unlock();
qDeleteAll(filters);
return success;
}
示例15: data
QVariant AttachedFiltersModel::data(const QModelIndex &index, int role) const
{
if ( !m_producer || !m_producer->is_valid()
|| index.row() >= m_producer->filter_count())
return QVariant();
switch (role ) {
case Qt::DisplayRole: {
QVariant result;
const QmlMetadata* meta = m_metaList[index.row()];
if (meta) {
result = meta->name();
} else {
// Fallback is raw mlt_service name
Mlt::Filter* filter = getFilter(index.row());
if (filter && filter->is_valid() && filter->get("mlt_service")) {
result = QString::fromUtf8(filter->get("mlt_service"));
}
delete filter;
}
return result;
}
case Qt::CheckStateRole: {
Mlt::Filter* filter = getFilter(index.row());
QVariant result = Qt::Unchecked;
if (filter && filter->is_valid() && !filter->get_int("disable"))
result = Qt::Checked;
delete filter;
return result;
}
break;
case TypeDisplayRole: {
QVariant result;
const QmlMetadata* meta = m_metaList[index.row()];
if (meta && meta->isAudio()) {
result = tr("Audio");
} else if (meta && meta->needsGPU()) {
result = tr("GPU");
} else {
result = tr("Video");
}
return result;
}
break;
default:
break;
}
return QVariant();
}