Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
0098e79f
Commit
0098e79f
authored
Dec 30, 2011
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvorbis: proper error logging and return.
parent
42a1f1d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
15 deletions
+38
-15
libvorbis.c
libavcodec/libvorbis.c
+38
-15
No files found.
libavcodec/libvorbis.c
View file @
0098e79f
...
@@ -61,38 +61,59 @@ static const AVOption options[] = {
...
@@ -61,38 +61,59 @@ static const AVOption options[] = {
};
};
static
const
AVClass
class
=
{
"libvorbis"
,
av_default_item_name
,
options
,
LIBAVUTIL_VERSION_INT
};
static
const
AVClass
class
=
{
"libvorbis"
,
av_default_item_name
,
options
,
LIBAVUTIL_VERSION_INT
};
static
const
char
*
error
(
int
oggerr
,
int
*
averr
)
{
switch
(
oggerr
)
{
case
OV_EFAULT
:
*
averr
=
AVERROR
(
EFAULT
);
return
"internal error"
;
case
OV_EIMPL
:
*
averr
=
AVERROR
(
EINVAL
);
return
"not supported"
;
case
OV_EINVAL
:
*
averr
=
AVERROR
(
EINVAL
);
return
"invalid request"
;
default:
*
averr
=
AVERROR
(
EINVAL
);
return
"unknown error"
;
}
}
static
av_cold
int
oggvorbis_init_encoder
(
vorbis_info
*
vi
,
AVCodecContext
*
avccontext
)
static
av_cold
int
oggvorbis_init_encoder
(
vorbis_info
*
vi
,
AVCodecContext
*
avccontext
)
{
{
OggVorbisContext
*
context
=
avccontext
->
priv_data
;
OggVorbisContext
*
context
=
avccontext
->
priv_data
;
double
cfreq
;
double
cfreq
;
int
r
;
if
(
avccontext
->
flags
&
CODEC_FLAG_QSCALE
)
{
if
(
avccontext
->
flags
&
CODEC_FLAG_QSCALE
)
{
/* variable bitrate */
/* variable bitrate */
if
(
vorbis_encode_setup_vbr
(
vi
,
avccontext
->
channels
,
float
quality
=
avccontext
->
global_quality
/
(
float
)
FF_QP2LAMBDA
;
r
=
vorbis_encode_setup_vbr
(
vi
,
avccontext
->
channels
,
avccontext
->
sample_rate
,
avccontext
->
sample_rate
,
avccontext
->
global_quality
/
(
float
)
FF_QP2LAMBDA
/
10
.
0
))
quality
/
10
.
0
);
return
-
1
;
if
(
r
)
{
av_log
(
avccontext
,
AV_LOG_ERROR
,
"Unable to set quality to %g: %s
\n
"
,
quality
,
error
(
r
,
&
r
));
return
r
;
}
}
else
{
}
else
{
int
minrate
=
avccontext
->
rc_min_rate
>
0
?
avccontext
->
rc_min_rate
:
-
1
;
int
minrate
=
avccontext
->
rc_min_rate
>
0
?
avccontext
->
rc_min_rate
:
-
1
;
int
maxrate
=
avccontext
->
rc_min_rate
>
0
?
avccontext
->
rc_max_rate
:
-
1
;
int
maxrate
=
avccontext
->
rc_min_rate
>
0
?
avccontext
->
rc_max_rate
:
-
1
;
/* constant bitrate */
/* constant bitrate */
if
(
vorbis_encode_setup_managed
(
vi
,
avccontext
->
channels
,
r
=
vorbis_encode_setup_managed
(
vi
,
avccontext
->
channels
,
avccontext
->
sample_rate
,
minrate
,
avccontext
->
sample_rate
,
minrate
,
avccontext
->
bit_rate
,
maxrate
))
avccontext
->
bit_rate
,
maxrate
);
return
-
1
;
if
(
r
)
{
av_log
(
avccontext
,
AV_LOG_ERROR
,
"Unable to set CBR to %d: %s
\n
"
,
avccontext
->
bit_rate
,
error
(
r
,
&
r
));
return
r
;
}
/* variable bitrate by estimate, disable slow rate management */
/* variable bitrate by estimate, disable slow rate management */
if
(
minrate
==
-
1
&&
maxrate
==
-
1
)
if
(
minrate
==
-
1
&&
maxrate
==
-
1
)
if
(
vorbis_encode_ctl
(
vi
,
OV_ECTL_RATEMANAGE2_SET
,
NULL
))
if
(
vorbis_encode_ctl
(
vi
,
OV_ECTL_RATEMANAGE2_SET
,
NULL
))
return
-
1
;
return
AVERROR
(
EINVAL
);
/* should not happen */
}
}
/* cutoff frequency */
/* cutoff frequency */
if
(
avccontext
->
cutoff
>
0
)
{
if
(
avccontext
->
cutoff
>
0
)
{
cfreq
=
avccontext
->
cutoff
/
1000
.
0
;
cfreq
=
avccontext
->
cutoff
/
1000
.
0
;
if
(
vorbis_encode_ctl
(
vi
,
OV_ECTL_LOWPASS_SET
,
&
cfreq
))
if
(
vorbis_encode_ctl
(
vi
,
OV_ECTL_LOWPASS_SET
,
&
cfreq
))
return
-
1
;
return
AVERROR
(
EINVAL
);
/* should not happen */
}
}
if
(
context
->
iblock
)
{
if
(
context
->
iblock
)
{
...
@@ -143,11 +164,13 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext)
...
@@ -143,11 +164,13 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext)
ogg_packet
header
,
header_comm
,
header_code
;
ogg_packet
header
,
header_comm
,
header_code
;
uint8_t
*
p
;
uint8_t
*
p
;
unsigned
int
offset
;
unsigned
int
offset
;
int
r
;
vorbis_info_init
(
&
context
->
vi
);
vorbis_info_init
(
&
context
->
vi
);
if
(
oggvorbis_init_encoder
(
&
context
->
vi
,
avccontext
)
<
0
)
{
r
=
oggvorbis_init_encoder
(
&
context
->
vi
,
avccontext
);
av_log
(
avccontext
,
AV_LOG_ERROR
,
"oggvorbis_encode_init: init_encoder failed
\n
"
);
if
(
r
<
0
)
{
return
-
1
;
av_log
(
avccontext
,
AV_LOG_ERROR
,
"oggvorbis_encode_init failed
\n
"
);
return
r
;
}
}
vorbis_analysis_init
(
&
context
->
vd
,
&
context
->
vi
);
vorbis_analysis_init
(
&
context
->
vd
,
&
context
->
vi
);
vorbis_block_init
(
&
context
->
vd
,
&
context
->
vb
);
vorbis_block_init
(
&
context
->
vd
,
&
context
->
vb
);
...
@@ -228,8 +251,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
...
@@ -228,8 +251,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
if
(
op
.
bytes
==
1
&&
op
.
e_o_s
)
if
(
op
.
bytes
==
1
&&
op
.
e_o_s
)
continue
;
continue
;
if
(
context
->
buffer_index
+
sizeof
(
ogg_packet
)
+
op
.
bytes
>
BUFFER_SIZE
)
{
if
(
context
->
buffer_index
+
sizeof
(
ogg_packet
)
+
op
.
bytes
>
BUFFER_SIZE
)
{
av_log
(
avccontext
,
AV_LOG_ERROR
,
"libvorbis: buffer overflow."
);
av_log
(
avccontext
,
AV_LOG_ERROR
,
"libvorbis: buffer overflow.
\n
"
);
return
-
1
;
return
AVERROR
(
EINVAL
)
;
}
}
memcpy
(
context
->
buffer
+
context
->
buffer_index
,
&
op
,
sizeof
(
ogg_packet
));
memcpy
(
context
->
buffer
+
context
->
buffer_index
,
&
op
,
sizeof
(
ogg_packet
));
context
->
buffer_index
+=
sizeof
(
ogg_packet
);
context
->
buffer_index
+=
sizeof
(
ogg_packet
);
...
@@ -249,8 +272,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
...
@@ -249,8 +272,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
//FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
//FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
if
(
l
>
buf_size
)
{
if
(
l
>
buf_size
)
{
av_log
(
avccontext
,
AV_LOG_ERROR
,
"libvorbis: buffer overflow."
);
av_log
(
avccontext
,
AV_LOG_ERROR
,
"libvorbis: buffer overflow.
\n
"
);
return
-
1
;
return
AVERROR
(
EINVAL
)
;
}
}
memcpy
(
packets
,
op2
->
packet
,
l
);
memcpy
(
packets
,
op2
->
packet
,
l
);
...
...
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