From patchwork Tue Nov 10 10:47:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23530 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 295BA44ACE4 for ; Tue, 10 Nov 2020 13:01:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E420E68BEE0; Tue, 10 Nov 2020 12:50:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A515368BE9B for ; Tue, 10 Nov 2020 12:50:07 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id p22so2522946wmg.3 for ; Tue, 10 Nov 2020 02:50:07 -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=tq1sJURKdpieT7qInyva0FMU7AccjQnT6NwSAROpUg8=; b=L8gu9YRMrin38gW6GYLfPG4wR/gR4cVRrXzXyTc6DkwdkymaR6p+QA7U2OW6TCZKju TiJzCfcfH4uUWvvYGeZVRmV6b1l13hOsdfzvJm8OZwzwlPXSOTWjcqbMGevp+jDG7wbG doe4wB4sJSOGUbv8dKMrw0OhJw9i5OZzg85bpOo585vwQ7gDFXS6BVS3I18h/bYwMVc/ jIPbn5JnnFwpPOmu/CpLeNJvqN7aT89iJuJL9xYhmZrBV8m+I7tIOsVIyDUm4f7f+k73 IZBj887RJd+yYJ1Rs4ea0ScfbvrHWj1dShrknmTXLJreIVkyJmJAXLPjf3V5W/vjA9DJ qAtQ== 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=tq1sJURKdpieT7qInyva0FMU7AccjQnT6NwSAROpUg8=; b=D3RkFGJvk0CDlB9vXjO4ZuXM7VSbyDv81YJhaapcAEdOyg2R0WI07Lm4fAlgBdEiOc 9uYARt5T99BK7luLE8GBkBvSyAvf4uPoIL5+Twi+PIiAUnYrZifTaoKx0YK8oJ6U8WVA xlxPZ++JitZtE1IgNkVM69VnZeKpZq3Wb4q8+zyJnmdI3LR9hqL2qNeVTEqvp6I71sYR 6htF8BVzejVgpDvReAAVgIFbWwNA8kwG+dc8ZJDLtVwBn7VQhqQkepNxztB0KIaE/z1H QNrZ0QpvqTL1E+ws+ooRmpqoMIiVbaNzMY+kdkl/SFMMJxlYj3NEmfDjVkkZ+/ZO7dFj 4TGw== X-Gm-Message-State: AOAM533nlWlDztjtBiymwU1SCnhHSjBckO3Wr2eOvfmD/W61NZLq0L9I B4KG7qv4g1+xRHixNcDdtjeELWBIQKM= X-Google-Smtp-Source: ABdhPJyvMH+jR+n3QqKDc9sdlUnpcPem5DIijRnYik0rsa5HMvZ7F7SBk/fd4xKJc/8ILX36Q3b51g== X-Received: by 2002:a1c:9e93:: with SMTP id h141mr3915683wme.153.1605005406822; Tue, 10 Nov 2020 02:50:06 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:50:06 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:44 +0100 Message-Id: <20201110104851.321029-48-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 047/114] 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 | 106 ++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index cb17832898..e4a2594954 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,20 +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); - 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); + 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); + } } return 0;