Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
8dad25eb
Commit
8dad25eb
authored
13 years ago
by
Justin Ruggles
Browse files
Options
Downloads
Patches
Plain Diff
libmp3lame: improve error handling in MP3lame_encode_init()
parent
310c372e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/libmp3lame.c
+25
-19
25 additions, 19 deletions
libavcodec/libmp3lame.c
with
25 additions
and
19 deletions
libavcodec/libmp3lame.c
+
25
−
19
View file @
8dad25eb
...
@@ -40,15 +40,27 @@ typedef struct Mp3AudioContext {
...
@@ -40,15 +40,27 @@ typedef struct Mp3AudioContext {
int
reservoir
;
int
reservoir
;
}
Mp3AudioContext
;
}
Mp3AudioContext
;
static
av_cold
int
MP3lame_encode_close
(
AVCodecContext
*
avctx
)
{
Mp3AudioContext
*
s
=
avctx
->
priv_data
;
av_freep
(
&
avctx
->
coded_frame
);
lame_close
(
s
->
gfp
);
return
0
;
}
static
av_cold
int
MP3lame_encode_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
MP3lame_encode_init
(
AVCodecContext
*
avctx
)
{
{
Mp3AudioContext
*
s
=
avctx
->
priv_data
;
Mp3AudioContext
*
s
=
avctx
->
priv_data
;
int
ret
;
if
(
avctx
->
channels
>
2
)
if
(
avctx
->
channels
>
2
)
return
-
1
;
return
AVERROR
(
EINVAL
)
;
if
((
s
->
gfp
=
lame_init
())
==
NULL
)
if
((
s
->
gfp
=
lame_init
())
==
NULL
)
goto
err
;
return
AVERROR
(
ENOMEM
)
;
lame_set_in_samplerate
(
s
->
gfp
,
avctx
->
sample_rate
);
lame_set_in_samplerate
(
s
->
gfp
,
avctx
->
sample_rate
);
lame_set_out_samplerate
(
s
->
gfp
,
avctx
->
sample_rate
);
lame_set_out_samplerate
(
s
->
gfp
,
avctx
->
sample_rate
);
lame_set_num_channels
(
s
->
gfp
,
avctx
->
channels
);
lame_set_num_channels
(
s
->
gfp
,
avctx
->
channels
);
...
@@ -66,19 +78,23 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
...
@@ -66,19 +78,23 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
}
}
lame_set_bWriteVbrTag
(
s
->
gfp
,
0
);
lame_set_bWriteVbrTag
(
s
->
gfp
,
0
);
lame_set_disable_reservoir
(
s
->
gfp
,
!
s
->
reservoir
);
lame_set_disable_reservoir
(
s
->
gfp
,
!
s
->
reservoir
);
if
(
lame_init_params
(
s
->
gfp
)
<
0
)
if
(
lame_init_params
(
s
->
gfp
)
<
0
)
{
goto
err_close
;
ret
=
-
1
;
goto
error
;
}
avctx
->
frame_size
=
lame_get_framesize
(
s
->
gfp
);
avctx
->
frame_size
=
lame_get_framesize
(
s
->
gfp
);
avctx
->
coded_frame
=
avcodec_alloc_frame
();
avctx
->
coded_frame
=
avcodec_alloc_frame
();
if
(
!
avctx
->
coded_frame
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
error
;
}
avctx
->
coded_frame
->
key_frame
=
1
;
avctx
->
coded_frame
->
key_frame
=
1
;
return
0
;
return
0
;
error:
err_close:
MP3lame_encode_close
(
avctx
);
lame_close
(
s
->
gfp
);
return
ret
;
err:
return
-
1
;
}
}
static
const
int
sSampleRates
[]
=
{
static
const
int
sSampleRates
[]
=
{
...
@@ -198,16 +214,6 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, unsigned char *frame,
...
@@ -198,16 +214,6 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, unsigned char *frame,
return
0
;
return
0
;
}
}
static
av_cold
int
MP3lame_encode_close
(
AVCodecContext
*
avctx
)
{
Mp3AudioContext
*
s
=
avctx
->
priv_data
;
av_freep
(
&
avctx
->
coded_frame
);
lame_close
(
s
->
gfp
);
return
0
;
}
#define OFFSET(x) offsetof(Mp3AudioContext, x)
#define OFFSET(x) offsetof(Mp3AudioContext, x)
#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static
const
AVOption
options
[]
=
{
static
const
AVOption
options
[]
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment