Commit c54e0061 authored by Reimar Döffinger's avatar Reimar Döffinger Committed by Reinhard Tartler

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 1d0d6305)

CC: libav-stable@libav.org
Signed-off-by: 's avatarReinhard Tartler <siretart@tauware.de>
parent e52e4fe1
...@@ -485,8 +485,13 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) ...@@ -485,8 +485,13 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
case 29: ctx->mode = MODE_6k5; break; case 29: ctx->mode = MODE_6k5; break;
case 37: ctx->mode = MODE_5k0; break; case 37: ctx->mode = MODE_5k0; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", avctx->block_align); if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
return AVERROR(EINVAL); 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); av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
......
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