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
f58f22cc
Commit
f58f22cc
authored
Dec 21, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
volume: add direct support for S32N, FL64 and U8
parent
2c22b194
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
120 additions
and
51 deletions
+120
-51
modules/audio_mixer/Modules.am
modules/audio_mixer/Modules.am
+8
-3
modules/audio_mixer/float.c
modules/audio_mixer/float.c
+36
-16
modules/audio_mixer/integer.c
modules/audio_mixer/integer.c
+75
-31
po/POTFILES.in
po/POTFILES.in
+1
-1
No files found.
modules/audio_mixer/Modules.am
View file @
f58f22cc
SOURCES_float32_mixer = float32.c
SOURCES_integer_mixer = integer.c
libfloat_mixer_plugin_la_SOURCES = float.c
libfloat_mixer_plugin_la_CFLAGS = $(AM_CFLAGS)
libfloat_mixer_plugin_la_LIBADD = $(AM_LIBADD) $(LIBM)
libinteger_mixer_plugin_la_SOURCES = integer.c
libinteger_mixer_plugin_la_CFLAGS = $(AM_CFLAGS)
libinteger_mixer_plugin_la_LIBADD = $(AM_LIBADD)
libvlc_LTLIBRARIES += \
libfloat
32
_mixer_plugin.la \
libfloat_mixer_plugin.la \
libinteger_mixer_plugin.la
modules/audio_mixer/float
32
.c
→
modules/audio_mixer/float.c
View file @
f58f22cc
...
...
@@ -39,7 +39,6 @@
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
audio_volume_t
*
,
block_t
*
,
float
);
/*****************************************************************************
* Module descriptor
...
...
@@ -53,31 +52,52 @@ vlc_module_begin ()
vlc_module_end
()
/**
*
Initializes the mix
er
*
Mixes a new output buff
er
*/
static
int
Create
(
vlc_object_t
*
p_this
)
static
void
FilterFL32
(
audio_volume_t
*
p_volume
,
block_t
*
p_buffer
,
float
f_multiplier
)
{
audio_volume_t
*
p_volume
=
(
audio_volume_t
*
)
p_this
;
if
(
f_multiplier
==
1
.
f
)
return
;
/* nothing to do */
if
(
p_volume
->
format
!=
VLC_CODEC_FL32
)
return
-
1
;
float
*
p
=
(
float
*
)
p_buffer
->
p_buffer
;
for
(
size_t
i
=
p_buffer
->
i_buffer
/
sizeof
(
float
);
i
>
0
;
i
--
)
*
(
p
++
)
*=
f_multiplier
;
p_volume
->
amplify
=
DoWork
;
return
0
;
(
void
)
p_volume
;
}
/**
* Mixes a new output buffer
*/
static
void
DoWork
(
audio_volume_t
*
p_volume
,
block_t
*
p_buffer
,
static
void
FilterFL64
(
audio_volume_t
*
p_volume
,
block_t
*
p_buffer
,
float
f_multiplier
)
{
if
(
f_multiplier
==
1
.
0
)
double
*
p
=
(
double
*
)
p_buffer
->
p_buffer
;
double
mult
=
f_multiplier
;
if
(
mult
==
1
.
)
return
;
/* nothing to do */
float
*
p
=
(
float
*
)
p_buffer
->
p_buffer
;
for
(
size_t
i
=
p_buffer
->
i_buffer
/
sizeof
(
float
);
i
>
0
;
i
--
)
*
(
p
++
)
*=
f_multiplier
;
*
(
p
++
)
*=
mult
;
(
void
)
p_volume
;
}
/**
* Initializes the mixer
*/
static
int
Create
(
vlc_object_t
*
p_this
)
{
audio_volume_t
*
p_volume
=
(
audio_volume_t
*
)
p_this
;
switch
(
p_volume
->
format
)
{
case
VLC_CODEC_FL32
:
p_volume
->
amplify
=
FilterFL32
;
break
;
case
VLC_CODEC_FL64
:
p_volume
->
amplify
=
FilterFL64
;
break
;
default:
return
-
1
;
}
return
0
;
}
modules/audio_mixer/integer.c
View file @
f58f22cc
...
...
@@ -22,6 +22,9 @@
# include "config.h"
#endif
#include <math.h>
#include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
...
...
@@ -37,51 +40,92 @@ vlc_module_begin ()
set_callbacks
(
Activate
,
NULL
)
vlc_module_end
()
static
void
FilterS16N
(
audio_volume_t
*
,
block_t
*
,
float
);
static
int
Activate
(
vlc_object_t
*
obj
)
static
void
FilterS32N
(
audio_volume_t
*
vol
,
block_t
*
block
,
float
volume
)
{
audio_volume_t
*
vol
=
(
audio_volume_t
*
)
obj
;
int32_t
*
p
=
(
int32_t
*
)
block
->
p_buffer
;
switch
(
vol
->
format
)
int32_t
mult
=
lroundf
(
volume
*
0x1
.
p24f
);
if
(
mult
==
(
1
<<
24
))
return
;
for
(
size_t
n
=
block
->
i_buffer
/
sizeof
(
*
p
);
n
>
0
;
n
--
)
{
case
VLC_CODEC_S16N
:
vol
->
amplify
=
FilterS16N
;
break
;
default:
return
-
1
;
int64_t
s
=
*
p
*
(
int64_t
)
mult
;
if
(
s
>=
(
INT32_MAX
<<
INT64_C
(
24
)))
*
p
=
INT32_MAX
;
else
if
(
s
<
(
INT32_MIN
<<
INT64_C
(
24
)))
*
p
=
INT32_MIN
;
else
*
p
=
s
>>
INT64_C
(
24
);
p
++
;
}
return
0
;
(
void
)
vol
;
}
static
void
FilterS16N
(
audio_volume_t
*
vol
,
block_t
*
block
,
float
volume
)
{
int
32_t
mult
=
volume
*
0x1
.
p16
;
int
16_t
*
p
=
(
int16_t
*
)
block
->
p_buffer
;
if
(
mult
==
0x10000
)
int16_t
mult
=
lroundf
(
volume
*
0x1
.
p8f
);
if
(
mult
==
(
1
<<
8
))
return
;
int16_t
*
p
=
(
int16_t
*
)
block
->
p_buffer
;
if
(
mult
<
0x10000
)
{
for
(
size_t
n
=
block
->
i_buffer
/
sizeof
(
*
p
);
n
>
0
;
n
--
)
{
*
p
=
(
*
p
*
mult
)
>>
16
;
int32_t
s
=
*
p
*
(
int32_t
)
mult
;
if
(
s
>=
(
INT16_MAX
<<
8
))
*
p
=
INT16_MAX
;
else
if
(
s
<
(
INT_MIN
<<
8
))
*
p
=
INT16_MIN
;
else
*
p
=
s
>>
8
;
p
++
;
}
}
else
{
mult
>>=
4
;
(
void
)
vol
;
}
static
void
FilterU8
(
audio_volume_t
*
vol
,
block_t
*
block
,
float
volume
)
{
uint8_t
*
p
=
(
uint8_t
*
)
block
->
p_buffer
;
int16_t
mult
=
lroundf
(
volume
*
0x1
.
p8f
);
if
(
mult
==
(
1
<<
8
))
return
;
for
(
size_t
n
=
block
->
i_buffer
/
sizeof
(
*
p
);
n
>
0
;
n
--
)
{
int32_t
v
=
(
*
p
*
mult
)
>>
12
;
if
(
abs
(
v
)
>
0x7fff
)
v
=
0x8000
;
*
(
p
++
)
=
v
;
}
int32_t
s
=
(
*
p
-
128
)
*
mult
;
if
(
s
>=
(
INT8_MAX
<<
8
))
*
p
=
255
;
else
if
(
s
<
(
INT8_MIN
<<
8
))
*
p
=
0
;
else
*
p
=
(
s
>>
8
)
+
128
;
p
++
;
}
(
void
)
vol
;
}
static
int
Activate
(
vlc_object_t
*
obj
)
{
audio_volume_t
*
vol
=
(
audio_volume_t
*
)
obj
;
switch
(
vol
->
format
)
{
case
VLC_CODEC_S32N
:
vol
->
amplify
=
FilterS32N
;
break
;
case
VLC_CODEC_S16N
:
vol
->
amplify
=
FilterS16N
;
break
;
case
VLC_CODEC_U8
:
vol
->
amplify
=
FilterU8
;
break
;
default:
return
-
1
;
}
return
0
;
}
po/POTFILES.in
View file @
f58f22cc
...
...
@@ -318,7 +318,7 @@ modules/audio_filter/spatializer/revmodel.hpp
modules/audio_filter/spatializer/spatializer.cpp
modules/audio_filter/spatializer/tuning.h
modules/audio_filter/stereo_widen.c
modules/audio_mixer/float
32
.c
modules/audio_mixer/float.c
modules/audio_mixer/integer.c
modules/audio_output/adummy.c
modules/audio_output/alsa.c
...
...
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