/*****************************************************************************
* extended_panels.cpp : Extended controls panels
****************************************************************************
- * Copyright (C) 2006-2008 the VideoLAN team
+ * Copyright (C) 2006-2012 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Antoine Cellerier <dionoea .t videolan d@t org>
+ * Jean-Baptiste Kempf <jb@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <QString>
#include <QFont>
#include <QGridLayout>
-#include <QSignalMapper>
#include <QComboBox>
#include <QTimer>
+#include <QFileDialog>
#include "components/extended_panels.hpp"
#include "dialogs/preferences.hpp"
#include "qt4.hpp"
#include "input_manager.hpp"
+#include "util/qt_dirs.hpp"
#include "../../audio_filter/equalizer_presets.h"
-#include <vlc_aout.h>
+#include <vlc_aout_intf.h>
#include <vlc_intf_strings.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
#include <vlc_modules.h>
+#include <vlc_plugin.h>
#include <vlc_charset.h> /* us_strtod */
+static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add );
+
#if 0
class ConfClickHandler : public QObject
{
QObject( _parent ), p_intf( _p_intf )
{
ui.setupUi( _parent );
- p_vout = NULL;
#define SETUP_VFILTER( widget ) \
{ \
vlc_object_t *p_obj = ( vlc_object_t * ) \
vlc_object_find_name( p_intf->p_libvlc, \
- #widget, \
- FIND_CHILD ); \
+ #widget ); \
QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
if( p_obj ) \
{ \
vlc_object_release( p_obj ); \
if( checkbox ) checkbox->setChecked( true ); \
- else groupbox->setChecked( true ); \
+ else if (groupbox) groupbox->setChecked( true ); \
} \
else \
{ \
if( checkbox ) checkbox->setChecked( false ); \
- else groupbox->setChecked( false ); \
+ else if (groupbox) groupbox->setChecked( false ); \
} \
} \
CONNECT( ui.widget##Enable, clicked(), this, updateFilters() );
+
+
#define SETUP_VFILTER_OPTION( widget, signal ) \
initComboBoxItems( ui.widget ); \
setWidgetValue( ui.widget ); \
SETUP_VFILTER_OPTION( extractComponentText, textChanged( const QString& ) )
SETUP_VFILTER( posterize )
- SETUP_VFILTER_OPTION( posterizeLevelSpin, valueChanged( int ) )
SETUP_VFILTER( colorthres )
SETUP_VFILTER_OPTION( colorthresColorText, textChanged( const QString& ) )
SETUP_VFILTER( motiondetect )
-// SETUP_VFILTER( noise )
-
SETUP_VFILTER( psychedelic )
SETUP_VFILTER( sharpen )
SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
- SETUP_VFILTER( panoramix )
- SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) )
- SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) )
-
SETUP_VFILTER( erase )
SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) )
+ BUTTONACT( ui.eraseBrowseBtn, browseEraseFile() );
SETUP_VFILTER( marq )
SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( const QString& ) )
SETUP_VFILTER_OPTION( logoYSpin, valueChanged( int ) )
SETUP_VFILTER_OPTION( logoXSpin, valueChanged( int ) )
SETUP_VFILTER_OPTION( logoOpacitySlider, valueChanged( int ) )
+ BUTTONACT( ui.logoBrowseBtn, browseLogo() );
SETUP_VFILTER( gradfun )
SETUP_VFILTER_OPTION( gradfunRadiusSlider, valueChanged( int ) )
SETUP_VFILTER( grain )
SETUP_VFILTER_OPTION( grainVarianceSlider, valueChanged( int ) )
+ SETUP_VFILTER( mirror )
+
+ SETUP_VFILTER( gaussianblur )
+ SETUP_VFILTER_OPTION( gaussianbluSigmaSlider, valueChanged( int ) )
+
+ SETUP_VFILTER( antiflicker )
+ SETUP_VFILTER_OPTION( antiflickerSofteningSizeSlider, valueChanged( int ) )
+
+
if( module_exists( "atmo" ) )
{
SETUP_VFILTER( atmo )
if( ui.leftRightCropSync->isChecked() )
ui.cropRightPx->setValue( ui.cropLeftPx->value() );
- p_vout = THEMIM->getVout();
+ vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout )
{
var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
ui.cropRightPx->setValue( 0 );
}
-void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add )
+static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add )
{
char *psz_parser, *psz_string;
const char *psz_filter_type;
{
psz_filter_type = "video-filter";
}
+ else if( module_provides( p_obj, "sub source" ) )
+ {
+ psz_filter_type = "sub-source";
+ }
else if( module_provides( p_obj, "sub filter" ) )
{
psz_filter_type = "sub-filter";
}
else
{
- module_release (p_obj);
msg_Err( p_intf, "Unknown video filter type." );
return;
}
- module_release (p_obj);
psz_string = config_GetPsz( p_intf, psz_filter_type );
}
else
{
+ free( psz_string );
return;
}
}
}
/* Remove trailing : : */
- if( strlen( psz_string ) > 0 &&
- *( psz_string + strlen( psz_string ) -1 ) == ':' )
+ size_t i_len = strlen( psz_string );
+ if( i_len > 0 && *( psz_string + i_len - 1 ) == ':' )
{
- *( psz_string + strlen( psz_string ) -1 ) = '\0';
+ *( psz_string + i_len - 1 ) = '\0';
}
}
else
}
else
{
- p_vout = THEMIM->getVout();
+ vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout )
{
var_SetString( p_vout, psz_filter_type, psz_string );
QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
- ChangeVFiltersString( qtu( module ),
+ ChangeVFiltersString( p_intf, qtu( module ),
checkbox ? checkbox->isChecked()
: groupbox->isChecked() );
}
+#define UPDATE_AND_APPLY_TEXT( widget, file ) \
+ CONNECT( ui.widget, textChanged( const QString& ), \
+ this, updateFilterOptions() ); \
+ ui.widget->setText( toNativeSeparators( file ) ); \
+ ui.widget->disconnect( SIGNAL( textChanged( const QString& ) ) );
+
+void ExtVideo::browseLogo()
+{
+ QString file = QFileDialog::getOpenFileName( NULL, qtr( "Logo filenames" ),
+ p_intf->p_sys->filepath, "Images (*.png *.jpg);;All (*)" );
+
+ UPDATE_AND_APPLY_TEXT( logoFileText, file );
+}
+
+void ExtVideo::browseEraseFile()
+{
+ QString file = QFileDialog::getOpenFileName( NULL, qtr( "Image mask" ),
+ p_intf->p_sys->filepath, "Images (*.png *.jpg);;All (*)" );
+
+ UPDATE_AND_APPLY_TEXT( eraseMaskText, file );
+}
+
+#undef UPDATE_AND_APPLY_TEXT
+
void ExtVideo::initComboBoxItems( QObject *widget )
{
QComboBox *combobox = qobject_cast<QComboBox*>( widget );
qtu( option ) );
if( p_item )
{
- int i_type = p_item->i_type & CONFIG_ITEM;
+ int i_type = p_item->i_type;
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
if( i_type == CONFIG_ITEM_INTEGER
}
else
{
- msg_Err( p_intf, "Couldn't find option \"%s\".",
- qtu( option ) );
+ msg_Err( p_intf, "Couldn't find option \"%s\".", qtu( option ) );
}
}
//std::cout << "Option name: " << option.toStdString() << std::endl;
vlc_object_t *p_obj = ( vlc_object_t * )
- vlc_object_find_name( p_intf->p_libvlc,
- qtu( module ),
- FIND_CHILD );
+ vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
int i_type;
vlc_value_t val;
}
else if( combobox ) combobox->setCurrentIndex(
combobox->findData( qlonglong(val.i_int) ) );
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
+ else msg_Warn( p_intf, "Could not find the correct Integer widget" );
}
else if( i_type == VLC_VAR_FLOAT )
{
if( slider ) slider->setValue( ( int )( val.f_float*( double )slider->tickInterval() ) ); /* hack alert! */
else if( doublespinbox ) doublespinbox->setValue( val.f_float );
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
+ else msg_Warn( p_intf, "Could not find the correct Float widget" );
}
else if( i_type == VLC_VAR_STRING )
{
if( lineedit ) lineedit->setText( qfu( val.psz_string ) );
else if( combobox ) combobox->setCurrentIndex(
combobox->findData( qfu( val.psz_string ) ) );
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
+ else msg_Warn( p_intf, "Could not find the correct String widget" );
free( val.psz_string );
}
else
//std::cout << "Option name: " << option.toStdString() << std::endl;
vlc_object_t *p_obj = ( vlc_object_t * )
- vlc_object_find_name( p_intf->p_libvlc,
- qtu( module ),
- FIND_CHILD );
+ vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
int i_type;
bool b_is_command;
if( !p_obj )
b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
}
- if( !b_is_command )
- {
- msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.",
- qtu( module ),
- qtu( option ) );
- /* FIXME: restart automatically somewhere near the end of this function */
- }
-
/* Try to cast to all the widgets we're likely to encounter. Only
* one of the casts is expected to work. */
QSlider *slider = qobject_cast<QSlider*> ( sender() );
else if( dial ) i_int = ( 540-dial->value() )%360;
else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
+ else msg_Warn( p_intf, "Could not find the correct Integer widget" );
config_PutInt( p_intf, qtu( option ), i_int );
if( b_is_command )
{
/ ( double )slider->tickInterval(); /* hack alert! */
else if( doublespinbox ) f_float = doublespinbox->value();
else if( lineedit ) f_float = lineedit->text().toDouble();
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
+ else msg_Warn( p_intf, "Could not find the correct Float widget" );
config_PutFloat( p_intf, qtu( option ), f_float );
if( b_is_command )
var_SetFloat( p_obj, qtu( option ), f_float );
}
else if( i_type == VLC_VAR_STRING )
{
- char *psz_string = NULL;
- if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
- else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
- combobox->currentIndex() ).toString() ) );
- else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
- config_PutPsz( p_intf, qtu( option ), psz_string );
+ QString val;
+ if( lineedit )
+ val = lineedit->text();
+ else if( combobox )
+ val = combobox->itemData( combobox->currentIndex() ).toString();
+ else
+ msg_Warn( p_intf, "Could not find the correct String widget" );
+ config_PutPsz( p_intf, qtu( option ), qtu( val ) );
if( b_is_command )
- var_SetString( p_obj, qtu( option ), psz_string );
- free( psz_string );
+ var_SetString( p_obj, qtu( option ), qtu( val ) );
}
else
msg_Err( p_intf,
qtu( option ),
i_type );
+ if( !b_is_command )
+ {
+ msg_Warn( p_intf, "Module %s's %s variable isn't a command. Brute-restarting the filter.",
+ qtu( module ),
+ qtu( option ) );
+ ChangeVFiltersString( p_intf, qtu( module ), false );
+ ChangeVFiltersString( p_intf, qtu( module ), true );
+ }
+
if( p_obj ) vlc_object_release( p_obj );
}
void ExtV4l2::Refresh( void )
{
- vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
+ vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
help->hide();
if( box )
{
}
if( p_obj )
{
- vlc_value_t val, text, name;
+ vlc_value_t val, text;
int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
&val, &text );
if( i_ret < 0 )
for( int i = 0; i < val.p_list->i_count; i++ )
{
+ vlc_value_t vartext;
const char *psz_var = text.p_list->p_values[i].psz_string;
- var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &name, NULL );
- const char *psz_label = name.psz_string;
+
+ if( var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &vartext, NULL ) )
+ continue;
+
+ QString name = qtr( vartext.psz_string );
+ free( vartext.psz_string );
msg_Dbg( p_intf, "v4l2 control \"%"PRIx64"\": %s (%s)",
- val.p_list->p_values[i].i_int, psz_var, name.psz_string );
+ val.p_list->p_values[i].i_int, psz_var, qtu( name ) );
int i_type = var_Type( p_obj, psz_var );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_INTEGER:
{
- QLabel *label = new QLabel( qtr( psz_label ), box );
+ QLabel *label = new QLabel( name, box );
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->addWidget( label );
int i_val = var_GetInteger( p_obj, psz_var );
if( i_type & VLC_VAR_HASCHOICE )
{
QComboBox *combobox = new QComboBox( box );
- combobox->setObjectName( qtr( psz_var ) );
+ combobox->setObjectName( qfu( psz_var ) );
vlc_value_t val2, text2;
var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
hlayout->addWidget( combobox );
}
else
+ if( (i_type & VLC_VAR_HASMIN) && (i_type & VLC_VAR_HASMAX) )
{
QSlider *slider = new QSlider( box );
- slider->setObjectName( qtr( psz_var ) );
+ slider->setObjectName( qfu( psz_var ) );
slider->setOrientation( Qt::Horizontal );
vlc_value_t val2;
var_Change( p_obj, psz_var, VLC_VAR_GETMIN,
&val2, NULL );
+ if( val2.i_int < INT_MIN )
+ val2.i_int = INT_MIN; /* FIXME */
slider->setMinimum( val2.i_int );
var_Change( p_obj, psz_var, VLC_VAR_GETMAX,
&val2, NULL );
+ if( val2.i_int > INT_MAX )
+ val2.i_int = INT_MAX; /* FIXME */
slider->setMaximum( val2.i_int );
- var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
- &val2, NULL );
- slider->setSingleStep( val2.i_int );
+ if( !var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
+ &val2, NULL ) )
+ slider->setSingleStep( val2.i_int );
slider->setValue( i_val );
-
CONNECT( slider, valueChanged( int ), this,
ValueChange( int ) );
hlayout->addWidget( slider );
}
+ else
+ {
+ QSpinBox *spinBox = new QSpinBox( box );
+ spinBox->setObjectName( qfu( psz_var ) );
+ spinBox->setMinimum( INT_MIN );
+ spinBox->setMaximum( INT_MAX );
+ spinBox->setValue( i_val );
+ CONNECT( spinBox, valueChanged( int ), this,
+ ValueChange( int ) );
+ hlayout->addWidget( spinBox );
+ }
layout->addLayout( hlayout );
break;
}
case VLC_VAR_BOOL:
{
- QCheckBox *button = new QCheckBox( qtr( psz_label ), box );
- button->setObjectName( qtr( psz_var ) );
+ QCheckBox *button = new QCheckBox( name, box );
+ button->setObjectName( qfu( psz_var ) );
button->setChecked( var_GetBool( p_obj, psz_var ) );
CONNECT( button, clicked( bool ), this,
{
if( i_type & VLC_VAR_ISCOMMAND )
{
- QPushButton *button = new QPushButton( qtr( psz_label ), box );
- button->setObjectName( qtr( psz_var ) );
+ QPushButton *button = new QPushButton( name, box );
+ button->setObjectName( qfu( psz_var ) );
CONNECT( button, clicked( bool ), this,
ValueChange( bool ) );
}
else
{
- QLabel *label = new QLabel( qtr( psz_label ), box );
+ QLabel *label = new QLabel( name, box );
layout->addWidget( label );
}
break;
msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
break;
}
- free( name.psz_string );
}
var_FreeList( &val, &text );
vlc_object_release( p_obj );
void ExtV4l2::ValueChange( int value )
{
QObject *s = sender();
- vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
+ vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
if( p_obj )
{
- char *psz_var = strdup( qtu( s->objectName() ) );
- int i_type = var_Type( p_obj, psz_var );
+ QString var = s->objectName();
+ int i_type = var_Type( p_obj, qtu( var ) );
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_INTEGER:
QComboBox *combobox = qobject_cast<QComboBox*>( s );
value = combobox->itemData( value ).toInt();
}
- var_SetInteger( p_obj, psz_var, value );
+ var_SetInteger( p_obj, qtu( var ), value );
break;
case VLC_VAR_BOOL:
- var_SetBool( p_obj, psz_var, value );
+ var_SetBool( p_obj, qtu( var ), value );
break;
case VLC_VAR_VOID:
- var_TriggerCallback( p_obj, psz_var );
+ var_TriggerCallback( p_obj, qtu( var ) );
break;
}
- free( psz_var );
vlc_object_release( p_obj );
}
else
* Equalizer
**********************************************************************/
-static const QString band_frequencies[] =
+static const QString vlc_band_frequencies[] =
{
" 60 Hz ", " 170 Hz ", " 310 Hz ", " 600 Hz ", " 1 kHz ",
" 3 kHz ", " 6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
};
+static const QString iso_band_frequencies[] =
+{
+ " 31.25 Hz ", " 62.5 Hz ", " 125 Hz ", " 250 Hz ", " 500 Hz ",
+ " 1 kHz ", " 2 kHz ", " 4 kHz ", " 8 kHz ", " 16 kHz "
+};
+
Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf )
{
presetsComboBox = ui.presetsCombo;
CONNECT( presetsComboBox, activated( int ), this, setCorePreset( int ) );
+ b_vlcBands = var_InheritBool( p_intf, "equalizer-vlcfreqs" );
+
/* Add the sliders for the Bands */
QGridLayout *grid = new QGridLayout( ui.frame );
grid->setMargin( 0 );
bands[i] = new QSlider( Qt::Vertical );
bands[i]->setMaximum( 400 );
bands[i]->setValue( 200 );
+ bands[i]->setMinimumWidth(36);
CONNECT( bands[i], valueChanged( int ), this, setCoreBands() );
- band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" );
+ QString val = QString("%1").arg( 0.0, 5, 'f', 1 );
+ band_texts[i] = new QLabel( (b_vlcBands ? vlc_band_frequencies[i]
+ : iso_band_frequencies[i]) + "\n" + val + "dB" );
band_texts[i]->setFont( smallFont );
grid->addWidget( bands[i], 0, i );
float f_preamp;
int i_preset;
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout )
{
psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
free( psz_pres );
}
-/* Functin called when enableButton is toggled */
+void Equalizer::changeFreqLabels( bool b_useVlcBands )
+{
+ b_vlcBands = b_useVlcBands;
+
+ const QString *band_frequencies = b_vlcBands
+ ? vlc_band_frequencies
+ : iso_band_frequencies;
+
+ for( int i = 0; i < BANDS; i++ )
+ {
+ const float f_val = (float)( bands[i]->value() ) / 10 - 20;
+ QString val = QString("%1").arg( f_val, 5, 'f', 1 );
+ band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
+ }
+}
+
+/* Function called when enableButton is toggled */
void Equalizer::enable()
{
bool en = ui.enableCheck->isChecked();
/* Function called when the set2Pass button is activated */
void Equalizer::set2Pass()
{
- aout_instance_t *p_aout= THEMIM->getAout();
+ vlc_object_t *p_aout= (vlc_object_t *)THEMIM->getAout();
bool b_2p = ui.eq2PassCheck->isChecked();
if( p_aout )
void Equalizer::setPreamp()
{
const float f = ( float )( ui.preampSlider->value() ) /10 - 20;
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 )
+ qtr( "dB" ) );
{
/**\todo smoothing */
+ const QString *band_frequencies = b_vlcBands
+ ? vlc_band_frequencies
+ : iso_band_frequencies;
+
QString values;
for( int i = 0; i < BANDS; i++ )
{
band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
values += " " + val;
}
- const char *psz_values = values.toAscii().constData();
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout )
{
//delCallbacks( p_aout );
- var_SetString( p_aout, "equalizer-bands", psz_values );
+ var_SetString( p_aout, "equalizer-bands", qtu( values ) );
//addCallbacks( p_aout );
vlc_object_release( p_aout );
}
/* Create the QString in Qt */
for( int i = 0 ; i< BANDS ;i++ )
- values += QString( " %1" ).arg( eqz_preset_10b[i_preset]->f_amp[i] );
+ values += QString( " %1" ).arg( eqz_preset_10b[i_preset].f_amp[i], 5, 'f', 1 );
/* Convert it to char * */
return strdup( values.toAscii().constData() );
return;
/* Update pre-amplification in the UI */
- float f_preamp = eqz_preset_10b[i_preset]->f_preamp;
+ float f_preamp = eqz_preset_10b[i_preset].f_preamp;
ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
ui.preampLabel->setText( qtr( "Preamp\n" )
+ QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) );
char *psz_values = createValuesFromPreset( i_preset );
if( !psz_values ) return ;
+ const QString *band_frequencies = b_vlcBands
+ ? vlc_band_frequencies
+ : iso_band_frequencies;
+
char *p = psz_values;
for( int i = 0; i < BANDS && *p; i++ )
{
}
/* Apply presets to audio output */
- aout_instance_t *p_aout= THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
if( p_aout )
{
var_SetString( p_aout , "equalizer-preset" , preset_list[i_preset] );
var_SetString( p_aout, "equalizer-bands", psz_values );
var_SetFloat( p_aout, "equalizer-preamp",
- eqz_preset_10b[i_preset]->f_preamp );
+ eqz_preset_10b[i_preset].f_preamp );
vlc_object_release( p_aout );
}
config_PutPsz( p_intf, "equalizer-bands", psz_values );
config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] );
config_PutFloat( p_intf, "equalizer-preamp",
- eqz_preset_10b[i_preset]->f_preamp );
+ eqz_preset_10b[i_preset].f_preamp );
free( psz_values );
}
static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
+ VLC_UNUSED( p_this ); VLC_UNUSED( psz_cmd ); VLC_UNUSED( oldval );
+
char *psz_preset = newval.psz_string;
Equalizer *eq = ( Equalizer * )p_data;
int i_preset = eq->presetsComboBox->findData( QVariant( psz_preset ) );
return VLC_SUCCESS;
}
-void Equalizer::delCallbacks( aout_instance_t *p_aout )
+void Equalizer::delCallbacks( vlc_object_t *p_aout )
{
//var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this );
//var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this );
var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this );
}
-void Equalizer::addCallbacks( aout_instance_t *p_aout )
+void Equalizer::addCallbacks( vlc_object_t *p_aout )
{
//var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this );
//var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this );
: QWidget( _parent ) , p_intf( _p_intf )
{
QFont smallFont = QApplication::font();
- smallFont.setPointSize( smallFont.pointSize() - 3 );
+ smallFont.setPointSize( smallFont.pointSize() - 2 );
QGridLayout *layout = new QGridLayout( this );
BUTTONACT( enableCheck, enable() );
/* Write down initial values */
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
char *psz_af;
if( p_aout )
free( psz_af );
enable( enableCheck->isChecked() );
updateSliders( controlVars );
- setValues( controlVars );
+ setValues();
}
void Compressor::enable()
}
}
-void Compressor::updateSliders( float * controlVars )
+void Compressor::updateSliders( float * p_controlVars )
{
for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
{
- if( oldControlVars[i] != controlVars[i] )
+ if( oldControlVars[i] != p_controlVars[i] )
{
compCtrl[i]->setValue(
- (int)( controlVars[i] / comp_controls[i].f_resolution ) );
+ (int)( p_controlVars[i] / comp_controls[i].f_resolution ) );
}
}
}
void Compressor::setInitValues()
{
- setValues( controlVars );
+ setValues();
}
-void Compressor::setValues( float * controlVars )
+void Compressor::setValues()
{
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
{
: QWidget( _parent ) , p_intf( _p_intf )
{
QFont smallFont = QApplication::font();
- smallFont.setPointSize( smallFont.pointSize() - 3 );
+ smallFont.setPointSize( smallFont.pointSize() - 1 );
QGridLayout *layout = new QGridLayout( this );
for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
{
spatCtrl[i] = new QSlider( Qt::Vertical );
- if( i < 2 )
- {
- spatCtrl[i]->setMaximum( 10 );
- spatCtrl[i]->setValue( 2 );
- }
- else
- {
- spatCtrl[i]->setMaximum( 10 );
- spatCtrl[i]->setValue( 0 );
- spatCtrl[i]->setMinimum( -10 );
- }
-
+ spatCtrl[i]->setValue( (int)var_InheritFloat( p_intf, spat_controls[i].psz_name ) * 10. );
oldControlVars[i] = spatCtrl[i]->value();
CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
layout->addWidget( spatCtrl[i], 1, i, Qt::AlignHCenter );
layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
+ spatCtrl[i]->setRange( 0, 10 );
}
+ spatCtrl[0]->setRange( 0, 11 );
BUTTONACT( enableCheck, enable() );
/* Write down initial values */
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
char *psz_af;
if( p_aout )
enableCheck->setChecked( true );
free( psz_af );
enable( enableCheck->isChecked() );
- setValues( controlVars );
+ setValues();
}
void Spatializer::enable()
}
void Spatializer::setInitValues()
{
- setValues( controlVars );
+ setValues();
}
-void Spatializer::setValues( float *controlVars )
+void Spatializer::setValues()
{
- aout_instance_t *p_aout = THEMIM->getAout();
+ vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout();
for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
{
- float f = (float)( spatCtrl[i]->value() );
+ float f = (float)( spatCtrl[i]->value() ) / 10;
ctrl_readout[i]->setText( QString::number( f, 'f', 1 ) );
}
+
if( p_aout )
{
for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
{
+ float f = (float)( spatCtrl[i]->value() ) / 10 ;
if( oldControlVars[i] != spatCtrl[i]->value() )
{
- var_SetFloat( p_aout, spat_controls[i].psz_name,
- ( float )spatCtrl[i]->value() );
- config_PutFloat( p_intf, spat_controls[i].psz_name,
- ( float ) spatCtrl[i]->value() );
- oldControlVars[i] = ( float ) spatCtrl[i]->value();
+ var_SetFloat( p_aout, spat_controls[i].psz_name, f );
+ config_PutFloat( p_intf, spat_controls[i].psz_name, f );
+ oldControlVars[i] = spatCtrl[i]->value();
}
}
vlc_object_release( p_aout );
}
}
-void Spatializer::delCallbacks( aout_instance_t *p_aout )
+void Spatializer::delCallbacks( vlc_object_t *p_aout )
{
+ VLC_UNUSED( p_aout );
// var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this );
// var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
}
-void Spatializer::addCallbacks( aout_instance_t *p_aout )
+void Spatializer::addCallbacks( vlc_object_t *p_aout )
{
+ VLC_UNUSED( p_aout );
// var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this );
// var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
}
#include <QToolButton>
#include <QGridLayout>
+#define SUBSDELAY_CFG_MODE "subsdelay-mode"
+#define SUBSDELAY_CFG_FACTOR "subsdelay-factor"
+#define SUBSDELAY_MODE_ABSOLUTE 0
+#define SUBSDELAY_MODE_RELATIVE_SOURCE_DELAY 1
+#define SUBSDELAY_MODE_RELATIVE_SOURCE_CONTENT 2
+
+SyncWidget::SyncWidget( QWidget *_parent ) : QWidget( _parent )
+{
+ QHBoxLayout *layout = new QHBoxLayout;
+ spinBox.setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ spinBox.setDecimals( 3 );
+ spinBox.setMinimum( -600.0 );
+ spinBox.setMaximum( 600.0 );
+ spinBox.setSingleStep( 0.1 );
+ spinBox.setSuffix( " s" );
+ spinBox.setButtonSymbols( QDoubleSpinBox::PlusMinus );
+ CONNECT( &spinBox, valueChanged( double ), this, valueChangedHandler( double ) );
+ layout->addWidget( &spinBox );
+ layout->addWidget( &spinLabel );
+ layout->setContentsMargins( 0, 0, 0, 0 );
+ setLayout( layout );
+}
+
+void SyncWidget::valueChangedHandler( double d )
+{
+ if ( d < 0 )
+ spinLabel.setText( qtr("(Hastened)") );
+ else if ( d > 0 )
+ spinLabel.setText( qtr("(Delayed)") );
+ else
+ spinLabel.setText( "" );
+ emit valueChanged( d );
+}
+
+void SyncWidget::setValue( double d )
+{
+ spinBox.setValue( d );
+}
+
SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf )
{
QGroupBox *AVBox, *subsBox;
-
- QToolButton *moinsAV, *plusAV;
- QToolButton *moinssubs, *plussubs;
- QToolButton *moinssubSpeed, *plussubSpeed;
-
QToolButton *updateButton;
b_userAction = true;
AVBox = new QGroupBox( qtr( "Audio/Video" ) );
QGridLayout *AVLayout = new QGridLayout( AVBox );
- moinsAV = new QToolButton;
- moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
- moinsAV->setAutoRaise( true );
- moinsAV->setText( "-" );
- AVLayout->addWidget( moinsAV, 0, 1, 1, 1 );
-
- plusAV = new QToolButton;
- plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
- plusAV->setAutoRaise( true );
- plusAV->setText( "+" );
- AVLayout->addWidget( plusAV, 0, 3, 1, 1 );
-
QLabel *AVLabel = new QLabel;
- AVLabel->setText( qtr( "Advance of audio over video:" ) );
+ AVLabel->setText( qtr( "Audio track synchronization:" ) );
AVLayout->addWidget( AVLabel, 0, 0, 1, 1 );
- AVSpin = new QDoubleSpinBox;
- AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
- AVSpin->setDecimals( 3 );
- AVSpin->setMinimum( -600.0 );
- AVSpin->setMaximum( 600.0 );
- AVSpin->setSingleStep( 0.1 );
- AVSpin->setToolTip( qtr( "A positive value means that\n"
- "the audio is ahead of the video" ) );
- AVSpin->setSuffix( " s" );
+ AVSpin = new SyncWidget( this );
AVLayout->addWidget( AVSpin, 0, 2, 1, 1 );
mainLayout->addWidget( AVBox, 1, 0, 1, 5 );
-
/* Subs */
subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
QGridLayout *subsLayout = new QGridLayout( subsBox );
- moinssubs = new QToolButton;
- moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
- moinssubs->setAutoRaise( true );
- moinssubs->setText( "-" );
- subsLayout->addWidget( moinssubs, 0, 1, 1, 1 );
-
- plussubs = new QToolButton;
- plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
- plussubs->setAutoRaise( true );
- plussubs->setText( "+" );
- subsLayout->addWidget( plussubs, 0, 3, 1, 1 );
-
QLabel *subsLabel = new QLabel;
- subsLabel->setText( qtr( "Advance of subtitles over video:" ) );
+ subsLabel->setText( qtr( "Subtitle track syncronization:" ) );
subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
- subsSpin = new QDoubleSpinBox;
- subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
- subsSpin->setDecimals( 3 );
- subsSpin->setMinimum( -600.0 );
- subsSpin->setMaximum( 600.0 );
- subsSpin->setSingleStep( 0.1 );
- subsSpin->setToolTip( qtr( "A positive value means that\n"
- "the subtitles are ahead of the video" ) );
- subsSpin->setSuffix( " s" );
+ subsSpin = new SyncWidget( this );
subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
-
- moinssubSpeed = new QToolButton;
- moinssubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
- moinssubSpeed->setAutoRaise( true );
- moinssubSpeed->setText( "-" );
- subsLayout->addWidget( moinssubSpeed, 1, 1, 1, 1 );
-
- plussubSpeed = new QToolButton;
- plussubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
- plussubSpeed->setAutoRaise( true );
- plussubSpeed->setText( "+" );
- subsLayout->addWidget( plussubSpeed, 1, 3, 1, 1 );
-
QLabel *subSpeedLabel = new QLabel;
- subSpeedLabel->setText( qtr( "Speed of the subtitles:" ) );
+ subSpeedLabel->setText( qtr( "Subtitles speed:" ) );
subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 1 );
subSpeedSpin = new QDoubleSpinBox;
subSpeedSpin->setMaximum( 100 );
subSpeedSpin->setSingleStep( 0.2 );
subSpeedSpin->setSuffix( " fps" );
+ subSpeedSpin->setButtonSymbols( QDoubleSpinBox::PlusMinus );
subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
+ QLabel *subDurationLabel = new QLabel;
+ subDurationLabel->setText( qtr( "Subtitles duration factor:" ) );
+ subsLayout->addWidget( subDurationLabel, 2, 0, 1, 1 );
+
+ subDurationSpin = new QDoubleSpinBox;
+ subDurationSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ subDurationSpin->setDecimals( 3 );
+ subDurationSpin->setMinimum( 0 );
+ subDurationSpin->setMaximum( 20 );
+ subDurationSpin->setSingleStep( 0.2 );
+ subDurationSpin->setButtonSymbols( QDoubleSpinBox::PlusMinus );
+ subsLayout->addWidget( subDurationSpin, 2, 2, 1, 1 );
+
mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
updateButton = new QToolButton;
updateButton->setAutoRaise( true );
mainLayout->addWidget( updateButton, 0, 4, 1, 1 );
-
/* Various Connects */
- CONNECT( moinsAV, clicked(), AVSpin, stepDown () );
- CONNECT( plusAV, clicked(), AVSpin, stepUp () );
- CONNECT( moinssubs, clicked(), subsSpin, stepDown () );
- CONNECT( plussubs, clicked(), subsSpin, stepUp () );
- CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
- CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
CONNECT( subSpeedSpin, valueChanged ( double ),
this, adjustSubsSpeed( double ) );
+ CONNECT( subDurationSpin, valueChanged ( double ),
+ this, adjustSubsDuration( double ) );
CONNECT( THEMIM->getIM(), synchroChanged(), this, update() );
BUTTON_SET_ACT_I( updateButton, "", update,
qtr( "Force update of this dialog's values" ), update() );
+ initSubsDuration();
+
/* Set it */
update();
}
+SyncControls::~SyncControls()
+{
+ subsdelayClean();
+}
+
void SyncControls::clean()
{
b_userAction = false;
AVSpin->setValue( 0.0 );
subsSpin->setValue( 0.0 );
subSpeedSpin->setValue( 1.0 );
+ subsdelayClean();
b_userAction = true;
}
i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
subsSpin->setValue( ( (double)i_delay ) / 1000000 );
subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
+ subDurationSpin->setValue( var_InheritFloat( p_intf, SUBSDELAY_CFG_FACTOR ) );
}
b_userAction = true;
}
}
}
+void SyncControls::adjustSubsDuration( double f_factor )
+{
+ if( THEMIM->getInput() && b_userAction )
+ {
+ subsdelaySetFactor( f_factor );
+ ChangeVFiltersString( p_intf, "subsdelay", f_factor > 0 );
+ }
+}
+
+void SyncControls::initSubsDuration()
+{
+ int i_mode = var_InheritInteger( p_intf, SUBSDELAY_CFG_MODE );
+
+ switch (i_mode)
+ {
+ default:
+ case SUBSDELAY_MODE_ABSOLUTE:
+ subDurationSpin->setToolTip( qtr( "Extend subtitles duration by this value.\n"
+ "Set 0 to disable." ) );
+ subDurationSpin->setSuffix( " s" );
+ break;
+ case SUBSDELAY_MODE_RELATIVE_SOURCE_DELAY:
+ subDurationSpin->setToolTip( qtr( "Multiply subtitles duration by this value.\n"
+ "Set 0 to disable." ) );
+ subDurationSpin->setSuffix( "" );
+ break;
+ case SUBSDELAY_MODE_RELATIVE_SOURCE_CONTENT:
+ subDurationSpin->setToolTip( qtr( "Recalculate subtitles duration according\n"
+ "to their content and this value.\n"
+ "Set 0 to disable." ) );
+ subDurationSpin->setSuffix( "" );
+ break;
+ }
+}
+
+void SyncControls::subsdelayClean()
+{
+ /* Remove subsdelay filter */
+ ChangeVFiltersString( p_intf, "subsdelay", false );
+}
+
+void SyncControls::subsdelaySetFactor( double f_factor )
+{
+ /* Set the factor in the preferences */
+ config_PutFloat( p_intf, SUBSDELAY_CFG_FACTOR, f_factor );
+
+ /* Try to find an instance of subsdelay, and set its factor */
+ vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_find_name( p_intf->p_libvlc, "subsdelay" );
+ if( p_obj )
+ {
+ var_SetFloat( p_obj, SUBSDELAY_CFG_FACTOR, f_factor );
+ vlc_object_release( p_obj );
+ }
+}
+
+
/**********************************************************************
* Video filters / Adjust
**********************************************************************/