From patchwork Thu Dec 10 11:16:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24511 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 5161644B4AD for ; Thu, 10 Dec 2020 13:42:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3DD0B68A17B; Thu, 10 Dec 2020 13:42:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8DCB6881E4 for ; Thu, 10 Dec 2020 13:42:11 +0200 (EET) Received: by mail-lf1-f68.google.com with SMTP id w13so7737471lfd.5 for ; Thu, 10 Dec 2020 03:42:11 -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=TMQdHLXTfi+St5Z+HFvAOdwWThpLOSRbyGEikJCbtiE=; b=Z8wCl3br7yC2t3byVPzkI8qC1812VAFAeOUMzxK3bpwzfOgf7+QeN87NLsLUN+8Aaz DYE3IzQ1e+wacMqe138g+sEn6f+4w/YadgcLZyD6kkJHakGDFYSJM42zFnJaPsh4zDbg O77einUoLjiqh96qnn/F46/tyFlFjFI2GH88rQrLRX/SCTZo8PG9OEcrY5qVcvLfDZv8 G5Zar0gvXrTsTa+qNev5vHVz1t7ofelESGgNQ+Vlr+BKF8Wh50KRx68JpUov2JXuN5qz UWerk/FGwalqFZe1fKYYX4MAar0iq+c0UYSoDZg1+AOAWUNYn77ehroc8fjUN9PY/IIk FULQ== 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=TMQdHLXTfi+St5Z+HFvAOdwWThpLOSRbyGEikJCbtiE=; b=GmdiaSNwF2mc3WkWlI2ZuAM1nZrwm9SOuopWiaAt2NN+JTpacq5Wc2FraOkWLWK9tv KEfKP0org88Qr8qG2Lr0/9a/fccXaM8UdOaak7jis9jDfvmhpz90MOPfjn3vPVO9W1lC LgRsrt/wGArj3dXeVkOXFy6rYIlxrLeu3rWMcD6ng2qpkn61tHd0YrZjtI0BgWW9AElD jbhoNVo9pIVKWftJBHhXlUmRc4Elf1vOzV4jOf55pHHDfqSbQ5+9j6Yh5EKyWGo3VDiH jOU6ElPQID4bdzgQC+UX20zHd7ZQefeiVSmhpbZ7U6Rc0ANO6pFX1fiCUJXqGy+6IARD BbdQ== X-Gm-Message-State: AOAM531jvZpyZL6uYefO24OsskcEoZQd638eMoAonq79siZMMWxekOpW 6SGKdWzyOEUf+lLo28hP0YOCpfKHFMwBuw== X-Google-Smtp-Source: ABdhPJyPwsmwscNdWfeuvw0MDq01QcoTPrXwDyUQj9zgs88rnHCX6Ft+Ac1LZN5btpr+y9LZBbeXYA== X-Received: by 2002:adf:ec0d:: with SMTP id x13mr7708621wrn.207.1607599138746; Thu, 10 Dec 2020 03:18:58 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id s133sm8942330wmf.38.2020.12.10.03.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:18:58 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:16:31 +0100 Message-Id: <20201210111657.2276739-14-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> References: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/39] avcodec/msmpeg4dec: Reuse identical MV VLC 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" msmpeg4dec and ituh263dec both create VLCs with identical parameters out of ff_mvtab. Given that ff_msmpeg4_decode_init() always (indirectly) calls ff_h263_decode_init_vlc(), the VLC initialized by the latter can be directly used by msmpeg4dec. Doing so saves a bit more than 2KB from the .bss segment as well as the code to initialize a VLC. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263.h | 2 ++ libavcodec/ituh263dec.c | 7 +++---- libavcodec/msmpeg4dec.c | 7 +------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libavcodec/h263.h b/libavcodec/h263.h index f891f72379..998f7d0d59 100644 --- a/libavcodec/h263.h +++ b/libavcodec/h263.h @@ -34,6 +34,7 @@ // reading vlc values. Changing these may improve speed and data cache needs // be aware though that decreasing them may need the number of stages that is // passed to get_vlc* to be increased. +#define H263_MV_VLC_BITS 9 #define INTRA_MCBPC_VLC_BITS 6 #define INTER_MCBPC_VLC_BITS 7 #define CBPY_VLC_BITS 6 @@ -44,6 +45,7 @@ extern VLC ff_h263_intra_MCBPC_vlc; extern VLC ff_h263_inter_MCBPC_vlc; extern VLC ff_h263_cbpy_vlc; +extern VLC ff_h263_mv_vlc; extern const enum AVPixelFormat ff_h263_hwaccel_pixfmt_list_420[]; diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 7ddb33b795..eec86c81b1 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -51,7 +51,6 @@ // reading vlc values. Changing these may improve speed and data cache needs // be aware though that decreasing them may need the number of stages that is // passed to get_vlc* to be increased. -#define MV_VLC_BITS 9 #define H263_MBTYPE_B_VLC_BITS 6 #define CBPC_B_VLC_BITS 3 @@ -98,7 +97,7 @@ void ff_h263_show_pict_info(MpegEncContext *s){ VLC ff_h263_intra_MCBPC_vlc; VLC ff_h263_inter_MCBPC_vlc; VLC ff_h263_cbpy_vlc; -static VLC mv_vlc; +VLC ff_h263_mv_vlc; static VLC h263_mbtype_b_vlc; static VLC cbpc_b_vlc; @@ -119,7 +118,7 @@ av_cold void ff_h263_decode_init_vlc(void) INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16, &ff_h263_cbpy_tab[0][1], 2, 1, &ff_h263_cbpy_tab[0][0], 2, 1, 64); - INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 33, + INIT_VLC_STATIC(&ff_h263_mv_vlc, H263_MV_VLC_BITS, 33, &ff_mvtab[0][1], 2, 1, &ff_mvtab[0][0], 2, 1, 538); ff_rl_init(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]); @@ -270,7 +269,7 @@ int ff_h263_resync(MpegEncContext *s){ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code) { int code, val, sign, shift; - code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2); + code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); if (code == 0) return pred; diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index 06e9707b65..d059e8eecc 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -38,7 +38,6 @@ #define V2_INTRA_CBPC_VLC_BITS 3 #define V2_MB_TYPE_VLC_BITS 7 #define MV_VLC_BITS 9 -#define V2_MV_VLC_BITS 9 #define TEX_VLC_BITS 9 #define DEFAULT_INTER_INDEX 3 @@ -66,7 +65,6 @@ static VLC v2_dc_lum_vlc; static VLC v2_dc_chroma_vlc; static VLC v2_intra_cbpc_vlc; static VLC v2_mb_type_vlc; -static VLC v2_mv_vlc; VLC ff_inter_intra_vlc; /* This is identical to H.263 except that its range is multiplied by 2. */ @@ -74,7 +72,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) { int code, val, sign, shift; - code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2); + code = get_vlc2(&s->gb, ff_h263_mv_vlc.table, H263_MV_VLC_BITS, 2); ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred); if (code < 0) return 0xffff; @@ -362,9 +360,6 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8, &ff_v2_mb_type[0][1], 2, 1, &ff_v2_mb_type[0][0], 2, 1, 128); - INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33, - &ff_mvtab[0][1], 2, 1, - &ff_mvtab[0][0], 2, 1, 538); INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128, &ff_wmv2_inter_table[0][0][1], 8, 4,