summaryrefslogtreecommitdiff
path: root/libavcodec/adpcmenc.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-01-30 13:06:57 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-01-30 19:12:55 -0500
commit877a1d409c13887903cf6aa5d8ac01fd8091a3f2 (patch)
tree4e0fb2e69b801fb187266d2f386f7c6820ada6f3 /libavcodec/adpcmenc.c
parentcb023d9afe9da0a9d221b5eeddd2981c520b5978 (diff)
adpcmenc: return proper AVERROR codes instead of -1
Diffstat (limited to 'libavcodec/adpcmenc.c')
-rw-r--r--libavcodec/adpcmenc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 26d673d4b5..f0f8c1f528 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -63,12 +63,16 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
ADPCMEncodeContext *s = avctx->priv_data;
uint8_t *extradata;
int i;
- if (avctx->channels > 2)
- return -1; /* only stereo or mono =) */
+ int ret = AVERROR(ENOMEM);
+
+ if (avctx->channels > 2) {
+ av_log(avctx, AV_LOG_ERROR, "only stereo or mono is supported\n");
+ return AVERROR(EINVAL);
+ }
if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
- return -1;
+ return AVERROR(EINVAL);
}
if (avctx->trellis) {
@@ -127,11 +131,13 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
avctx->sample_rate != 44100) {
av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
"22050 or 44100\n");
+ ret = AVERROR(EINVAL);
goto error;
}
avctx->frame_size = 512 * (avctx->sample_rate / 11025);
break;
default:
+ ret = AVERROR(EINVAL);
goto error;
}
@@ -144,7 +150,7 @@ error:
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
av_freep(&s->trellis_hash);
- return -1;
+ return ret;
}
static av_cold int adpcm_encode_close(AVCodecContext *avctx)
@@ -688,10 +694,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
}
break;
default:
- error:
- return -1;
+ return AVERROR(EINVAL);
}
return dst - frame;
+error:
+ return AVERROR(ENOMEM);
}