From patchwork Fri Nov 20 07:20:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23843 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 BCBBD448F87 for ; Fri, 20 Nov 2020 09:40:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E85B468BC62; Fri, 20 Nov 2020 09:26:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 053C868BB43 for ; Fri, 20 Nov 2020 09:25:40 +0200 (EET) Received: by mail-ej1-f65.google.com with SMTP id k27so11456240ejs.10 for ; Thu, 19 Nov 2020 23:25:40 -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=Y6VzCF886BhzS8iljlIDjiTeXZXVAdYIT++kEXg9Dkc=; b=SrNnu1he3upyELlDtBmpPlsdbwhxyEXmLVh0OM2HvlYAXkgKioOQZ4v6vawXOPesfX pPmQ8WOt2SQiuf1P8kLeLe9du2p1zY0fEPNEwQ1cR9Q9QI9gdMJl0UgAtjYtLMak5Wa7 mbJYwJqAVbNqfiIxkbn8i6E5+M0MvtYEohXNf8VDHk44O1Bgj5NK9s/5Ld9pQKO25Fsq wx8lamlLJPNjomEvzdT2G1pnrk00QVULmBsnjFNqBQ4JWVi3ZKVWtqh4+dXwhCNO4LKj KQd6PUD9SXjaQqrsfe43Lh+fsYXMO9fnnVqRh+wJtK77zUvwI1PzY3fdDbc/TD1XdOmv H00w== 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=Y6VzCF886BhzS8iljlIDjiTeXZXVAdYIT++kEXg9Dkc=; b=L+2C3vq3ww5IT0oqQIIjvuLRchM2gJn/MmcATFOH6zU/XbH8tbu3A55QFvCN9dMoJO F9Jqe7n7CkUq27/A2tafwuM3FUt2nRTOj4a2Vsi7pY68BQ8uPOYLCTL5EwwIfDc9BgPQ RivsRdpyhd7bVdsOVfCI5UjCUOO9Elv1zfuz/ty2XIDaIo1I4iKiX8B2dfuLMIgY4gPy Iz9g31gtIXgSWB+NH3zsKdlMz17udDZOEEX3p8SwCcefrL0LP7POdLLyeRZfRUEJmovD E9hUHv4H3F/Ht8Jw3f4eawjKSiQbGUCQJJPxhJkWvplhGHlaFI/Igu8rmpm9Fkqyy3aG eWbg== X-Gm-Message-State: AOAM530ONfktPn0hI9CyxzK/4gYCMUl9cQZsBQwXnLJsP0ctVS8fMu9u +S4DdyiLBmUUXaCbXR+XsW/sZWhBVEJ0mQ== X-Google-Smtp-Source: ABdhPJyiupzUaB8yVifUFn4nN3Mg34wl0UTn9dpvicI3welu7XYm+L6cl7J6uS8lfum2A0fLkypypg== X-Received: by 2002:a17:906:af47:: with SMTP id ly7mr33410539ejb.532.1605857140221; Thu, 19 Nov 2020 23:25:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:39 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:20:03 +0100 Message-Id: <20201120072116.818090-91-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 090/162] avcodec/atrac3plus: Simplify creating VLCs 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" Use ff_init_vlc_from_lengths() to offload the computation of the codes. Signed-off-by: Andreas Rheinhardt --- libavcodec/atrac3plus.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c index 6b046a887e..f527d3b9fc 100644 --- a/libavcodec/atrac3plus.c +++ b/libavcodec/atrac3plus.c @@ -51,9 +51,7 @@ static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat, int *tab_offset, VLC *out_vlc) { int i, b; - uint16_t codes[256]; uint8_t bits[256]; - unsigned code = 0; int index = 0; int min_len = *cb++; // get shortest codeword length int max_len = *cb++; // get longest codeword length @@ -62,17 +60,15 @@ static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat, for (i = *cb++; i > 0; i--) { av_assert0(index < 256); bits[index] = b; - codes[index] = code++; index++; } - code <<= 1; } out_vlc->table = &tables_data[*tab_offset]; out_vlc->table_allocated = 1 << max_len; - ff_init_vlc_sparse(out_vlc, max_len, index, bits, 1, 1, codes, 2, 2, - xlat, 1, 1, INIT_VLC_USE_NEW_STATIC); + ff_init_vlc_from_lengths(out_vlc, max_len, index, bits, 1, + xlat, 1, 1, 0, INIT_VLC_USE_NEW_STATIC, NULL); *tab_offset += 1 << max_len; }