From patchwork Sun Oct 23 19:35:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38922 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp1859858pzb; Sun, 23 Oct 2022 12:36:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ekcqlctz3ppSVjMgQgwW19ixBs360h/gPG9JTh2ZL2+4+tIWxpRpT7OuxaG3h2WzKZtb9 X-Received: by 2002:aa7:c981:0:b0:461:522c:ce0d with SMTP id c1-20020aa7c981000000b00461522cce0dmr11796910edt.169.1666553802786; Sun, 23 Oct 2022 12:36:42 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u8-20020a056402064800b00458cdba7a90si21926494edx.471.2022.10.23.12.36.42; Sun, 23 Oct 2022 12:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=nLhuPVPt; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B27C68BCE7; Sun, 23 Oct 2022 22:36:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2056.outbound.protection.outlook.com [40.92.50.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D02E068BCBB for ; Sun, 23 Oct 2022 22:36:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OTq5s/JOINfN6AmpwBI16Vt1FGNjHOoFUs/RN/vWzokqwZ/SLSfVpVyp5sr7gsWkEvpRkhRuwCj0dVrbMdOZY5YAb3aEYWKHy0BypJccMlpgR1AFVChfS5d793LpY7+A98wNTSEcGII37pNAffr+YmVCeYkoRpqcLNIcCDwTKlbKq53cMA/KyzsQyyt3j/6bh14Af7IOgyr09xKZkX9Ey3KdkEhcErZzikG8tHa492o2YZ3v9UDa/u9YuGKyXiE0Q+KrRIgBeWlC6EUlK8OSLjkKXgfgYWkCMoaQsBjg8fKSoM9Vq2Bf5GuOZGWCWEpYi2K5xh3I3sl6mdc+wj16TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SUbTclk6zDig59Klv6qBkX57JODK3gc1ZqxvwNQ9LsM=; b=ZjRBjLPNCoOQn90ivkCKQSP+2ROqwGH5pucorerv77kjLkqEVNg6//gz4apDHMK3hxI5voC9WgkiyEUzwRGut3SRG/4+pTQ9h1FLd+Z0ESirwVA1mpWg1wvEBGgxPxDSghEhOjl4nyDMHS+bZFz9lLBP9mBu/EXZSwXEYHtFfg1RNuVzcl55fgs+gKgctCWPkHDwU0rEr6KD+/3knn5yNGsHSBVKU/1EzHZmumNJYignFSwylUfNiGAE7wyjptTyNl7wQtaLBhXa9ErIHe7j2BYvGvueqfQDeehFGnSSa4gW9TPI/gbM/WJDOtK5wz8jlIsqDt4WGvABoBt2fubBcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SUbTclk6zDig59Klv6qBkX57JODK3gc1ZqxvwNQ9LsM=; b=nLhuPVPtckli9kLEY0//KKwYDXhm1aFfpdXUAJ9aCsahDlMSpnS62htmKTxXZ5obSRmT4ptFMJmqNDeJv76u1xdVkMxOoSVha65C3IxBZLq1huShLXArBfAHh5wbXT1Xh7S7L4Ne2Qx1b4NJixQ3QTTe31tTdK7FAm2/Psmd25oacncdFq7LN8gwNgD9m/5CJC+2sQmWchBEysSgIKvRQ9U/YX1BEM0uWx9JxCRwrk85Shr4qd0MFPOckiFz/AI94AVlb6EKYLerdtgHL8pYcurqa28vGi8A/hBBrqhk4thjDflzgdEcYF6UBJ2BIg+kHO2tXWrawAUsCgNR1C6w0w== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by GV2P250MB0825.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Sun, 23 Oct 2022 19:36:13 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe%7]) with mapi id 15.20.5709.015; Sun, 23 Oct 2022 19:36:13 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Oct 2022 21:35:57 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [u06z16Xb8VWVRs79mQBFQuzvHcth52LGkt8aWkUBQqE=] X-ClientProxiedBy: FR3P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::13) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221023193610.674990-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|GV2P250MB0825:EE_ X-MS-Office365-Filtering-Correlation-Id: 33473d9f-81a8-4764-2b7c-08dab52dd84a X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmqH3kRfXJefTqIxzT/YbMNW0TXLbx0WVYMq6R8v+LTaurvbsiZHUy2/+2hWvkPHzPDpwG0b02qHBeqMk7AU3Xq+c/7met9pKBjwaUObeidLKNpfqDtQBqcFbPwIF/c7sOVuo2WvbaVM3iMkQehh3vXW74fyRbmuyhOxSuhpkbBPXq2l0vxbzmFGHZ+93wPYel3jydl7LWT3rYW66pwfXVIZZeYzyngw0Y3uGjWJoLZFBP1E9qQUEn63KiVnvCwbmtoXL3qIEec3JmrqjVdfGlt98UMfWrkKlFAeCYKLcuyWg4xCLBAdx+Rcl4Yodza8UHRdcwb4EBLGJX0OVey2Fu/VKH4fPV9RuTF+w52TfGFxa/42atOmUzrM99P47dMUROwQR5otnLXbtGJNH/ae+kqB4TL7DG+0SepFAlmiml0wQ4kwTOGAelRvWWQ8J2NyUrv/h31IcWgFiUIXkUEzdhB0eZCxXnFquuKTxvkb4To4YMRKat39IkCMEKd2TFOMCJ9dGiiHM7x2NSOOxmyACYJftAgcCjvidkW1JSWwQXYTHYkQB9ud39BBS71vbgbxO3rVjafbCYkxaDuPtow7x6UaTCiiiDIXe2pjjdLqY7AbGLp285Sn08DDZJPrVWD02kKwfdU696h+KSWbwzJQvFjYdAe9AsqXbHkq6taYafSOfRs0+0m9G4m1PhFvZpBi5VZchor3kJhvnXrtbGHfRfkDGzOJ94Kcc6IV/P1y2+UkgLP68lvn1HZRrhn3BgOgViE= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-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f-81a8-4764-2b7c-08dab52dd84a X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2022 19:36:13.5115 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2P250MB0825 Subject: [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: KSazjT5i/CKF Signed-off-by: Andreas Rheinhardt --- libavcodec/eamad.c | 3 +-- libavcodec/mdec.c | 3 +-- libavcodec/mpeg12.c | 19 +++++++++++-------- libavcodec/mpeg12dec.c | 28 ++++++++++++---------------- libavcodec/mpeg12vlc.h | 14 +++++++------- libavcodec/speedhqdec.c | 6 ++++-- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 2a5aac912d..20f347f0ab 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -134,7 +134,6 @@ static inline void idct_put(MadContext *t, AVFrame *frame, int16_t *block, static inline int decode_block_intra(MadContext *s, int16_t * block) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; const uint8_t *scantable = s->scantable.permutated; int16_t *quant_matrix = s->quant_matrix; @@ -148,7 +147,7 @@ static inline int decode_block_intra(MadContext *s, int16_t * block) /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index f27cf84122..7116b73b8e 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -63,7 +63,6 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) { int level, diff, i, j, run; int component; - RLTable *rl = &ff_rl_mpeg1; uint8_t * const scantable = a->scantable.permutated; const uint16_t *quant_matrix = a->quant_matrix; const int qscale = a->qscale; @@ -84,7 +83,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &a->gb); - GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &a->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index df6aba9d74..351ebf420f 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -63,7 +63,8 @@ static const uint8_t table_mb_btype[11][2] = { { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT }; -av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) +av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[], + unsigned static_size, int flags) { int i; VLCElem table[680] = { 0 }; @@ -94,9 +95,9 @@ av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags) level = rl->table_level[code]; } } - rl->rl_vlc[0][i].len = len; - rl->rl_vlc[0][i].level = level; - rl->rl_vlc[0][i].run = run; + rl_vlc[i].len = len; + rl_vlc[i].level = level; + rl_vlc[i].run = run; } } @@ -122,6 +123,9 @@ VLC ff_mb_ptype_vlc; VLC ff_mb_btype_vlc; VLC ff_mb_pat_vlc; +RL_VLC_ELEM ff_mpeg1_rl_vlc[680]; +RL_VLC_ELEM ff_mpeg2_rl_vlc[674]; + static av_cold void mpeg12_init_vlcs(void) { INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12, @@ -147,8 +151,8 @@ static av_cold void mpeg12_init_vlcs(void) &table_mb_btype[0][1], 2, 1, &table_mb_btype[0][0], 2, 1, 64); - INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0); - INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0); + INIT_2D_VLC_RL(ff_rl_mpeg1, ff_mpeg1_rl_vlc, 0); + INIT_2D_VLC_RL(ff_rl_mpeg2, ff_mpeg2_rl_vlc, 0); } av_cold void ff_mpeg12_init_vlcs(void) @@ -231,7 +235,6 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb, int16_t *block, int index, int qscale) { int dc, diff, i = 0, component; - RLTable *rl = &ff_rl_mpeg1; /* DC coefficient */ component = index <= 3 ? 0 : index - 4 + 1; @@ -256,7 +259,7 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb, while (1) { int level, run, j; - GET_RL_VLC(level, run, re, gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index c942be158e..914516bbd9 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -152,7 +152,6 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix = s->inter_matrix; const int qscale = s->qscale; @@ -175,7 +174,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s, } /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -241,7 +240,6 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const int qscale = s->qscale; @@ -264,7 +262,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -326,7 +324,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -358,7 +355,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { @@ -416,7 +413,6 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, int16_t *block, int n) { int level, i, j, run; - RLTable *rl = &ff_rl_mpeg1; uint8_t *const scantable = s->intra_scantable.permutated; const int qscale = s->qscale; OPEN_READER(re, &s->gb); @@ -437,7 +433,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, /* now quantify & encode AC coefficients */ for (;;) { - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0); + GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0); if (level != 0) { i += run; @@ -489,7 +485,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, { int level, dc, diff, i, j, run; int component; - RLTable *rl; + const RL_VLC_ELEM *rl_vlc; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -512,16 +508,16 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, mismatch = block[0] ^ 1; i = 0; if (s->intra_vlc_format) - rl = &ff_rl_mpeg2; + rl_vlc = ff_mpeg2_rl_vlc; else - rl = &ff_rl_mpeg1; + rl_vlc = ff_mpeg1_rl_vlc; { OPEN_READER(re, &s->gb); /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { @@ -575,7 +571,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, { int level, dc, diff, i, j, run; int component; - RLTable *rl; + const RL_VLC_ELEM *rl_vlc; uint8_t *const scantable = s->intra_scantable.permutated; const uint16_t *quant_matrix; const int qscale = s->qscale; @@ -595,16 +591,16 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, block[0] = dc * (1 << (3 - s->intra_dc_precision)); i = 0; if (s->intra_vlc_format) - rl = &ff_rl_mpeg2; + rl_vlc = ff_mpeg2_rl_vlc; else - rl = &ff_rl_mpeg1; + rl_vlc = ff_mpeg1_rl_vlc; { OPEN_READER(re, &s->gb); /* now quantify & encode AC coefficients */ for (;;) { UPDATE_CACHE(re, &s->gb); - GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], + GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level >= 64 || i > 63) { diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h index 4fb19371f0..d0083f1124 100644 --- a/libavcodec/mpeg12vlc.h +++ b/libavcodec/mpeg12vlc.h @@ -50,17 +50,17 @@ extern VLC ff_mv_vlc; void ff_mpeg12_init_vlcs(void); -#define INIT_2D_VLC_RL(rl, static_size, flags)\ -{\ - static RL_VLC_ELEM rl_vlc_table[static_size];\ - rl.rl_vlc[0] = rl_vlc_table;\ - ff_init_2d_vlc_rl(&rl, static_size, flags);\ -} +#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\ + ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags) extern RLTable ff_rl_mpeg1; extern RLTable ff_rl_mpeg2; -void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags); +extern RL_VLC_ELEM ff_mpeg1_rl_vlc[]; +extern RL_VLC_ELEM ff_mpeg2_rl_vlc[]; + +void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[], + unsigned static_size, int flags); void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len); diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c index acca437bd5..7cb5ff03cc 100644 --- a/libavcodec/speedhqdec.c +++ b/libavcodec/speedhqdec.c @@ -77,6 +77,8 @@ static VLC dc_chroma_vlc_le; static VLC dc_alpha_run_vlc_le; static VLC dc_alpha_level_vlc_le; +static RL_VLC_ELEM speedhq_rl_vlc[674]; + static inline int decode_dc_le(GetBitContext *gb, int component) { int code, diff; @@ -154,7 +156,7 @@ static inline int decode_dct_block(const SHQContext *s, GetBitContext *gb, int l for ( ;; ) { int level, run; UPDATE_CACHE_LE(re, gb); - GET_RL_VLC(level, run, re, gb, ff_rl_speedhq.rl_vlc[0], + GET_RL_VLC(level, run, re, gb, speedhq_rl_vlc, TEX_VLC_BITS, 2, 0); if (level == 127) { break; @@ -564,7 +566,7 @@ static av_cold void speedhq_static_init(void) ff_mpeg12_vlc_dc_chroma_code, 2, 2, INIT_VLC_OUTPUT_LE, 514); - INIT_2D_VLC_RL(ff_rl_speedhq, 674, INIT_VLC_LE); + INIT_2D_VLC_RL(ff_rl_speedhq, speedhq_rl_vlc, INIT_VLC_LE); compute_alpha_vlcs(); }