From patchwork Tue Nov 10 10:58:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23578 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 D8B7644B529 for ; Tue, 10 Nov 2020 13:16:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E19368C0D5; Tue, 10 Nov 2020 12:59:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11DC868BFF6 for ; Tue, 10 Nov 2020 12:59:36 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id c17so12171184wrc.11 for ; Tue, 10 Nov 2020 02:59:36 -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=slfBDbBID+hZkmigRqplltMYvGPET1v/OnCz2Fw3O4A=; b=llh7MZQJFB1yqTkGd5SMqaE8X3d77YL7+1zi719uFsBEtKgo91gekJDkknHjbCzDCj hgOdUJvsRGKZIH4V/HIvP3Qu04tTajr+3qGV0aWi4VwYSXl5BJP3dmOpME3DksousQXl lJaD3elTSvGhlHy698NENXydBDyeVO8B7dCJunSBJb2ciTgLq0xHM4Gz3twFQbZk6Woj MpMl4Bvak/6W4c89FqtjAq8EYQkNspUui1Iy1bh5zphVq8N4uXEvRtJPnnTPnjsIZN9Q w4Pdgg1tHOlRPexN+CulbbJNDKcPRXEN4rgmvedT587r+l8fYgAPrfMJLWqFDPYH9jtc UdEQ== 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=slfBDbBID+hZkmigRqplltMYvGPET1v/OnCz2Fw3O4A=; b=KyjAnNZ/3uj8CHLwgv9R/hlpI1FoieLcYpg8CuBe9TjNxiahMyiD2ohKNeM0UEae4B zdD7dgrMaHRJEbSBQrIvNtzJJwwAfznyv/rY2zExbLDFwEtA5eaO5wqLa2GSglCXaJjA nS4SiYUMFRi5PvvyKzbonzTAJ/dpZYXpO7z2cC5EwjRY7LWSQV0f6Z4wPcC+gLf5YugD 7iEYJ9JYEoxMCokaaxVH0D4XdwADnkjzJAJt6gR2wx2BfKdRqDZInkS6kXETplRBeSu/ aZ7npQMvcXdRi7Jj1RlmGMIRb8v4T5GhcsX8qmbtp+Z8+OGFW6oyYRe+4wDXwZteN5FQ 9foQ== X-Gm-Message-State: AOAM530h2eP87Q5CZGZ28js/eLzOZrdHCiryMr1MO9JWXRwLb8Vu7TWt 3DOah/td21+ygAZSyHmXoiRvMVrysMQ= X-Google-Smtp-Source: ABdhPJwr4xv9IXvFU/BZaPVBw+M7AoFyD8yVirmjj3JZJ4qGRTwpfpL2eM1UN+2t0NSUkwFi/QfaOA== X-Received: by 2002:a5d:6a0b:: with SMTP id m11mr7229145wru.190.1605005975209; Tue, 10 Nov 2020 02:59:35 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id o197sm2561308wme.17.2020.11.10.02.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:59:34 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:58:34 +0100 Message-Id: <20201110105836.321916-21-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 112/114] avcodec/qdmc: Make tables used to initialize VLCs smaller 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" This is possible by switching to ff_init_vlc_from_lengths() which allows to replace tables of codes of size uint16_t or uint32_t by tables of symbols of size uint8_t; in case there already were symbols tables the savings are even bigger. Signed-off-by: Andreas Rheinhardt --- libavcodec/qdmc.c | 91 +++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index f4e507fa60..8b50fbf30a 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -119,58 +119,36 @@ static const uint8_t noise_bands_selector[] = { 4, 3, 2, 1, 0, 0, 0, }; -static const uint8_t noise_value_bits[] = { - 12, 7, 9, 7, 10, 9, 11, 9, 9, 2, 9, 9, 9, 9, - 9, 3, 9, 10, 10, 12, 2, 3, 3, 5, 5, 6, 7, +static const uint8_t noise_value[][2] = { + { 1, 2 }, { 10, 7 }, { 26, 9 }, { 22, 9 }, { 24, 9 }, { 14, 9 }, + { 8, 6 }, { 6, 5 }, { 7, 5 }, { 9, 7 }, { 30, 9 }, { 32, 10 }, + { 13, 10 }, { 20, 9 }, { 28, 9 }, { 12, 7 }, { 15, 11 }, { 36, 12 }, + { 0, 12 }, { 34, 10 }, { 18, 9 }, { 11, 9 }, { 16, 9 }, { 5, 3 }, + { 2, 3 }, { 4, 3 }, { 3, 2 }, }; -static const uint8_t noise_value_symbols[] = { - 0, 10, 11, 12, 13, 14, 15, 16, 18, 1, 20, 22, 24, - 26, 28, 2, 30, 32, 34, 36, 3, 4, 5, 6, 7, 8, 9, +static const uint8_t noise_segment_length[][2] = { + { 1, 1 }, { 2, 2 }, { 3, 4 }, { 8, 9 }, { 9, 10 }, { 0, 10 }, + { 13, 8 }, { 7, 7 }, { 6, 6 }, { 17, 5 }, { 4, 4 }, { 5, 4 }, }; -static const uint16_t noise_value_codes[] = { - 0xC7A, 0x002, 0x0FA, 0x03A, 0x35A, 0x1C2, 0x07A, 0x1FA, - 0x17A, 0x000, 0x0DA, 0x142, 0x0C2, 0x042, 0x1DA, 0x001, - 0x05A, 0x15A, 0x27A, 0x47A, 0x003, 0x005, 0x006, 0x012, - 0x00A, 0x022, 0x01A, +static const uint8_t amplitude[][2] = { + { 18, 3 }, { 16, 3 }, { 22, 7 }, { 8, 10 }, { 4, 10 }, { 3, 9 }, + { 2, 8 }, { 23, 8 }, { 10, 8 }, { 11, 7 }, { 21, 5 }, { 20, 4 }, + { 1, 7 }, { 7, 10 }, { 5, 10 }, { 9, 9 }, { 6, 10 }, { 25, 11 }, + { 26, 12 }, { 27, 13 }, { 0, 13 }, { 24, 9 }, { 12, 6 }, { 13, 5 }, + { 14, 4 }, { 19, 3 }, { 15, 3 }, { 17, 2 }, }; -static const uint8_t noise_segment_length_bits[] = { - 10, 8, 5, 1, 2, 4, 4, 4, 6, 7, 9, 10, -}; - -static const uint8_t noise_segment_length_symbols[] = { - 0, 13, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, -}; - -static const uint16_t noise_segment_length_codes[] = { - 0x30B, 0x8B, 0x1B, 0x0, 0x1, 0x3, 0x7, 0xF, 0x2b, 0x4B, 0xB, 0x10B, -}; - -static const uint8_t freq_diff_bits[] = { - 18, 2, 4, 4, 5, 4, 4, 5, 5, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 6, - 7, 6, 6, 6, 7, 7, 7, 7, 7, 8, 9, 9, 8, 9, 11, 11, 12, 12, 13, 12, - 14, 15, 18, 16, 17, -}; - -static const uint32_t freq_diff_codes[] = { - 0x2AD46, 0x1, 0x0, 0x3, 0xC, 0xA, 0x7, 0x18, 0x12, 0xE, 0x4, 0x16, - 0xF, 0x1C, 0x8, 0x22, 0x26, 0x2, 0x3B, 0x34, 0x74, 0x1F, 0x14, 0x2B, - 0x1B, 0x3F, 0x28, 0x54, 0x6, 0x4B, 0xB, 0x68, 0xE8, 0x46, 0xC6, 0x1E8, - 0x146, 0x346, 0x546, 0x746, 0x1D46, 0xF46, 0xD46, 0x6D46, 0xAD46, 0x2D46, - 0x1AD46, -}; - -static const uint8_t amplitude_bits[] = { - 13, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, - 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 8, 9, 11, 12, 13, -}; - -static const uint16_t amplitude_codes[] = { - 0x1EC6, 0x6, 0xC2, 0x142, 0x242, 0x246, 0xC6, 0x46, 0x42, 0x146, 0xA2, - 0x62, 0x26, 0x16, 0xE, 0x5, 0x4, 0x3, 0x0, 0x1, 0xA, 0x12, 0x2, 0x22, - 0x1C6, 0x2C6, 0x6C6, 0xEC6, +static const uint8_t freq_diff[][2] = { + { 2, 4 }, { 14, 6 }, { 26, 7 }, { 31, 8 }, { 32, 9 }, { 35, 9 }, + { 7, 5 }, { 10, 5 }, { 22, 7 }, { 27, 7 }, { 19, 7 }, { 20, 7 }, + { 4, 5 }, { 13, 5 }, { 17, 6 }, { 15, 6 }, { 8, 5 }, { 5, 4 }, + { 28, 7 }, { 33, 9 }, { 36, 11 }, { 38, 12 }, { 42, 14 }, { 45, 16 }, + { 44, 18 }, { 0, 18 }, { 46, 17 }, { 43, 15 }, { 40, 13 }, { 37, 11 }, + { 39, 12 }, { 41, 12 }, { 34, 8 }, { 16, 6 }, { 11, 5 }, { 9, 4 }, + { 1, 2 }, { 3, 4 }, { 30, 7 }, { 29, 7 }, { 23, 6 }, { 24, 6 }, + { 18, 6 }, { 6, 4 }, { 12, 5 }, { 21, 6 }, { 25, 6 }, }; static const uint8_t amplitude_diff_bits[] = { @@ -209,15 +187,18 @@ static av_cold void qdmc_init_static_data(void) { int i; - INIT_VLC_STATIC_LE(&vtable[0], 12, FF_ARRAY_ELEMS(noise_value_bits), - noise_value_bits, 1, 1, noise_value_codes, 2, 2, noise_value_symbols, 1, 1, 4096); - INIT_VLC_STATIC_LE(&vtable[1], 10, FF_ARRAY_ELEMS(noise_segment_length_bits), - noise_segment_length_bits, 1, 1, noise_segment_length_codes, 2, 2, - noise_segment_length_symbols, 1, 1, 1024); - INIT_VLC_STATIC_LE(&vtable[2], 12, FF_ARRAY_ELEMS(amplitude_bits), - amplitude_bits, 1, 1, amplitude_codes, 2, 2, NULL, 0, 0, 4098); - INIT_VLC_STATIC_LE(&vtable[3], 12, FF_ARRAY_ELEMS(freq_diff_bits), - freq_diff_bits, 1, 1, freq_diff_codes, 4, 4, NULL, 0, 0, 4160); + INIT_VLC_STATIC_FROM_LENGTHS(&vtable[0], 12, FF_ARRAY_ELEMS(noise_value), + &noise_value[0][1], 2, + &noise_value[0][0], 2, 1, 0, INIT_VLC_LE, 4096); + INIT_VLC_STATIC_FROM_LENGTHS(&vtable[1], 10, FF_ARRAY_ELEMS(noise_segment_length), + &noise_segment_length[0][1], 2, + &noise_segment_length[0][0], 2, 1, 0, INIT_VLC_LE, 1024); + INIT_VLC_STATIC_FROM_LENGTHS(&vtable[2], 12, FF_ARRAY_ELEMS(amplitude), + &litude[0][1], 2, + &litude[0][0], 2, 1, 0, INIT_VLC_LE, 4098); + INIT_VLC_STATIC_FROM_LENGTHS(&vtable[3], 12, FF_ARRAY_ELEMS(freq_diff), + &freq_diff[0][1], 2, + &freq_diff[0][0], 2, 1, 0, INIT_VLC_LE, 4160); INIT_VLC_STATIC_LE(&vtable[4], 8, FF_ARRAY_ELEMS(amplitude_diff_bits), amplitude_diff_bits, 1, 1, amplitude_diff_codes, 1, 1, NULL, 0, 0, 256); INIT_VLC_STATIC_LE(&vtable[5], 6, FF_ARRAY_ELEMS(phase_diff_bits),