[libav-commits] sipr: fall back to setting mode based on bit_rate.

Reimar Döffinger git at libav.org
Sat Oct 6 08:48:09 CEST 2012

Module: libav
Branch: release/0.8
Commit: e9ac06160f4550c339dbd1a30a6c6925a7a17dbd

Author:    Reimar Döffinger <Reimar.Doeffinger at gmx.de>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Thu Jan  5 21:01:56 2012 +0100

sipr: fall back to setting mode based on bit_rate.

Not all applications (e.g. MPlayer) set block_align, and
when using a different demuxer it might not even be
easily available.
So fall back to selecting mode based on bit rate as before
if block_align has not useful value.
It can't be worse than failing to decode completely.

(cherry picked from commit 1d0d63052b82c76e10c45cd38cdd27677de72e81)

CC: libav-stable at libav.org
Signed-off-by: Reinhard Tartler <siretart at tauware.de>
(cherry picked from commit c54e00610f20d2342fe9b17a5460abfbd411c8fb)

Signed-off-by: Anton Khirnov <anton at khirnov.net>


 libavcodec/sipr.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
index 4502fa5..818524c 100644
--- a/libavcodec/sipr.c
+++ b/libavcodec/sipr.c
@@ -486,8 +486,13 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
     case 29: ctx->mode = MODE_6k5; break;
     case 37: ctx->mode = MODE_5k0; break;
-        av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", avctx->block_align);
-        return AVERROR(EINVAL);
+        if      (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
+        else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
+        else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
+        else                              ctx->mode = MODE_5k0;
+        av_log(avctx, AV_LOG_WARNING,
+               "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
+               avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
     av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);

More information about the libav-commits mailing list