Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
00fea26f
Commit
00fea26f
authored
May 01, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr: add native matrix for rematrixing
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
f0839764
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
rematrix.c
libswresample/rematrix.c
+23
-0
swresample.c
libswresample/swresample.c
+2
-0
swresample_internal.h
libswresample/swresample_internal.h
+3
-0
No files found.
libswresample/rematrix.c
View file @
00fea26f
...
...
@@ -253,12 +253,30 @@ static int auto_matrix(SwrContext *s)
int
swri_rematrix_init
(
SwrContext
*
s
){
int
i
,
j
;
int
nb_in
=
av_get_channel_layout_nb_channels
(
s
->
in_ch_layout
);
int
nb_out
=
av_get_channel_layout_nb_channels
(
s
->
out_ch_layout
);
if
(
!
s
->
rematrix_custom
)
{
int
r
=
auto_matrix
(
s
);
if
(
r
)
return
r
;
}
if
(
s
->
midbuf
.
fmt
==
AV_SAMPLE_FMT_S16P
){
s
->
native_matrix
=
av_mallocz
(
nb_in
*
nb_out
*
sizeof
(
int
));
s
->
native_one
=
av_mallocz
(
sizeof
(
int
));
for
(
i
=
0
;
i
<
nb_out
;
i
++
)
for
(
j
=
0
;
j
<
nb_in
;
j
++
)
((
int
*
)
s
->
native_matrix
)[
i
*
nb_in
+
j
]
=
lrintf
(
s
->
matrix
[
i
][
j
]
*
32768
);
*
((
int
*
)
s
->
native_one
)
=
32768
;
}
else
if
(
s
->
midbuf
.
fmt
==
AV_SAMPLE_FMT_FLTP
){
s
->
native_matrix
=
av_mallocz
(
nb_in
*
nb_out
*
sizeof
(
float
));
s
->
native_one
=
av_mallocz
(
sizeof
(
float
));
for
(
i
=
0
;
i
<
nb_out
;
i
++
)
for
(
j
=
0
;
j
<
nb_in
;
j
++
)
((
float
*
)
s
->
native_matrix
)[
i
*
nb_in
+
j
]
=
s
->
matrix
[
i
][
j
];
*
((
float
*
)
s
->
native_one
)
=
1
.
0
;
}
else
av_assert0
(
0
);
//FIXME quantize for integeres
for
(
i
=
0
;
i
<
SWR_CH_MAX
;
i
++
)
{
int
ch_in
=
0
;
...
...
@@ -281,6 +299,11 @@ void swri_sum2(enum AVSampleFormat format, void *dst, const void *src0, const vo
}
}
void
swri_rematrix_free
(
SwrContext
*
s
){
av_freep
(
&
s
->
native_matrix
);
av_freep
(
&
s
->
native_one
);
}
int
swri_rematrix
(
SwrContext
*
s
,
AudioData
*
out
,
AudioData
*
in
,
int
len
,
int
mustcopy
){
int
out_i
,
in_i
,
i
,
j
;
...
...
libswresample/swresample.c
View file @
00fea26f
...
...
@@ -176,6 +176,7 @@ void swr_free(SwrContext **ss){
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_resample_free
(
&
s
->
resample
);
swri_rematrix_free
(
s
);
}
av_freep
(
ss
);
...
...
@@ -193,6 +194,7 @@ int swr_init(struct SwrContext *s){
swri_audio_convert_free
(
&
s
->
in_convert
);
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_rematrix_free
(
s
);
s
->
flushed
=
0
;
...
...
libswresample/swresample_internal.h
View file @
00fea26f
...
...
@@ -80,6 +80,8 @@ struct SwrContext {
struct
ResampleContext
*
resample
;
///< resampling context
float
matrix
[
SWR_CH_MAX
][
SWR_CH_MAX
];
///< floating point rematrixing coefficients
uint8_t
*
native_matrix
;
uint8_t
*
native_one
;
int32_t
matrix32
[
SWR_CH_MAX
][
SWR_CH_MAX
];
///< 17.15 fixed point rematrixing coefficients
uint8_t
matrix_ch
[
SWR_CH_MAX
][
SWR_CH_MAX
+
1
];
///< Lists of input channels per output channel that have non zero rematrixing coefficients
...
...
@@ -96,6 +98,7 @@ int swri_resample_float(struct ResampleContext *c, float *dst, const float *
int
swri_resample_double
(
struct
ResampleContext
*
c
,
double
*
dst
,
const
double
*
src
,
int
*
consumed
,
int
src_size
,
int
dst_size
,
int
update_ctx
);
int
swri_rematrix_init
(
SwrContext
*
s
);
void
swri_rematrix_free
(
SwrContext
*
s
);
int
swri_rematrix
(
SwrContext
*
s
,
AudioData
*
out
,
AudioData
*
in
,
int
len
,
int
mustcopy
);
void
swri_sum2
(
enum
AVSampleFormat
format
,
void
*
dst
,
const
void
*
src0
,
const
void
*
src1
,
float
coef0
,
float
coef1
,
int
len
);
...
...
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