From patchwork Sat Oct 24 11:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23191 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 909EC44BC1A for ; Sat, 24 Oct 2020 14:05:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 512BC68A315; Sat, 24 Oct 2020 14:05:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3E4468A0C3 for ; Sat, 24 Oct 2020 14:05:08 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id d3so5213138wma.4 for ; Sat, 24 Oct 2020 04:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K1mPxQwzwWJaTH1Rq2g6RauGh8vbCFGzOBA9CKv5/Rc=; b=BFdTerYBONmoy7DG8lH4UT0lgg6U8BKH6YMcUjhkLDZzzWHXRfx//FYTMIs3wejcjS W5XoKpCfTY0e5OWOGlHODCvx35/aCip+utUlpLRP/Uc1JdpSmBw0Q9bjYB6WrbbFS8ll 8E3kqv+aXt/MG+lEgmB7OIFdmOpJ31j4+GCMF6zjxuQFShE5XjDLVppV4dOjYgsVHb2M DK1SenusiNdvY4v6fqum/lnSvfFuEhnAQaPlMz6879jDxSAV4uoyED8TdkVRUedVmkQI TBx3YVDhscUuaFHchQ54QqHBL0aMxzhxi68G8uO6KFDlQFYnFOCsPulO2PEIQWlaiyFX HElQ== 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:mime-version :content-transfer-encoding; bh=K1mPxQwzwWJaTH1Rq2g6RauGh8vbCFGzOBA9CKv5/Rc=; b=RjhumWmfiLP0++cK4UNkobhnOdL70Y5ZAPH9+W03cDgCaT2pfwkpJ6tHDENsDgbW8d qr4Z358gH/JCJ5l2ccAPz6Nqy/JxcNrQjBsQq5YElX9bx0VUxBuFg+Ym5R/KSRG+6Q1i Gv37Q5dNYfQxY8vxfUjFGRie65srUdZxYcQdw91tV7ZYZdfdqaUXXt5+r8ohviOY9Kzq 2gsSTUwC5f993IBuePrgSPZYk2Jr9xRKaUkkwCulqTsfUMjFAlzeMKmyIoxfNQL6+zFL gkSm9BQLTIjS+BPZXeoFPgE9mHJoC8F3o9B+ilTki8kSyJxULijXtNjzFm3wDD4gchSw A7bg== X-Gm-Message-State: AOAM531F440OxVUuOd4tQaTK78wpFd7plHAaO+HuSA8f3klWFaEG90q3 iY7YeJkZDuQH+1WqUUIiY2xiTgiCX2w= X-Google-Smtp-Source: ABdhPJxGoSsudZ3mmyORwtmnjGws9VPHeeHqICNv97nEjw8xj9U0XRof6CptLeaVZvLPSQN7a01D9Q== X-Received: by 2002:a1c:4306:: with SMTP id q6mr6923541wma.189.1603537507609; Sat, 24 Oct 2020 04:05:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id m1sm8476890wme.48.2020.10.24.04.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Oct 2020 04:05:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Oct 2020 13:04:56 +0200 Message-Id: <20201024110500.5424-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/mobiclip: Reduce size of VLCs, inline constants 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" The longest motion vector VLC for mobiclip is six bits long, so using eight bits for the VLC table is wasteful. Furthermore, the length can be inlined. Signed-off-by: Andreas Rheinhardt --- libavcodec/mobiclip.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index 48467614ab..8d37243d87 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -31,6 +31,8 @@ #include "golomb.h" #include "internal.h" +#define MOBI_MV_VLC_BITS 6 + static const uint8_t zigzag4x4_tab[] = { 0x00, 0x04, 0x01, 0x02, 0x05, 0x08, 0x0C, 0x09, 0x06, 0x03, 0x07, 0x0A, @@ -364,14 +366,14 @@ static av_cold int mobiclip_init(AVCodecContext *avctx) } for (int j = 0; j < 16; j++) { - ret = ff_init_vlc_sparse(&s->mv_vlc[0][j], 8, mv_len[j], + ret = ff_init_vlc_sparse(&s->mv_vlc[0][j], MOBI_MV_VLC_BITS, mv_len[j], mv_bits_mods[j], sizeof(*mv_bits_mods[j]), sizeof(*mv_bits_mods[j]), mv_codes_mods[j], sizeof(*mv_codes_mods[j]), sizeof(*mv_codes_mods[j]), mv_syms_mods[j], sizeof(*mv_syms_mods[j]), sizeof(*mv_syms_mods[j]), 0); if (ret < 0) return ret; - ret = ff_init_vlc_sparse(&s->mv_vlc[1][j], 8, mv_len[j], + ret = ff_init_vlc_sparse(&s->mv_vlc[1][j], MOBI_MV_VLC_BITS, mv_len[j], mv_bits[j], sizeof(*mv_bits[j]), sizeof(*mv_bits[j]), mv_codes[j], sizeof(*mv_codes[j]), sizeof(*mv_codes[j]), mv_syms[j], sizeof(*mv_syms[j]), sizeof(*mv_syms[j]), 0); @@ -1259,7 +1261,7 @@ static int predict_motion(AVCodecContext *avctx, int ret, idx2; idx2 = get_vlc2(gb, s->mv_vlc[s->moflex][tidx].table, - s->mv_vlc[s->moflex][tidx].bits, 1); + MOBI_MV_VLC_BITS, 1); if (idx2 < 0) return AVERROR_INVALIDDATA; @@ -1335,7 +1337,7 @@ static int mobiclip_decode(AVCodecContext *avctx, void *data, motion[x / 16 + 2].y = 0; idx = get_vlc2(gb, s->mv_vlc[s->moflex][0].table, - s->mv_vlc[s->moflex][0].bits, 1); + MOBI_MV_VLC_BITS, 1); if (idx < 0) return AVERROR_INVALIDDATA;