#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <assert.h>
#include <string.h>
#include <vlc_common.h>
#include <vlc_filter.h>
#include <vlc_image.h>
-#include <vlc_osd.h>
-
-#include <vlc_memory.h>
#ifdef LoadImage
# undef LoadImage
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-
+
#define I_VALUES_TEXT N_("Value of the audio channels levels")
-#define I_VALUES_LONGTEXT N_("Value of the audio level of each channels between 0 and 1" \
+#define I_VALUES_LONGTEXT N_("Value of the audio level of each channels between 0 and 1. " \
"Each level should be separated with ':'.")
#define POSX_TEXT N_("X coordinate")
#define POSX_LONGTEXT N_("X coordinate of the bargraph." )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
- set_capability( "sub filter", 0 )
+ set_capability( "sub source", 0 )
set_callbacks( OpenSub, Close )
- set_description( N_("Audio Bar Graph Video sub filter") )
+ set_description( N_("Audio Bar Graph Video sub source") )
set_shortname( N_("Audio Bar Graph Video") )
add_shortcut( "audiobargraph_v" )
- add_string( CFG_PREFIX "i_values", NULL, NULL, I_VALUES_TEXT, I_VALUES_LONGTEXT, false )
- add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true )
- add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true )
- add_integer_with_range( CFG_PREFIX "transparency", 255, 0, 255, NULL,
+ add_string( CFG_PREFIX "i_values", NULL, I_VALUES_TEXT, I_VALUES_LONGTEXT, false )
+ add_integer( CFG_PREFIX "x", 0, POSX_TEXT, POSX_LONGTEXT, true )
+ add_integer( CFG_PREFIX "y", 0, POSY_TEXT, POSY_LONGTEXT, true )
+ add_integer_with_range( CFG_PREFIX "transparency", 255, 0, 255,
TRANS_TEXT, TRANS_LONGTEXT, false )
- add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false )
- change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
- add_integer( CFG_PREFIX "alarm", 0, NULL, ALARM_TEXT, ALARM_LONGTEXT, true )
- add_integer( CFG_PREFIX "barWidth", 10, NULL, BARWIDTH_TEXT, BARWIDTH_LONGTEXT, true )
+ add_integer( CFG_PREFIX "position", -1, POS_TEXT, POS_LONGTEXT, false )
+ change_integer_list( pi_pos_values, ppsz_pos_descriptions )
+ add_integer( CFG_PREFIX "alarm", 0, ALARM_TEXT, ALARM_LONGTEXT, true )
+ add_integer( CFG_PREFIX "barWidth", 10, BARWIDTH_TEXT, BARWIDTH_LONGTEXT, true )
/* video output filter submodule */
add_submodule ()
set_capability( "video filter2", 0 )
set_callbacks( OpenVideo, Close )
- set_description( N_("Audio Bar Graph Video sub filter") )
+ set_description( N_("Audio Bar Graph Video sub source") )
add_shortcut( "audiobargraph_v" )
vlc_module_end ()
filter_t *p_blend;
vlc_mutex_t lock;
-
+
BarGraph_t p_BarGraph;
int i_pos;
void parse_i_values( BarGraph_t *p_BarGraph, char *i_values);
/**
- * Open the sub filter
+ * Open the sub source
*/
static int OpenSub( vlc_object_t *p_this )
{
p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" );
p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter,
"audiobargraph_v-transparency" );
- p_BarGraph->i_alpha = __MAX( __MIN( p_BarGraph->i_alpha, 255 ), 0 );
+ p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 );
i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" );
//p_BarGraph->nbChannels = 0;
//p_BarGraph->i_values = NULL;
/* Misc init */
if( b_sub )
{
- p_filter->pf_sub_filter = FilterSub;
+ p_filter->pf_sub_source = FilterSub;
}
else
{
filter_DeleteBlend( p_sys->p_blend );
vlc_mutex_destroy( &p_sys->lock );
-
+
if( p_BarGraph->p_pic )
{
picture_Release( p_BarGraph->p_pic );
p_BarGraph->p_pic = NULL;
}
free( p_BarGraph->i_values );
-
+
free( p_sys );
}
/**
- * Sub filter
+ * Sub source
*/
static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
{
/* Create new SPU region */
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_CODEC_YUVA;
- fmt.i_aspect = VOUT_ASPECT_FACTOR;
fmt.i_sar_num = fmt.i_sar_den = 1;
fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
/* where to locate the bar graph: */
if( p_sys->i_pos < 0 )
{ /* set to an absolute xy */
- p_region->i_align = OSD_ALIGN_RIGHT | OSD_ALIGN_TOP;
+ p_region->i_align = SUBPICTURE_ALIGN_RIGHT | SUBPICTURE_ALIGN_TOP;
p_spu->b_absolute = true;
}
else
}
else if ( !strcmp( psz_var, "audiobargraph_v-transparency" ) )
{
- p_BarGraph->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
+ p_BarGraph->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
}
else if ( !strcmp( psz_var, "audiobargraph_v-i_values" ) )
{
int i_width = 0;
int i_line;
int moinsTrois, moinsCinq, moinsSept, moinsDix, moinsVingt;
-
+
if (nbChannels == 0) {
i_width = 20;
} else {
i_width = 2 * nbChannels * barWidth + 10;
}
-
+
moinsTrois = 0.71*scale + 20;
moinsCinq = 0.56*scale + 20;
moinsSept = 0.45*scale + 20;
moinsDix = 0.32*scale + 20;
moinsVingt = 0.1*scale + 20;
-
- p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), i_width+20, scale+30, VOUT_ASPECT_FACTOR * (i_width+20)/(scale+30));
-
+
+ p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), i_width+20, scale+30, 1, 1);
+
// blacken the whole picture
for( i = 0 ; i < p_pic->i_planes ; i++ )
{
memset( p_pic->p[i].p_pixels, 0x00,
p_pic->p[i].i_visible_lines * p_pic->p[i].i_pitch );
}
-
+
// side bar
for ( i_line = 20; i_line < scale+20; i_line++ ) {
-
+
#define DrawPointsBlack(a,b) {\
for (i=a; i<b; i++) {\
*(p_pic->p[0].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[0].i_pitch + i ) = 0x00; \
*(p_pic->p[2].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[2].i_pitch + i ) = 128;\
*(p_pic->p[3].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[3].i_pitch + i ) = 0xFF; \
}\
- }
-
+ }
+
// vertical line
DrawPointsBlack(20,22);
DrawPointsWhite(22,24);
-
+
// -3dB
if (i_line == moinsTrois - 2) {
// 3
// 3
DrawPointsBlack(16,19);
}
-
+
// -5dB
if (i_line == moinsCinq - 2) {
// 5
// 5
DrawPointsBlack(16,19);
}
-
+
// -7dB
if (i_line == moinsSept - 2) {
// 7
// 7
DrawPointsBlack(16,19);
}
-
-
+
+
// -10dB
if (i_line == moinsDix - 2) {
// 1
// 0
DrawPointsBlack(16,19);
}
-
+
// -20dB
if (i_line == moinsVingt - 2) {
// 2
// 0
DrawPointsBlack(16,19);
}
-
-
+
+
}
-
+
// draw the bars and channel indicators
for (i=0; i<nbChannels; i++) {
for( j = barWidth+20 ; j < 2*barWidth+20; j++)
}
}
}
-
-
-
+
+
+
if (alarm) {// draw the alarm square
// bottom
for ( i_line = 0; i_line < 10; i_line++ ) {
}
}
}
-
+
return p_pic;
}
res = strtok_r(i_values, delim, &tok);
while (res != NULL) {
p_BarGraph->nbChannels++;
- p_BarGraph->i_values = realloc_or_free(p_BarGraph->i_values,
+ p_BarGraph->i_values = xrealloc(p_BarGraph->i_values,
p_BarGraph->nbChannels*sizeof(int));
- assert(p_BarGraph->i_values);
- p_BarGraph->i_values[p_BarGraph->nbChannels-1] = __MAX( __MIN( atof(res)*p_BarGraph->scale, p_BarGraph->scale ), 0 );
+ p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP( atof(res)*p_BarGraph->scale, 0, p_BarGraph->scale );
res = strtok_r(NULL, delim, &tok);
}