From patchwork Wed Jul 8 12:55:37 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: 20894 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:80ca:0:0:0:0:0 with SMTP id c10csp533739ybm; Wed, 8 Jul 2020 05:56:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL8jDuz0eLXR9Q0xYbE1EFQ0wUhkLeRYZZi31hpkrW05JDMcqfbj9HJVkhffdg2qgsomVY X-Received: by 2002:a5d:444e:: with SMTP id x14mr55873663wrr.279.1594212982564; Wed, 08 Jul 2020 05:56:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594212982; cv=none; d=google.com; s=arc-20160816; b=Jor4cV/1nypQ2NhDKl+jc5/Blaha16OzJof+cwM4zfiuHvjcZ940mK4yIkYYIl7+aI gixrSRoHSq8aVnQ3D/M0vFcl3cq4zjqYvuag3cIQPTMSi0bnjevzgX8tOXynCVSG546h Y8GCqLTSLq7dmrDPntnEF4IygyD73TCaItjDuv1+j2QOTFCK1KGwlkFYRDUmUNBSJm9o KKxtkT+WZ5fpf70ZXZP6Are94y9dWrNrKQE+lwTR57fHcVf3K+mQ0ttP0K05u8DgiVay zHM2j0zvQirBhI4OCNknRfg0U6z3c1trqBFQA9BQXAErsGzyXhg7CW1xjUvIbQTc/vqj 7Pbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:from:to :dkim-signature:date:delivered-to; bh=vnqzTPqxEm8m2rppv0X6IlaKHNer0SJlHTEKqIoR+uw=; b=KNRlYGLK4V7R/CgDLokrSkEycjOgMdWgchhAkiiZlzpoJlBIZo5cvCtxkBA1ICaP6C 80CUFG5Ejjs0Jv47/yOBvyRjU+HQ0zibpCUro6Mswcp6ty1k29X4vIci1vrxVCGVxITV gdIEeSOnwOlR2VJuvAwG3Qjle88q52CvQTNeZxbmpGdimS0G7RgSx/C50ZLDcv/ZkiJG XIChSA4OI3wWjenJYYIlv3FaKAp/kBYoMXEG8YVqAsOsR6MFy+vPPDqSuVO+5zbFRanS 8+vxZgjrDQMjn3sDefEQESSPbW5LQX/woLc4M1UwVN+8HelRr8UJeKlXB2Ld6SB+Us9d Q89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@zanevaniperen.com header.s=protonmail header.b=iNtRUaOV; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p9si13116081wrx.177.2020.07.08.05.56.21; Wed, 08 Jul 2020 05:56:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@zanevaniperen.com header.s=protonmail header.b=iNtRUaOV; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B875068B2DB; Wed, 8 Jul 2020 15:55:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6E2F368A615 for ; Wed, 8 Jul 2020 15:55:42 +0300 (EEST) Date: Wed, 08 Jul 2020 12:55:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1594212941; bh=L/AsFJ1lztysEQv3hkv/1RkYUFyh/I/Nq8tQFVqfvmo=; h=Date:To:From:Cc:Reply-To:Subject:From; b=iNtRUaOVdMWDmMeNECvrdyKUj7tN1vnxXDRb4dFvVh/znRGaSAquAzanM8EkESD9z 7HG71wXJF3HiQOPf8ugjMpWPIZw09M9vu86H97/NWWrLgQ2xscPauJFEljO4FJvbFM L9QaqS5A4Ezk6UBxbPxZBAqOpsxurBgcnbRfLR8I= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200708125433.238118-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 v6 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" X-TUID: 3hspjcJCkgwj Content-Length: 3214 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) ||