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
e181e290
Commit
e181e290
authored
Apr 01, 2017
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/examples/transcode_aac: replace local get_error_text with av_err2str
parent
147c5ff1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
26 deletions
+14
-26
transcode_aac.c
doc/examples/transcode_aac.c
+14
-26
No files found.
doc/examples/transcode_aac.c
View file @
e181e290
...
...
@@ -45,18 +45,6 @@
/** The number of output channels */
#define OUTPUT_CHANNELS 2
/**
* Convert an error code into a text message.
* @param error Error code to be converted
* @return Corresponding error text (not thread-safe)
*/
static
const
char
*
get_error_text
(
const
int
error
)
{
static
char
error_buffer
[
255
];
av_strerror
(
error
,
error_buffer
,
sizeof
(
error_buffer
));
return
error_buffer
;
}
/** Open an input file and the required decoder. */
static
int
open_input_file
(
const
char
*
filename
,
AVFormatContext
**
input_format_context
,
...
...
@@ -70,7 +58,7 @@ static int open_input_file(const char *filename,
if
((
error
=
avformat_open_input
(
input_format_context
,
filename
,
NULL
,
NULL
))
<
0
)
{
fprintf
(
stderr
,
"Could not open input file '%s' (error '%s')
\n
"
,
filename
,
get_error_text
(
error
));
filename
,
av_err2str
(
error
));
*
input_format_context
=
NULL
;
return
error
;
}
...
...
@@ -78,7 +66,7 @@ static int open_input_file(const char *filename,
/** Get information on the input file (number of streams etc.). */
if
((
error
=
avformat_find_stream_info
(
*
input_format_context
,
NULL
))
<
0
)
{
fprintf
(
stderr
,
"Could not open find stream info (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
avformat_close_input
(
input_format_context
);
return
error
;
}
...
...
@@ -117,7 +105,7 @@ static int open_input_file(const char *filename,
/** Open the decoder for the audio stream to use it later. */
if
((
error
=
avcodec_open2
(
avctx
,
input_codec
,
NULL
))
<
0
)
{
fprintf
(
stderr
,
"Could not open input codec (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
avcodec_free_context
(
&
avctx
);
avformat_close_input
(
input_format_context
);
return
error
;
...
...
@@ -149,7 +137,7 @@ static int open_output_file(const char *filename,
if
((
error
=
avio_open
(
&
output_io_context
,
filename
,
AVIO_FLAG_WRITE
))
<
0
)
{
fprintf
(
stderr
,
"Could not open output file '%s' (error '%s')
\n
"
,
filename
,
get_error_text
(
error
));
filename
,
av_err2str
(
error
));
return
error
;
}
...
...
@@ -219,7 +207,7 @@ static int open_output_file(const char *filename,
/** Open the encoder for the audio stream to use it later. */
if
((
error
=
avcodec_open2
(
avctx
,
output_codec
,
NULL
))
<
0
)
{
fprintf
(
stderr
,
"Could not open output codec (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
goto
cleanup
;
}
...
...
@@ -325,7 +313,7 @@ static int write_output_file_header(AVFormatContext *output_format_context)
int
error
;
if
((
error
=
avformat_write_header
(
output_format_context
,
NULL
))
<
0
)
{
fprintf
(
stderr
,
"Could not write output file header (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
return
error
;
}
return
0
;
...
...
@@ -349,7 +337,7 @@ static int decode_audio_frame(AVFrame *frame,
*
finished
=
1
;
else
{
fprintf
(
stderr
,
"Could not read frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
return
error
;
}
}
...
...
@@ -363,7 +351,7 @@ static int decode_audio_frame(AVFrame *frame,
if
((
error
=
avcodec_decode_audio4
(
input_codec_context
,
frame
,
data_present
,
&
input_packet
))
<
0
)
{
fprintf
(
stderr
,
"Could not decode frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
av_packet_unref
(
&
input_packet
);
return
error
;
}
...
...
@@ -410,7 +398,7 @@ static int init_converted_samples(uint8_t ***converted_input_samples,
output_codec_context
->
sample_fmt
,
0
))
<
0
)
{
fprintf
(
stderr
,
"Could not allocate converted input samples (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
av_freep
(
&
(
*
converted_input_samples
)[
0
]);
free
(
*
converted_input_samples
);
return
error
;
...
...
@@ -434,7 +422,7 @@ static int convert_samples(const uint8_t **input_data,
converted_data
,
frame_size
,
input_data
,
frame_size
))
<
0
)
{
fprintf
(
stderr
,
"Could not convert input samples (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
return
error
;
}
...
...
@@ -567,7 +555,7 @@ static int init_output_frame(AVFrame **frame,
*/
if
((
error
=
av_frame_get_buffer
(
*
frame
,
0
))
<
0
)
{
fprintf
(
stderr
,
"Could not allocate output frame samples (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
av_frame_free
(
frame
);
return
error
;
}
...
...
@@ -602,7 +590,7 @@ static int encode_audio_frame(AVFrame *frame,
if
((
error
=
avcodec_encode_audio2
(
output_codec_context
,
&
output_packet
,
frame
,
data_present
))
<
0
)
{
fprintf
(
stderr
,
"Could not encode frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
av_packet_unref
(
&
output_packet
);
return
error
;
}
...
...
@@ -611,7 +599,7 @@ static int encode_audio_frame(AVFrame *frame,
if
(
*
data_present
)
{
if
((
error
=
av_write_frame
(
output_format_context
,
&
output_packet
))
<
0
)
{
fprintf
(
stderr
,
"Could not write frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
av_packet_unref
(
&
output_packet
);
return
error
;
}
...
...
@@ -671,7 +659,7 @@ static int write_output_file_trailer(AVFormatContext *output_format_context)
int
error
;
if
((
error
=
av_write_trailer
(
output_format_context
))
<
0
)
{
fprintf
(
stderr
,
"Could not write output file trailer (error '%s')
\n
"
,
get_error_text
(
error
));
av_err2str
(
error
));
return
error
;
}
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