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
7ff55d9b
Commit
7ff55d9b
authored
Nov 20, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adx: calculate the number of blocks in a packet
parent
05c1f11b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
adxdec.c
libavcodec/adxdec.c
+11
-2
No files found.
libavcodec/adxdec.c
View file @
7ff55d9b
...
...
@@ -122,6 +122,7 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int16_t
*
samples
=
data
;
const
uint8_t
*
buf
=
buf0
;
int
rest
=
buf_size
;
int
num_blocks
;
if
(
!
c
->
header_parsed
)
{
int
hdrsize
=
adx_decode_header
(
avctx
,
buf
,
rest
);
...
...
@@ -136,8 +137,15 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
/* 18 bytes of data are expanded into 32*2 bytes of audio,
so guard against buffer overflows */
if
(
rest
/
(
BLOCK_SIZE
*
c
->
channels
)
>
*
data_size
/
(
BLOCK_SAMPLES
*
c
->
channels
))
num_blocks
=
(
rest
+
c
->
in_temp
)
/
(
BLOCK_SIZE
*
c
->
channels
);
if
(
num_blocks
>
*
data_size
/
(
BLOCK_SAMPLES
*
c
->
channels
))
{
rest
=
(
*
data_size
/
(
BLOCK_SAMPLES
*
c
->
channels
))
*
BLOCK_SIZE
;
num_blocks
=
(
rest
+
c
->
in_temp
)
/
(
BLOCK_SIZE
*
c
->
channels
);
}
if
(
!
num_blocks
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"packet is too small
\n
"
);
return
AVERROR_INVALIDDATA
;
}
if
(
c
->
in_temp
)
{
int
copysize
=
BLOCK_SIZE
*
avctx
->
channels
-
c
->
in_temp
;
...
...
@@ -148,9 +156,10 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if
(
avctx
->
channels
==
2
)
adx_decode
(
c
,
samples
+
1
,
c
->
dec_temp
+
BLOCK_SIZE
,
1
);
samples
+=
BLOCK_SAMPLES
*
c
->
channels
;
num_blocks
--
;
}
while
(
rest
>=
BLOCK_SIZE
*
c
->
channels
)
{
while
(
num_blocks
--
)
{
adx_decode
(
c
,
samples
,
buf
,
0
);
if
(
c
->
channels
==
2
)
adx_decode
(
c
,
samples
+
1
,
buf
+
BLOCK_SIZE
,
1
);
...
...
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