Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
e1da5491
Commit
e1da5491
authored
Jan 26, 2013
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple channel mixer: move the decision logic to the Open function
There should be no functionnal change here
parent
f3e0178e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
132 deletions
+174
-132
modules/audio_filter/channel_mixer/simple.c
modules/audio_filter/channel_mixer/simple.c
+174
-132
No files found.
modules/audio_filter/channel_mixer/simple.c
View file @
e1da5491
...
...
@@ -53,169 +53,158 @@ vlc_module_end ()
*****************************************************************************/
static
bool
IsSupported
(
const
audio_format_t
*
p_input
,
const
audio_format_t
*
p_output
);
struct
filter_sys_t
{
void
(
*
pf_dowork
)(
filter_t
*
,
block_t
*
,
block_t
*
);
};
static
block_t
*
Filter
(
filter_t
*
,
block_t
*
);
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
const
unsigned
i_input_physical
=
p_filter
->
fmt_in
.
audio
.
i_physical_channels
;
static
void
DoWork_7_x_to_2_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
6
]
+
0
.
5
*
p_src
[
0
]
+
p_src
[
2
]
/
4
+
p_src
[
4
]
/
4
;
*
p_dest
++
=
p_src
[
6
]
+
0
.
5
*
p_src
[
1
]
+
p_src
[
3
]
/
4
+
p_src
[
5
]
/
4
;
const
bool
b_input_7_0
=
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_7_0
;
const
bool
b_input_5_0
=
!
b_input_7_0
&&
(
(
i_input_physical
&
AOUT_CHANS_5_0
)
==
AOUT_CHANS_5_0
||
(
i_input_physical
&
AOUT_CHANS_5_0_MIDDLE
)
==
AOUT_CHANS_5_0_MIDDLE
);
const
bool
b_input_4_center_rear
=
!
b_input_7_0
&&
!
b_input_5_0
&&
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_4_CENTER_REAR
;
const
bool
b_input_3_0
=
!
b_input_7_0
&&
!
b_input_5_0
&&
!
b_input_4_center_rear
&&
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_3_0
;
p_src
+=
7
;
int
i_input_nb
=
aout_FormatNbChannels
(
&
p_filter
->
fmt_in
.
audio
);
int
i_output_nb
=
aout_FormatNbChannels
(
&
p_filter
->
fmt_out
.
audio
);
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
static
void
DoWork_5_x_to_2_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
int
i
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
4
]
+
0
.
5
*
p_src
[
0
]
+
0
.
33
*
p_src
[
2
];
*
p_dest
++
=
p_src
[
4
]
+
0
.
5
*
p_src
[
1
]
+
0
.
33
*
p_src
[
3
];
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_buffer
=
p_in_buf
->
i_buffer
*
i_output_nb
/
i_input_nb
;
p_src
+=
5
;
if
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHANS_2_0
)
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
static
void
DoWork_4_0_to_2_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
VLC_UNUSED
(
p_filter
);
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
if
(
b_input_7_0
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
6
]
+
0
.
5
*
p_src
[
0
]
+
p_src
[
2
]
/
4
+
p_src
[
4
]
/
4
;
p_dest
++
;
*
p_dest
=
p_src
[
6
]
+
0
.
5
*
p_src
[
1
]
+
p_src
[
3
]
/
4
+
p_src
[
5
]
/
4
;
p_dest
++
;
*
p_dest
++
=
p_src
[
2
]
+
p_src
[
3
]
+
0
.
5
*
p_src
[
0
];
*
p_dest
++
=
p_src
[
2
]
+
p_src
[
3
]
+
0
.
5
*
p_src
[
1
];
p_src
+=
4
;
}
}
p_src
+=
7
;
static
void
DoWork_3_x_to_2_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
2
]
+
0
.
5
*
p_src
[
0
];
*
p_dest
++
=
p_src
[
2
]
+
0
.
5
*
p_src
[
1
];
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
b_input_5_0
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
4
]
+
0
.
5
*
p_src
[
0
]
+
0
.
33
*
p_src
[
2
];
p_dest
++
;
*
p_dest
=
p_src
[
4
]
+
0
.
5
*
p_src
[
1
]
+
0
.
33
*
p_src
[
3
];
p_dest
++
;
p_src
+=
3
;
p_src
+=
5
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
b_input_3_0
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
2
]
+
0
.
5
*
p_src
[
0
];
p_dest
++
;
*
p_dest
=
p_src
[
2
]
+
0
.
5
*
p_src
[
1
];
p_dest
++
;
p_src
+=
3
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
b_input_4_center_rear
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
2
]
+
p_src
[
3
]
+
0
.
5
*
p_src
[
0
];
p_dest
++
;
*
p_dest
=
p_src
[
2
]
+
p_src
[
3
]
+
0
.
5
*
p_src
[
1
];
p_dest
++
;
p_src
+=
4
;
}
static
void
DoWork_7_x_to_1_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
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_src
+=
7
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHAN_CENTER
)
}
static
void
DoWork_5_x_to_1_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
if
(
b_input_7_0
)
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_dest
++
=
p_src
[
4
]
+
p_src
[
0
]
/
4
+
p_src
[
1
]
/
4
+
p_src
[
2
]
/
6
+
p_src
[
3
]
/
6
;
p_src
+=
7
;
p_src
+=
5
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
b_input_5_0
)
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
++
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
p_src
+=
5
;
static
void
DoWork_3_x_to_1_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
2
]
+
p_src
[
0
]
/
4
+
p_src
[
1
]
/
4
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
if
(
b_input_3_0
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
2
]
+
p_src
[
0
]
/
4
+
p_src
[
1
]
/
4
;
p_dest
++
;
p_src
+=
3
;
p_src
+=
3
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
if
(
p_filter
->
fmt_in
.
audio
.
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
++
;
static
void
DoWork_2_x_to_1_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
VLC_UNUSED
(
p_filter
);
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
0
]
/
2
+
p_src
[
1
]
/
2
;
p_src
+=
2
;
}
p_src
+=
2
;
}
else
}
static
void
DoWork_7_x_to_4_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
assert
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHANS_4_0
);
assert
(
b_input_7_0
||
b_input_5_0
);
*
p_dest
++
=
p_src
[
6
]
+
0
.
5
*
p_src
[
0
]
+
p_src
[
2
]
/
6
;
*
p_dest
++
=
p_src
[
6
]
+
0
.
5
*
p_src
[
1
]
+
p_src
[
3
]
/
6
;
*
p_dest
++
=
p_src
[
2
]
/
6
+
p_src
[
4
];
*
p_dest
++
=
p_src
[
3
]
/
6
+
p_src
[
5
];
if
(
b_input_7_0
)
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
6
]
+
0
.
5
*
p_src
[
0
]
+
p_src
[
2
]
/
6
;
p_dest
++
;
*
p_dest
=
p_src
[
6
]
+
0
.
5
*
p_src
[
1
]
+
p_src
[
3
]
/
6
;
p_dest
++
;
*
p_dest
=
p_src
[
2
]
/
6
+
p_src
[
4
];
p_dest
++
;
*
p_dest
=
p_src
[
3
]
/
6
+
p_src
[
5
];
p_dest
++
;
p_src
+=
7
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
else
for
(
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
=
p_src
[
4
]
+
0
.
5
*
p_src
[
0
];
p_dest
++
;
*
p_dest
=
p_src
[
4
]
+
0
.
5
*
p_src
[
1
];
p_dest
++
;
*
p_dest
=
p_src
[
2
];
p_dest
++
;
*
p_dest
=
p_src
[
3
];
p_dest
++
;
p_src
+=
5
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
p_src
+=
7
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
static
void
DoWork_5_x_to_4_0
(
filter_t
*
p_filter
,
block_t
*
p_in_buf
,
block_t
*
p_out_buf
)
{
float
*
p_dest
=
(
float
*
)
p_out_buf
->
p_buffer
;
const
float
*
p_src
=
(
const
float
*
)
p_in_buf
->
p_buffer
;
for
(
int
i
=
p_in_buf
->
i_nb_samples
;
i
--
;
)
{
*
p_dest
++
=
p_src
[
4
]
+
0
.
5
*
p_src
[
0
];
*
p_dest
++
=
p_src
[
4
]
+
0
.
5
*
p_src
[
1
];
*
p_dest
++
=
p_src
[
2
];
*
p_dest
++
=
p_src
[
3
];
p_src
+=
5
;
if
(
p_filter
->
fmt_in
.
audio
.
i_physical_channels
&
AOUT_CHAN_LFE
)
p_src
++
;
}
}
/*****************************************************************************
* OpenFilter:
*****************************************************************************/
static
int
OpenFilter
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
audio_format_t
fmt_in
=
p_filter
->
fmt_in
.
audio
;
audio_format_t
fmt_out
=
p_filter
->
fmt_out
.
audio
;
...
...
@@ -224,11 +213,58 @@ static int OpenFilter( vlc_object_t *p_this )
fmt_out
.
i_format
=
p_filter
->
fmt_out
.
i_codec
;
if
(
!
IsSupported
(
&
fmt_in
,
&
fmt_out
)
)
return
-
1
;
return
VLC_EGENERIC
;
p_filter
->
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
if
(
unlikely
(
p_filter
->
p_sys
)
)
return
VLC_ENOMEM
;
p_filter
->
pf_audio_filter
=
Filter
;
return
0
;
const
unsigned
i_input_physical
=
p_filter
->
fmt_in
.
audio
.
i_physical_channels
;
const
bool
b_input_7_0
=
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_7_0
;
const
bool
b_input_5_0
=
!
b_input_7_0
&&
(
(
i_input_physical
&
AOUT_CHANS_5_0
)
==
AOUT_CHANS_5_0
||
(
i_input_physical
&
AOUT_CHANS_5_0_MIDDLE
)
==
AOUT_CHANS_5_0_MIDDLE
);
const
bool
b_input_4_center_rear
=
!
b_input_7_0
&&
!
b_input_5_0
&&
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_4_CENTER_REAR
;
const
bool
b_input_3_0
=
!
b_input_7_0
&&
!
b_input_5_0
&&
!
b_input_4_center_rear
&&
(
i_input_physical
&
~
AOUT_CHAN_LFE
)
==
AOUT_CHANS_3_0
;
if
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHANS_2_0
)
{
if
(
b_input_7_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_7_x_to_2_0
;
else
if
(
b_input_5_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_5_x_to_2_0
;
else
if
(
b_input_4_center_rear
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_4_0_to_2_0
;
else
if
(
b_input_3_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_3_x_to_2_0
;
}
else
if
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHAN_CENTER
)
{
if
(
b_input_7_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_7_x_to_1_0
;
else
if
(
b_input_5_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_5_x_to_1_0
;
else
if
(
b_input_3_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_3_x_to_1_0
;
else
p_filter
->
p_sys
->
pf_dowork
=
DoWork_2_x_to_1_0
;
}
else
{
assert
(
p_filter
->
fmt_out
.
audio
.
i_physical_channels
==
AOUT_CHANS_4_0
);
assert
(
b_input_7_0
||
b_input_5_0
);
if
(
b_input_7_0
)
p_filter
->
p_sys
->
pf_dowork
=
DoWork_7_x_to_4_0
;
else
p_filter
->
p_sys
->
pf_dowork
=
DoWork_5_x_to_4_0
;
}
return
VLC_SUCCESS
;
}
/*****************************************************************************
...
...
@@ -236,6 +272,7 @@ static int OpenFilter( vlc_object_t *p_this )
*****************************************************************************/
static
block_t
*
Filter
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_filter
->
p_sys
;
if
(
!
p_block
||
!
p_block
->
i_nb_samples
)
{
if
(
p_block
)
...
...
@@ -260,7 +297,12 @@ static block_t *Filter( filter_t *p_filter, block_t *p_block )
p_out
->
i_pts
=
p_block
->
i_pts
;
p_out
->
i_length
=
p_block
->
i_length
;
DoWork
(
p_filter
,
p_block
,
p_out
);
int
i_input_nb
=
aout_FormatNbChannels
(
&
p_filter
->
fmt_in
.
audio
);
int
i_output_nb
=
aout_FormatNbChannels
(
&
p_filter
->
fmt_out
.
audio
);
p_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_out
->
i_buffer
=
p_block
->
i_buffer
*
i_output_nb
/
i_input_nb
;
p_sys
->
pf_dowork
(
p_filter
,
p_block
,
p_out
);
block_Release
(
p_block
);
...
...
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