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
9a38184a
Commit
9a38184a
authored
Oct 19, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/decode_audio: allocate the packet dynamically
AVPackets on stack are discouraged now.
parent
45a1ce2f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
decode_audio.c
doc/examples/decode_audio.c
+6
-5
No files found.
doc/examples/decode_audio.c
View file @
9a38184a
...
...
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
uint8_t
inbuf
[
AUDIO_INBUF_SIZE
+
AV_INPUT_BUFFER_PADDING_SIZE
];
uint8_t
*
data
;
size_t
data_size
;
AVPacket
av
pkt
;
AVPacket
*
pkt
;
AVFrame
*
decoded_frame
=
NULL
;
if
(
argc
<=
2
)
{
...
...
@@ -110,7 +110,7 @@ int main(int argc, char **argv)
/* register all the codecs */
avcodec_register_all
();
av_init_packet
(
&
avpkt
);
pkt
=
av_packet_alloc
(
);
/* find the MPEG audio decoder */
codec
=
avcodec_find_decoder
(
AV_CODEC_ID_MP2
);
...
...
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
}
}
ret
=
av_parser_parse2
(
parser
,
c
,
&
avpkt
.
data
,
&
avpkt
.
size
,
ret
=
av_parser_parse2
(
parser
,
c
,
&
pkt
->
data
,
&
pkt
->
size
,
data
,
data_size
,
AV_NOPTS_VALUE
,
AV_NOPTS_VALUE
,
0
);
if
(
ret
<
0
)
{
...
...
@@ -166,8 +166,8 @@ int main(int argc, char **argv)
data
+=
ret
;
data_size
-=
ret
;
if
(
avpkt
.
size
)
decode
(
c
,
&
av
pkt
,
decoded_frame
,
outfile
);
if
(
pkt
->
size
)
decode
(
c
,
pkt
,
decoded_frame
,
outfile
);
if
(
data_size
<
AUDIO_REFILL_THRESH
)
{
memmove
(
inbuf
,
data
,
data_size
);
...
...
@@ -185,6 +185,7 @@ int main(int argc, char **argv)
avcodec_free_context
(
&
c
);
av_parser_close
(
parser
);
av_frame_free
(
&
decoded_frame
);
av_packet_free
(
&
pkt
);
return
0
;
}
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