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
387afa9d
Commit
387afa9d
authored
18 years ago
by
Baptiste Coudurier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix adpcm swf decoding
Originally committed as revision 8186 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
4906b026
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
39 deletions
+20
-39
adpcm.c
libavcodec/adpcm.c
+20
-39
No files found.
libavcodec/adpcm.c
View file @
387afa9d
...
...
@@ -150,10 +150,6 @@ typedef struct ADPCMContext {
int
channel
;
/* for stereo MOVs, decode left, then decode right, then tell it's decoded */
ADPCMChannelStatus
status
[
2
];
short
sample_buffer
[
32
];
/* hold left samples while waiting for right samples */
/* SWF only */
int
nb_bits
;
int
nb_samples
;
}
ADPCMContext
;
/* XXX: implement encoding */
...
...
@@ -1240,46 +1236,30 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
{
GetBitContext
gb
;
const
int
*
table
;
int
k0
,
signmask
;
int
k0
,
signmask
,
nb_bits
;
int
size
=
buf_size
*
8
;
init_get_bits
(
&
gb
,
buf
,
size
);
//FIXME the following return -1 may be removed only after
//1. correctly spliting the stream into packets at demuxer or parser level
//2. checking array bounds when writing
//3. moving the global nb_bits header into extradata
return
-
1
;
// first frame, read bits & inital values
if
(
!
c
->
nb_bits
)
{
c
->
nb_bits
=
get_bits
(
&
gb
,
2
)
+
2
;
// av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", c->nb_bits);
}
//read bits & inital values
nb_bits
=
get_bits
(
&
gb
,
2
)
+
2
;
//av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
table
=
swf_index_tables
[
nb_bits
-
2
];
k0
=
1
<<
(
nb_bits
-
2
);
signmask
=
1
<<
(
nb_bits
-
1
);
table
=
swf_index_tables
[
c
->
nb_bits
-
2
];
k0
=
1
<<
(
c
->
nb_bits
-
2
);
signmask
=
1
<<
(
c
->
nb_bits
-
1
);
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
*
samples
++
=
c
->
status
[
i
].
predictor
=
get_sbits
(
&
gb
,
16
);
c
->
status
[
i
].
step_index
=
get_bits
(
&
gb
,
6
);
}
while
(
get_bits_count
(
&
gb
)
<
=
size
)
while
(
get_bits_count
(
&
gb
)
<
size
)
{
int
i
;
c
->
nb_samples
++
;
// wrap around at every 4096 samples...
if
((
c
->
nb_samples
&
0xfff
)
==
1
)
{
for
(
i
=
0
;
i
<=
st
;
i
++
)
{
*
samples
++
=
c
->
status
[
i
].
predictor
=
get_sbits
(
&
gb
,
16
);
c
->
status
[
i
].
step_index
=
get_bits
(
&
gb
,
6
);
}
}
// similar to IMA adpcm
for
(
i
=
0
;
i
<=
st
;
i
++
)
{
int
delta
=
get_bits
(
&
gb
,
c
->
nb_bits
);
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
// similar to IMA adpcm
int
delta
=
get_bits
(
&
gb
,
nb_bits
);
int
step
=
step_table
[
c
->
status
[
i
].
step_index
];
long
vpdiff
=
0
;
// vpdiff = (delta+0.5)*step/4
int
k
=
k0
;
...
...
@@ -1303,12 +1283,13 @@ return -1;
c
->
status
[
i
].
predictor
=
av_clip
(
c
->
status
[
i
].
predictor
,
-
32768
,
32767
);
*
samples
++
=
c
->
status
[
i
].
predictor
;
if
(
samples
>=
samples_end
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"allocated output buffer is too small
\n
"
);
return
-
1
;
}
}
}
// src += get_bits_count(&gb)*8;
src
+=
size
;
src
+=
buf_size
;
break
;
}
case
CODEC_ID_ADPCM_YAMAHA
:
...
...
This diff is collapsed.
Click to expand it.
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