Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
fe52be6f
Commit
fe52be6f
authored
Mar 20, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audiobargraph: use variable & callback for audio values (refs #9491)
Also fix potential buffer overflow with snprintf().
parent
f2092cbf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
25 deletions
+31
-25
modules/audio_filter/audiobargraph_a.c
modules/audio_filter/audiobargraph_a.c
+15
-13
modules/video_filter/audiobargraph_v.c
modules/video_filter/audiobargraph_v.c
+16
-12
No files found.
modules/audio_filter/audiobargraph_a.c
View file @
fe52be6f
...
@@ -159,6 +159,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -159,6 +159,7 @@ static int Open( vlc_object_t *p_this )
p_filter
->
pf_audio_filter
=
DoWork
;
p_filter
->
pf_audio_filter
=
DoWork
;
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
,
VLC_VAR_STRING
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -169,12 +170,11 @@ static int Open( vlc_object_t *p_this )
...
@@ -169,12 +170,11 @@ static int Open( vlc_object_t *p_this )
static
block_t
*
DoWork
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
)
static
block_t
*
DoWork
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
)
{
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
int
i
,
j
;
int
i
;
float
*
p_sample
=
(
float
*
)
p_in_buf
->
p_buffer
;
float
*
p_sample
=
(
float
*
)
p_in_buf
->
p_buffer
;
float
i_value
[
AOUT_CHAN_MAX
];
float
i_value
[
AOUT_CHAN_MAX
];
float
ch
;
float
ch
;
float
max
=
0
.
0
;
float
max
=
0
.
0
;
char
message
[
255
];
int
nbChannels
=
0
;
int
nbChannels
=
0
;
ValueDate_t
*
current
=
NULL
;
ValueDate_t
*
current
=
NULL
;
float
sum
;
float
sum
;
...
@@ -190,7 +190,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
...
@@ -190,7 +190,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
/* 1 - Compute the peack values */
/* 1 - Compute the peack values */
for
(
i
=
0
;
i
<
(
int
)(
p_in_buf
->
i_nb_samples
);
i
++
)
for
(
i
=
0
;
i
<
(
int
)(
p_in_buf
->
i_nb_samples
);
i
++
)
{
{
for
(
j
=
0
;
j
<
nbChannels
;
j
++
)
{
for
(
int
j
=
0
;
j
<
nbChannels
;
j
++
)
{
ch
=
(
*
p_sample
++
);
ch
=
(
*
p_sample
++
);
if
(
ch
>
i_value
[
j
])
if
(
ch
>
i_value
[
j
])
i_value
[
j
]
=
ch
;
i_value
[
j
]
=
ch
;
...
@@ -255,18 +255,20 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
...
@@ -255,18 +255,20 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
if
(
p_sys
->
bargraph
)
{
if
(
p_sys
->
bargraph
)
{
/* 6 - sent the message with the values for the BarGraph */
/* 6 - sent the message with the values for the BarGraph */
if
((
nbChannels
>
0
)
&&
(
p_sys
->
counter
%
(
p_sys
->
bargraph_repetition
)
==
0
))
{
if
((
nbChannels
>
0
)
&&
(
p_sys
->
counter
%
(
p_sys
->
bargraph_repetition
)
==
0
))
{
j
=
snprintf
(
message
,
255
,
"@audiobargraph_v audiobargraph_v-i_values "
);
char
message
[
256
];
for
(
i
=
0
;
i
<
(
nbChannels
-
1
);
i
++
)
{
size_t
j
=
0
;
j
+=
snprintf
(
message
+
j
,
255
,
"%f:"
,
i_value
[
i
]);
}
snprintf
(
message
+
j
,
255
,
"%f
\n
"
,
i_value
[
nbChannels
-
1
]);
msg_Dbg
(
p_filter
,
"message values : %s"
,
message
);
//test = send(p_sys->TCPconnection,message,strlen(message),0);
for
(
i
=
0
;
i
<
nbChannels
;
i
++
)
{
//net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
if
(
j
>=
sizeof
(
message
))
break
;
j
+=
snprintf
(
message
+
j
,
sizeof
(
message
),
"%f:"
,
i_value
[
i
]);
}
net_Write
(
p_filter
,
p_sys
->
TCPconnection
,
NULL
,
message
,
strlen
(
message
));
message
[
--
j
]
=
'\0'
;
msg_Dbg
(
p_filter
,
"values: %s"
,
message
);
var_SetString
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
,
message
);
}
}
}
}
...
@@ -278,7 +280,6 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
...
@@ -278,7 +280,6 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
p_sys
->
counter
=
0
;
p_sys
->
counter
=
0
;
}
}
//free(message);
p_sys
->
counter
++
;
p_sys
->
counter
++
;
return
p_in_buf
;
return
p_in_buf
;
...
@@ -293,6 +294,7 @@ static void Close( vlc_object_t *p_this )
...
@@ -293,6 +294,7 @@ static void Close( vlc_object_t *p_this )
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
ValueDate_t
*
current
;
ValueDate_t
*
current
;
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
);
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
p_sys
->
last
=
NULL
;
p_sys
->
last
=
NULL
;
...
...
modules/video_filter/audiobargraph_v.c
View file @
fe52be6f
...
@@ -45,9 +45,6 @@
...
@@ -45,9 +45,6 @@
* Module descriptor
* 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. " \
"Each level should be separated with ':'.")
#define POSX_TEXT N_("X coordinate")
#define POSX_TEXT N_("X coordinate")
#define POSX_LONGTEXT N_("X coordinate of the bargraph." )
#define POSX_LONGTEXT N_("X coordinate of the bargraph." )
#define POSY_TEXT N_("Y coordinate")
#define POSY_TEXT N_("Y coordinate")
...
@@ -86,7 +83,7 @@ vlc_module_begin ()
...
@@ -86,7 +83,7 @@ vlc_module_begin ()
set_shortname
(
N_
(
"Audio Bar Graph Video"
)
)
set_shortname
(
N_
(
"Audio Bar Graph Video"
)
)
add_shortcut
(
"audiobargraph_v"
)
add_shortcut
(
"audiobargraph_v"
)
add_
string
(
CFG_PREFIX
"i_values"
,
NULL
,
I_VALUES_TEXT
,
I_VALUES_LONGTEXT
,
false
)
add_
obsolete_string
(
CFG_PREFIX
"i_values"
)
add_integer
(
CFG_PREFIX
"x"
,
0
,
POSX_TEXT
,
POSX_LONGTEXT
,
true
)
add_integer
(
CFG_PREFIX
"x"
,
0
,
POSX_TEXT
,
POSX_LONGTEXT
,
true
)
add_integer
(
CFG_PREFIX
"y"
,
0
,
POSY_TEXT
,
POSY_LONGTEXT
,
true
)
add_integer
(
CFG_PREFIX
"y"
,
0
,
POSY_TEXT
,
POSY_LONGTEXT
,
true
)
add_integer_with_range
(
CFG_PREFIX
"transparency"
,
255
,
0
,
255
,
add_integer_with_range
(
CFG_PREFIX
"transparency"
,
255
,
0
,
255
,
...
@@ -146,11 +143,10 @@ struct filter_sys_t
...
@@ -146,11 +143,10 @@ struct filter_sys_t
};
};
static
const
char
*
const
ppsz_filter_options
[]
=
{
static
const
char
*
const
ppsz_filter_options
[]
=
{
"
i_values"
,
"
x"
,
"y"
,
"transparency"
,
"position"
,
"barWidth"
,
NULL
"x"
,
"y"
,
"transparency"
,
"position"
,
"barWidth"
,
NULL
};
};
static
const
char
*
const
ppsz_filter_callbacks
[]
=
{
static
const
char
*
const
ppsz_filter_callbacks
[]
=
{
"audiobargraph_v-i_values"
,
"audiobargraph_v-x"
,
"audiobargraph_v-x"
,
"audiobargraph_v-y"
,
"audiobargraph_v-y"
,
"audiobargraph_v-transparency"
,
"audiobargraph_v-transparency"
,
...
@@ -238,10 +234,9 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
...
@@ -238,10 +234,9 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
p_BarGraph
->
i_alpha
=
var_CreateGetIntegerCommand
(
p_filter
,
p_BarGraph
->
i_alpha
=
var_CreateGetIntegerCommand
(
p_filter
,
"audiobargraph_v-transparency"
);
"audiobargraph_v-transparency"
);
p_BarGraph
->
i_alpha
=
VLC_CLIP
(
p_BarGraph
->
i_alpha
,
0
,
255
);
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->nbChannels = 0;
//p_BarGraph->i_values = NULL;
//p_BarGraph->i_values = NULL;
parse_i_values
(
p_BarGraph
,
i_values
);
parse_i_values
(
p_BarGraph
,
&
(
char
){
0
}
);
p_BarGraph
->
alarm
=
false
;
p_BarGraph
->
alarm
=
false
;
p_BarGraph
->
barWidth
=
var_CreateGetIntegerCommand
(
p_filter
,
"audiobargraph_v-barWidth"
);
p_BarGraph
->
barWidth
=
var_CreateGetIntegerCommand
(
p_filter
,
"audiobargraph_v-barWidth"
);
...
@@ -254,10 +249,15 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
...
@@ -254,10 +249,15 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
vlc_mutex_init
(
&
p_sys
->
lock
);
vlc_mutex_init
(
&
p_sys
->
lock
);
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
,
VLC_VAR_STRING
);
var_AddCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
var_AddCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
BarGraphCallback
,
p_sys
);
BarGraphCallback
,
p_sys
);
var_AddCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
,
BarGraphCallback
,
p_sys
);
var_TriggerCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
var_TriggerCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
var_TriggerCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
);
for
(
int
i
=
0
;
ppsz_filter_callbacks
[
i
];
i
++
)
for
(
int
i
=
0
;
ppsz_filter_callbacks
[
i
];
i
++
)
var_AddCallback
(
p_filter
,
ppsz_filter_callbacks
[
i
],
var_AddCallback
(
p_filter
,
ppsz_filter_callbacks
[
i
],
...
@@ -290,8 +290,11 @@ static void Close( vlc_object_t *p_this )
...
@@ -290,8 +290,11 @@ static void Close( vlc_object_t *p_this )
var_DelCallback
(
p_filter
,
ppsz_filter_callbacks
[
i
],
var_DelCallback
(
p_filter
,
ppsz_filter_callbacks
[
i
],
BarGraphCallback
,
p_sys
);
BarGraphCallback
,
p_sys
);
var_DelCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
,
BarGraphCallback
,
p_sys
);
var_DelCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
var_DelCallback
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
,
BarGraphCallback
,
p_sys
);
BarGraphCallback
,
p_sys
);
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-i_values"
);
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
var_Destroy
(
p_filter
->
p_libvlc
,
"audiobargraph_v-alarm"
);
if
(
p_sys
->
p_blend
)
if
(
p_sys
->
p_blend
)
...
@@ -495,16 +498,17 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
...
@@ -495,16 +498,17 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
picture_Release
(
p_BarGraph
->
p_pic
);
picture_Release
(
p_BarGraph
->
p_pic
);
p_BarGraph
->
p_pic
=
NULL
;
p_BarGraph
->
p_pic
=
NULL
;
}
}
char
*
psz_i_values
=
strdup
(
newval
.
psz_string
);
char
*
psz
=
xstrdup
(
newval
.
psz_string
?
newval
.
psz_string
:
""
);
free
(
p_BarGraph
->
i_values
);
free
(
p_BarGraph
->
i_values
);
//p_BarGraph->i_values = NULL;
//p_BarGraph->i_values = NULL;
//p_BarGraph->nbChannels = 0;
//p_BarGraph->nbChannels = 0;
// in case many answer are received at the same time, only keep one
// in case many answer are received at the same time, only keep one
res
=
strchr
(
psz
_i_values
,
'@'
);
res
=
strchr
(
psz
,
'@'
);
if
(
res
)
if
(
res
)
*
res
=
0
;
*
res
=
0
;
parse_i_values
(
p_BarGraph
,
psz
_i_values
);
parse_i_values
(
p_BarGraph
,
psz
);
free
(
psz
_i_values
);
free
(
psz
);
LoadBarGraph
(
p_this
,
p_BarGraph
);
LoadBarGraph
(
p_this
,
p_BarGraph
);
}
}
else
if
(
!
strcmp
(
psz_var
,
"audiobargraph_v-alarm"
)
)
else
if
(
!
strcmp
(
psz_var
,
"audiobargraph_v-alarm"
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment