diff mbox series

[FFmpeg-devel,v2,7/7] avcodec/adpcmenc: cleanup trellis checks

Message ID 20200610233155.1050210-8-zane@zanevaniperen.com
State Superseded
Headers show
Series adpcm_ima_apm encoder + apm muxer
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Zane van Iperen June 10, 2020, 11:33 p.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavcodec/adpcmenc.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 8396180cb6..27b2a81f4b 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -72,25 +72,26 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
-    if (avctx->trellis && (unsigned)avctx->trellis > 16U) {
-        av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
-        return AVERROR(EINVAL);
-    }
+    if (avctx->trellis) {
+        int frontier, max_paths;
 
-    if (avctx->trellis &&
-       (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
-        avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM)) {
-        /*
-         * The current trellis implementation doesn't work for extended
-         * runs of samples without periodic resets. Disallow it.
-         */
-        av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
-        return AVERROR_PATCHWELCOME;
-    }
+        if ((unsigned)avctx->trellis > 16U) {
+            av_log(avctx, AV_LOG_ERROR, "invalid trellis size\n");
+            return AVERROR(EINVAL);
+        }
 
-    if (avctx->trellis) {
-        int frontier  = 1 << avctx->trellis;
-        int max_paths =  frontier * FREEZE_INTERVAL;
+        if (avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI ||
+            avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_APM) {
+            /*
+             * The current trellis implementation doesn't work for extended
+             * runs of samples without periodic resets. Disallow it.
+             */
+            av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
+            return AVERROR_PATCHWELCOME;
+        }
+
+        frontier  = 1 << avctx->trellis;
+        max_paths =  frontier * FREEZE_INTERVAL;
         FF_ALLOC_OR_GOTO(avctx, s->paths,
                          max_paths * sizeof(*s->paths), error);
         FF_ALLOC_OR_GOTO(avctx, s->node_buf,