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
595b2a8e
Commit
595b2a8e
authored
Nov 21, 2007
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* simple.c: Extended the filter for mono output, and also converted it to the
audio_filter2 architecture.
parent
95d126fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
156 additions
and
8 deletions
+156
-8
modules/audio_filter/channel_mixer/simple.c
modules/audio_filter/channel_mixer/simple.c
+156
-8
No files found.
modules/audio_filter/channel_mixer/simple.c
View file @
595b2a8e
...
@@ -24,9 +24,10 @@
...
@@ -24,9 +24,10 @@
/*****************************************************************************
/*****************************************************************************
* Preamble
* Preamble
*****************************************************************************/
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/vlc.h>
#include <vlc_aout.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
#include <vlc_block.h>
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
...
@@ -36,6 +37,9 @@ static int Create ( vlc_object_t * );
...
@@ -36,6 +37,9 @@ static int Create ( vlc_object_t * );
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
aout_buffer_t
*
);
static
int
OpenFilter
(
vlc_object_t
*
);
static
block_t
*
Filter
(
filter_t
*
,
block_t
*
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
...
@@ -45,6 +49,11 @@ vlc_module_begin();
...
@@ -45,6 +49,11 @@ vlc_module_begin();
set_category
(
CAT_AUDIO
);
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_callbacks
(
Create
,
NULL
);
set_callbacks
(
Create
,
NULL
);
add_submodule
();
set_description
(
_
(
"audio filter for simple channel mixing"
)
);
set_capability
(
"audio filter2"
,
10
);
set_callbacks
(
OpenFilter
,
NULL
);
vlc_module_end
();
vlc_module_end
();
/*****************************************************************************
/*****************************************************************************
...
@@ -65,24 +74,27 @@ static int Create( vlc_object_t *p_this )
...
@@ -65,24 +74,27 @@ static int Create( vlc_object_t *p_this )
return
-
1
;
return
-
1
;
}
}
/* Only conversion to Stereo and 4.0 right now */
/* Only conversion to
Mono,
Stereo and 4.0 right now */
if
(
p_filter
->
output
.
i_physical_channels
!=
if
(
p_filter
->
output
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
)
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
)
&&
p_filter
->
output
.
i_physical_channels
!=
&&
p_filter
->
output
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
)
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
{
&&
p_filter
->
output
.
i_physical_channels
!=
AOUT_CHAN_CENTER
)
return
-
1
;
{
}
return
-
1
;
}
/* Only from 7/7.1/5/5.1 */
/* Only from 7/7.1/5/5.1
/2.0
*/
if
(
(
p_filter
->
input
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
if
(
(
p_filter
->
input
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
(
p_filter
->
input
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
(
p_filter
->
input
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
AOUT_CHAN_MIDDLELEFT
|
AOUT_CHAN_MIDDLERIGHT
|
AOUT_CHAN_MIDDLELEFT
|
AOUT_CHAN_MIDDLERIGHT
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
)
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
p_filter
->
input
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
)
)
{
{
return
-
1
;
return
-
1
;
}
}
...
@@ -136,6 +148,37 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
...
@@ -136,6 +148,37 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
}
}
else
if
(
p_filter
->
output
.
i_physical_channels
==
AOUT_CHAN_CENTER
)
{
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_MIDDLELEFT
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
6
]
+
p_src
[
0
]
/
4
+
p_src
[
1
]
/
4
+
p_src
[
2
]
/
8
+
p_src
[
3
]
/
8
+
p_src
[
4
]
/
8
+
p_src
[
5
]
/
8
;
p_dest
++
;
p_src
+=
7
;
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_REARLEFT
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
4
]
+
p_src
[
0
]
/
4
+
p_src
[
1
]
/
4
+
p_src
[
2
]
/
6
+
p_src
[
3
]
/
6
;
p_dest
++
;
p_src
+=
5
;
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
0
]
/
2
+
p_src
[
1
]
/
2
;
p_dest
++
;
p_src
+=
2
;
}
}
else
else
{
{
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_MIDDLELEFT
)
if
(
p_filter
->
input
.
i_physical_channels
&
AOUT_CHAN_MIDDLELEFT
)
...
@@ -173,3 +216,108 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
...
@@ -173,3 +216,108 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
}
}
}
/*****************************************************************************
* OpenFilter:
*****************************************************************************/
static
int
OpenFilter
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
if
(
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
==
p_filter
->
fmt_out
.
audio
.
i_physical_channels
&&
p_filter
->
fmt_in
.
audio
.
i_original_channels
==
p_filter
->
fmt_out
.
audio
.
i_original_channels
)
||
p_filter
->
fmt_in
.
i_codec
!=
p_filter
->
fmt_out
.
i_codec
||
p_filter
->
fmt_in
.
audio
.
i_rate
!=
p_filter
->
fmt_out
.
audio
.
i_rate
||
p_filter
->
fmt_in
.
i_codec
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
/* Only conversion to Mono, Stereo and 4.0 right now */
if
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
)
&&
p_filter
->
fmt_out
.
audio
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
p_filter
->
fmt_out
.
audio
.
i_physical_channels
!=
AOUT_CHAN_CENTER
)
{
return
-
1
;
}
/* Only from 7/7.1/5/5.1/2.0 */
if
(
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
~
AOUT_CHAN_LFE
)
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
|
AOUT_CHAN_CENTER
|
AOUT_CHAN_MIDDLELEFT
|
AOUT_CHAN_MIDDLERIGHT
|
AOUT_CHAN_REARLEFT
|
AOUT_CHAN_REARRIGHT
)
&&
p_filter
->
fmt_in
.
audio
.
i_physical_channels
!=
(
AOUT_CHAN_LEFT
|
AOUT_CHAN_RIGHT
)
)
{
return
-
1
;
}
p_filter
->
pf_audio_filter
=
Filter
;
return
0
;
}
/*****************************************************************************
* Filter:
*****************************************************************************/
static
block_t
*
Filter
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
aout_filter_t
aout_filter
;
aout_buffer_t
in_buf
,
out_buf
;
block_t
*
p_out
;
int
i_out_size
;
if
(
!
p_block
||
!
p_block
->
i_samples
)
{
if
(
p_block
)
p_block
->
pf_release
(
p_block
);
return
NULL
;
}
i_out_size
=
p_block
->
i_samples
*
p_filter
->
fmt_out
.
audio
.
i_bitspersample
*
p_filter
->
fmt_out
.
audio
.
i_channels
/
8
;
p_out
=
p_filter
->
pf_audio_buffer_new
(
p_filter
,
i_out_size
);
if
(
!
p_out
)
{
msg_Warn
(
p_filter
,
"can't get output buffer"
);
p_block
->
pf_release
(
p_block
);
return
NULL
;
}
p_out
->
i_samples
=
p_block
->
i_samples
;
p_out
->
i_dts
=
p_block
->
i_dts
;
p_out
->
i_pts
=
p_block
->
i_pts
;
p_out
->
i_length
=
p_block
->
i_length
;
aout_filter
.
p_sys
=
(
struct
aout_filter_sys_t
*
)
p_filter
->
p_sys
;
aout_filter
.
input
=
p_filter
->
fmt_in
.
audio
;
aout_filter
.
input
.
i_format
=
p_filter
->
fmt_in
.
i_codec
;
aout_filter
.
output
=
p_filter
->
fmt_out
.
audio
;
aout_filter
.
output
.
i_format
=
p_filter
->
fmt_out
.
i_codec
;
in_buf
.
p_buffer
=
p_block
->
p_buffer
;
in_buf
.
i_nb_bytes
=
p_block
->
i_buffer
;
in_buf
.
i_nb_samples
=
p_block
->
i_samples
;
out_buf
.
p_buffer
=
p_out
->
p_buffer
;
out_buf
.
i_nb_bytes
=
p_out
->
i_buffer
;
out_buf
.
i_nb_samples
=
p_out
->
i_samples
;
DoWork
(
(
aout_instance_t
*
)
p_filter
,
&
aout_filter
,
&
in_buf
,
&
out_buf
);
p_block
->
pf_release
(
p_block
);
p_out
->
i_buffer
=
out_buf
.
i_nb_bytes
;
p_out
->
i_samples
=
out_buf
.
i_nb_samples
;
return
p_out
;
}
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