summaryrefslogtreecommitdiff
path: root/libavcodec/libvorbis.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-02-29 00:02:55 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-02-29 14:54:25 -0500
commita45a1ea52174233265a77632a3f3f40c67f3c6d6 (patch)
tree1309815b5c4b476b651a691b04a78d2a94084da3 /libavcodec/libvorbis.c
parent592c4dbc7efbf2e308288e9d0cf7ca16cb2882c6 (diff)
libvorbis: add/update error messages
also use AVERROR codes for some return values instead of -1
Diffstat (limited to 'libavcodec/libvorbis.c')
-rw-r--r--libavcodec/libvorbis.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index 7ddc5f9048..991c64f81d 100644
--- a/libavcodec/libvorbis.c
+++ b/libavcodec/libvorbis.c
@@ -173,15 +173,17 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
vorbis_info_init(&s->vi);
if ((ret = oggvorbis_init_encoder(&s->vi, avctx))) {
- av_log(avctx, AV_LOG_ERROR, "oggvorbis_encode_init: init_encoder failed\n");
+ av_log(avctx, AV_LOG_ERROR, "encoder setup failed\n");
goto error;
}
if ((ret = vorbis_analysis_init(&s->vd, &s->vi))) {
+ av_log(avctx, AV_LOG_ERROR, "analysis init failed\n");
ret = vorbis_error_to_averror(ret);
goto error;
}
s->dsp_initialized = 1;
if ((ret = vorbis_block_init(&s->vd, &s->vb))) {
+ av_log(avctx, AV_LOG_ERROR, "dsp init failed\n");
ret = vorbis_error_to_averror(ret);
goto error;
}
@@ -260,12 +262,16 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, unsigned char *packets,
for (i = 0; i < samples; i++)
buffer[c][i] = audio[i * channels + co];
}
- if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0)
+ if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
+ }
} else {
if (!s->eof)
- if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0)
+ if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n");
return vorbis_error_to_averror(ret);
+ }
s->eof = 1;
}
@@ -279,17 +285,21 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, unsigned char *packets,
/* add any available packets to the output packet buffer */
while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) {
if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) {
- av_log(avctx, AV_LOG_ERROR, "libvorbis: buffer overflow.");
- return -1;
+ av_log(avctx, AV_LOG_ERROR, "packet buffer is too small");
+ return AVERROR_BUG;
}
av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL);
av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL);
}
- if (ret < 0)
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
break;
+ }
}
- if (ret < 0)
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error getting available packets\n");
return vorbis_error_to_averror(ret);
+ }
/* output then next packet from the output buffer, if available */
pkt_size = 0;
@@ -300,8 +310,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, unsigned char *packets,
avctx->coded_frame->pts = ff_samples_to_time_base(avctx,
op.granulepos);
if (pkt_size > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "libvorbis: buffer overflow.");
- return -1;
+ av_log(avctx, AV_LOG_ERROR, "output buffer is too small");
+ return AVERROR(EINVAL);
}
av_fifo_generic_read(s->pkt_fifo, packets, pkt_size, NULL);
}