[FFmpeg-cvslog] libopencore-amr: Check the return value of amr_decode_fix_avctx
Martin Storsjö
git at videolan.org
Wed Nov 7 10:50:06 CET 2012
ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Nov 6 12:18:57 2012 +0200| [ad961726dc0bec7435aae7fbab10471b9063018b] | committer: Martin Storsjö
libopencore-amr: Check the return value of amr_decode_fix_avctx
This allows getting rid of redundant checks later in the codec
specific init functions.
Move the check to before actually initializing the decoder lib,
to simplify error handling.
This fixes a case of returning a value from a void function, present since
d40dab907.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad961726dc0bec7435aae7fbab10471b9063018b
---
libavcodec/libopencore-amr.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
index a754d52..0c472b7 100644
--- a/libavcodec/libopencore-amr.c
+++ b/libavcodec/libopencore-amr.c
@@ -27,7 +27,7 @@
#include "audio_frame_queue.h"
#include "internal.h"
-static void amr_decode_fix_avctx(AVCodecContext *avctx)
+static int amr_decode_fix_avctx(AVCodecContext *avctx)
{
const int is_amr_wb = 1 + (avctx->codec_id == AV_CODEC_ID_AMR_WB);
@@ -41,6 +41,7 @@ static void amr_decode_fix_avctx(AVCodecContext *avctx)
avctx->channels = 1;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ return 0;
}
#if CONFIG_LIBOPENCORE_AMRNB
@@ -107,6 +108,10 @@ static const AVClass class = {
static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
{
AMRContext *s = avctx->priv_data;
+ int ret;
+
+ if ((ret = amr_decode_fix_avctx(avctx)) < 0)
+ return ret;
s->dec_state = Decoder_Interface_init();
if (!s->dec_state) {
@@ -114,13 +119,6 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
return -1;
}
- amr_decode_fix_avctx(avctx);
-
- if (avctx->channels > 1) {
- av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
- return AVERROR(ENOSYS);
- }
-
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
@@ -324,15 +322,12 @@ typedef struct AMRWBContext {
static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
{
AMRWBContext *s = avctx->priv_data;
+ int ret;
- s->state = D_IF_init();
-
- amr_decode_fix_avctx(avctx);
+ if ((ret = amr_decode_fix_avctx(avctx)) < 0)
+ return ret;
- if (avctx->channels > 1) {
- av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
- return AVERROR(ENOSYS);
- }
+ s->state = D_IF_init();
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
More information about the ffmpeg-cvslog
mailing list