From patchwork Fri Nov 20 07:19:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23817 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 D96EB44AFE3 for ; Fri, 20 Nov 2020 09:35:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08B8268BB4A; Fri, 20 Nov 2020 09:25:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6913E68B9E3 for ; Fri, 20 Nov 2020 09:25:13 +0200 (EET) Received: by mail-ed1-f67.google.com with SMTP id cq7so8477008edb.4 for ; Thu, 19 Nov 2020 23:25:13 -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=N/orFnE3ll/YyZbxoxs6nznrigD32eTyMa2AaP4PI8c=; b=j09iFB/OyjFbmYsfM377hzYFNblnf4SpjVyKdtNAD/WrD7qSwLv2ZoOOl0RKQ/b8oe jdA6lhMbULyxCqQr6QXMCA5mndKAn/3PA5fd8u4Zuaq7JwyIYF2udFWEtbVqXIyIj+hb B5cJP9zb5ykSsMSD6yYHGnLpBKWhmF1YJ08ckm213HRktEzswzzpa2vXzFSqK8G1L8zz gK6ZHlDkfH/R3pasYzB6hz9/V0UqJTMdNaYxOTkVhQ2ywaeNJw8UrofNe2OKnC7sG5hP BdboW29q3Xb2GY3YuOpGPbNI+jidIiO1/iM7G53gvfetosW0IlVOAlb0s+yPOSUJP9/V 0WVQ== 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=N/orFnE3ll/YyZbxoxs6nznrigD32eTyMa2AaP4PI8c=; b=HL2r0E2EtvsKddCdFMf/O52AkdatHgKCJt6lM5XId+cglDwJ3fmZ+V7E50irFrLt41 QLV7kec7JqebUWnzLZ196mrssGGi+VDSudkvgaOrgHDhrsF2WxNWBVJ04s0P7h5fKx71 hqGQCxnV+4JoG4k95ptlACU1WrNxVOeoZR9VEUg3MIoFZkcGEXWv/m7ISjWR1VsBfTxh U91KzQ37NnO60Q0Q3WzeJBg3sW3d8JwcPGaATiLdK1uR1A5CV6+EMr3thcaOP1/tJrww bFKP6fJRKG816DMPAijma2VT4pcur5Rp/iSuk+VeJsenR8Fo68HBS/m4RayeytW5/JmM Qukw== X-Gm-Message-State: AOAM530mb/FUQmNhXgCjtlxEe4F5B3bkE5c+4m0WcDAFPFYDKo4IAl0a qMXOsIUJbmIJ6v659aJoQvEhDURmkg3mcg== X-Google-Smtp-Source: ABdhPJy/0tQeICFcU1oJC9hGC1ZKfu/7S6bhe285I7A4+EnpvGojD+NqfNC0OmKKS4/wzzJaCEuzgA== X-Received: by 2002:aa7:c2d7:: with SMTP id m23mr33985707edp.230.1605857112523; Thu, 19 Nov 2020 23:25: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.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:12 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:19:35 +0100 Message-Id: <20201120072116.818090-63-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 062/162] avcodec/mobiclip: Avoid code duplication when initializing 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" Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 107 ++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index db9266f72a..d188e1cd57 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -157,48 +157,9 @@ static const uint8_t mv_len[16] = 10, 8, 8, 7, 8, 8, 8, 7, 8, 8, 8, 7, 7, 7, 7, 6, }; -static const uint8_t mv_bits[16][10] = -{ - { 3, 4, 5, 5, 3, 5, 6, 6, 4, 1 }, - { 2, 3, 4, 5, 5, 2, 3, 3 }, - { 2, 4, 4, 3, 3, 4, 4, 2 }, - { 1, 4, 4, 3, 4, 4, 3 }, - { 3, 3, 2, 4, 5, 5, 3, 2 }, - { 3, 4, 4, 3, 3, 3, 3, 2 }, - { 1, 3, 3, 4, 4, 4, 5, 5 }, - { 1, 4, 4, 3, 3, 4, 4 }, - { 2, 4, 4, 3, 3, 4, 4, 2 }, - { 1, 3, 3, 4, 4, 4, 5, 5 }, - { 2, 3, 4, 4, 4, 4, 3, 2 }, - { 2, 3, 3, 4, 4, 3, 2 }, - { 1, 4, 4, 3, 3, 4, 4 }, - { 1, 4, 4, 3, 3, 4, 4 }, - { 2, 3, 3, 4, 4, 3, 2 }, - { 2, 3, 3, 3, 3, 2 }, -}; - -static const uint8_t mv_syms[16][10] = -{ - { 8, 2, 3, 6, 1, 7, 5, 4, 9, 0 }, - { 9, 2, 3, 5, 4, 1, 8, 0 }, - { 0, 5, 4, 2, 9, 3, 8, 1 }, - { 1, 5, 4, 2, 8, 3, 0 }, - { 2, 9, 8, 3, 5, 4, 0, 1 }, - { 3, 5, 4, 2, 9, 8, 0, 1 }, - { 1, 2, 0, 9, 8, 3, 5, 4 }, - { 1, 8, 5, 2, 0, 4, 3 }, - { 0, 5, 4, 2, 8, 3, 9, 1 }, - { 1, 2, 0, 9, 8, 3, 5, 4 }, - { 0, 3, 9, 8, 5, 4, 2, 1 }, - { 0, 4, 3, 8, 5, 2, 1 }, - { 1, 5, 4, 2, 0, 9, 3 }, - { 1, 9, 5, 2, 0, 4, 3 }, - { 0, 5, 3, 9, 4, 2, 1 }, - { 0, 4, 5, 3, 2, 1 }, -}; - -static const uint8_t mv_bits_mods[16][10] = +static const uint8_t mv_bits[2][16][10] = { + { { 2, 3, 3, 5, 5, 4, 4, 5, 5, 2 }, { 2, 3, 4, 4, 3, 4, 4, 2 }, { 3, 4, 4, 2, 4, 4, 3, 2 }, @@ -215,10 +176,30 @@ static const uint8_t mv_bits_mods[16][10] = { 2, 3, 4, 4, 3, 3, 2 }, { 2, 3, 4, 4, 3, 3, 2 }, { 3, 3, 2, 2, 3, 3 }, + }, + { + { 3, 4, 5, 5, 3, 5, 6, 6, 4, 1 }, + { 2, 3, 4, 5, 5, 2, 3, 3 }, + { 2, 4, 4, 3, 3, 4, 4, 2 }, + { 1, 4, 4, 3, 4, 4, 3 }, + { 3, 3, 2, 4, 5, 5, 3, 2 }, + { 3, 4, 4, 3, 3, 3, 3, 2 }, + { 1, 3, 3, 4, 4, 4, 5, 5 }, + { 1, 4, 4, 3, 3, 4, 4 }, + { 2, 4, 4, 3, 3, 4, 4, 2 }, + { 1, 3, 3, 4, 4, 4, 5, 5 }, + { 2, 3, 4, 4, 4, 4, 3, 2 }, + { 2, 3, 3, 4, 4, 3, 2 }, + { 1, 4, 4, 3, 3, 4, 4 }, + { 1, 4, 4, 3, 3, 4, 4 }, + { 2, 3, 3, 4, 4, 3, 2 }, + { 2, 3, 3, 3, 3, 2 }, + } }; -static const uint8_t mv_syms_mods[16][10] = +static const uint8_t mv_syms[2][16][10] = { + { { 1, 8, 9, 4, 3, 2, 7, 5, 6, 0 }, { 0, 9, 5, 4, 2, 3, 8, 1 }, { 3, 9, 5, 0, 4, 8, 2, 1 }, @@ -235,6 +216,25 @@ static const uint8_t mv_syms_mods[16][10] = { 2, 4, 9, 5, 3, 0, 1 }, { 0, 4, 9, 5, 3, 2, 1 }, { 5, 4, 1, 0, 3, 2 }, + }, + { + { 8, 2, 3, 6, 1, 7, 5, 4, 9, 0 }, + { 9, 2, 3, 5, 4, 1, 8, 0 }, + { 0, 5, 4, 2, 9, 3, 8, 1 }, + { 1, 5, 4, 2, 8, 3, 0 }, + { 2, 9, 8, 3, 5, 4, 0, 1 }, + { 3, 5, 4, 2, 9, 8, 0, 1 }, + { 1, 2, 0, 9, 8, 3, 5, 4 }, + { 1, 8, 5, 2, 0, 4, 3 }, + { 0, 5, 4, 2, 8, 3, 9, 1 }, + { 1, 2, 0, 9, 8, 3, 5, 4 }, + { 0, 3, 9, 8, 5, 4, 2, 1 }, + { 0, 4, 3, 8, 5, 2, 1 }, + { 1, 5, 4, 2, 0, 9, 3 }, + { 1, 9, 5, 2, 0, 4, 3 }, + { 0, 5, 3, 9, 4, 2, 1 }, + { 0, 4, 5, 3, 2, 1 }, + } }; typedef struct BlockXY { @@ -306,21 +306,16 @@ static av_cold int mobiclip_init(AVCodecContext *avctx) bits0, sizeof(*bits0), syms1, sizeof(*syms1), sizeof(*syms1), 0, 0, 1 << MOBI_RL_VLC_BITS); - for (int j = 0; j < 16; j++) { + for (int i = 0; i < 2; i++) { static VLC_TYPE vlc_buf[2 * 16 << MOBI_MV_VLC_BITS][2]; - mv_vlc[0][j].table = &vlc_buf[2 * j << MOBI_MV_VLC_BITS]; - mv_vlc[0][j].table_allocated = 1 << MOBI_MV_VLC_BITS; - ff_init_vlc_from_lengths(&mv_vlc[0][j], MOBI_MV_VLC_BITS, mv_len[j], - mv_bits_mods[j], sizeof(*mv_bits_mods[j]), - mv_syms_mods[j], sizeof(*mv_syms_mods[j]), - sizeof(*mv_syms_mods[j]), 0, - INIT_VLC_USE_NEW_STATIC, NULL); - mv_vlc[1][j].table = &vlc_buf[(2 * j + 1) << MOBI_MV_VLC_BITS]; - mv_vlc[1][j].table_allocated = 1 << MOBI_MV_VLC_BITS; - ff_init_vlc_from_lengths(&mv_vlc[1][j], MOBI_MV_VLC_BITS, mv_len[j], - mv_bits[j], sizeof(*mv_bits[j]), - mv_syms[j], sizeof(*mv_syms[j]), sizeof(*mv_syms[j]), - 0, INIT_VLC_USE_NEW_STATIC, NULL); + for (int j = 0; j < 16; j++) { + mv_vlc[i][j].table = &vlc_buf[(16 * i + j) << MOBI_MV_VLC_BITS]; + mv_vlc[i][j].table_allocated = 1 << MOBI_MV_VLC_BITS; + ff_init_vlc_from_lengths(&mv_vlc[i][j], MOBI_MV_VLC_BITS, mv_len[j], + mv_bits[i][j], sizeof(*mv_bits[i][j]), + mv_syms[i][j], sizeof(*mv_syms[i][j]), sizeof(*mv_syms[i][j]), + 0, INIT_VLC_USE_NEW_STATIC, NULL); + } } return 0;