From a65f7c96fce257966ca7e224cbc1ff91af81e91c Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Feb 2012 13:10:38 -0500 Subject: ra144enc: remove unneeded sample_fmt check --- libavcodec/ra144enc.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'libavcodec/ra144enc.c') diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index c8a09a2ed2..302f66b410 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -38,10 +38,6 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) RA144Context *ractx; int ret; - if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) { - av_log(avctx, AV_LOG_ERROR, "invalid sample format\n"); - return -1; - } if (avctx->channels != 1) { av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", avctx->channels); -- cgit v1.2.3 From 03359ebcf99d2949f44069836224273d383b1638 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Feb 2012 13:29:09 -0500 Subject: ra144enc: set AVCodecContext.coded_frame --- libavcodec/ra144enc.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'libavcodec/ra144enc.c') diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 302f66b410..5977928362 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -33,6 +33,15 @@ #include "ra144.h" +static av_cold int ra144_encode_close(AVCodecContext *avctx) +{ + RA144Context *ractx = avctx->priv_data; + ff_lpc_end(&ractx->lpc_ctx); + av_freep(&avctx->coded_frame); + return 0; +} + + static av_cold int ra144_encode_init(AVCodecContext * avctx) { RA144Context *ractx; @@ -51,15 +60,19 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) ractx->avctx = avctx; ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER, FF_LPC_TYPE_LEVINSON); - return ret; -} + if (ret < 0) + goto error; + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->coded_frame) { + ret = AVERROR(ENOMEM); + goto error; + } -static av_cold int ra144_encode_close(AVCodecContext *avctx) -{ - RA144Context *ractx = avctx->priv_data; - ff_lpc_end(&ractx->lpc_ctx); return 0; +error: + ra144_encode_close(avctx); + return ret; } -- cgit v1.2.3 From 4b7f8838e865bb2f803310ac2b27f9166309e4a0 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 22 Feb 2012 13:35:38 -0500 Subject: ra144enc: use int16_t* for input samples rather than void* --- libavcodec/ra144enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavcodec/ra144enc.c') diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 5977928362..ff8316912f 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -441,6 +441,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, int16_t block_coefs[NBLOCKS][LPC_ORDER]; int lpc_refl[LPC_ORDER]; /**< reflection coefficients of the frame */ unsigned int refl_rms[NBLOCKS]; /**< RMS of the reflection coefficients */ + const int16_t *samples = data; int energy = 0; int i, idx; @@ -515,7 +516,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); for (i = 0; i < NBLOCKS * BLOCKSIZE; i++) - ractx->curr_block[i] = *((int16_t *)data + i) >> 2; + ractx->curr_block[i] = samples[i] >> 2; return FRAMESIZE; } -- cgit v1.2.3