From patchwork Fri Jun 12 11:46:57 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: 20311 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 D551144B0F5 for ; Fri, 12 Jun 2020 14:47:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B739268B67E; Fri, 12 Jun 2020 14:47:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40136.protonmail.ch (mail-40136.protonmail.ch [185.70.40.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B09E968B685 for ; Fri, 12 Jun 2020 14:47:09 +0300 (EEST) Date: Fri, 12 Jun 2020 11:46:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1591962428; bh=lwcALXewH5FgKw9EMhNQisR8wDSixZ4/9JSX8Ja6aPo=; h=Date:To:From:Cc:Reply-To:Subject:From; b=iT+x0aL5fk9iT3laizVmYo7uIXHPTGpVsHOpzM9MKGd7aq1mUWb+/n/sQJexq92/l s05HI6hsf1IhgfrHkefO5+5cEHtB/7u6SBswKZWChwMusRlnedAhmt1RGxm2/7Q78l pEe8j/SOV0x62AU2JmbLeK5XxVJu+BIF15oBABH0= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200612114603.1157417-8-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 v3 7/7] 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 d2d90b9176..38cd8add3e 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,