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
a1f7885a
Commit
a1f7885a
authored
Sep 14, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shorten: split reading of file header into a separate functions
parent
9ef6c797
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
61 deletions
+70
-61
shorten.c
libavcodec/shorten.c
+70
-61
No files found.
libavcodec/shorten.c
View file @
a1f7885a
...
...
@@ -273,44 +273,9 @@ static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_siz
}
}
static
int
shorten_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
data_size
,
AVPacket
*
avpkt
)
static
int
read_header
(
ShortenContext
*
s
)
{
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
ShortenContext
*
s
=
avctx
->
priv_data
;
int
i
,
input_buf_size
=
0
;
int16_t
*
samples
=
data
;
if
(
s
->
max_framesize
==
0
){
s
->
max_framesize
=
1024
;
// should hopefully be enough for the first header
s
->
bitstream
=
av_fast_realloc
(
s
->
bitstream
,
&
s
->
allocated_bitstream_size
,
s
->
max_framesize
);
}
if
(
1
&&
s
->
max_framesize
){
//FIXME truncated
buf_size
=
FFMIN
(
buf_size
,
s
->
max_framesize
-
s
->
bitstream_size
);
input_buf_size
=
buf_size
;
if
(
s
->
bitstream_index
+
s
->
bitstream_size
+
buf_size
>
s
->
allocated_bitstream_size
){
// printf("memmove\n");
memmove
(
s
->
bitstream
,
&
s
->
bitstream
[
s
->
bitstream_index
],
s
->
bitstream_size
);
s
->
bitstream_index
=
0
;
}
memcpy
(
&
s
->
bitstream
[
s
->
bitstream_index
+
s
->
bitstream_size
],
buf
,
buf_size
);
buf
=
&
s
->
bitstream
[
s
->
bitstream_index
];
buf_size
+=
s
->
bitstream_size
;
s
->
bitstream_size
=
buf_size
;
if
(
buf_size
<
s
->
max_framesize
){
*
data_size
=
0
;
return
input_buf_size
;
}
}
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
skip_bits
(
&
s
->
gb
,
s
->
bitindex
);
if
(
!
s
->
blocksize
)
{
int
i
;
int
maxnlpc
=
0
;
/* shorten signature */
if
(
get_bits_long
(
&
s
->
gb
,
32
)
!=
AV_RB32
(
"ajkg"
))
{
...
...
@@ -367,11 +332,55 @@ static int shorten_decode_frame(AVCodecContext *avctx,
for
(
i
=
0
;
i
<
s
->
header_size
;
i
++
)
s
->
header
[
i
]
=
(
char
)
get_ur_golomb_shorten
(
&
s
->
gb
,
VERBATIM_BYTE_SIZE
);
if
(
decode_wave_header
(
avctx
,
s
->
header
,
s
->
header_size
)
<
0
)
if
(
decode_wave_header
(
s
->
avctx
,
s
->
header
,
s
->
header_size
)
<
0
)
return
-
1
;
s
->
cur_chan
=
0
;
s
->
bitshift
=
0
;
return
0
;
}
static
int
shorten_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
data_size
,
AVPacket
*
avpkt
)
{
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
ShortenContext
*
s
=
avctx
->
priv_data
;
int
i
,
input_buf_size
=
0
;
int16_t
*
samples
=
data
;
if
(
s
->
max_framesize
==
0
){
s
->
max_framesize
=
1024
;
// should hopefully be enough for the first header
s
->
bitstream
=
av_fast_realloc
(
s
->
bitstream
,
&
s
->
allocated_bitstream_size
,
s
->
max_framesize
);
}
if
(
1
&&
s
->
max_framesize
){
//FIXME truncated
buf_size
=
FFMIN
(
buf_size
,
s
->
max_framesize
-
s
->
bitstream_size
);
input_buf_size
=
buf_size
;
if
(
s
->
bitstream_index
+
s
->
bitstream_size
+
buf_size
>
s
->
allocated_bitstream_size
){
// printf("memmove\n");
memmove
(
s
->
bitstream
,
&
s
->
bitstream
[
s
->
bitstream_index
],
s
->
bitstream_size
);
s
->
bitstream_index
=
0
;
}
memcpy
(
&
s
->
bitstream
[
s
->
bitstream_index
+
s
->
bitstream_size
],
buf
,
buf_size
);
buf
=
&
s
->
bitstream
[
s
->
bitstream_index
];
buf_size
+=
s
->
bitstream_size
;
s
->
bitstream_size
=
buf_size
;
if
(
buf_size
<
s
->
max_framesize
){
*
data_size
=
0
;
return
input_buf_size
;
}
}
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
skip_bits
(
&
s
->
gb
,
s
->
bitindex
);
if
(
!
s
->
blocksize
)
{
int
ret
;
if
((
ret
=
read_header
(
s
))
<
0
)
return
ret
;
}
else
{
...
...
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