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 @@
#include <QRegExp>
#include <QButtonGroup>
#include <QSpinBox>
#include <QUrl>
#include <assert.h>
#include <vlc_modules.h>
......@@ -240,7 +241,24 @@ void VLCProfileSelector::updateOptions( int i )
smrl.option( "vcodec", value );
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" );
if ( !value.isEmpty() && value.toInt() > 0 )
......@@ -397,10 +415,17 @@ VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value
this, activatePanels() );
CONNECT( ui.valueholder_audio_copy, stateChanged( int ),
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();
fillProfile( value );
muxSelected();
codecSelected();
}
void VLCProfileEditor::loadCapabilities()
......@@ -463,6 +488,8 @@ inline void VLCProfileEditor::registerCodecs()
ADD_VCODEC( "Theora", "theo" )
ADD_VCODEC( "Dirac", "drac" )
#undef ADD_VCODEC
/* can do quality */
qpcodecsList << "h264";
#define ADD_ACODEC( name, fourcc ) ui.valueholder_audio_codec->addItem( name, QVariant( fourcc ) );
ADD_ACODEC( "MPEG Audio", "mpga" )
......@@ -504,36 +531,40 @@ inline void VLCProfileEditor::registerCodecs()
void VLCProfileEditor::muxSelected()
{
QRadioButton *current =
qobject_cast<QRadioButton *>( ui.buttonGroup->checkedButton() );
#define SETYESNOSTATE( name, prop ) \
ui.name->setChecked( current->property( prop ).toBool() )
for ( int i=0; i< ui.muxer->layout()->count(); i++ )
{
QRadioButton *current =
qobject_cast<QRadioButton *>(ui.muxer->layout()->itemAt(i)->widget());
if ( unlikely( !current ) ) continue;
if ( !current->isChecked() ) continue;
/* dumb :/ */
SETYESNOSTATE( capvideo, "capvideo" );
SETYESNOSTATE( capaudio, "capaudio" );
SETYESNOSTATE( capmenu, "capmenu" );
SETYESNOSTATE( capsubs, "capsubs" );
SETYESNOSTATE( capstream, "capstream" );
SETYESNOSTATE( capchaps, "capchaps" );
bool b = caps["muxers"].contains( "mux_" + current->property("sout").toString() );
if ( b )
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;
}
/* dumb :/ */
SETYESNOSTATE( capvideo, "capvideo" );
SETYESNOSTATE( capaudio, "capaudio" );
SETYESNOSTATE( capmenu, "capmenu" );
SETYESNOSTATE( capsubs, "capsubs" );
SETYESNOSTATE( capstream, "capstream" );
SETYESNOSTATE( capchaps, "capchaps" );
bool b = caps["muxers"].contains( "mux_" + current->property("sout").toString() );
if ( b )
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
}
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 )
{
QRegExp rx(OLDFORMAT);
......@@ -586,6 +617,11 @@ void VLCProfileEditor::fillProfile( const QString& qs )
QComboBox *box = qobject_cast<QComboBox *>( object );
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()
const QComboBox *box = qobject_cast<const QComboBox *>( object );
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() )
configuration << QString( "%1_%2=%3" )
......@@ -717,6 +758,7 @@ void VLCProfileEditor::reset()
ui.valueholder_video_copy->setChecked( false );
ui.valueholder_audio_copy->setChecked( false );
activatePanels();
fixBirateState(); /* defaults to bitrate, not qp */
/* end with top level ones for cascaded setEnabled() */
ui.valueholder_video_enable->setChecked( false );
ui.valueholder_audio_enable->setChecked( false );
......@@ -729,6 +771,18 @@ void VLCProfileEditor::activatePanels()
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 CATANDPROP
#undef OLDFORMAT
......@@ -71,6 +71,7 @@ public:
QString name;
QString muxValue;
QString transcodeValue();
QStringList qpcodecsList;
private:
void registerCodecs();
void fillProfile( const QString& qs );
......@@ -83,7 +84,10 @@ protected slots:
virtual void close();
private slots:
void muxSelected();
void codecSelected();
void activatePanels();
void fixBirateState();
void fixQPState();
};
#endif
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>584</width>
<height>442</height>
<height>471</height>
</rect>
</property>
<property name="windowTitle">
......@@ -303,7 +303,10 @@
</item>
<item>
<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">
<number>0</number>
</property>
......@@ -337,6 +340,61 @@
</property>
</widget>
</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">
<widget class="QLabel" name="vFrameLabel">
<property name="text">
......@@ -347,28 +405,6 @@
</property>
</widget>
</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">
<widget class="QDoubleSpinBox" name="valueholder_vcodec_framerate">
<property name="alignment">
......@@ -385,7 +421,7 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Resolution</string>
......@@ -499,6 +535,19 @@
</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"/>
</item>
</layout>
</widget>
</item>
......@@ -744,7 +793,9 @@
<tabstop>valueholder_video_copy</tabstop>
<tabstop>valueholder_video_codec</tabstop>
<tabstop>valueholder_vcodec_bitrate</tabstop>
<tabstop>valueholder_vcodec_qp</tabstop>
<tabstop>valueholder_vcodec_framerate</tabstop>
<tabstop>valueholder_vcodec_custom</tabstop>
<tabstop>valueholder_vcodec_scale</tabstop>
<tabstop>valueholder_vcodec_width</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