From patchwork Sat Jan 6 16:48:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jacobs X-Patchwork-Id: 7161 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp726176jaa; Sat, 6 Jan 2018 08:48:45 -0800 (PST) X-Google-Smtp-Source: ACJfBosFIySmGB6bJSlAuxriYJHN+KwjNFnn5/IFQ7jukWD49eF+4mD60yGRSKG8QDFClMfYMr8j X-Received: by 10.223.161.151 with SMTP id u23mr6394645wru.28.1515257325028; Sat, 06 Jan 2018 08:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515257324; cv=none; d=google.com; s=arc-20160816; b=wKIiPYOYV5FyvHFX+p2HrCZXvF2nR0QRyt9TGm+W4CFj9sYfk7fH97WTrL1BSL1ZYD iyJWKYuGXEaBX2qny3WBJpWZw7hzBLbQ8THJrO+DRkCcFgjAdvRHEI2U0h6hyXhsjCip U0KJbyHcn/37J0XgEajxHA4DMdXjXJCzFmq53zh4a0qQrCvKxXAeKeyloyXMWXF3QSfl 1U6p3tn2GVuqz2I7GEkY+nou/uNNxePonhmedN4VB7nktLbq9PbMWYXl6+3ocFa/a4/N GQGSrL1uaQKygB9W2njLrDX6APUeYSFj5B5mwjagWeG6hLH7GnCdVaCQar7fZME2i1y9 8wUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=U9iyKmYvJyGVguuphJzkoSwuln8n0PkDk4jp5qxZgmw=; b=vlB4TXyHrLbEtVQxlWksFDRC5bIgZ0+V2rKJ+3zJUHhTXbM9l8Ju5VVmsXjZOSQg7G WaNdAHX7bUCWKdB4Z1YoX2Nx4O6/qoFPooTg9TpR4iycHgzpszGrFuhJeUKifQUBv0CB bqqEsKTFSAquYYqZxu7sYsVUSyBwmOAcprUgegAsoS/weOeOyzZd003AutKB16sVwIAw QajY3s10JTGUND3YuMamkGP/9Cn5JK6Ru58hTz2mo09tQlcsB2/WYOpD8HTCqjnSLMm/ F5wufrtPnRezF71aOX1C/UYKUpLQrDyXn3mvrwz3n9KHEzJ85jYz279my/tCYIxdCiZD fehw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d82si5308817wmd.237.2018.01.06.08.48.44; Sat, 06 Jan 2018 08:48:44 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B594F689DE1; Sat, 6 Jan 2018 18:48:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04DDA689DDD for ; Sat, 6 Jan 2018 18:48:37 +0200 (EET) Received: from marge.gnuage.org (unknown [IPv6:2a01:e35:2e26:9790::10]) by smtp6-g21.free.fr (Postfix) with ESMTPS id 1BF4D780331 for ; Sat, 6 Jan 2018 17:48:36 +0100 (CET) Received: from [2a01:e35:2e26:9790:bc8a:b994:5b68:84cc] (helo=xps) by marge.gnuage.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eXre7-0001rs-JE; Sat, 06 Jan 2018 17:48:35 +0100 Received: from aurel by xps with local (Exim 4.90) (envelope-from ) id 1eXre7-0006sI-FI; Sat, 06 Jan 2018 17:48:35 +0100 From: Aurelien Jacobs To: FFmpeg development discussions and patches Date: Sat, 6 Jan 2018 17:48:04 +0100 Message-Id: <20180106164808.26162-2-aurel@gnuage.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106164808.26162-1-aurel@gnuage.org> References: <20180106164808.26162-1-aurel@gnuage.org> X-SA-Exim-Connect-IP: 2a01:e35:2e26:9790:bc8a:b994:5b68:84cc X-SA-Exim-Mail-From: aurel@gnuage.org X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on marge.gnuage.org X-Spam-Level: X-Spam-Status: No, score=-0.2 required=3.0 tests=BAYES_00, FSL_HELO_NON_FQDN_1, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on marge.gnuage.org) Subject: [FFmpeg-devel] [PATCH 1/5] aptx: simplify by pre-calculating factor_max 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: Aurelien Jacobs MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/aptx.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c index a35d2861c1..7b9556ce42 100644 --- a/libavcodec/aptx.c +++ b/libavcodec/aptx.c @@ -188,7 +188,7 @@ typedef const struct { const int32_t *quantize_dither_factors; const int16_t *quantize_factor_select_offset; int tables_size; - int32_t quantized_bits; + int32_t factor_max; int32_t prediction_order; } ConstTables; @@ -198,25 +198,25 @@ static ConstTables tables[NB_SUBBANDS] = { quantize_dither_factors_LF, quantize_factor_select_offset_LF, FF_ARRAY_ELEMS(quantize_intervals_LF), - 7, 24 }, + 0x11FF, 24 }, [MLF] = { quantize_intervals_MLF, invert_quantize_dither_factors_MLF, quantize_dither_factors_MLF, quantize_factor_select_offset_MLF, FF_ARRAY_ELEMS(quantize_intervals_MLF), - 4, 12 }, + 0x14FF, 12 }, [MHF] = { quantize_intervals_MHF, invert_quantize_dither_factors_MHF, quantize_dither_factors_MHF, quantize_factor_select_offset_MHF, FF_ARRAY_ELEMS(quantize_intervals_MHF), - 2, 6 }, + 0x16FF, 6 }, [HF] = { quantize_intervals_HF, invert_quantize_dither_factors_HF, quantize_dither_factors_HF, quantize_factor_select_offset_HF, FF_ARRAY_ELEMS(quantize_intervals_HF), - 3, 12 }, + 0x15FF, 12 }, }; static const int16_t quantization_factors[32] = { @@ -530,16 +530,14 @@ static void aptx_invert_quantization(InvertQuantize *invert_quantize, qr = rshift64_clip24(((int64_t)qr<<32) + MUL64(dither, tables->invert_quantize_dither_factors[idx]), 32); invert_quantize->reconstructed_difference = MUL64(invert_quantize->quantization_factor, qr) >> 19; - shift = 24 - tables->quantized_bits; - /* update factor_select */ factor_select = 32620 * invert_quantize->factor_select; factor_select = rshift32(factor_select + (tables->quantize_factor_select_offset[idx] << 15), 15); - invert_quantize->factor_select = av_clip(factor_select, 0, (shift << 8) | 0xFF); + invert_quantize->factor_select = av_clip(factor_select, 0, tables->factor_max); /* update quantization factor */ idx = (invert_quantize->factor_select & 0xFF) >> 3; - shift -= invert_quantize->factor_select >> 8; + shift = (tables->factor_max - invert_quantize->factor_select) >> 8; invert_quantize->quantization_factor = (quantization_factors[idx] << 11) >> shift; }