From patchwork Fri Nov 20 07:18:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23751 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 9BA9744A644 for ; Fri, 20 Nov 2020 09:24:20 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7F59268B9B2; Fri, 20 Nov 2020 09:24:20 +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 C5CA768B99F for ; Fri, 20 Nov 2020 09:24:12 +0200 (EET) Received: by mail-ej1-f65.google.com with SMTP id a16so11511042ejj.5 for ; Thu, 19 Nov 2020 23:24:12 -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=WqFHj4lIBHtzs2092zA7cqBT0Pr0Zpr/mSZwY5TYFWU=; b=Q+gR/28tg8xfrtLi3B38RaB8YB+mdGNp0ihYFZBc3QSwRVNJABBW3Hc0hLakuW1Ud5 YsmlUzCRLYV+3BmAQioeCytKRvZLRi0/pwY/YcSMs23+dyUSnqs2ZsuVMHyIUbmuWkzx 7bVmb72rLjKlNLlqGA4KGjWnv3//RMjuCTR7q457cYL4x5LtBmh60VudnafA/1VaLkoi REPTYK2KNwzs3eK4CAaiduzojZ/+LUL0qCiwiz6QfAxpUwR5Zsls21Pv/dJCOneYaxxB 0uWFCusfaOtusd0V95L1tZcIFZb6avO0FSD1RqS7YNrSEzQzXlUpBZ/B8Nf5VLqcnz/J MtsA== 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=WqFHj4lIBHtzs2092zA7cqBT0Pr0Zpr/mSZwY5TYFWU=; b=lFRIboKkBtU5YtoyTe08amCOWmVJ2pKdfm6+PR0XFOZNS6S4R3wFGMQFqzqqEZWga3 E1q4R4w3pvTwSj4ja92r97F7VmGXE//5RiIlcDS4pjdj62puB5EC0XAZfSyb/JciL7S0 nsIrYGK7BvGHtHK+poZWj4H2Q+0KW16HH+dC6tdreroj0ynwTMJnYbrrDOxRZIX6yZrz KZwHQ/3U4Qk02tWk6B8HZWUyjgE0NJhF4JIsNuyymtv9MWfa4ZJYXq/4O1xb/gYlX7Mf /YEsfvbZ3Zrw702uuOJl88gf+tWTs0ErW33FikeyBknjN6BxhKRoeO6xnqeHmsuYd2dQ qsQg== X-Gm-Message-State: AOAM5336Ysz1jcQXNXqnicSuZmM+wueXa6ks2mK4OSVJZ732y4mDlCWD sS+1jfUJwfNXjKGVr7jpkSbt/c3ItMhD7w== X-Google-Smtp-Source: ABdhPJzd2PCK8v3wqGkEqstIyoG0tTZeqXTBaU/84GEZZHCUf/4nuEh5AvNtU/wXy7brS+bI1gjWGQ== X-Received: by 2002:a17:906:4698:: with SMTP id a24mr33244472ejr.90.1605857052071; Thu, 19 Nov 2020 23:24:12 -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.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:24:11 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:18:40 +0100 Message-Id: <20201120072116.818090-8-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 007/162] avcodec/cllc: Improve 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" One can offload the computation of the codes to ff_init_vlc_from_lengths(); this also improves performance: The number of decicycles for one call to read_code_table() decreased from 198343 to 148338 with the sample sample-cllc-rgb.avi from the FATE suite; it has been looped 100 times and the test repeated ten times to test it sufficiently often. Signed-off-by: Andreas Rheinhardt --- libavcodec/cllc.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libavcodec/cllc.c b/libavcodec/cllc.c index 8b1bc75faa..837e04f173 100644 --- a/libavcodec/cllc.c +++ b/libavcodec/cllc.c @@ -46,11 +46,9 @@ static int read_code_table(CLLCContext *ctx, GetBitContext *gb, VLC *vlc) { uint8_t symbols[256]; uint8_t bits[256]; - uint16_t codes[256]; - int num_lens, num_codes, num_codes_sum, prefix; + int num_lens, num_codes, num_codes_sum; int i, j, count; - prefix = 0; count = 0; num_codes_sum = 0; @@ -74,19 +72,13 @@ static int read_code_table(CLLCContext *ctx, GetBitContext *gb, VLC *vlc) for (j = 0; j < num_codes; j++) { symbols[count] = get_bits(gb, 8); bits[count] = i + 1; - codes[count] = prefix++; count++; } - if (prefix > (65535 - 256)/2) { - return AVERROR_INVALIDDATA; - } - - prefix <<= 1; } - return ff_init_vlc_sparse(vlc, VLC_BITS, count, bits, 1, 1, - codes, 2, 2, symbols, 1, 1, 0); + return ff_init_vlc_from_lengths(vlc, VLC_BITS, count, bits, 1, + symbols, 1, 1, 0, 0, ctx->avctx); } /*