From: Reimar Döffinger <reimar.doeffin...@gmx.de>

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.

Signed-off-by: Reimar Döffinger <reimar.doeffin...@gmx.de>
(cherry picked from commit 1d0d63052b82c76e10c45cd38cdd27677de72e81)

Signed-off-by: Reinhard Tartler <siret...@tauware.de>
---
 libavcodec/sipr.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Reimar claims that this patch fixes http://bugs.debian.org/686570. I was
not able to test this patch because avplay fails on the test file that
was attached to the debian bug with avplay:

>> ./avplay /tmp/voa03.ra
avplay version v0.8-2980-ga94da3d, Copyright (c) 2003-2012 the Libav developers
  built on Sep  3 2012 22:36:41 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
/tmp/voa03.ra: Operation not permitted

Comments and over takers welcome.

diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c
index 971d05b..f090dc9 100644
--- a/libavcodec/sipr.c
+++ b/libavcodec/sipr.c
@@ -486,7 +486,10 @@ static av_cold int sipr_decoder_init(AVCodecContext * 
avctx)
     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->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);
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to