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
3d66717f
Commit
3d66717f
authored
Oct 19, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/decode_audio: use the new audio decoding API
parent
0946c754
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
decode_audio.c
doc/examples/decode_audio.c
+20
-14
No files found.
doc/examples/decode_audio.c
View file @
3d66717f
...
...
@@ -40,24 +40,30 @@
static
void
decode
(
AVCodecContext
*
dec_ctx
,
AVPacket
*
pkt
,
AVFrame
*
frame
,
FILE
*
outfile
)
{
int
len
,
got_fram
e
;
int
ret
,
data_siz
e
;
while
(
pkt
->
size
>
0
)
{
len
=
avcodec_decode_audio4
(
dec_ctx
,
frame
,
&
got_frame
,
pkt
);
if
(
len
<
0
)
{
fprintf
(
stderr
,
"Error while decoding
\n
"
);
/* send the packet with the compressed data to the decoder */
ret
=
avcodec_send_packet
(
dec_ctx
,
pkt
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error submitting the packet to the decoder
\n
"
);
exit
(
1
);
}
/* read all the output frames (in general there may be any number of them */
while
(
ret
>=
0
)
{
ret
=
avcodec_receive_frame
(
dec_ctx
,
frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
return
;
else
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error during decoding
\n
"
);
exit
(
1
);
}
if
(
got_frame
)
{
/* if a frame has been decoded, output it */
int
data_size
=
av_samples_get_buffer_size
(
NULL
,
dec_ctx
->
channels
,
data_size
=
av_samples_get_buffer_size
(
NULL
,
dec_ctx
->
channels
,
frame
->
nb_samples
,
dec_ctx
->
sample_fmt
,
1
);
fwrite
(
frame
->
data
[
0
],
1
,
data_size
,
outfile
);
}
pkt
->
size
-=
len
;
pkt
->
data
+=
len
;
}
}
int
main
(
int
argc
,
char
**
argv
)
...
...
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