Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
d81d5e5f
Commit
d81d5e5f
authored
Nov 26, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge all fixed-point and floating-point audio format converters
parent
1c808907
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
782 additions
and
1360 deletions
+782
-1360
configure.ac
configure.ac
+2
-2
modules/audio_filter/converter/Modules.am
modules/audio_filter/converter/Modules.am
+2
-12
modules/audio_filter/converter/fixed.c
modules/audio_filter/converter/fixed.c
+118
-98
modules/audio_filter/converter/fixed32tofloat32.c
modules/audio_filter/converter/fixed32tofloat32.c
+0
-129
modules/audio_filter/converter/float.c
modules/audio_filter/converter/float.c
+660
-0
modules/audio_filter/converter/float32tos16.c
modules/audio_filter/converter/float32tos16.c
+0
-108
modules/audio_filter/converter/float32tos8.c
modules/audio_filter/converter/float32tos8.c
+0
-100
modules/audio_filter/converter/float32tou16.c
modules/audio_filter/converter/float32tou16.c
+0
-100
modules/audio_filter/converter/float32tou8.c
modules/audio_filter/converter/float32tou8.c
+0
-100
modules/audio_filter/converter/s16tofixed32.c
modules/audio_filter/converter/s16tofixed32.c
+0
-100
modules/audio_filter/converter/s16tofloat32.c
modules/audio_filter/converter/s16tofloat32.c
+0
-141
modules/audio_filter/converter/s16tofloat32swab.c
modules/audio_filter/converter/s16tofloat32swab.c
+0
-182
modules/audio_filter/converter/s8tofloat32.c
modules/audio_filter/converter/s8tofloat32.c
+0
-96
modules/audio_filter/converter/u8tofixed32.c
modules/audio_filter/converter/u8tofixed32.c
+0
-96
modules/audio_filter/converter/u8tofloat32.c
modules/audio_filter/converter/u8tofloat32.c
+0
-96
No files found.
configure.ac
View file @
d81d5e5f
...
...
@@ -1108,7 +1108,7 @@ VLC_ADD_PLUGINS([dummy logger memcpy])
VLC_ADD_PLUGINS([mpgv mpga m4v m4a h264 ps pva avi asf mp4 rawdv nsv real aiff mjpeg demuxdump flacsys tta])
VLC_ADD_PLUGINS([cvdsub svcdsub spudec subsdec dvbsub mpeg_audio lpcm a52 dts cinepak flac])
VLC_ADD_PLUGINS([deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise])
VLC_ADD_PLUGINS([
fixed32tos16 s16tofixed32 u8tofixed32
mono])
VLC_ADD_PLUGINS([
converter_fixed
mono])
VLC_ADD_PLUGINS([trivial_resampler ugly_resampler])
VLC_ADD_PLUGINS([trivial_channel_mixer trivial_mixer])
VLC_ADD_PLUGINS([playlist export sgimb nsc xtag])
...
...
@@ -1128,7 +1128,7 @@ if test "${SYS}" != "mingwce"; then
VLC_ADD_PLUGINS([aout_file linear_resampler bandlimited_resampler])
VLC_ADD_PLUGINS([float32_mixer spdif_mixer simple_channel_mixer])
VLC_ADD_PLUGINS([dolby_surround_decoder headphone_channel_mixer normvol equalizer param_eq])
VLC_ADD_PLUGINS([
fixed32tofloat32 float32tos16 float32tos8 float32tou16 float32tou8 a52tospdif dtstospdif s16tofloat32 s16tofloat32swab s8tofloat32 u8tofloat32
audio_format])
VLC_ADD_PLUGINS([
converter_float a52tospdif dtstospdif
audio_format])
fi
dnl
...
...
modules/audio_filter/converter/Modules.am
View file @
d81d5e5f
SOURCES_float32tos16 = float32tos16.c
SOURCES_float32tos8 = float32tos8.c
SOURCES_float32tou16 = float32tou16.c
SOURCES_float32tou8 = float32tou8.c
SOURCES_converter_fixed = fixed.c
SOURCES_converter_float = float.c
SOURCES_a52tospdif = a52tospdif.c
SOURCES_a52tofloat32 = a52tofloat32.c
SOURCES_dtstospdif = dtstospdif.c
SOURCES_dtstofloat32 = dtstofloat32.c
SOURCES_fixed32tos16 = fixed32tos16.c
SOURCES_s16tofixed32 = s16tofixed32.c
SOURCES_fixed32tofloat32 = fixed32tofloat32.c
SOURCES_s16tofloat32 = s16tofloat32.c
SOURCES_s16tofloat32swab = s16tofloat32swab.c
SOURCES_s8tofloat32 = s8tofloat32.c
SOURCES_u8tofixed32 = u8tofixed32.c
SOURCES_u8tofloat32 = u8tofloat32.c
SOURCES_mpgatofixed32 = mpgatofixed32.c
modules/audio_filter/converter/fixed
32tos16
.c
→
modules/audio_filter/converter/fixed.c
View file @
d81d5e5f
/*****************************************************************************
* fixed
32tos16.c : converter from fixed32 to signed 16 bits integer
* fixed
.c: Fixed-point audio format conversions
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
* Marc Ariberti <marcari@videolan.org>
* Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -33,28 +35,38 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
int
Create_F32ToS16
(
vlc_object_t
*
);
static
void
Do_F32ToS16
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
int
Create_S16ToF32
(
vlc_object_t
*
);
static
void
Do_S16ToF32
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
int
Create_U8ToF32
(
vlc_object_t
*
);
static
void
Do_U8ToF32
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for fixed32->s16 conversion"
)
);
set_capability
(
"audio filter"
,
10
);
set_callbacks
(
Create
,
NULL
);
set_description
(
_
(
"Fixed point audio format conversions"
)
);
add_submodule
();
set_callbacks
(
Create_F32ToS16
,
NULL
);
set_capability
(
"audio filter"
,
10
);
add_submodule
();
set_callbacks
(
Create_S16ToF32
,
NULL
);
set_capability
(
"audio filter"
,
15
);
add_submodule
();
set_callbacks
(
Create_U8ToF32
,
NULL
);
set_capability
(
"audio filter"
,
1
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
* F32 to S16
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
static
int
Create
_F32ToS16
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
...
...
@@ -69,10 +81,10 @@ static int Create( vlc_object_t *p_this )
return
-
1
;
}
p_filter
->
pf_do_work
=
Do
Work
;
p_filter
->
pf_do_work
=
Do
_F32ToS16
;
p_filter
->
b_in_place
=
1
;
return
0
;
return
VLC_SUCCESS
;
;
}
/*****************************************************************************
...
...
@@ -98,77 +110,6 @@ static int Create( vlc_object_t *p_this )
# define VLC_F_ONE VLC_F(0x10000000)
struct
audio_dither
{
vlc_fixed_t
error
[
3
];
vlc_fixed_t
random
;
};
/********************************************************************
* NAME: prng()
* DESCRIPTION: 32-bit pseudo-random number generator
********************************************************************/
static
inline
unsigned
long
prng
(
unsigned
long
state
)
{
return
(
state
*
0x0019660dL
+
0x3c6ef35fL
)
&
0xffffffffL
;
}
/********************************************************************
* NAME: mpg321_s24_to_s16_pcm()
* DESCRIPTION: generic linear sample quantize and dither routine
********************************************************************/
static
inline
int16_t
mpg321_s24_to_s16_pcm
(
unsigned
int
bits
,
vlc_fixed_t
sample
,
struct
audio_dither
*
dither
)
{
unsigned
int
scalebits
;
vlc_fixed_t
output
,
mask
,
random
;
enum
{
MIN
=
-
VLC_F_ONE
,
MAX
=
VLC_F_ONE
-
1
};
/* noise shape */
sample
+=
dither
->
error
[
0
]
-
dither
->
error
[
1
]
+
dither
->
error
[
2
];
dither
->
error
[
2
]
=
dither
->
error
[
1
];
dither
->
error
[
1
]
=
dither
->
error
[
0
]
/
2
;
/* bias */
output
=
sample
+
(
1L
<<
(
VLC_F_FRACBITS
+
1
-
bits
-
1
));
scalebits
=
VLC_F_FRACBITS
+
1
-
bits
;
mask
=
(
1L
<<
scalebits
)
-
1
;
/* dither */
random
=
prng
(
dither
->
random
);
output
+=
(
random
&
mask
)
-
(
dither
->
random
&
mask
);
dither
->
random
=
random
;
/* clip */
if
(
output
>
MAX
)
{
output
=
MAX
;
if
(
sample
>
MAX
)
sample
=
MAX
;
}
else
if
(
output
<
MIN
)
{
output
=
MIN
;
if
(
sample
<
MIN
)
sample
=
MIN
;
}
/* quantize */
output
&=
~
mask
;
/* error feedback */
dither
->
error
[
0
]
=
sample
-
output
;
/* scale */
return
output
>>
scalebits
;
}
/*****************************************************************************
* s24_to_s16_pcm: Scale a 24 bit pcm sample to a 16 bit pcm sample.
*****************************************************************************/
...
...
@@ -187,29 +128,108 @@ static inline int16_t s24_to_s16_pcm(vlc_fixed_t sample)
return
(
sample
>>
(
VLC_F_FRACBITS
+
1
-
16
));
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
static
void
Do_F32ToS16
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
vlc_fixed_t
*
p_in
=
(
vlc_fixed_t
*
)
p_in_buf
->
p_buffer
;
int16_t
*
p_out
=
(
int16_t
*
)
p_out_buf
->
p_buffer
;
#if 0
static struct audio_dither dither;
#endif
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
)
;
i
--
;
)
{
#if 0
/* Accurate scaling */
*p_out++ = mpg321_s24_to_s16_pcm(16, *p_in++, &dither);
#endif
/* Fast Scaling */
*
p_out
++
=
s24_to_s16_pcm
(
*
p_in
++
);
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
/
2
;
}
/*****************************************************************************
* S16 to F32
*****************************************************************************/
static
int
Create_S16ToF32
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
||
p_filter
->
input
.
i_format
!=
AOUT_FMT_S16_NE
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
Do_S16ToF32
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
static
void
Do_S16ToF32
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
int16_t
*
p_in
=
(
int16_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
vlc_fixed_t
*
p_out
=
(
vlc_fixed_t
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
(
vlc_fixed_t
)(
(
int32_t
)(
*
p_in
)
*
(
FIXED32_ONE
>>
16
)
);
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
vlc_fixed_t
)
/
sizeof
(
int16_t
);
}
/*****************************************************************************
* U8 to F32
*****************************************************************************/
static
int
Create_U8ToF32
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'u'
,
'8'
,
' '
,
' '
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
Do_U8ToF32
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
static
void
Do_U8ToF32
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
vlc_fixed_t
*
p_out
=
(
vlc_fixed_t
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
(
vlc_fixed_t
)(
(
int32_t
)(
*
p_in
-
128
)
*
(
FIXED32_ONE
/
128
)
);
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
vlc_fixed_t
);
}
modules/audio_filter/converter/fixed32tofloat32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* fixed32float32.c: converter from fixed32 to float32 bits integer
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_aout.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
FixedToFloat
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
void
FloatToFixed
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for fixed32<->float32 conversion"
)
);
set_capability
(
"audio filter"
,
10
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
)
&&
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
if
(
p_filter
->
input
.
i_format
==
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
)
{
p_filter
->
pf_do_work
=
FixedToFloat
;
}
else
{
p_filter
->
pf_do_work
=
FloatToFixed
;
}
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* FixedToFloat: convert a buffer
*****************************************************************************/
static
void
FixedToFloat
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
vlc_fixed_t
*
p_in
=
(
vlc_fixed_t
*
)
p_in_buf
->
p_buffer
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
)
;
i
--
;
)
{
*
p_out
++
=
(
float
)
*
p_in
++
/
(
float
)
FIXED32_ONE
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
;
}
/*****************************************************************************
* FloatToFixed: convert a buffer
*****************************************************************************/
static
void
FloatToFixed
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
float
*
p_in
=
(
float
*
)
p_in_buf
->
p_buffer
;
vlc_fixed_t
*
p_out
=
(
vlc_fixed_t
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
)
;
i
--
;
)
{
*
p_out
++
=
(
vlc_fixed_t
)(
*
p_in
++
*
(
float
)
FIXED32_ONE
);
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
;
}
modules/audio_filter/converter/float.c
0 → 100644
View file @
d81d5e5f
This diff is collapsed.
Click to expand it.
modules/audio_filter/converter/float32tos16.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* float32tos16.c : converter from float32 to signed 16 bits integer
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_aout.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for float32->s16 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
AOUT_FMT_S16_NE
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
float
*
p_in
=
(
float
*
)
p_in_buf
->
p_buffer
;
int16_t
*
p_out
=
(
int16_t
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
i
--
;
)
{
#if 0
/* Slow version. */
if ( *p_in >= 1.0 ) *p_out = 32767;
else if ( *p_in < -1.0 ) *p_out = -32768;
else *p_out = *p_in * 32768.0;
#else
/* This is walken's trick based on IEEE float format. */
union
{
float
f
;
int32_t
i
;
}
u
;
u
.
f
=
*
p_in
+
384
.
0
;
if
(
u
.
i
>
0x43c07fff
)
*
p_out
=
32767
;
else
if
(
u
.
i
<
0x43bf8000
)
*
p_out
=
-
32768
;
else
*
p_out
=
u
.
i
-
0x43c00000
;
#endif
p_in
++
;
p_out
++
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
/
2
;
}
modules/audio_filter/converter/float32tos8.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* float32tos8.c : converter from float32 to signed 8 bits integer
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc_aout.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for float32->s8 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
's'
,
'8'
,
' '
,
' '
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
float
*
p_in
=
(
float
*
)
p_in_buf
->
p_buffer
;
int8_t
*
p_out
=
(
int8_t
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
i
--
;
)
{
if
(
*
p_in
>=
1
.
0
)
*
p_out
=
127
;
else
if
(
*
p_in
<
-
1
.
0
)
*
p_out
=
-
128
;
else
*
p_out
=
(
int8_t
)(
*
p_in
*
128
);
p_in
++
;
p_out
++
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
/
4
;
}
modules/audio_filter/converter/float32tou16.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* float32tou16.c : converter from float32 to unsigned 16 bits integer
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for float32->u16 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
AOUT_FMT_U16_NE
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
float
*
p_in
=
(
float
*
)
p_in_buf
->
p_buffer
;
uint16_t
*
p_out
=
(
uint16_t
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
i
--
;
)
{
if
(
*
p_in
>=
1
.
0
)
*
p_out
=
65535
;
else
if
(
*
p_in
<
-
1
.
0
)
*
p_out
=
0
;
else
*
p_out
=
(
uint16_t
)(
32768
+
*
p_in
*
32768
);
p_in
++
;
p_out
++
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
/
2
;
}
modules/audio_filter/converter/float32tou8.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* float32tou8.c : converter from float32 to unsigned 8 bits integer
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for float32->u8 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'u'
,
'8'
,
' '
,
' '
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
;
float
*
p_in
=
(
float
*
)
p_in_buf
->
p_buffer
;
uint8_t
*
p_out
=
(
uint8_t
*
)
p_out_buf
->
p_buffer
;
for
(
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
i
--
;
)
{
if
(
*
p_in
>=
1
.
0
)
*
p_out
=
255
;
else
if
(
*
p_in
<
-
1
.
0
)
*
p_out
=
0
;
else
*
p_out
=
(
uint8_t
)(
128
+
*
p_in
*
128
);
p_in
++
;
p_out
++
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
/
4
;
}
modules/audio_filter/converter/s16tofixed32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* s16tofixed32.c : converter from signed 16 bits integer to fixed 32
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Marc Ariberti <marcari@videolan.ord>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for s16->fixed32 conversion"
)
);
set_capability
(
"audio filter"
,
15
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate filter
*****************************************************************************
* This function allocates and initializes a s16->fixed32 audio filter.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
||
p_filter
->
input
.
i_format
!=
AOUT_FMT_S16_NE
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
1
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
int16_t
*
p_in
=
(
int16_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
vlc_fixed_t
*
p_out
=
(
vlc_fixed_t
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
(
vlc_fixed_t
)(
(
int32_t
)(
*
p_in
)
*
(
FIXED32_ONE
>>
16
)
);
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
vlc_fixed_t
)
/
sizeof
(
int16_t
);
}
modules/audio_filter/converter/s16tofloat32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* s16tofloat32.c : converter from signed 16 bits integer to float32
*****************************************************************************
* Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
void
DoWork24
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for s16->float32 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
(
p_filter
->
input
.
i_format
!=
AOUT_FMT_S16_NE
&&
p_filter
->
input
.
i_format
!=
AOUT_FMT_S24_NE
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
if
(
p_filter
->
input
.
i_format
==
AOUT_FMT_S24_NE
)
p_filter
->
pf_do_work
=
DoWork24
;
else
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
int16_t
*
p_in
=
(
int16_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
#if 0
/* Slow version */
*p_out = (float)*p_in / 32768.0;
#else
/* This is walken's trick based on IEEE float format. On my PIII
* this takes 16 seconds to perform one billion conversions, instead
* of 19 seconds for the above division. */
union
{
float
f
;
int32_t
i
;
}
u
;
u
.
i
=
*
p_in
+
0x43c00000
;
*
p_out
=
u
.
f
-
384
.
0
;
#endif
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
2
;
}
static
void
DoWork24
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_in_buf
->
p_buffer
+
(
i
-
1
)
*
3
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
#ifdef WORDS_BIGENDIAN
*
p_out
=
((
float
)(
(((
int32_t
)
*
(
int16_t
*
)(
p_in
))
<<
8
)
+
p_in
[
2
]))
#else
*
p_out
=
((
float
)(
(((
int32_t
)
*
(
int16_t
*
)(
p_in
+
1
))
<<
8
)
+
p_in
[
0
]))
#endif
/
8388608
.
0
;
p_in
-=
3
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
4
/
3
;
}
modules/audio_filter/converter/s16tofloat32swab.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* s16tofloat32swab.c : converter from signed 16 bits integer to float32
* with endianness change
*****************************************************************************
* Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#include <vlc_aout.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
static
void
DoWork24
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for s16->float32 with endianness conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
if
(
(
p_filter
->
input
.
i_format
==
VLC_FOURCC
(
's'
,
'1'
,
'6'
,
'l'
)
||
p_filter
->
input
.
i_format
==
VLC_FOURCC
(
's'
,
'1'
,
'6'
,
'b'
))
&&
p_filter
->
output
.
i_format
==
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
&&
p_filter
->
input
.
i_format
!=
AOUT_FMT_S16_NE
)
{
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
if
(
(
p_filter
->
input
.
i_format
==
VLC_FOURCC
(
's'
,
'2'
,
'4'
,
'l'
)
||
p_filter
->
input
.
i_format
==
VLC_FOURCC
(
's'
,
'2'
,
'4'
,
'b'
))
&&
p_filter
->
output
.
i_format
==
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
&&
p_filter
->
input
.
i_format
!=
AOUT_FMT_S24_NE
)
{
p_filter
->
pf_do_work
=
DoWork24
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
return
-
1
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
int16_t
*
p_in
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
#ifdef HAVE_SWAB
# ifdef HAVE_ALLOCA
int16_t
*
p_swabbed
=
alloca
(
i
*
sizeof
(
int16_t
)
);
# else
int16_t
*
p_swabbed
=
malloc
(
i
*
sizeof
(
int16_t
)
);
# endif
swab
(
p_in_buf
->
p_buffer
,
(
void
*
)
p_swabbed
,
i
*
sizeof
(
int16_t
)
);
p_in
=
p_swabbed
+
i
-
1
;
#else
byte_t
p_tmp
[
2
];
p_in
=
(
int16_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
#endif
while
(
i
--
)
{
#ifndef HAVE_SWAB
p_tmp
[
0
]
=
((
byte_t
*
)
p_in
)[
1
];
p_tmp
[
1
]
=
((
byte_t
*
)
p_in
)[
0
];
*
p_out
=
(
float
)(
*
(
int16_t
*
)
p_tmp
)
/
32768
.
0
;
#else
*
p_out
=
(
float
)
*
p_in
/
32768
.
0
;
#endif
p_in
--
;
p_out
--
;
}
#ifdef HAVE_SWAB
# ifndef HAVE_ALLOCA
free
(
p_swabbed
);
# endif
#endif
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
2
;
}
static
void
DoWork24
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_in_buf
->
p_buffer
+
(
i
-
1
)
*
3
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
byte_t
p_tmp
[
3
];
while
(
i
--
)
{
p_tmp
[
0
]
=
p_in
[
2
];
p_tmp
[
1
]
=
p_in
[
1
];
p_tmp
[
2
]
=
p_in
[
0
];
#ifdef WORDS_BIGENDIAN
*
p_out
=
((
float
)(
(((
int32_t
)
*
(
int16_t
*
)(
p_tmp
))
<<
8
)
+
p_tmp
[
2
]))
#else
*
p_out
=
((
float
)(
(((
int32_t
)
*
(
int16_t
*
)(
p_tmp
+
1
))
<<
8
)
+
p_tmp
[
0
]))
#endif
/
8388608
.
0
;
p_in
-=
3
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
4
/
3
;
}
modules/audio_filter/converter/s8tofloat32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* s8tofloat32.c : converter from signed 8 bits integer to float32.
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for s8->float32 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: create and initialize converter
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
's'
,
'8'
,
' '
,
' '
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
int8_t
*
p_in
=
(
int8_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
(
float
)(
*
p_in
)
/
128
.
0
;
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
float
);
}
modules/audio_filter/converter/u8tofixed32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* u8tofixed32.c : converter from unsigned 8 bits integer to fixed32.
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for u8->fixed32 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: create and initialize converter
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'u'
,
'8'
,
' '
,
' '
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'i'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
vlc_fixed_t
*
p_out
=
(
vlc_fixed_t
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
(
vlc_fixed_t
)(
(
int32_t
)(
*
p_in
-
128
)
*
(
FIXED32_ONE
/
128
)
);
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
vlc_fixed_t
);
}
modules/audio_filter/converter/u8tofloat32.c
deleted
100644 → 0
View file @
1c808907
/*****************************************************************************
* u8tofloat32.c : converter from unsigned 8 bits integer to float32.
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
/* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "vlc_aout.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
DoWork
(
aout_instance_t
*
,
aout_filter_t
*
,
aout_buffer_t
*
,
aout_buffer_t
*
);
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_category
(
CAT_AUDIO
);
set_subcategory
(
SUBCAT_AUDIO_MISC
);
set_description
(
_
(
"Audio filter for u8->float32 conversion"
)
);
set_capability
(
"audio filter"
,
1
);
set_callbacks
(
Create
,
NULL
);
vlc_module_end
();
/*****************************************************************************
* Create: create and initialize converter
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
aout_filter_t
*
p_filter
=
(
aout_filter_t
*
)
p_this
;
if
(
p_filter
->
input
.
i_format
!=
VLC_FOURCC
(
'u'
,
'8'
,
' '
,
' '
)
||
p_filter
->
output
.
i_format
!=
VLC_FOURCC
(
'f'
,
'l'
,
'3'
,
'2'
)
)
{
return
-
1
;
}
if
(
!
AOUT_FMTS_SIMILAR
(
&
p_filter
->
input
,
&
p_filter
->
output
)
)
{
return
-
1
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
VLC_TRUE
;
return
0
;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int
i
=
p_in_buf
->
i_nb_samples
*
aout_FormatNbChannels
(
&
p_filter
->
input
);
/* We start from the end because b_in_place is true */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_in_buf
->
p_buffer
+
i
-
1
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
while
(
i
--
)
{
*
p_out
=
((
float
)
*
p_in
-
128
)
/
128
.
0
;
p_in
--
;
p_out
--
;
}
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
sizeof
(
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