Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
00fea26f
Commit
00fea26f
authored
12 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
swr: add native matrix for rematrixing
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
f0839764
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libswresample/rematrix.c
+23
-0
23 additions, 0 deletions
libswresample/rematrix.c
libswresample/swresample.c
+2
-0
2 additions, 0 deletions
libswresample/swresample.c
libswresample/swresample_internal.h
+3
-0
3 additions, 0 deletions
libswresample/swresample_internal.h
with
28 additions
and
0 deletions
libswresample/rematrix.c
+
23
−
0
View file @
00fea26f
...
@@ -253,12 +253,30 @@ static int auto_matrix(SwrContext *s)
...
@@ -253,12 +253,30 @@ static int auto_matrix(SwrContext *s)
int
swri_rematrix_init
(
SwrContext
*
s
){
int
swri_rematrix_init
(
SwrContext
*
s
){
int
i
,
j
;
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
)
{
if
(
!
s
->
rematrix_custom
)
{
int
r
=
auto_matrix
(
s
);
int
r
=
auto_matrix
(
s
);
if
(
r
)
if
(
r
)
return
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
//FIXME quantize for integeres
for
(
i
=
0
;
i
<
SWR_CH_MAX
;
i
++
)
{
for
(
i
=
0
;
i
<
SWR_CH_MAX
;
i
++
)
{
int
ch_in
=
0
;
int
ch_in
=
0
;
...
@@ -281,6 +299,11 @@ void swri_sum2(enum AVSampleFormat format, void *dst, const void *src0, const vo
...
@@ -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
swri_rematrix
(
SwrContext
*
s
,
AudioData
*
out
,
AudioData
*
in
,
int
len
,
int
mustcopy
){
int
out_i
,
in_i
,
i
,
j
;
int
out_i
,
in_i
,
i
,
j
;
...
...
This diff is collapsed.
Click to expand it.
libswresample/swresample.c
+
2
−
0
View file @
00fea26f
...
@@ -176,6 +176,7 @@ void swr_free(SwrContext **ss){
...
@@ -176,6 +176,7 @@ void swr_free(SwrContext **ss){
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_resample_free
(
&
s
->
resample
);
swri_resample_free
(
&
s
->
resample
);
swri_rematrix_free
(
s
);
}
}
av_freep
(
ss
);
av_freep
(
ss
);
...
@@ -193,6 +194,7 @@ int swr_init(struct SwrContext *s){
...
@@ -193,6 +194,7 @@ int swr_init(struct SwrContext *s){
swri_audio_convert_free
(
&
s
->
in_convert
);
swri_audio_convert_free
(
&
s
->
in_convert
);
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
out_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_audio_convert_free
(
&
s
->
full_convert
);
swri_rematrix_free
(
s
);
s
->
flushed
=
0
;
s
->
flushed
=
0
;
...
...
This diff is collapsed.
Click to expand it.
libswresample/swresample_internal.h
+
3
−
0
View file @
00fea26f
...
@@ -80,6 +80,8 @@ struct SwrContext {
...
@@ -80,6 +80,8 @@ struct SwrContext {
struct
ResampleContext
*
resample
;
///< resampling context
struct
ResampleContext
*
resample
;
///< resampling context
float
matrix
[
SWR_CH_MAX
][
SWR_CH_MAX
];
///< floating point rematrixing coefficients
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
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
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 *
...
@@ -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_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
);
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
);
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
);
void
swri_sum2
(
enum
AVSampleFormat
format
,
void
*
dst
,
const
void
*
src0
,
const
void
*
src1
,
float
coef0
,
float
coef1
,
int
len
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment