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
b304244b
Commit
b304244b
authored
Sep 08, 2011
by
Baptiste Coudurier
Committed by
Justin Ruggles
Sep 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adpcmenc: fix QT IMA ADPCM encoder
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
bf334535
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
+38
-7
adpcmenc.c
libavcodec/adpcmenc.c
+35
-4
adpcm_ima_qt
tests/ref/acodec/adpcm_ima_qt
+3
-3
No files found.
libavcodec/adpcmenc.c
View file @
b304244b
...
...
@@ -164,6 +164,39 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho
return
nibble
;
}
static
inline
unsigned
char
adpcm_ima_qt_compress_sample
(
ADPCMChannelStatus
*
c
,
short
sample
)
{
int
delta
=
sample
-
c
->
prev_sample
;
int
mask
,
step
=
ff_adpcm_step_table
[
c
->
step_index
];
int
diff
=
step
>>
3
;
int
nibble
=
0
;
if
(
delta
<
0
)
{
nibble
=
8
;
delta
=
-
delta
;
}
for
(
mask
=
4
;
mask
;)
{
if
(
delta
>=
step
)
{
nibble
|=
mask
;
delta
-=
step
;
diff
+=
step
;
}
step
>>=
1
;
mask
>>=
1
;
}
if
(
nibble
&
8
)
c
->
prev_sample
-=
diff
;
else
c
->
prev_sample
+=
diff
;
c
->
prev_sample
=
av_clip_int16
(
c
->
prev_sample
);
c
->
step_index
=
av_clip
(
c
->
step_index
+
ff_adpcm_index_table
[
nibble
],
0
,
88
);
return
nibble
;
}
static
inline
unsigned
char
adpcm_ms_compress_sample
(
ADPCMChannelStatus
*
c
,
short
sample
)
{
int
predictor
,
nibble
,
bias
;
...
...
@@ -497,16 +530,14 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
adpcm_compress_trellis
(
avctx
,
samples
+
ch
,
buf
,
&
c
->
status
[
ch
],
64
);
for
(
i
=
0
;
i
<
64
;
i
++
)
put_bits
(
&
pb
,
4
,
buf
[
i
^
1
]);
c
->
status
[
ch
].
prev_sample
=
c
->
status
[
ch
].
predictor
&
~
0x7F
;
}
else
{
for
(
i
=
0
;
i
<
64
;
i
+=
2
){
int
t1
,
t2
;
t1
=
adpcm_ima_compress_sample
(
&
c
->
status
[
ch
],
samples
[
avctx
->
channels
*
(
i
+
0
)
+
ch
]);
t2
=
adpcm_ima_compress_sample
(
&
c
->
status
[
ch
],
samples
[
avctx
->
channels
*
(
i
+
1
)
+
ch
]);
t1
=
adpcm_ima_
qt_
compress_sample
(
&
c
->
status
[
ch
],
samples
[
avctx
->
channels
*
(
i
+
0
)
+
ch
]);
t2
=
adpcm_ima_
qt_
compress_sample
(
&
c
->
status
[
ch
],
samples
[
avctx
->
channels
*
(
i
+
1
)
+
ch
]);
put_bits
(
&
pb
,
4
,
t2
);
put_bits
(
&
pb
,
4
,
t1
);
}
c
->
status
[
ch
].
prev_sample
&=
~
0x7F
;
}
}
...
...
tests/ref/acodec/adpcm_ima_qt
View file @
b304244b
0
19564da45949d0b5278bd75ee9a4ac2
*./tests/data/acodec/adpcm_qt.aiff
0
57d27978b35888776512e4e9669a63b
*./tests/data/acodec/adpcm_qt.aiff
281252 ./tests/data/acodec/adpcm_qt.aiff
a7fb054f7bd82270c8fd476eb9f5677c
*./tests/data/adpcm_ima_qt.acodec.out.wav
stddev: 9
20.19 PSNR: 37.05
MAXDIFF:34029 bytes: 1058560/ 1058400
3890343c0c20934e014d7ac93f5d65bd
*./tests/data/adpcm_ima_qt.acodec.out.wav
stddev: 9
18.61 PSNR: 37.07
MAXDIFF:34029 bytes: 1058560/ 1058400
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