Commit 2f603334 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: profiles_editor: add bitrate field and custom field

parent a15751bb
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <QRegExp> #include <QRegExp>
#include <QButtonGroup> #include <QButtonGroup>
#include <QSpinBox> #include <QSpinBox>
#include <QUrl>
#include <assert.h> #include <assert.h>
#include <vlc_modules.h> #include <vlc_modules.h>
...@@ -240,7 +241,24 @@ void VLCProfileSelector::updateOptions( int i ) ...@@ -240,7 +241,24 @@ void VLCProfileSelector::updateOptions( int i )
smrl.option( "vcodec", value ); smrl.option( "vcodec", value );
HASHPICK( "vcodec", "bitrate" ); HASHPICK( "vcodec", "bitrate" );
smrl.option( "vb", value.toInt() ); if ( value.toInt() > 0 )
{
smrl.option( "vb", value.toInt() );
} else {
/* special handling */
QStringList codecoptions;
HASHPICK( "vcodec", "qp" );
if( value.toInt() > 0 )
codecoptions << QString( "qp=%1" ).arg( value );
HASHPICK( "vcodec", "custom" );
if( !value.isEmpty() )
codecoptions << QUrl::fromPercentEncoding( value.toAscii() );
smrl.option( "venc",
QString("x264{%1}").arg( codecoptions.join(",") ) );
}
HASHPICK( "vcodec", "framerate" ); HASHPICK( "vcodec", "framerate" );
if ( !value.isEmpty() && value.toInt() > 0 ) if ( !value.isEmpty() && value.toInt() > 0 )
...@@ -397,10 +415,17 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value ...@@ -397,10 +415,17 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value
this, activatePanels() ); this, activatePanels() );
CONNECT( ui.valueholder_audio_copy, stateChanged( int ), CONNECT( ui.valueholder_audio_copy, stateChanged( int ),
this, activatePanels() ); this, activatePanels() );
CONNECT( ui.valueholder_vcodec_bitrate, editingFinished( ),
this, fixBirateState() );
CONNECT( ui.valueholder_vcodec_qp, editingFinished( ),
this, fixQPState() );
CONNECT( ui.valueholder_video_codec, currentIndexChanged( int ),
this, codecSelected() );
reset(); reset();
fillProfile( value ); fillProfile( value );
muxSelected(); muxSelected();
codecSelected();
} }
void VLCProfileEditor::loadCapabilities() void VLCProfileEditor::loadCapabilities()
...@@ -463,6 +488,8 @@ inline void VLCProfileEditor::registerCodecs() ...@@ -463,6 +488,8 @@ inline void VLCProfileEditor::registerCodecs()
ADD_VCODEC( "Theora", "theo" ) ADD_VCODEC( "Theora", "theo" )
ADD_VCODEC( "Dirac", "drac" ) ADD_VCODEC( "Dirac", "drac" )
#undef ADD_VCODEC #undef ADD_VCODEC
/* can do quality */
qpcodecsList << "h264";
#define ADD_ACODEC( name, fourcc ) ui.valueholder_audio_codec->addItem( name, QVariant( fourcc ) ); #define ADD_ACODEC( name, fourcc ) ui.valueholder_audio_codec->addItem( name, QVariant( fourcc ) );
ADD_ACODEC( "MPEG Audio", "mpga" ) ADD_ACODEC( "MPEG Audio", "mpga" )
...@@ -504,36 +531,40 @@ inline void VLCProfileEditor::registerCodecs() ...@@ -504,36 +531,40 @@ inline void VLCProfileEditor::registerCodecs()
void VLCProfileEditor::muxSelected() void VLCProfileEditor::muxSelected()
{ {
QRadioButton *current =
qobject_cast<QRadioButton *>( ui.buttonGroup->checkedButton() );
#define SETYESNOSTATE( name, prop ) \ #define SETYESNOSTATE( name, prop ) \
ui.name->setChecked( current->property( prop ).toBool() ) ui.name->setChecked( current->property( prop ).toBool() )
for ( int i=0; i< ui.muxer->layout()->count(); i++ ) /* dumb :/ */
{ SETYESNOSTATE( capvideo, "capvideo" );
QRadioButton *current = SETYESNOSTATE( capaudio, "capaudio" );
qobject_cast<QRadioButton *>(ui.muxer->layout()->itemAt(i)->widget()); SETYESNOSTATE( capmenu, "capmenu" );
if ( unlikely( !current ) ) continue; SETYESNOSTATE( capsubs, "capsubs" );
if ( !current->isChecked() ) continue; SETYESNOSTATE( capstream, "capstream" );
SETYESNOSTATE( capchaps, "capchaps" );
/* dumb :/ */ bool b = caps["muxers"].contains( "mux_" + current->property("sout").toString() );
SETYESNOSTATE( capvideo, "capvideo" ); if ( b )
SETYESNOSTATE( capaudio, "capaudio" ); ui.muxerwarning->setText(
SETYESNOSTATE( capmenu, "capmenu" ); QString( "<img src=\":/menu/info\"/> %1" )
SETYESNOSTATE( capsubs, "capsubs" ); .arg( qtr( "This muxer is not provided directly by VLC: It could be missing." ) )
SETYESNOSTATE( capstream, "capstream" ); );
SETYESNOSTATE( capchaps, "capchaps" ); else
bool b = caps["muxers"].contains( "mux_" + current->property("sout").toString() ); ui.muxerwarning->setText("");
if ( b ) return;
ui.muxerwarning->setText(
QString( "<img src=\":/menu/info\"/> %1" )
.arg( qtr( "This muxer is not provided directly by VLC: It could be missing." ) )
);
else
ui.muxerwarning->setText("");
return;
}
#undef SETYESNOSTATE #undef SETYESNOSTATE
} }
void VLCProfileEditor::codecSelected()
{
/* Enable quality preset */
QString currentcodec = ui.valueholder_video_codec->
itemData(ui.valueholder_video_codec->currentIndex() ).toString();
ui.valueholder_vcodec_qp->setEnabled( qpcodecsList.contains( currentcodec ) );
}
void VLCProfileEditor::fillProfile( const QString& qs ) void VLCProfileEditor::fillProfile( const QString& qs )
{ {
QRegExp rx(OLDFORMAT); QRegExp rx(OLDFORMAT);
...@@ -586,6 +617,11 @@ void VLCProfileEditor::fillProfile( const QString& qs ) ...@@ -586,6 +617,11 @@ void VLCProfileEditor::fillProfile( const QString& qs )
QComboBox *box = qobject_cast<QComboBox *>( object ); QComboBox *box = qobject_cast<QComboBox *>( object );
box->setCurrentIndex( box->findData( value ) ); box->setCurrentIndex( box->findData( value ) );
} }
else if( object->inherits( "QLineEdit" ) )
{
QLineEdit *box = qobject_cast<QLineEdit *>( object );
box->setText( QUrl::fromPercentEncoding( value.toAscii() ) );
}
} }
} }
} }
...@@ -702,6 +738,11 @@ QString VLCProfileEditor::transcodeValue() ...@@ -702,6 +738,11 @@ QString VLCProfileEditor::transcodeValue()
const QComboBox *box = qobject_cast<const QComboBox *>( object ); const QComboBox *box = qobject_cast<const QComboBox *>( object );
value = currentData( box ).toString(); value = currentData( box ).toString();
} }
else if( object->inherits( "QLineEdit" ) )
{
const QLineEdit *box = qobject_cast<const QLineEdit *>( object );
value = QUrl::toPercentEncoding( box->text(), "", "_;" );
}
if ( !value.isEmpty() ) if ( !value.isEmpty() )
configuration << QString( "%1_%2=%3" ) configuration << QString( "%1_%2=%3" )
...@@ -717,6 +758,7 @@ void VLCProfileEditor::reset() ...@@ -717,6 +758,7 @@ void VLCProfileEditor::reset()
ui.valueholder_video_copy->setChecked( false ); ui.valueholder_video_copy->setChecked( false );
ui.valueholder_audio_copy->setChecked( false ); ui.valueholder_audio_copy->setChecked( false );
activatePanels(); activatePanels();
fixBirateState(); /* defaults to bitrate, not qp */
/* end with top level ones for cascaded setEnabled() */ /* end with top level ones for cascaded setEnabled() */
ui.valueholder_video_enable->setChecked( false ); ui.valueholder_video_enable->setChecked( false );
ui.valueholder_audio_enable->setChecked( false ); ui.valueholder_audio_enable->setChecked( false );
...@@ -729,6 +771,18 @@ void VLCProfileEditor::activatePanels() ...@@ -729,6 +771,18 @@ void VLCProfileEditor::activatePanels()
ui.transcodeaudio->setEnabled( ! ui.valueholder_audio_copy->isChecked() ); ui.transcodeaudio->setEnabled( ! ui.valueholder_audio_copy->isChecked() );
} }
void VLCProfileEditor::fixBirateState()
{
/* exclusive bitrate choice */
ui.valueholder_vcodec_qp->setValue( 0 );
}
void VLCProfileEditor::fixQPState()
{
/* exclusive bitrate choice */
ui.valueholder_vcodec_bitrate->setValue( 0 );
}
#undef CATPROP2NAME #undef CATPROP2NAME
#undef CATANDPROP #undef CATANDPROP
#undef OLDFORMAT #undef OLDFORMAT
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
QString name; QString name;
QString muxValue; QString muxValue;
QString transcodeValue(); QString transcodeValue();
QStringList qpcodecsList;
private: private:
void registerCodecs(); void registerCodecs();
void fillProfile( const QString& qs ); void fillProfile( const QString& qs );
...@@ -83,7 +84,10 @@ protected slots: ...@@ -83,7 +84,10 @@ protected slots:
virtual void close(); virtual void close();
private slots: private slots:
void muxSelected(); void muxSelected();
void codecSelected();
void activatePanels(); void activatePanels();
void fixBirateState();
void fixQPState();
}; };
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>584</width> <width>584</width>
<height>442</height> <height>471</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -303,7 +303,10 @@ ...@@ -303,7 +303,10 @@
</item> </item>
<item> <item>
<widget class="QWidget" name="transcodevideo" native="true"> <widget class="QWidget" name="transcodevideo" native="true">
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
...@@ -337,6 +340,61 @@ ...@@ -337,6 +340,61 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSpinBox" name="valueholder_vcodec_bitrate">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="specialValueText">
<string>Not Used</string>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="suffix">
<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>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>or Quality</string>
</property>
<property name="buddy">
<cstring>valueholder_vcodec_qp</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="valueholder_vcodec_qp">
<property name="specialValueText">
<string>Not Used</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="vFrameLabel"> <widget class="QLabel" name="vFrameLabel">
<property name="text"> <property name="text">
...@@ -347,28 +405,6 @@ ...@@ -347,28 +405,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<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="accelerated">
<bool>true</bool>
</property>
<property name="suffix">
<string> kb/s</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>32768</number>
</property>
<property name="value">
<number>800</number>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate"> <widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<property name="alignment"> <property name="alignment">
...@@ -385,7 +421,7 @@ ...@@ -385,7 +421,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Resolution</string> <string>Resolution</string>
...@@ -499,6 +535,19 @@ ...@@ -499,6 +535,19 @@
</layout> </layout>
</widget> </widget>
</item> </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"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -744,7 +793,9 @@ ...@@ -744,7 +793,9 @@
<tabstop>valueholder_video_copy</tabstop> <tabstop>valueholder_video_copy</tabstop>
<tabstop>valueholder_video_codec</tabstop> <tabstop>valueholder_video_codec</tabstop>
<tabstop>valueholder_vcodec_bitrate</tabstop> <tabstop>valueholder_vcodec_bitrate</tabstop>
<tabstop>valueholder_vcodec_qp</tabstop>
<tabstop>valueholder_vcodec_framerate</tabstop> <tabstop>valueholder_vcodec_framerate</tabstop>
<tabstop>valueholder_vcodec_custom</tabstop>
<tabstop>valueholder_vcodec_scale</tabstop> <tabstop>valueholder_vcodec_scale</tabstop>
<tabstop>valueholder_vcodec_width</tabstop> <tabstop>valueholder_vcodec_width</tabstop>
<tabstop>valueholder_vcodec_height</tabstop> <tabstop>valueholder_vcodec_height</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