From patchwork Fri Nov 20 07:19:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23787 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 E52E044AF11 for ; Fri, 20 Nov 2020 09:30:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AECD668BA8B; Fri, 20 Nov 2020 09:24:57 +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 5861E68BA6C for ; Fri, 20 Nov 2020 09:24:47 +0200 (EET) Received: by mail-ej1-f65.google.com with SMTP id f20so11491174ejz.4 for ; Thu, 19 Nov 2020 23:24:47 -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=Ap2+12C/N6FyXSWWkUzDt1y7978WCwEi2YLY9OVOeOk=; b=ehDaJkTiGX7f0rWXsFvBmvrif4Gc3ovc5FF+Ze8c72i1nQ2BoP9wEyFExb7nkA2pPw r5qltzbxeiXmz2/bE/oLZClrhTEc5zT03XBTJrvxtmGK35sA3trpw9ZeyIWmY4uWAbnn EoAcFBHQyo0jX2BxrdHLTntd152ocBeqLbyoOgCoHDPezWY8qaH+PhgR+mpdOMwZJ2Pb Io/1RPX5ZAzzBGYfX8pqOfIvvvw6aiNKgr4Ges69YeoDzqClqPqeSFbrqrCS8Y70Mdso dUncEto1E8oR9Op4vv0o6jLvfwiRs8T+OG/3CfFo8IUd0urSvqTAZzdPWDji5TU94VrE Ltew== 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=Ap2+12C/N6FyXSWWkUzDt1y7978WCwEi2YLY9OVOeOk=; b=H7HM9c7/Sb5IfdeD60fPmeV5qFlg6ibkretuVCfoexCFTnjxL3vNZtZxWFswW/cai8 DDlCENNtZc0j2JE1r4C+1/aEctiyzJHzvppKisQEW8wOdmzvIX2mvngrX3pcUS9eIYw4 1zoMdOXvDst5lgIIQIbh191yv2lKESTAxwyHkECvChjOeQnkYemzEbXhmKlkwVjCLaCw z6Zo8lb9gRYQjYyQsuZncjmWM5+DCteAGAShON6e1j8YcJCHY4tZ2ovDv8Ffgx5m4glR o2U26wqMMzMufX0mb5/vM8W22UAkqnBeLs1+xd49QQONkVq6pF2q3lBHhpVQqG/XRcNi JM6w== X-Gm-Message-State: AOAM533r5wHo0RyR4c/hNx/NKfD/rnNbDazDBnYXGDRwXuroVRVfVZ8z H4sDN/GFvYy+LBfFf/cZiEVmxDG27DjApw== X-Google-Smtp-Source: ABdhPJy5SvOR0reQBid+LhOI+u9A/yvBE0eDFSKslhlVNgso9Jg2dGyjf5/U4bKPrxiLXYVMjaW5ug== X-Received: by 2002:a17:906:2f87:: with SMTP id w7mr34147319eji.83.1605857086440; Thu, 19 Nov 2020 23:24:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:24:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:09 +0100 Message-Id: <20201120072116.818090-37-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 036/162] avcodec/mimic: Reduce size of tables used to initialize 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" By switching to ff_init_vlc_from_lengths() one can replace a table of codes of type uint32_t with a table of symbols of type uint8_t saving space. The old tables also had holes in it (because of the symbols) which are now superfluous, saving ever more space. Signed-off-by: Andreas Rheinhardt --- libavcodec/mimic.c | 55 ++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 0f8103ef85..7a74b99086 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -65,43 +65,25 @@ typedef struct MimicContext { int next_prev_index; } MimicContext; -static const uint32_t huffcodes[] = { - 0x0000000a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000000b, - 0x0000001b, 0x00000038, 0x00000078, 0x00000079, 0x0000007a, 0x000000f9, - 0x000000fa, 0x000003fb, 0x000007f8, 0x000007f9, 0x000007fa, 0x000007fb, - 0x00000ff8, 0x00000ff9, 0x00000001, 0x00000039, 0x0000007b, 0x000000fb, - 0x000001f8, 0x000001f9, 0x00000ffa, 0x00000ffb, 0x00001ff8, 0x00001ff9, - 0x00001ffa, 0x00001ffb, 0x00003ff8, 0x00003ff9, 0x00003ffa, 0x00000000, - 0x00000004, 0x0000003a, 0x000001fa, 0x00003ffb, 0x00007ff8, 0x00007ff9, - 0x00007ffa, 0x00007ffb, 0x0000fff8, 0x0000fff9, 0x0000fffa, 0x0000fffb, - 0x0001fff8, 0x0001fff9, 0x0001fffa, 0x00000000, 0x0000000c, 0x000000f8, - 0x000001fb, 0x0001fffb, 0x0003fff8, 0x0003fff9, 0x0003fffa, 0x0003fffb, - 0x0007fff8, 0x0007fff9, 0x0007fffa, 0x0007fffb, 0x000ffff8, 0x000ffff9, - 0x000ffffa, 0x00000000, 0x0000001a, 0x000003f8, 0x000ffffb, 0x001ffff8, - 0x001ffff9, 0x001ffffa, 0x001ffffb, 0x003ffff8, 0x003ffff9, 0x003ffffa, - 0x003ffffb, 0x007ffff8, 0x007ffff9, 0x007ffffa, 0x007ffffb, 0x00000000, - 0x0000003b, 0x000003f9, 0x00fffff8, 0x00fffff9, 0x00fffffa, 0x00fffffb, - 0x01fffff8, 0x01fffff9, 0x01fffffa, 0x01fffffb, 0x03fffff8, 0x03fffff9, - 0x03fffffa, 0x03fffffb, 0x07fffff8, 0x00000000, 0x000003fa, 0x07fffff9, - 0x07fffffa, 0x07fffffb, 0x0ffffff8, 0x0ffffff9, 0x0ffffffa, 0x0ffffffb, - 0x1ffffff8, 0x1ffffff9, 0x1ffffffa, 0x1ffffffb, 0x3ffffff8, 0x3ffffff9, - 0x3ffffffa, +static const uint8_t huffsyms[] = { + 0x10, 0x20, 0x30, 0x00, 0x11, 0x40, 0x50, 0x12, 0x13, 0x21, 0x31, 0x60, + 0x14, 0x15, 0x16, 0x22, 0x41, 0x17, 0x18, 0x23, 0x24, 0x25, 0x32, 0x42, + 0x51, 0x61, 0x70, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x26, 0x27, + 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x52, 0x53, 0x54, 0x55, 0x56, + 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x62, 0x63, 0x64, 0x65, + 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, 0x73, + 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, }; static const uint8_t huffbits[] = { - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 4, 5, 6, 7, 7, 7, 8, - 8, 10, 11, 11, 11, 11, 12, 12, 2, 6, 7, 8, - 9, 9, 12, 12, 13, 13, 13, 13, 14, 14, 14, 0, - 3, 6, 9, 14, 15, 15, 15, 15, 16, 16, 16, 16, - 17, 17, 17, 0, 4, 8, 9, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 0, 5, 10, 20, 21, - 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 0, - 6, 10, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, - 26, 26, 27, 0, 10, 27, 27, 27, 28, 28, 28, 28, - 29, 29, 29, 29, 30, 30, 30, + 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, + 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, + 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, + 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, + 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, + 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, }; static const uint8_t col_zag[64] = { @@ -142,8 +124,9 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) ctx->prev_index = 0; ctx->cur_index = 15; - if ((ret = init_vlc(&ctx->vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits), - huffbits, 1, 1, huffcodes, 4, 4, 0)) < 0) { + ret = ff_init_vlc_from_lengths(&ctx->vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits), + huffbits, 1, huffsyms, 1, 1, 0, 0, avctx); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n"); return ret; }