Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
a7c6e19e
Commit
a7c6e19e
authored
Nov 05, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spatializer: convert to audio filter2
parent
8d266a98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
54 deletions
+39
-54
modules/audio_filter/spatializer/spatializer.cpp
modules/audio_filter/spatializer/spatializer.cpp
+39
-54
No files found.
modules/audio_filter/spatializer/spatializer.cpp
View file @
a7c6e19e
...
@@ -40,6 +40,7 @@ using std::nothrow;
...
@@ -40,6 +40,7 @@ using std::nothrow;
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
#include "revmodel.hpp"
#include "revmodel.hpp"
#define SPAT_AMP 0.3
#define SPAT_AMP 0.3
...
@@ -69,7 +70,7 @@ static void Close( vlc_object_t * );
...
@@ -69,7 +70,7 @@ static void Close( vlc_object_t * );
vlc_module_begin
()
vlc_module_begin
()
set_description
(
N_
(
"Audio Spatializer"
)
)
set_description
(
N_
(
"Audio Spatializer"
)
)
set_shortname
(
N_
(
"Spatializer"
)
)
set_shortname
(
N_
(
"Spatializer"
)
)
set_capability
(
"audio filter"
,
0
)
set_capability
(
"audio filter
2
"
,
0
)
set_category
(
CAT_AUDIO
)
set_category
(
CAT_AUDIO
)
set_subcategory
(
SUBCAT_AUDIO_AFILTER
)
set_subcategory
(
SUBCAT_AUDIO_AFILTER
)
...
@@ -86,7 +87,7 @@ vlc_module_end ()
...
@@ -86,7 +87,7 @@ vlc_module_end ()
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
struct
aout_
filter_sys_t
struct
filter_sys_t
{
{
vlc_mutex_t
lock
;
vlc_mutex_t
lock
;
revmodel
*
p_reverbm
;
revmodel
*
p_reverbm
;
...
@@ -118,46 +119,37 @@ static const callback_s callbacks[] = {
...
@@ -118,46 +119,37 @@ static const callback_s callbacks[] = {
};
};
enum
{
num_callbacks
=
sizeof
(
callbacks
)
/
sizeof
(
callback_s
)
};
enum
{
num_callbacks
=
sizeof
(
callbacks
)
/
sizeof
(
callback_s
)
};
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
static
block_t
*
DoWork
(
filter_t
*
,
block_t
*
);
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
/*****************************************************************************
* Open:
* Open:
*****************************************************************************/
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
aout_filter_sys_t
*
p_sys
;
filter_sys_t
*
p_sys
;
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
vlc_object_t
*
p_aout
=
p_filter
->
p_parent
;
bool
b_fit
=
true
;
msg_Dbg
(
p_this
,
"Opening filter spatializer"
);
if
(
p_filter
->
fmt_in
.
audio
.
i_format
!=
VLC_CODEC_FL32
||
if
(
p_filter
->
fmt_in
.
audio
.
i_format
!=
VLC_CODEC_FL32
||
p_filter
->
fmt_out
.
audio
.
i_format
!=
VLC_CODEC_FL32
)
p_filter
->
fmt_out
.
audio
.
i_format
!=
VLC_CODEC_FL32
)
{
{
b_fit
=
false
;
p_filter
->
fmt_in
.
audio
.
i_format
=
VLC_CODEC_FL32
;
p_filter
->
fmt_in
.
audio
.
i_format
=
VLC_CODEC_FL32
;
p_filter
->
fmt_out
.
audio
.
i_format
=
VLC_CODEC_FL32
;
p_filter
->
fmt_out
.
audio
.
i_format
=
VLC_CODEC_FL32
;
msg_Warn
(
p_filter
,
"bad input or output format"
);
msg_Warn
(
p_filter
,
"bad input or output format"
);
return
VLC_EGENERIC
;
}
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
fmt_in
.
audio
,
&
p_filter
->
fmt_out
.
audio
)
)
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
fmt_in
.
audio
,
&
p_filter
->
fmt_out
.
audio
)
)
{
{
b_fit
=
false
;
memcpy
(
&
p_filter
->
fmt_out
.
audio
,
&
p_filter
->
fmt_in
.
audio
,
memcpy
(
&
p_filter
->
fmt_out
.
audio
,
&
p_filter
->
fmt_in
.
audio
,
sizeof
(
audio_sample_format_t
)
);
sizeof
(
audio_sample_format_t
)
);
msg_Warn
(
p_filter
,
"input and output formats are not similar"
);
msg_Warn
(
p_filter
,
"input and output formats are not similar"
);
}
if
(
!
b_fit
)
{
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
pf_audio_filter
=
DoWork
;
p_filter
->
b_in_place
=
true
;
/* Allocate structure */
/* Allocate structure */
p_sys
=
p_filter
->
p_sys
=
(
aout_filter_sys_t
*
)
malloc
(
sizeof
(
aout_filter_sys_t
)
);
p_sys
=
p_filter
->
p_sys
=
(
filter_sys_t
*
)
malloc
(
sizeof
(
*
p_sys
)
);
if
(
!
p_sys
)
if
(
!
p_sys
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
...
@@ -189,9 +181,9 @@ static int Open( vlc_object_t *p_this )
...
@@ -189,9 +181,9 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
*****************************************************************************/
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
{
aout_filter_t
*
p_filter
=
(
aout_
filter_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
aout_
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_filter
->
p_parent
;
vlc_object_t
*
p_aout
=
p_filter
->
p_parent
;
/* Delete the callbacks */
/* Delete the callbacks */
for
(
unsigned
i
=
0
;
i
<
num_callbacks
;
++
i
)
for
(
unsigned
i
=
0
;
i
<
num_callbacks
;
++
i
)
...
@@ -211,17 +203,15 @@ static void Close( vlc_object_t *p_this )
...
@@ -211,17 +203,15 @@ static void Close( vlc_object_t *p_this )
* DoWork: call SpatFilter
* DoWork: call SpatFilter
*****************************************************************************/
*****************************************************************************/
static
inline
static
void
SpatFilter
(
filter_t
*
p_filter
,
float
*
out
,
float
*
in
,
void
SpatFilter
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
unsigned
i_samples
,
unsigned
i_channels
)
float
*
out
,
float
*
in
,
int
i_samples
,
int
i_channels
)
{
{
aout_
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
int
i
,
ch
;
for
(
unsigned
i
=
0
;
i
<
i_samples
;
i
++
)
for
(
i
=
0
;
i
<
i_samples
;
i
++
)
{
{
for
(
ch
=
0
;
ch
<
2
;
ch
++
)
for
(
unsigned
ch
=
0
;
ch
<
2
;
ch
++
)
{
{
in
[
ch
]
=
in
[
ch
]
*
SPAT_AMP
;
in
[
ch
]
=
in
[
ch
]
*
SPAT_AMP
;
}
}
...
@@ -231,15 +221,12 @@ void SpatFilter( aout_instance_t *p_aout, aout_filter_t *p_filter,
...
@@ -231,15 +221,12 @@ void SpatFilter( aout_instance_t *p_aout, aout_filter_t *p_filter,
}
}
}
}
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
static
block_t
*
DoWork
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
)
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
{
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
SpatFilter
(
p_filter
,
(
float
*
)
p_in_buf
->
p_buffer
,
p_out_buf
->
i_buffer
=
p_in_buf
->
i_buffer
;
SpatFilter
(
p_aout
,
p_filter
,
(
float
*
)
p_out_buf
->
p_buffer
,
(
float
*
)
p_in_buf
->
p_buffer
,
p_in_buf
->
i_nb_samples
,
(
float
*
)
p_in_buf
->
p_buffer
,
p_in_buf
->
i_nb_samples
,
aout_FormatNbChannels
(
&
p_filter
->
fmt_in
.
audio
)
);
aout_FormatNbChannels
(
&
p_filter
->
fmt_in
.
audio
)
);
return
p_in_buf
;
}
}
...
@@ -247,11 +234,10 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
...
@@ -247,11 +234,10 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
* Variables callbacks
* Variables callbacks
*****************************************************************************/
*****************************************************************************/
static
int
RoomCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
static
int
RoomCallback
(
vlc_object_t
*
p_this
,
char
const
*
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
vlc_value_t
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
(
void
)
psz_cmd
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
aout_filter_sys_t
*
p_sys
=
(
aout_filter_sys_t
*
)
p_data
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
p_sys
->
p_reverbm
->
setroomsize
(
newval
.
f_float
);
p_sys
->
p_reverbm
->
setroomsize
(
newval
.
f_float
);
...
@@ -259,44 +245,43 @@ static int RoomCallback( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -259,44 +245,43 @@ static int RoomCallback( vlc_object_t *p_this, char const *psz_cmd,
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
WidthCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
static
int
WidthCallback
(
vlc_object_t
*
p_this
,
char
const
*
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
vlc_value_t
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
(
void
)
psz_cmd
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
aout_filter_sys_t
*
p_sys
=
(
aout_filter_sys_t
*
)
p_data
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
p_sys
->
p_reverbm
->
setwidth
(
newval
.
f_float
);
p_sys
->
p_reverbm
->
setwidth
(
newval
.
f_float
);
msg_Dbg
(
p_this
,
"width is now %3.1f"
,
newval
.
f_float
);
msg_Dbg
(
p_this
,
"width is now %3.1f"
,
newval
.
f_float
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
WetCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
static
int
WetCallback
(
vlc_object_t
*
p_this
,
char
const
*
,
vlc_value_t
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
(
void
)
psz_cmd
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
aout_filter_sys_t
*
p_sys
=
(
aout_filter_sys_t
*
)
p_data
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
p_sys
->
p_reverbm
->
setwet
(
newval
.
f_float
);
p_sys
->
p_reverbm
->
setwet
(
newval
.
f_float
);
msg_Dbg
(
p_this
,
"'wet' value is now %3.1f"
,
newval
.
f_float
);
msg_Dbg
(
p_this
,
"'wet' value is now %3.1f"
,
newval
.
f_float
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
DryCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
static
int
DryCallback
(
vlc_object_t
*
p_this
,
char
const
*
,
vlc_value_t
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
(
void
)
psz_cmd
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
aout_filter_sys_t
*
p_sys
=
(
aout_filter_sys_t
*
)
p_data
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
p_sys
->
p_reverbm
->
setdry
(
newval
.
f_float
);
p_sys
->
p_reverbm
->
setdry
(
newval
.
f_float
);
msg_Dbg
(
p_this
,
"'dry' value is now %3.1f"
,
newval
.
f_float
);
msg_Dbg
(
p_this
,
"'dry' value is now %3.1f"
,
newval
.
f_float
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
DampCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
static
int
DampCallback
(
vlc_object_t
*
p_this
,
char
const
*
,
vlc_value_t
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
(
void
)
psz_cmd
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
aout_filter_sys_t
*
p_sys
=
(
aout_filter_sys_t
*
)
p_data
;
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
vlc_mutex_locker
locker
(
&
p_sys
->
lock
);
p_sys
->
p_reverbm
->
setdamp
(
newval
.
f_float
);
p_sys
->
p_reverbm
->
setdamp
(
newval
.
f_float
);
...
...
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