From patchwork Tue Nov 10 10:47:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23509 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 EDE5E449CD8 for ; Tue, 10 Nov 2020 12:58:17 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B48D068BE9C; Tue, 10 Nov 2020 12:50:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E2A7968BE50 for ; Tue, 10 Nov 2020 12:49:59 +0200 (EET) Received: by mail-wm1-f51.google.com with SMTP id a3so1216055wmb.5 for ; Tue, 10 Nov 2020 02:49:59 -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=npZENk1RMGTVjSpoZWR7eL8Ac6z/cczH0epYZxQgH9E=; b=V9aT/F+kmqflupTv4ax5It8930TJBklWaLL3oWNyQx49ER5LjQsc9SI/VWSOjyhUis QHfrENHxRR2zkNPpD4bbOvnxEqElfVNlLGdpwqCa7ZaBSWWCkWbcaF+cJ5ZqwPf731D/ YGgE1kqynHy74y1tk+JymUAL4ReD1dMU++f93b00PPUH865mZAzOh+zGs/r4/iMMcyDV TszThqgSywQKMCYu9l1nheT4GFmSdm9zx6Ijem0qc98c9Is7y2r/ny3Axds5aTq7a7BD Oa1Lq3oK7QFHj83tudiSql8xkTm4LKNsqAGugzofEzEppyHE29lXHg9zw6XRWGTzdpwo 4XSw== 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=npZENk1RMGTVjSpoZWR7eL8Ac6z/cczH0epYZxQgH9E=; b=XuxTUej5SiCliwdUdPRYm/aUWh9XmolFUhgGWr2WVnBSmAcIx+pRl19o7Yy8oMb3fe bOcmHnCPII/w6Fhhvtq5DRSaw+jhOtqgaBsViZPYLsB1ibdGbbjsqWKo6BwLfd87WHW0 HzjjBdF8307wvWjceiVIRp201MQmAgs30GwjJMtoTQCDK4NBBn2v0LRimwT/y0zMNgp9 pG5q3llBVrrgnw6FjsiUnIE/c0WtlF3s5whWOQtu/i52DJQ5ajgod3XcPFJXHBU76sD+ 1HfXhEnEJPQCziFND7kJAQV9rJJdqWIrcloGWJxPjnAAIq2y6VDtv9NbyK7DLtXV5m3a e6xw== X-Gm-Message-State: AOAM533IopiaHPaZVGdFzHCOP3sY2gjLY9LNOU1RHzPaxdNBXHmWcO1D /UECjbHi8IB+Im3mw7b7JbYQCYJRr08= X-Google-Smtp-Source: ABdhPJwTh7pxNiHnJeZ2+XhC5cLkOAYgdVtV4aVJGJx7+IJyJJPJuHA0vy7JSVauaVdv9SxPxZZEJw== X-Received: by 2002:a05:600c:4147:: with SMTP id h7mr3855169wmm.146.1605005399026; Tue, 10 Nov 2020 02:49:59 -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.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:49:58 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:36 +0100 Message-Id: <20201110104851.321029-40-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 039/114] avcodec/mpc7: Apply offsets when creating 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/mpc7.c | 12 ++++++------ libavcodec/mpc7data.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 532ea113c2..3c1a8578dd 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -98,10 +98,10 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) &mpc7_scfi[0], 2, 1, 0, 0, 1 << MPC7_SCFI_BITS); INIT_VLC_STATIC_FROM_LENGTHS(&dscf_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, &mpc7_dscf[1], 2, - &mpc7_dscf[0], 2, 1, 0, 0, 1 << MPC7_DSCF_BITS); + &mpc7_dscf[0], 2, 1, -7, 0, 1 << MPC7_DSCF_BITS); INIT_VLC_STATIC_FROM_LENGTHS(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, &mpc7_hdr[1], 2, - &mpc7_hdr[0], 2, 1, 0, 0, 1 << MPC7_HDR_BITS); + &mpc7_hdr[0], 2, 1, -5, 0, 1 << MPC7_HDR_BITS); for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ for(j = 0; j < 2; j++){ quant_vlc[i][j].table = quant_table; @@ -110,7 +110,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx) ff_init_vlc_from_lengths(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], &raw_quant_table[1], 2, &raw_quant_table[0], 2, 1, - 0, INIT_VLC_USE_NEW_STATIC); + mpc7_quant_vlc_off[i], INIT_VLC_USE_NEW_STATIC); raw_quant_table += 2 * mpc7_quant_vlc_sizes[i]; } } @@ -151,7 +151,7 @@ static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int * case 3: case 4: case 5: case 6: case 7: i1 = get_bits1(gb); for(i = 0; i < SAMPLES_PER_BAND; i++) - *dst++ = get_vlc2(gb, quant_vlc[idx-1][i1].table, 9, 2) - mpc7_quant_vlc_off[idx-1]; + *dst++ = get_vlc2(gb, quant_vlc[idx-1][i1].table, 9, 2); break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: @@ -166,7 +166,7 @@ static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int * static int get_scale_idx(GetBitContext *gb, int ref) { - int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; + int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1); if (t == 8) return get_bits(gb, 6); return ref + t; @@ -222,7 +222,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data, for(i = 0; i <= c->maxbands; i++){ for(ch = 0; ch < 2; ch++){ int t = 4; - if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5; + if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1); if(t == 4) bands[i].res[ch] = get_bits(&gb, 4); else bands[i].res[ch] = bands[i-1].res[ch] + t; if (bands[i].res[ch] < -1 || bands[i].res[ch] > 17) { diff --git a/libavcodec/mpc7data.h b/libavcodec/mpc7data.h index b578cbdb27..ee77393fce 100644 --- a/libavcodec/mpc7data.h +++ b/libavcodec/mpc7data.h @@ -55,8 +55,8 @@ static const uint8_t mpc7_quant_vlc_sizes[MPC7_QUANT_VLC_TABLES] = { 27, 25, 7, 9, 15, 31, 63 }; -static const uint8_t mpc7_quant_vlc_off[MPC7_QUANT_VLC_TABLES] = { - 0, 0, 3, 4, 7, 15, 31 +static const int8_t mpc7_quant_vlc_off[MPC7_QUANT_VLC_TABLES] = { + 0, 0, -3, -4, -7, -15, -31 }; static const uint8_t mpc7_quant_vlcs[177 * 2 * 2] = {