Commit 900a129f authored by Martin Storsjö's avatar Martin Storsjö

libopencore-amr, libvo-amrwbenc: Return proper error codes in most places

Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent a8ec07c9
...@@ -92,7 +92,7 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx) ...@@ -92,7 +92,7 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
if (avctx->channels > 1) { if (avctx->channels > 1) {
av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
return -1; return AVERROR(ENOSYS);
} }
return 0; return 0;
...@@ -126,7 +126,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, ...@@ -126,7 +126,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
if (packet_size > buf_size) { if (packet_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
buf_size, packet_size); buf_size, packet_size);
return -1; return AVERROR_INVALIDDATA;
} }
s->frameCount++; s->frameCount++;
...@@ -159,12 +159,12 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) ...@@ -159,12 +159,12 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
if (avctx->sample_rate != 8000) { if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n"); av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return -1; return AVERROR(ENOSYS);
} }
if (avctx->channels != 1) { if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return -1; return AVERROR(ENOSYS);
} }
avctx->frame_size = 160; avctx->frame_size = 160;
...@@ -178,7 +178,7 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) ...@@ -178,7 +178,7 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) { if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported); av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
return -1; return AVERROR(ENOSYS);
} }
return 0; return 0;
...@@ -202,7 +202,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, ...@@ -202,7 +202,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx,
if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) { if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported); av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
return -1; return AVERROR(ENOSYS);
} }
written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data, written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
...@@ -250,7 +250,7 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx) ...@@ -250,7 +250,7 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
if (avctx->channels > 1) { if (avctx->channels > 1) {
av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n"); av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
return -1; return AVERROR(ENOSYS);
} }
return 0; return 0;
...@@ -277,7 +277,7 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, ...@@ -277,7 +277,7 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
if (packet_size > buf_size) { if (packet_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
buf_size, packet_size + 1); buf_size, packet_size + 1);
return -1; return AVERROR_INVALIDDATA;
} }
s->frameCount++; s->frameCount++;
......
...@@ -65,17 +65,17 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx) ...@@ -65,17 +65,17 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
if (avctx->sample_rate != 16000) { if (avctx->sample_rate != 16000) {
av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n"); av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
return -1; return AVERROR(ENOSYS);
} }
if (avctx->channels != 1) { if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return -1; return AVERROR(ENOSYS);
} }
if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) { if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
return -1; return AVERROR(ENOSYS);
} }
avctx->frame_size = 320; avctx->frame_size = 320;
...@@ -105,7 +105,7 @@ static int amr_wb_encode_frame(AVCodecContext *avctx, ...@@ -105,7 +105,7 @@ static int amr_wb_encode_frame(AVCodecContext *avctx,
if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) { if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported); av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
return -1; return AVERROR(ENOSYS);
} }
size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx); size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
return size; return size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment