Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
8593b743
Commit
8593b743
authored
Sep 19, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rematrix: dont use floats for int16 code.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
c3c1af6d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
17 deletions
+27
-17
rematrix.c
libswresample/rematrix.c
+14
-5
rematrix_template.c
libswresample/rematrix_template.c
+5
-5
swresample_internal.h
libswresample/swresample_internal.h
+1
-0
g726
tests/ref/acodec/g726
+3
-3
dv_fmt
tests/ref/lavf/dv_fmt
+2
-2
mxf_d10
tests/ref/lavf/mxf_d10
+2
-2
No files found.
libswresample/rematrix.c
View file @
8593b743
...
...
@@ -22,12 +22,18 @@
#include "libavutil/audioconvert.h"
#include "libavutil/avassert.h"
#define ONE (1.0)
#define R(x) x
#define SAMPLE float
#define RENAME(x) x ## _float
#include "rematrix_template.c"
#undef SAMPLE
#undef RENAME
#undef R
#undef ONE
#define ONE (-32768)
#define R(x) (((x) + 16384)>>15)
#define SAMPLE int16_t
#define RENAME(x) x ## _s16
#include "rematrix_template.c"
...
...
@@ -188,6 +194,7 @@ int swr_rematrix_init(SwrContext *s){
int
ch_in
=
0
;
for
(
j
=
0
;
j
<
64
;
j
++
){
s
->
matrix
[
out_i
][
in_i
]
=
matrix
[
i
][
j
];
s
->
matrix16
[
out_i
][
in_i
]
=
lrintf
(
matrix
[
i
][
j
]
*
32768
);
if
(
matrix
[
i
][
j
]){
s
->
matrix_ch
[
out_i
][
++
ch_in
]
=
in_i
;
sum
+=
fabs
(
matrix
[
i
][
j
]);
...
...
@@ -203,8 +210,10 @@ int swr_rematrix_init(SwrContext *s){
if
((
s
->
out_sample_fmt
<
AV_SAMPLE_FMT_FLT
||
s
->
int_sample_fmt
<
AV_SAMPLE_FMT_FLT
)
&&
maxcoef
>
1
.
0
){
for
(
i
=
0
;
i
<
SWR_CH_MAX
;
i
++
)
for
(
j
=
0
;
j
<
SWR_CH_MAX
;
j
++
)
for
(
j
=
0
;
j
<
SWR_CH_MAX
;
j
++
)
{
s
->
matrix
[
i
][
j
]
/=
maxcoef
;
s
->
matrix16
[
i
][
j
]
=
lrintf
(
s
->
matrix
[
i
][
j
]
*
32768
);
}
}
for
(
i
=
0
;
i
<
av_get_channel_layout_nb_channels
(
s
->
out_ch_layout
);
i
++
){
for
(
j
=
0
;
j
<
av_get_channel_layout_nb_channels
(
s
->
in_ch_layout
);
j
++
){
...
...
@@ -229,7 +238,7 @@ av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout))
if
(
s
->
int_sample_fmt
==
AV_SAMPLE_FMT_FLT
){
copy_float
(
out
->
ch
[
out_i
],
in
->
ch
[
in_i
],
s
->
matrix
[
out_i
][
in_i
],
len
);
}
else
copy_s16
(
out
->
ch
[
out_i
],
in
->
ch
[
in_i
],
s
->
matrix
[
out_i
][
in_i
],
len
);
copy_s16
(
out
->
ch
[
out_i
],
in
->
ch
[
in_i
],
s
->
matrix
16
[
out_i
][
in_i
],
len
);
}
else
{
out
->
ch
[
out_i
]
=
in
->
ch
[
in_i
];
}
...
...
@@ -241,7 +250,7 @@ av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout))
len
);
}
else
{
sum2_s16
(
out
->
ch
[
out_i
],
in
->
ch
[
s
->
matrix_ch
[
out_i
][
1
]
],
in
->
ch
[
s
->
matrix_ch
[
out_i
][
2
]
],
s
->
matrix
[
out_i
][
s
->
matrix_ch
[
out_i
][
1
]
],
s
->
matrix
[
out_i
][
s
->
matrix_ch
[
out_i
][
2
]
],
s
->
matrix
16
[
out_i
][
s
->
matrix_ch
[
out_i
][
1
]
],
s
->
matrix16
[
out_i
][
s
->
matrix_ch
[
out_i
][
2
]
],
len
);
}
break
;
...
...
@@ -260,9 +269,9 @@ av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout))
int
v
=
0
;
for
(
j
=
0
;
j
<
s
->
matrix_ch
[
out_i
][
0
];
j
++
){
in_i
=
s
->
matrix_ch
[
out_i
][
1
+
j
];
v
+=
((
int16_t
*
)
in
->
ch
[
in_i
])[
i
]
*
s
->
matrix
[
out_i
][
in_i
];
//FIXME use int16 coeffs
v
+=
((
int16_t
*
)
in
->
ch
[
in_i
])[
i
]
*
s
->
matrix
16
[
out_i
][
in_i
];
}
((
int16_t
*
)
out
->
ch
[
out_i
])[
i
]
=
v
;
((
int16_t
*
)
out
->
ch
[
out_i
])[
i
]
=
(
v
+
16384
)
>>
15
;
}
}
}
...
...
libswresample/rematrix_template.c
View file @
8593b743
...
...
@@ -19,20 +19,20 @@
*/
static
void
RENAME
(
sum2
)(
SAMPLE
*
out
,
const
SAMPLE
*
in1
,
const
SAMPLE
*
in2
,
float
coeff1
,
float
coeff2
,
int
len
){
static
void
RENAME
(
sum2
)(
SAMPLE
*
out
,
const
SAMPLE
*
in1
,
const
SAMPLE
*
in2
,
SAMPLE
coeff1
,
SAMPLE
coeff2
,
int
len
){
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
out
[
i
]
=
coeff1
*
in1
[
i
]
+
coeff2
*
in2
[
i
];
//FIXME better int16
out
[
i
]
=
R
(
coeff1
*
in1
[
i
]
+
coeff2
*
in2
[
i
]);
}
static
void
RENAME
(
copy
)(
SAMPLE
*
out
,
const
SAMPLE
*
in
,
float
coeff
,
int
len
){
if
(
coeff
==
1
.
0
){
static
void
RENAME
(
copy
)(
SAMPLE
*
out
,
const
SAMPLE
*
in
,
SAMPLE
coeff
,
int
len
){
if
(
coeff
==
ONE
){
memcpy
(
out
,
in
,
sizeof
(
SAMPLE
)
*
len
);
}
else
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
out
[
i
]
=
coeff
*
in
[
i
];
//FIXME better int16
out
[
i
]
=
R
(
coeff
*
in
[
i
]);
}
}
libswresample/swresample_internal.h
View file @
8593b743
...
...
@@ -61,6 +61,7 @@ typedef struct SwrContext { //FIXME find unused fields
struct
AVResampleContext
*
resample
;
float
matrix
[
SWR_CH_MAX
][
SWR_CH_MAX
];
int16_t
matrix16
[
SWR_CH_MAX
][
SWR_CH_MAX
];
uint8_t
matrix_ch
[
SWR_CH_MAX
][
SWR_CH_MAX
+
1
];
//TODO callbacks for asm optims
...
...
tests/ref/acodec/g726
View file @
8593b743
a76fc937faac62c5de057cd69191732a
*./tests/data/acodec/g726.wav
687d70267e999fc9afba2a1ecc960f3c
*./tests/data/acodec/g726.wav
24052 ./tests/data/acodec/g726.wav
124de13e6cb5af64ea8758aa49feb7fc
*./tests/data/g726.acodec.out.wav
stddev: 855
4.23
PSNR: 17.69 MAXDIFF:29353 bytes: 95984/ 1058400
700845e9457cae5f961fb703cb46d6a7
*./tests/data/g726.acodec.out.wav
stddev: 855
3.69
PSNR: 17.69 MAXDIFF:29353 bytes: 95984/ 1058400
tests/ref/lavf/dv_fmt
View file @
8593b743
6e716216d5f9e3819db8eb8796de9129
*./tests/data/lavf/lavf.dv
3a6a9163a67b729b4a6b5d972ccceb97
*./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x
92d1e3f0
./tests/data/lavf/lavf.dv CRC=0x
5ce4e5e4
tests/ref/lavf/mxf_d10
View file @
8593b743
8eb67301f72f2b5860fafab422b920ad
*./tests/data/lavf/lavf.mxf_d10
23177c8a72f34e243e9ffc4f6c70d3c7
*./tests/data/lavf/lavf.mxf_d10
5330989 ./tests/data/lavf/lavf.mxf_d10
./tests/data/lavf/lavf.mxf_d10 CRC=0x
96c02dfd
./tests/data/lavf/lavf.mxf_d10 CRC=0x
81602ff1
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