From patchwork Fri Nov 20 07:19:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23764 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 7DE1E44AC1A for ; Fri, 20 Nov 2020 09:25:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4540768BBA1; Fri, 20 Nov 2020 09:25:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C67A68B9A1 for ; Fri, 20 Nov 2020 09:25:32 +0200 (EET) Received: by mail-ej1-f68.google.com with SMTP id o9so11541892ejg.1 for ; Thu, 19 Nov 2020 23:25:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=Csn2sLU4D+jLqugqtx4BzcYkROjEsPoj5zH4Zgx/p0Q=; b=jUm1ClcX1XnbtdKDFJWtwuH4QhC1LsVta6SeXmsIjhLaNCVXK4jqbhv8SJI2/CHQ4J 7JCcMjhDcJd/Oj2WYOlD2J6ipeLCDmxBC9VCi6M8LVumLTBi4VKyCzpzYMEIwWeQ/fHA koTy5a72YVO6mUM7A6iRKj4QohbVJju6I4vIM873yytgjf4Y7Nd930/Qm3ijglAo11+z 2Vs8r1KeHL2eqCT/ZjCqMGTLIjmZ0qZ/7qJ6Vs02fo5U6qG+gmiMo1nBqRfUbrjyvmA5 vFezJZSO7gMVsU5P9xTQMmGgAvmr3a/SC6XYNI7D+92eu8VwZL1RVPPop0er2Ci//nEH GZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=Csn2sLU4D+jLqugqtx4BzcYkROjEsPoj5zH4Zgx/p0Q=; b=QV57J/3FTT3Kl0VyBEH+HyIcOuH2WsjtOirQJ2JnH4FNd/B4yXM6ye3ofah/KjgHlR 4b4+SdJuiXP79tNjlh5ZOSDozEChvXEnSpM6QhsgikRuSWNHlqu2f1nNmFHgMRm0fZtc oPu/wrKUmmFhe/vi1WG1sXClGicQ/GpnVMRQkdfJe2jps7DcYX697nYljQ9Npl6jWHGZ S7eZ12Q6Kyu+Qq1NqIps8V/AP8LdfzlsnET4nkSJ4HgQEuK7gMjzqxy9JvTiUbjzy+NF eHllhzfaEIahOZcwJU4wpItFUJyEF5v7RoXaS6GdqEXD2AE3OeMj7Ojgc/vNchi1ZVWn 7sLw== X-Gm-Message-State: AOAM533HnKcD3dSSttq+LqQWG3cPfIbaw6dfKmpa2GE79lbYq4zWZcXA /oB429cLfGbMJrCgY/zgdaqjz7Ko3Gt/CQ== X-Google-Smtp-Source: ABdhPJzLqhrJUOV6GlPMs4ggPUYUsBgaWTCKGBQcjqWLFOmnKTwVfxkCSQK3yYKVZGUR/5WXgRGVaw== X-Received: by 2002:a17:906:1381:: with SMTP id f1mr31228216ejc.87.1605857131304; Thu, 19 Nov 2020 23:25:31 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id lz27sm779419ejb.39.2020.11.19.23.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:30 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:54 +0100 Message-Id: <20201120072116.818090-82-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> References: <20201120072116.818090-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 081/162] avcodec/sheervideo: Simplify creating VLC table 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ff_init_vlc_from_lengths() can be used to offload the computation of the codes; it also needn't check whether the codes are already properly ordered (they are). Signed-off-by: Andreas Rheinhardt --- libavcodec/sheervideo.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c index 3e60ef26a5..876b5cace6 100644 --- a/libavcodec/sheervideo.c +++ b/libavcodec/sheervideo.c @@ -1784,11 +1784,10 @@ static void decode_rgb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) static av_cold int build_vlc(VLC *vlc, const SheerTable *table) { const uint8_t *cur = table->lens; - uint16_t codes[1024]; uint8_t lens[1024]; unsigned count = 0; - for (unsigned step = 1, len = 1, index = 0; len > 0; len += step) { + for (unsigned step = 1, len = 1; len > 0; len += step) { unsigned new_count = count; if (len == 16) { @@ -1797,17 +1796,13 @@ static av_cold int build_vlc(VLC *vlc, const SheerTable *table) } else new_count += *cur++; - for (; count < new_count; count++) { - codes[count] = index >> (32 - len); - index += 1U << (32 - len); + for (; count < new_count; count++) lens[count] = len; - } } ff_free_vlc(vlc); - return init_vlc(vlc, SHEER_VLC_BITS, count, - lens, sizeof(*lens), sizeof(*lens), - codes, sizeof(*codes), sizeof(*codes), 0); + return ff_init_vlc_from_lengths(vlc, SHEER_VLC_BITS, count, + lens, sizeof(*lens), NULL, 0, 0, 0, 0, NULL); } static int decode_frame(AVCodecContext *avctx,