From patchwork Mon Jul 6 09:25:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 20844 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7BA42449C46 for ; Mon, 6 Jul 2020 12:25:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6667668B3D0; Mon, 6 Jul 2020 12:25:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D5C568AFE6 for ; Mon, 6 Jul 2020 12:25:18 +0300 (EEST) Date: Mon, 06 Jul 2020 09:25:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1594027517; bh=L/AsFJ1lztysEQv3hkv/1RkYUFyh/I/Nq8tQFVqfvmo=; h=Date:To:From:Cc:Reply-To:Subject:From; b=Iyg2c24nJlQVB2cwjm0t5JsQTzOg9K59B7+LBGzTd9YD/bxBIc0xVFgiu9IskCFUz tiVQ9irttuHvEQbeEmfgd0LjEXeYB9yRjYZeAgF0gE8lscuG1ofnydHMB++IoqZKks 1wkcYHY1iVww5OkFTCsmd7YL/T9MQafNqSwi9RNE= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200706092347.102557-7-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v5 6/6] avcodec/adpcmenc: cleanup trellis checks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- libavcodec/adpcmenc.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 4985abb163..adb7bf0bbf 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -69,25 +69,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; if (!FF_ALLOC_TYPED_ARRAY(s->paths, max_paths) || !FF_ALLOC_TYPED_ARRAY(s->node_buf, 2 * frontier) || !FF_ALLOC_TYPED_ARRAY(s->nodep_buf, 2 * frontier) ||