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
4a876eba
Commit
4a876eba
authored
Mar 17, 2012
by
Ronald S. Bultje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adpcm: convert adpcm_ea to bytestream2.
parent
524af484
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
29 deletions
+24
-29
adpcm.c
libavcodec/adpcm.c
+24
-29
No files found.
libavcodec/adpcm.c
View file @
4a876eba
...
...
@@ -403,9 +403,7 @@ static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf,
switch
(
avctx
->
codec
->
id
)
{
case
CODEC_ID_ADPCM_EA
:
has_coded_samples
=
1
;
if
(
buf_size
<
4
)
return
0
;
*
coded_samples
=
AV_RL32
(
buf
);
*
coded_samples
=
bytestream2_get_le32
(
gb
);
*
coded_samples
-=
*
coded_samples
%
28
;
nb_samples
=
(
buf_size
-
12
)
/
30
*
28
;
break
;
...
...
@@ -868,37 +866,35 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
break
;
case
CODEC_ID_ADPCM_EA
:
{
int
32_t
previous_left_sample
,
previous_right_sample
;
int
32_t
current_left_sample
,
current_right_sample
;
int
32_t
next_left_sample
,
next_right_sample
;
int
32_t
coeff1l
,
coeff2l
,
coeff1r
,
coeff2r
;
uint8_
t
shift_left
,
shift_right
;
int
previous_left_sample
,
previous_right_sample
;
int
current_left_sample
,
current_right_sample
;
int
next_left_sample
,
next_right_sample
;
int
coeff1l
,
coeff2l
,
coeff1r
,
coeff2r
;
in
t
shift_left
,
shift_right
;
/* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
each coding 28 stereo samples. */
src
+=
4
;
// skip sample count (already read)
current_left_sample
=
(
int16_t
)
bytestream_get_le16
(
&
src
);
previous_left_sample
=
(
int16_t
)
bytestream_get_le16
(
&
src
);
current_right_sample
=
(
int16_t
)
bytestream_get_le16
(
&
src
);
previous_right_sample
=
(
int16_t
)
bytestream_get_le16
(
&
src
);
current_left_sample
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
previous_left_sample
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
current_right_sample
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
previous_right_sample
=
sign_extend
(
bytestream2_get_le16u
(
&
gb
),
16
);
for
(
count1
=
0
;
count1
<
nb_samples
/
28
;
count1
++
)
{
coeff1l
=
ea_adpcm_table
[
*
src
>>
4
]
;
coeff
2l
=
ea_adpcm_table
[(
*
src
>>
4
)
+
4
];
coeff
1r
=
ea_adpcm_table
[
*
src
&
0x0F
];
coeff
2r
=
ea_adpcm_table
[(
*
src
&
0x0F
)
+
4
];
src
++
;
int
byte
=
bytestream2_get_byteu
(
&
gb
)
;
coeff
1l
=
ea_adpcm_table
[
byte
>>
4
];
coeff
2l
=
ea_adpcm_table
[(
byte
>>
4
)
+
4
];
coeff
1r
=
ea_adpcm_table
[
byte
&
0x0F
];
coeff2r
=
ea_adpcm_table
[(
byte
&
0x0F
)
+
4
]
;
shift_left
=
20
-
(
*
src
>>
4
);
shift_
right
=
20
-
(
*
src
&
0x0F
);
s
rc
++
;
byte
=
bytestream2_get_byteu
(
&
gb
);
shift_
left
=
20
-
(
byte
>>
4
);
s
hift_right
=
20
-
(
byte
&
0x0F
)
;
for
(
count2
=
0
;
count2
<
28
;
count2
++
)
{
next_left_sample
=
sign_extend
(
*
src
>>
4
,
4
)
<<
shift_left
;
next_
right_sample
=
sign_extend
(
*
src
,
4
)
<<
shift_righ
t
;
src
++
;
byte
=
bytestream2_get_byteu
(
&
gb
)
;
next_
left_sample
=
sign_extend
(
byte
>>
4
,
4
)
<<
shift_lef
t
;
next_right_sample
=
sign_extend
(
byte
,
4
)
<<
shift_right
;
next_left_sample
=
(
next_left_sample
+
(
current_left_sample
*
coeff1l
)
+
...
...
@@ -911,13 +907,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
current_left_sample
=
av_clip_int16
(
next_left_sample
);
previous_right_sample
=
current_right_sample
;
current_right_sample
=
av_clip_int16
(
next_right_sample
);
*
samples
++
=
(
unsigned
short
)
current_left_sample
;
*
samples
++
=
(
unsigned
short
)
current_right_sample
;
*
samples
++
=
current_left_sample
;
*
samples
++
=
current_right_sample
;
}
}
if
(
src
-
buf
==
buf_size
-
2
)
src
+=
2
;
// Skip terminating 0x0000
bytestream2_skip
(
&
gb
,
2
);
// Skip terminating 0x0000
break
;
}
...
...
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