From patchwork Wed Dec 2 04:22:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24315 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 1CE0D44AAF6 for ; Wed, 2 Dec 2020 06:36:42 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22C3068A72C; Wed, 2 Dec 2020 06:24:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3998268A67C for ; Wed, 2 Dec 2020 06:24:37 +0200 (EET) Received: by mail-ej1-f66.google.com with SMTP id qw4so614102ejb.12 for ; Tue, 01 Dec 2020 20:24:37 -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=Llu8L8wu7WvqlKWthuVpIZqY1Yl7xD1nTuW+Tl23nPg=; b=YcwM8j0nXw3VH3sM0l9f/3ZjyV/1wKTfBPcN8gx8LSCIY2+2dSlznafEjCTxcOvBBx TJPZzEdfunAfedQHmqmr6UtjGmZf/4Yhlx0hO2zd2UUG/QC+Bz/kng+UQwaW2kUFjhPC eLId5a8pQax+NTX3JrLMddzcw5KUrt+lMITciY4+/e26IgwAlWR53NMcdTmknLTYcb5A frsyBH/MuXcJYXi29YzKVyDl3Gx9PGZvYoWgwCmEMejEBpqb1QVN1thXbAyCV7RZBOip xI6p60lRn0qSwNEjRIXRL4cwZKUMy4gcFwJQw9iYZQG5olBjp67M96cM8gr5mUdMJ1wa wgHQ== 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=Llu8L8wu7WvqlKWthuVpIZqY1Yl7xD1nTuW+Tl23nPg=; b=P4kAg0pkJ07PK9f26MiYosookobBbvYI/9atWxXRnoTq8Hl21lgwoi9Zmd2SnexdD3 OLzRxCOIsuYQ2g1ZYxFb6rRFwP9qhy8Yuxb8KTTZ754/ggg9jD4CL/HGhS95aXXQLOS0 NbhVbVULUfPo9wNE7qYrulLeJhBN9xZM8mHNu9k5GDZ6QZqf13YEKvw1hGYZF7rYmBR6 NP5/5fseQbHcs8pMcrLOtCczwt136q272OIxwJMromBGaEwPkhdJaIuPA3zOchkwwPT7 5OEKU4iDqSzTLxShZd1W+W8wSE8ZRPztPVQkkGpipZnofivelvRVHI8q8oXDuDM0u6zC KPjw== X-Gm-Message-State: AOAM533DTlV0dqvylJu/HLEvFbkorcx/ryC+HIi4iGbicweFSald9fop 5JUTM0/9+PKF+IeXY3x+9xhGHcIFs/0ixA== X-Google-Smtp-Source: ABdhPJx3Yx1qNSWT/CJFggeLBK3IUdJNVEJA5DhXtK5ae8c1NsVogoFDZVNqis7NEGzl0R9OJAC0kw== X-Received: by 2002:a17:906:e15:: with SMTP id l21mr542881eji.509.1606883076402; Tue, 01 Dec 2020 20:24:36 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id mc25sm265087ejb.58.2020.12.01.20.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 20:24:35 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Dec 2020 05:22:38 +0100 Message-Id: <20201202042244.519127-77-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> References: <20201127010249.2724610-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 211/217] avcodec/bink: Don't waste space for 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" The Bink video decoder uses VLCs; the longest codes of these VLCs have different lengths, yet they are all so small that each VLC is read in one go, so that the number of elements in the VLC table actually used by each table is 1 << nb_bits, where nb_bits is the length of the longest code. Yet when determining the size of the VLC table nb_bits has been overestimated as the number of bits of the longest code in all VLCs, making said table unnecessary big (2048 vs 976 elements). Signed-off-by: Andreas Rheinhardt --- libavcodec/bink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index f1fa9c0071..04c104be48 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1311,11 +1311,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac static av_cold void bink_init_vlcs(void) { - for (int i = 0; i < 16; i++) { - static VLC_TYPE table[16 * 128][2]; + for (int i = 0, offset = 0; i < 16; i++) { + static VLC_TYPE table[976][2]; const int maxbits = bink_tree_lens[i][15]; - bink_trees[i].table = table + i*128; + bink_trees[i].table = table + offset; bink_trees[i].table_allocated = 1 << maxbits; + offset += bink_trees[i].table_allocated; init_vlc(&bink_trees[i], maxbits, 16, bink_tree_lens[i], 1, 1, bink_tree_bits[i], 1, 1, INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE);