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
2d6c29f5
Commit
2d6c29f5
authored
Apr 29, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr: add set_audiodata_fmt() and use it to simplify code
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
65722e7f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
swresample.c
libswresample/swresample.c
+11
-10
swresample_internal.h
libswresample/swresample_internal.h
+0
-1
No files found.
libswresample/swresample.c
View file @
2d6c29f5
...
...
@@ -153,6 +153,10 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
return
s
;
}
static
void
set_audiodata_fmt
(
AudioData
*
a
,
enum
AVSampleFormat
fmt
){
a
->
bps
=
av_get_bytes_per_sample
(
fmt
);
a
->
planar
=
av_sample_fmt_is_planar
(
fmt
);
}
static
void
free_temp
(
AudioData
*
a
){
av_free
(
a
->
data
);
...
...
@@ -191,9 +195,6 @@ int swr_init(struct SwrContext *s){
s
->
flushed
=
0
;
s
->
in
.
planar
=
av_sample_fmt_is_planar
(
s
->
in_sample_fmt
);
s
->
out
.
planar
=
av_sample_fmt_is_planar
(
s
->
out_sample_fmt
);
if
(
s
->
in_sample_fmt
>=
AV_SAMPLE_FMT_NB
){
av_log
(
s
,
AV_LOG_ERROR
,
"Requested input sample format %d is invalid
\n
"
,
s
->
in_sample_fmt
);
return
AVERROR
(
EINVAL
);
...
...
@@ -216,6 +217,9 @@ int swr_init(struct SwrContext *s){
return
AVERROR
(
EINVAL
);
}
set_audiodata_fmt
(
&
s
->
in
,
s
->
in_sample_fmt
);
set_audiodata_fmt
(
&
s
->
out
,
s
->
out_sample_fmt
);
if
(
s
->
out_sample_rate
!=
s
->
in_sample_rate
||
(
s
->
flags
&
SWR_FLAG_RESAMPLE
)){
s
->
resample
=
swri_resample_init
(
s
->
resample
,
s
->
out_sample_rate
,
s
->
in_sample_rate
,
s
->
filter_size
,
s
->
phase_shift
,
s
->
linear_interp
,
s
->
cutoff
,
s
->
int_sample_fmt
);
}
else
...
...
@@ -267,9 +271,6 @@ av_assert0(s->used_ch_count);
av_assert0
(
s
->
out
.
ch_count
);
s
->
resample_first
=
RSC
*
s
->
out
.
ch_count
/
s
->
in
.
ch_count
-
RSC
<
s
->
out_sample_rate
/
(
float
)
s
->
in_sample_rate
-
1
.
0
;
s
->
in
.
bps
=
av_get_bytes_per_sample
(
s
->
in_sample_fmt
);
s
->
int_bps
=
av_get_bytes_per_sample
(
s
->
int_sample_fmt
);
s
->
out
.
bps
=
av_get_bytes_per_sample
(
s
->
out_sample_fmt
);
s
->
in_buffer
=
s
->
in
;
if
(
!
s
->
resample
&&
!
s
->
rematrix
&&
!
s
->
channel_map
){
...
...
@@ -300,12 +301,12 @@ av_assert0(s->out.ch_count);
s
->
in_buffer
.
ch_count
=
s
->
out
.
ch_count
;
}
s
->
postin
.
bps
=
s
->
midbuf
.
bps
=
s
->
preout
.
bps
=
s
->
int_bps
;
s
->
postin
.
planar
=
s
->
midbuf
.
planar
=
s
->
preout
.
planar
=
1
;
set_audiodata_fmt
(
&
s
->
postin
,
s
->
int_sample_fmt
);
set_audiodata_fmt
(
&
s
->
midbuf
,
s
->
int_sample_fmt
);
set_audiodata_fmt
(
&
s
->
preout
,
s
->
int_sample_fmt
);
if
(
s
->
resample
){
s
->
in_buffer
.
bps
=
s
->
int_bps
;
s
->
in_buffer
.
planar
=
1
;
set_audiodata_fmt
(
&
s
->
in_buffer
,
s
->
int_sample_fmt
);
}
s
->
dither
=
s
->
preout
;
...
...
libswresample/swresample_internal.h
View file @
2d6c29f5
...
...
@@ -57,7 +57,6 @@ struct SwrContext {
int
linear_interp
;
/**< if 1 then the resampling FIR filter will be linearly interpolated */
double
cutoff
;
/**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */
int
int_bps
;
///< internal bytes per sample
int
resample_first
;
///< 1 if resampling must come first, 0 if rematrixing
int
rematrix
;
///< flag to indicate if rematrixing is needed (basically if input and output layouts mismatch)
int
rematrix_custom
;
///< flag to indicate that a custom matrix has been defined
...
...
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