From patchwork Thu Dec 10 11:16:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24519 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c00a:0:0:0:0:0 with SMTP id c10csp4931831ybf; Thu, 10 Dec 2020 03:20:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3CfUqigKf+h2MnLOXGzdsxLp1Tto305pu4J+m0UIJWDLWQ+Qi1TVTfeWFGkttsCura/ft X-Received: by 2002:a05:600c:208:: with SMTP id 8mr7788857wmi.143.1607599249335; Thu, 10 Dec 2020 03:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607599249; cv=none; d=google.com; s=arc-20160816; b=liQh4qPjGgm2thg4Y7vKw8Y07tCQLOqJTPHMH+BKQQYOxAMY0/T5fkN+ReyTKaBp1G x+NXx+LuFPISYs+Zq7zn7od2Wxw7cWIW8HEWso/Pe7wWytC9YFMQ/mj9gym9sk31kxVx rvCCyrYwbnoidQFMwOeIaXTWjU02eFcXHeFaJxk916nx1LbmhymY+LV5ci27qLk65GwD QFn20MFPhP7vtCNGjwichTndqW2CHIGuNZq49tCppA0qOq1LRQEb7u0pEG3ZRPWOo7gK 2RvrzawYlVpmHqHmvGnQjnA5++Y2jl/wq2unyrJDVNsT2IMOOlO32E4B3I1Frip8xaJh xrGQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=pNddBMIRDqHtBa/EpzB3HHMKOqInvnfR7Od5zQ5iPqE=; b=rrzCwGJXxf4vvLAFQdmr0xUpoVXuCrPhOjpHayHLLx6++gr9vEtmsYRJy5eo1h/tch ucZw8BM+3GnC1oFtrQmYuB/NNO+NjzWSIBc4tkFbUYxs5Nj5qdhmMRlMjoLF+mdFTDW+ 2NW7oJMtGL7ah32n0K8bzbgcBU2RwwaYJAbrb5hr1WrY/pspPKNwQwTMiMUvj6ZV+zrn uxs6tSg5bPPPPVLn6MdnJMP4oqlrZMLox5mRKbbQJxh3lAi8U+7RsEY1JhB+QcY7/Oyq aZ+4nuZk4spl78zsLJ87+SFnAsFSjB8FSUOoithF127hLaYJaK2HkMj8NUHKSQ1aI0pn rVyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ijdxsnFa; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y80si5207476wmd.104.2020.12.10.03.20.49; Thu, 10 Dec 2020 03:20:49 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=ijdxsnFa; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20E2C68A329; Thu, 10 Dec 2020 13:19:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA451689FE7 for ; Thu, 10 Dec 2020 13:18:52 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id a6so4308215wmc.2 for ; Thu, 10 Dec 2020 03:18:52 -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=kK2378aIfPvos0rK1fyeeWFrF5Tl515Bj5MvCD3w4bs=; b=ijdxsnFawM9XlS0Q5rAiFQE/uTfmXZn129h0jSmxGfD13GtfaIMomHo1o12pAWPPLD UeWWuSDv7+WaxzOPuP/m/z9O+lsVhQh5tFiuOWObyXH5MMVdXSc1D3qdc5ijtclZOzvq TJEyZT+h+ySKRDuRbiLqziFutLKmMKhcWkJ5IYh3qSEVaDGThvewwKLfXup1A/lJE+IE sa1ZkMq/2C14CTJ1xAxa5OwM7Wdm1ts9CPw2hcavF71QOAATwmyyT/rPwXClXNVg0J/X i7DD3Zyg2T3glHk29hOA81XfTbuyE9rNBffJuG1o++uGqlRUoWSFUC3PRtvWkEpAsIq2 E8Dw== 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=kK2378aIfPvos0rK1fyeeWFrF5Tl515Bj5MvCD3w4bs=; b=haLOE18O1DIQLByAjKZEdoqB+csEe/LTdNL9OB7jSgBcMvQ8tBi5fopg90QDVo2jdh COQtxi9ZXEHlUVjbFuPkwMFIIvJL7Iqszw7gKGnRqBOD50JnKg1vsoLyDwiBOpjI7z6u uq2FFuRzfslsBmm/S8GjkipdBtsixavTJlW6LTvyeLjDy4Cp6bwWXEEjiRBLd9lmEMi3 bbW9VIOPNLWCvM4TiFHkCI2DbO4khzZtCtghEn3B2QTEwuh4FGQ0rn7MWIckIxH8yY/W 4XP/Z3MTQG8bVH7HwDrgxOSXSjj//zbIYYbsbzeZfLafbxSIdhVgKsEwLWAgfUn47Epw vlvA== X-Gm-Message-State: AOAM530HPMdhPV7xT8Wp5DrqTvWg5LypVAFM+1QHP8rtL/y3YsXE8g3f ttY9svcEL29ZioStzKS6M5AvdNpA+8NGvQ== X-Received: by 2002:a1c:41c5:: with SMTP id o188mr7578209wma.18.1607599132227; Thu, 10 Dec 2020 03:18:52 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id s133sm8942330wmf.38.2020.12.10.03.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:18:51 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:16:25 +0100 Message-Id: <20201210111657.2276739-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> References: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/39] avcodec/rl: Allow to create only a few VLC tables 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" X-TUID: +O786ymLntJQ Content-Length: 2148 It is not uncommon that only the first one is used; this is similar to ff_init_2d_vlc_rl(). Signed-off-by: Andreas Rheinhardt --- libavcodec/rl.c | 3 +++ libavcodec/rl.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/libavcodec/rl.c b/libavcodec/rl.c index c532b5bf56..93153ff723 100644 --- a/libavcodec/rl.c +++ b/libavcodec/rl.c @@ -80,6 +80,9 @@ av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size) int qmul = q * 2; int qadd = (q - 1) | 1; + if (!rl->rl_vlc[q]) + return; + if (q == 0) { qmul = 1; qadd = 0; diff --git a/libavcodec/rl.h b/libavcodec/rl.h index a83debccf7..26e0b32a90 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -68,6 +68,14 @@ void ff_rl_init_vlc(RLTable *rl, unsigned static_size); }\ } +#define INIT_FIRST_VLC_RL(rl, static_size) \ +do { \ + static RL_VLC_ELEM rl_vlc_table[static_size]; \ + \ + rl.rl_vlc[0] = rl_vlc_table; \ + ff_rl_init_vlc(&rl, static_size); \ +} while (0) + static inline int get_rl_index(const RLTable *rl, int last, int run, int level) { int index;