Commit 0d3e1643 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: sout_profiles: add video and audio filters (fix #7865)

parent 25316fbf
......@@ -36,6 +36,7 @@
#include <QButtonGroup>
#include <QSpinBox>
#include <QUrl>
#include <QListWidgetItem>
#include <assert.h>
#include <vlc_modules.h>
......@@ -246,6 +247,13 @@ void VLCProfileSelector::updateOptions( int i )
smrl.option( "vb", value.toInt() );
}
HASHPICK( "video", "filters" );
if ( !value.isEmpty() )
{
QStringList valuesList = QUrl::fromPercentEncoding( value.toAscii() ).split( ";" );
smrl.option( "vfilter", QString("{%1}").arg( valuesList.join( "," ) ) );
}
/*if ( codec is h264 )*/
{
/* special handling */
......@@ -304,6 +312,14 @@ void VLCProfileSelector::updateOptions( int i )
HASHPICK( "acodec", "samplerate" );
smrl.option( "samplerate", value.toInt() );
HASHPICK( "audio", "filters" );
if ( !value.isEmpty() )
{
QStringList valuesList = QUrl::fromPercentEncoding( value.toAscii() ).split( ";" );
smrl.option( "afilter", QString("{%1}").arg( valuesList.join( "," ) ) );
}
} else {
HASHPICK( "audio", "copy" );
if ( ! value.isEmpty() )
......@@ -410,6 +426,7 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value
}
loadCapabilities();
registerCodecs();
registerFilters();
QPushButton *saveButton = new QPushButton(
( qs_name.isEmpty() ) ? qtr( "Create" ) : qtr( "Save" ) );
......@@ -454,6 +471,39 @@ void VLCProfileEditor::loadCapabilities()
module_list_free (p_all);
}
inline void VLCProfileEditor::registerFilters()
{
size_t count;
module_t **p_all = module_list_get (&count);
for (size_t i = 0; i < count; i++)
{
module_t *p_module = p_all[i];
if ( module_get_score( p_module ) > 0 ) continue;
QString capability = module_get_capability( p_module );
QListWidget *listWidget = NULL;
QListWidgetItem *item;
if ( capability == "video filter2" )
listWidget = ui.valueholder_video_filters;
else if ( capability == "audio filter" )
listWidget = ui.valueholder_audio_filters;
if ( !listWidget ) continue;
item = new QListWidgetItem( module_get_name( p_module, true ) );
item->setCheckState( Qt::Unchecked );
item->setToolTip( QString( module_get_help( p_module ) ) );
item->setData( Qt::UserRole, QString( module_get_object( p_module ) ) );
listWidget->addItem( item );
}
module_list_free (p_all);
ui.valueholder_video_filters->sortItems();
ui.valueholder_audio_filters->sortItems();
}
inline void VLCProfileEditor::registerCodecs()
{
#define SETMUX( button, val, vid, aud, men, sub, stream, chaps ) \
......@@ -631,6 +681,19 @@ void VLCProfileEditor::fillProfile( const QString& qs )
QLineEdit *box = qobject_cast<QLineEdit *>( object );
box->setText( QUrl::fromPercentEncoding( value.toAscii() ) );
}
else if ( object->inherits( "QListWidget" ) )
{
QStringList valuesList = QUrl::fromPercentEncoding( value.toAscii() ).split( ";" );
const QListWidget *list = qobject_cast<const QListWidget *>( object );
for( int i=0; i < list->count(); i++ )
{
QListWidgetItem *item = list->item( i );
if ( valuesList.contains( item->data( Qt::UserRole ).toString() ) )
item->setCheckState( Qt::Checked );
else
item->setCheckState( Qt::Unchecked );
}
}
}
}
}
......@@ -752,6 +815,18 @@ QString VLCProfileEditor::transcodeValue()
const QLineEdit *box = qobject_cast<const QLineEdit *>( object );
value = QUrl::toPercentEncoding( box->text(), "", "_;" );
}
else if ( object->inherits( "QListWidget" ) )
{
const QListWidget *list = qobject_cast<const QListWidget *>( object );
QStringList valuesList;
for( int i=0; i < list->count(); i++ )
{
const QListWidgetItem *item = list->item( i );
if ( item->checkState() == Qt::Checked )
valuesList.append( item->data( Qt::UserRole ).toString() );
}
value = QUrl::toPercentEncoding( valuesList.join( ";" ), "", "_;" );
}
if ( !value.isEmpty() )
configuration << QString( "%1_%2=%3" )
......
......@@ -74,6 +74,7 @@ public:
QStringList qpcodecsList;
private:
void registerCodecs();
void registerFilters();
void fillProfile( const QString& qs );
void fillProfileOldFormat( const QString& qs );
typedef QSet<QString> resultset;
......
......@@ -294,6 +294,12 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="valueholder_video_copy">
<property name="text">
......@@ -302,14 +308,18 @@
</widget>
</item>
<item>
<widget class="QWidget" name="transcodevideo" native="true">
<layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="margin">
<widget class="QTabWidget" name="transcodevideo">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">
<string>Encoding parameters</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="vCodecLabel">
<property name="enabled">
......@@ -340,37 +350,46 @@
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSpinBox" name="valueholder_vcodec_bitrate">
<item row="3" column="0">
<widget class="QLabel" name="vFrameLabel">
<property name="text">
<string>Frame Rate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_framerate</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not Used</string>
<string>Same as source</string>
</property>
<property name="accelerated">
<bool>true</bool>
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> kb/s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>32768</number>
<string> fps</string>
</property>
<property name="singleStep">
<number>16</number>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Custom options</string>
</property>
<property name="value">
<number>800</number>
<property name="buddy">
<cstring>valueholder_vcodec_custom</cstring>
</property>
</widget>
</item>
<item>
<item row="4" column="1">
<widget class="QLineEdit" name="valueholder_vcodec_custom"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
......@@ -379,57 +398,61 @@
</sizepolicy>
</property>
<property name="text">
<string>or Quality</string>
<string>Quality</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_qp</cstring>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QSpinBox" name="valueholder_vcodec_qp">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not Used</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="vFrameLabel">
<property name="text">
<string>Frame Rate</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_framerate</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<item row="1" column="1">
<widget class="QSpinBox" name="valueholder_vcodec_bitrate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Same as source</string>
<string>Not Used</string>
</property>
<property name="prefix">
<string/>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="suffix">
<string> fps</string>
<string> kb/s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>32768</number>
</property>
<property name="singleStep">
<number>16</number>
</property>
<property name="value">
<number>800</number>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Resolution</string>
</attribute>
<layout class="QFormLayout" name="formLayout_6">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
......@@ -446,7 +469,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="vScaleLabel">
<property name="text">
<string>Scale</string>
......@@ -456,14 +479,21 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="valueholder_vcodec_scale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="0">
<widget class="QLabel" name="Framesize">
<property name="text">
<string>Frame size</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="widthLabel">
......@@ -525,31 +555,19 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Framesize">
<property name="text">
<string>Frame size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Custom options</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_custom</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="valueholder_vcodec_custom"/>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Filters</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QListWidget" name="valueholder_video_filters"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
......@@ -573,6 +591,12 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="valueholder_audio_copy">
<property name="text">
......@@ -581,11 +605,15 @@
</widget>
</item>
<item>
<widget class="QWidget" name="transcodeaudio" native="true">
<layout class="QFormLayout" name="_2">
<property name="margin">
<widget class="QTabWidget" name="transcodeaudio">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Encoding parameters</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="aCodecLabel">
<property name="text">
......@@ -669,6 +697,17 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Filters</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="2">
<widget class="QListWidget" name="valueholder_audio_filters"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
......@@ -791,6 +830,7 @@
<tabstop>ASFMux</tabstop>
<tabstop>valueholder_video_enable</tabstop>
<tabstop>valueholder_video_copy</tabstop>
<tabstop>transcodevideo</tabstop>
<tabstop>valueholder_video_codec</tabstop>
<tabstop>valueholder_vcodec_bitrate</tabstop>
<tabstop>valueholder_vcodec_qp</tabstop>
......@@ -799,12 +839,15 @@
<tabstop>valueholder_vcodec_scale</tabstop>
<tabstop>valueholder_vcodec_width</tabstop>
<tabstop>valueholder_vcodec_height</tabstop>
<tabstop>valueholder_video_filters</tabstop>
<tabstop>valueholder_audio_enable</tabstop>
<tabstop>valueholder_audio_copy</tabstop>
<tabstop>transcodeaudio</tabstop>
<tabstop>valueholder_audio_codec</tabstop>
<tabstop>valueholder_acodec_bitrate</tabstop>
<tabstop>valueholder_acodec_channels</tabstop>
<tabstop>valueholder_acodec_samplerate</tabstop>
<tabstop>valueholder_audio_filters</tabstop>
<tabstop>valueholder_subtitles_enable</tabstop>
<tabstop>valueholder_subtitles_codec</tabstop>
<tabstop>valueholder_subtitles_overlay</tabstop>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment