On 09/21/2012 10:31 AM, Reinhard Tartler wrote: > On Tue, Sep 4, 2012 at 7:03 PM, Reinhard Tartler <siret...@tauware.de> wrote: >> Not all applications (e.g. MPlayer) set block_align, and >> when using a different demuxer it might not even be >> easily available. >> >> Therefore 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. >> >> Based on a patch by: Reimar Döffinger <reimar.doeffin...@gmx.de> with >> suggestions by Derek Buitenhuis <derek.buitenh...@gmail.com> >> >> (commit 1d0d63052b82c76e10c45cd38cdd27677de72e81) >> >> Signed-off-by: Reinhard Tartler <siret...@tauware.de> >> --- >> libavcodec/sipr.c | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> Derek, did you mean something like this one? I persume that >> AV_EF_EXPLODE has to be set explicitly by the application so that an >> invalid block_align does not signal the error. >> >> diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c >> index 971d05b..1839a22 100644 >> --- a/libavcodec/sipr.c >> +++ b/libavcodec/sipr.c >> @@ -485,8 +485,16 @@ static av_cold int sipr_decoder_init(AVCodecContext * >> avctx) >> case 29: ctx->mode = MODE_6k5; break; >> case 37: ctx->mode = MODE_5k0; break; >> default: >> - av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", >> avctx->block_align); >> - return AVERROR(EINVAL); >> + if (avctx->err_recognition & AV_EF_EXPLODE) { >> + av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", >> avctx->block_align); >> + return AVERROR(EINVAL); >> + } >> + else { >> + 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_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name); >> -- > > is the patch above OK to apply? >
I like the previous version better. Just change it to AV_LOG_WARNING, and maybe give a more specific message like "Invalid block_align. Guessing the mode based on bit_rate." -Justin _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel