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
899895ef
Commit
899895ef
authored
Jan 29, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorized 8->16 bits audio conversions.
parent
f3a2e18c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
93 deletions
+36
-93
modules/audio_filter/converter/format.c
modules/audio_filter/converter/format.c
+36
-93
No files found.
modules/audio_filter/converter/format.c
View file @
899895ef
...
...
@@ -596,56 +596,42 @@ static block_t *U8toS8( filter_t *p_filter, block_t *p_block )
}
/* */
static
block_t
*
S8toU16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
static
inline
block_t
*
X8toX16
(
filter_t
*
p_filter
,
block_t
*
p_block
,
bool
b_signed_src
,
bool
b_signed_dst
)
{
block_t
*
p_block_out
;
int8_t
*
p_in
;
uint16_t
*
p_out
;
int
i
;
p_block_out
=
filter_NewAudioBuffer
(
p_filter
,
p_block
->
i_buffer
*
2
);
p_block_out
=
filter_NewAudioBuffer
(
p_filter
,
p_block
->
i_buffer
*
2
);
if
(
!
p_block_out
)
{
msg_Warn
(
p_filter
,
"can't get output buffer"
);
return
NULL
;
}
p_in
=
(
int8_t
*
)
p_block
->
p_buffer
;
p_out
=
(
uint16_t
*
)
p_block_out
->
p_buffer
;
for
(
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
((
*
p_in
++
)
+
128
)
<<
8
;
p_block_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_block_out
->
i_dts
=
p_block
->
i_dts
;
p_block_out
->
i_pts
=
p_block
->
i_pts
;
p_block_out
->
i_length
=
p_block
->
i_length
;
p_block_out
->
i_rate
=
p_block
->
i_rate
;
block_Release
(
p_block
);
return
p_block_out
;
}
static
block_t
*
U8toS16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
block_t
*
p_block_out
;
uint8_t
*
p_in
;
int16_t
*
p_out
;
int
i
;
p_block_out
=
filter_NewAudioBuffer
(
p_filter
,
p_block
->
i_buffer
*
2
);
if
(
!
p_block_out
)
if
(
b_signed_src
==
b_signed_dst
)
{
msg_Warn
(
p_filter
,
"can't get output buffer"
);
return
NULL
;
/* U8->U16 or S8->S16 */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_block
->
p_buffer
;
uint16_t
*
p_out
=
(
uint16_t
*
)
p_block_out
->
p_buffer
;
for
(
int
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
(
*
p_in
++
)
<<
8
;
}
else
if
(
b_signed_src
)
{
/* S8->U16 */
int8_t
*
p_in
=
(
int8_t
*
)
p_block
->
p_buffer
;
uint16_t
*
p_out
=
(
uint16_t
*
)
p_block_out
->
p_buffer
;
for
(
int
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
((
*
p_in
++
)
+
128
)
<<
8
;
}
else
{
/* U8->S16 */
uint8_t
*
p_in
=
(
uint8_t
*
)
p_block
->
p_buffer
;
int16_t
*
p_out
=
(
int16_t
*
)
p_block_out
->
p_buffer
;
for
(
int
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
((
*
p_in
++
)
-
128
)
<<
8
;
}
p_in
=
(
uint8_t
*
)
p_block
->
p_buffer
;
p_out
=
(
int16_t
*
)
p_block_out
->
p_buffer
;
for
(
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
((
*
p_in
++
)
-
128
)
<<
8
;
p_block_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_block_out
->
i_dts
=
p_block
->
i_dts
;
...
...
@@ -656,67 +642,24 @@ static block_t *U8toS16( filter_t *p_filter, block_t *p_block )
block_Release
(
p_block
);
return
p_block_out
;
}
static
block_t
*
S8toS16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
block_t
*
p_block_out
;
int8_t
*
p_in
;
int16_t
*
p_out
;
int
i
;
p_block_out
=
filter_NewAudioBuffer
(
p_filter
,
p_block
->
i_buffer
*
2
);
if
(
!
p_block_out
)
{
msg_Warn
(
p_filter
,
"can't get output buffer"
);
return
NULL
;
}
p_in
=
(
int8_t
*
)
p_block
->
p_buffer
;
p_out
=
(
int16_t
*
)
p_block_out
->
p_buffer
;
for
(
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
(
*
p_in
++
)
<<
8
;
p_block_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_block_out
->
i_dts
=
p_block
->
i_dts
;
p_block_out
->
i_pts
=
p_block
->
i_pts
;
p_block_out
->
i_length
=
p_block
->
i_length
;
p_block_out
->
i_rate
=
p_block
->
i_rate
;
block_Release
(
p_block
);
return
p_block_out
;
return
X8toX16
(
p_filter
,
p_block
,
true
,
true
);
}
static
block_t
*
U8toU16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
block_t
*
p_block_out
;
uint8_t
*
p_in
;
uint16_t
*
p_out
;
int
i
;
p_block_out
=
filter_NewAudioBuffer
(
p_filter
,
p_block
->
i_buffer
*
2
);
if
(
!
p_block_out
)
{
msg_Warn
(
p_filter
,
"can't get output buffer"
);
return
NULL
;
}
p_in
=
(
uint8_t
*
)
p_block
->
p_buffer
;
p_out
=
(
uint16_t
*
)
p_block_out
->
p_buffer
;
for
(
i
=
p_block
->
i_buffer
;
i
--
;
)
*
p_out
++
=
(
*
p_in
++
)
<<
8
;
return
X8toX16
(
p_filter
,
p_block
,
true
,
true
);
}
static
block_t
*
S8toU16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
return
X8toX16
(
p_filter
,
p_block
,
true
,
false
);
}
static
block_t
*
U8toS16
(
filter_t
*
p_filter
,
block_t
*
p_block
)
{
return
X8toX16
(
p_filter
,
p_block
,
false
,
true
);
}
p_block_out
->
i_nb_samples
=
p_block
->
i_nb_samples
;
p_block_out
->
i_dts
=
p_block
->
i_dts
;
p_block_out
->
i_pts
=
p_block
->
i_pts
;
p_block_out
->
i_length
=
p_block
->
i_length
;
p_block_out
->
i_rate
=
p_block
->
i_rate
;
block_Release
(
p_block
);
return
p_block_out
;
}
/*****************************************************************************
* Swap a buffer of words
...
...
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