From patchwork Fri Nov 20 07:20:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23766 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 5F92E44AFE3 for ; Fri, 20 Nov 2020 09:26:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2DCE068BC2B; Fri, 20 Nov 2020 09:26:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B1E1688179 for ; Fri, 20 Nov 2020 09:25:47 +0200 (EET) Received: by mail-ed1-f66.google.com with SMTP id d18so8471343edt.7 for ; Thu, 19 Nov 2020 23:25:47 -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=DF+doVDKWd1MdcWarRBke1HDah0mKctBxq4bfq+rOI8=; b=TPq+yaJ/2tyiv9y5hNv77DHQZMLduG747y4IiMqRF/kLiSPLr8q07JF3qu5NIr1Qx5 AtY8HyI6HOEAl4BHQRFwgwVW3MGqLdWCN6Ux8BLw6bdC8HuuDdJ+v2lEqdn7lu5BrMSl ZdfE39E2u28yFk7rZ9zSGt6N24NFApGbTyGR5/2h/Goi/sEgFPApSDYwpxNAW/w4Isea wm2yhHeqGh9GftEJ5bkE2RpIaGWtA5nia8nuev3EkA4ey+k0D6MG4ArYhls9Q9vPabd2 cx8vbYKcKOMC62S7quefQsc1U4iMv892UaYr9mWgXwgr0K433tcpk1Cg6THZSRRWMS4+ AVEQ== 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=DF+doVDKWd1MdcWarRBke1HDah0mKctBxq4bfq+rOI8=; b=pyFdxtJekCnF81BKlXnuRIvmbbc02IK6KMBzAD5bkDY4MlwnIf3xSGjyVblRX/SEJv hUD6JRlCBx+nR7wUSPQcAsz1xi/dBz3jOL8v7EwzqXpabjGhot45UsD1Bfrds7PE29i2 Z61R18wbqN1ObbMtWm0rplIcPyI9blE063EX9OmSd4nn7Ah0M5qnc0QA22VqC0jDzUgv mqFTNwoKUCS+coUyjBID6AznOMt3Wu4gi2zobarQvceZfnu4Ao16wx4vM1ZDqiCBwljl 8vOYrBPPbcKGwVm+al4A3ydxARwQFxy9gBsUTHHuSNrKgeXhIi8piblmvWcH5AsndqJr nbow== X-Gm-Message-State: AOAM533eFIaGPygxfNnSyH07DUW3SvU9s8OEvlBy37z7VDhUHzxM+Dw1 g0lkei6Kl/l8Jp9oB5tVXiI8O3XIXMOUGA== X-Google-Smtp-Source: ABdhPJwsdQBdT+FzXcQUf+7s/lXrw6m2Vxp6z/Z6/I4NRZpPX2n59k4em/35PE1bryTSA7qMsdAiQw== X-Received: by 2002:a05:6402:1350:: with SMTP id y16mr1634143edw.360.1605857146419; Thu, 19 Nov 2020 23:25:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 23:25:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Nov 2020 08:20:09 +0100 Message-Id: <20201120072116.818090-97-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 096/162] avcodec/vc1: Already offset subblock VLC tables during init 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" Offseting by +1 is possible without adding dummy elements to the beginning of the codes and lengths tables by switching to ff_init_vlc_from_lengths() as this allows one to set the symbols arbitrarily without incurring any penalty. Signed-off-by: Andreas Rheinhardt --- All the VC1 patches have improved documentation on what the symbols actually contain. libavcodec/vc1.c | 7 ++++--- libavcodec/vc1_block.c | 2 +- libavcodec/vc1data.c | 27 +++++++++++++++++---------- libavcodec/vc1data.h | 6 +++--- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 9df778bcab..d973fd6c57 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -1616,9 +1616,10 @@ av_cold int ff_vc1_init_common(VC1Context *v) ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]]; ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2]; - init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, - ff_vc1_subblkpat_bits[i], 1, 1, - ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + ff_init_vlc_from_lengths(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, + &ff_vc1_subblkpat_tabs[i][0][1], 2, + &ff_vc1_subblkpat_tabs[i][0][0], 2, 1, + 0, INIT_VLC_USE_NEW_STATIC, NULL); } for (i = 0; i < 4; i++) { ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]]; diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 5c33170933..b8987b0015 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -1143,7 +1143,7 @@ static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n, ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)]; } if (ttblk == TT_4X4) { - subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1); + subblkpat = ~get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1); } if ((ttblk != TT_8X8 && ttblk != TT_4X4) && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block)) diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c index 19f1cad45f..e92d9b7310 100644 --- a/libavcodec/vc1data.c +++ b/libavcodec/vc1data.c @@ -921,16 +921,23 @@ const uint8_t ff_vc1_ttblk_bits[3][8] = { { 2, 3, 3, 3, 3, 3, 4, 4 } }; -/* SUBBLKPAT tables, p93-94, reordered */ -const uint8_t ff_vc1_subblkpat_codes[3][15] = { - { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1 }, - { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1 }, - { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15 } -}; -const uint8_t ff_vc1_subblkpat_bits[3][15] = { - { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1}, - { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2}, - { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4} +/* SUBBLKPAT tables, p93-94, reordered and offset by 1 */ +const uint8_t ff_vc1_subblkpat_tabs[3][15][2] = { + { + { 0x0B, 4 }, { 0x0D, 4 }, { 0x07, 4 }, { 0x0C, 5 }, { 0x03, 5 }, + { 0x0A, 5 }, { 0x05, 5 }, { 0x08, 5 }, { 0x04, 5 }, { 0x02, 5 }, + { 0x06, 6 }, { 0x09, 6 }, { 0x01, 5 }, { 0x0E, 5 }, { 0x0F, 1 }, + }, + { + { 0x02, 3 }, { 0x06, 5 }, { 0x09, 5 }, { 0x0C, 4 }, { 0x0F, 2 }, + { 0x03, 4 }, { 0x0A, 4 }, { 0x05, 4 }, { 0x0E, 5 }, { 0x07, 5 }, + { 0x0D, 5 }, { 0x0B, 5 }, { 0x08, 4 }, { 0x01, 4 }, { 0x04, 4 }, + }, + { + { 0x06, 5 }, { 0x09, 5 }, { 0x0C, 4 }, { 0x03, 4 }, { 0x0A, 4 }, + { 0x04, 3 }, { 0x08, 3 }, { 0x05, 4 }, { 0x0E, 5 }, { 0x0D, 5 }, + { 0x01, 3 }, { 0x02, 3 }, { 0x07, 5 }, { 0x0B, 5 }, { 0x0F, 4 }, + } }; /* MV differential tables, p265 */ diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h index 90dd8baf61..02603ca9bc 100644 --- a/libavcodec/vc1data.h +++ b/libavcodec/vc1data.h @@ -152,9 +152,9 @@ extern const uint8_t ff_vc1_ttmb_bits[3][16]; extern const uint8_t ff_vc1_ttblk_codes[3][8]; extern const uint8_t ff_vc1_ttblk_bits[3][8]; -/* SUBBLKPAT tables, p93-94, reordered */ -extern const uint8_t ff_vc1_subblkpat_codes[3][15]; -extern const uint8_t ff_vc1_subblkpat_bits[3][15]; +/* SUBBLKPAT tables (tables #65-#67). + * The symbols contain the Subblock Pattern. */ +extern const uint8_t ff_vc1_subblkpat_tabs[3][15][2]; /* MV differential tables, p265 */ extern const uint16_t ff_vc1_mv_diff_codes[4][73];