From patchwork Fri Feb 19 07:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 25792 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 2A05B447D4B for ; Fri, 19 Feb 2021 09:51:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 198FD68A486; Fri, 19 Feb 2021 09:51:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0EE5168A31D for ; Fri, 19 Feb 2021 09:50:54 +0200 (EET) Received: by mail-wr1-f41.google.com with SMTP id r21so6589838wrr.9 for ; Thu, 18 Feb 2021 23:50:54 -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=kNBTPlg2Rd6rRCPIPRC8N4IYR90Bl0CI5k2C/S79TyY=; b=KGHR6FUkb9Z12orVrE1B7GJzF68KSRkXs3Mk7NPO7er2IZuzKwKH0xfTjIK6ZcZZXe wLtNb14vQ98IWDXdSRD/LBYW1Hn6UC/T0dnF1+uaR1IwChskWLYop46EJsWKcCTjCX/7 fUdbtCnX6/BxddBFaV3FbAe8UxGxKMyuYyhP3FKMEeZdOjzZx9cEkHcre7OaXsaClnm0 rjuQJ28DlspHW3GSX3U69dF7pFTPYwNf/DkV/aquQ6RE+aKSCIq5iTSCdaSl2NgnpCFi XDgFkFf3iJX231eupUi/VBBa2YT6V5pGOco6bCZgDxwdreqyBQkLpJt9aLxCF8ghCR96 0Hkg== 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=kNBTPlg2Rd6rRCPIPRC8N4IYR90Bl0CI5k2C/S79TyY=; b=RQvP+bIWoHkDkWic/iNn4LISHXTMG7rJ+pmPB6+a9egfKvEOTzuPN6ITaqv5HHCZDV eg50jYoV3E94mi9WXA6PP+jvOZjbxlgw73P2kktPLRr9yEkkLhsDe6Xx8V2M4mFJOvy/ HssOSG7tG3uhnuXsPw7MjZefkkcy7hN7GG4/hQWz7M9GAd8UlFHmnfvrPdfy5Hp3Uatz Nlb1C/GqrFCctb3YfXH0V2QHUNe6cafThjjw16CUml4EZYOaUm0LbqlAXh6mHPBtsY5X 0mRDSlsqCTFt/4+G5EfZFGyRM1BYvFdLmaFcdF9uuBA3zDc7vTJ+T14s1XWHTj2Q0X7P 2KpQ== X-Gm-Message-State: AOAM531R22EmYVjHlZ3hr8n8FpzBj3eNc0woSWRalkYuZVNy06NnFjn2 Fh3qooYYiHSWE45QOrtCqkE+fiwXb2A= X-Google-Smtp-Source: ABdhPJwifwBfz6So6PGqYBh1MM/Z+gmzizYfp/sYYihbdmMccvabhpXoUgEHbr298L8+hLhYKpUZtw== X-Received: by 2002:adf:92c4:: with SMTP id 62mr7810105wrn.245.1613721053334; Thu, 18 Feb 2021 23:50:53 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id z190sm6130795wme.15.2021.02.18.23.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 23:50:53 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Feb 2021 08:50:12 +0100 Message-Id: <20210219075022.2445161-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210219075022.2445161-1-andreas.rheinhardt@gmail.com> References: <20210219075022.2445161-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/15] avcodec/acelp_pitch_delay: Inline small functions only used once 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" ff_acelp_decode_8bit_to_1st_delay3, ff_acelp_decode_4bit_to_2nd_delay3 and ff_acelp_decode_5_6_bit_to_2nd_delay3 are all only used once (by g729dec) whereas ff_acelp_decode_9bit_to_1st_delay6 and ff_acelp_decode_6bit_to_2nd_delay6 are completely unused; with the possible exception of ff_acelp_decode_4bit_to_2nd_delay3, these functions are so small that inlining them is appropriate; and as long as ff_acelp_decode_4bit_to_2nd_delay3 is only called once, this is also true for it. Signed-off-by: Andreas Rheinhardt --- libavcodec/acelp_pitch_delay.c | 41 ------------------------------- libavcodec/acelp_pitch_delay.h | 45 +++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c index a070d1b25d..1eca97ec69 100644 --- a/libavcodec/acelp_pitch_delay.c +++ b/libavcodec/acelp_pitch_delay.c @@ -29,47 +29,6 @@ #include "celp_math.h" #include "audiodsp.h" -int ff_acelp_decode_8bit_to_1st_delay3(int ac_index) -{ - ac_index += 58; - if(ac_index > 254) - ac_index = 3 * ac_index - 510; - return ac_index; -} - -int ff_acelp_decode_4bit_to_2nd_delay3( - int ac_index, - int pitch_delay_min) -{ - if(ac_index < 4) - return 3 * (ac_index + pitch_delay_min); - else if(ac_index < 12) - return 3 * pitch_delay_min + ac_index + 6; - else - return 3 * (ac_index + pitch_delay_min) - 18; -} - -int ff_acelp_decode_5_6_bit_to_2nd_delay3( - int ac_index, - int pitch_delay_min) -{ - return 3 * pitch_delay_min + ac_index - 2; -} - -int ff_acelp_decode_9bit_to_1st_delay6(int ac_index) -{ - if(ac_index < 463) - return ac_index + 105; - else - return 6 * (ac_index - 368); -} -int ff_acelp_decode_6bit_to_2nd_delay6( - int ac_index, - int pitch_delay_min) -{ - return 6 * pitch_delay_min + ac_index - 3; -} - void ff_acelp_update_past_gain( int16_t* quant_energy, int gain_corr_factor, diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h index 2aade2f226..73fa3c331a 100644 --- a/libavcodec/acelp_pitch_delay.h +++ b/libavcodec/acelp_pitch_delay.h @@ -41,7 +41,13 @@ * with 1/3 resolution, 19 < pitch_delay < 85 * integers only, 85 <= pitch_delay <= 143 */ -int ff_acelp_decode_8bit_to_1st_delay3(int ac_index); +static inline int ff_acelp_decode_8bit_to_1st_delay3(int ac_index) +{ + ac_index += 58; + if (ac_index > 254) + ac_index = 3 * ac_index - 510; + return ac_index; +} /** * @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits @@ -58,9 +64,11 @@ int ff_acelp_decode_8bit_to_1st_delay3(int ac_index); * @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k, * AMR @@7.4k for the second subframe. */ -int ff_acelp_decode_5_6_bit_to_2nd_delay3( - int ac_index, - int pitch_delay_min); +static inline int ff_acelp_decode_5_6_bit_to_2nd_delay3(int ac_index, + int pitch_delay_min) +{ + return 3 * pitch_delay_min + ac_index - 2; +} /** * @brief Decode pitch delay with 1/3 precision. @@ -78,9 +86,16 @@ int ff_acelp_decode_5_6_bit_to_2nd_delay3( * @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k, * AMR @@5.15k, AMR @@4.75k for the second subframe. */ -int ff_acelp_decode_4bit_to_2nd_delay3( - int ac_index, - int pitch_delay_min); +static inline int ff_acelp_decode_4bit_to_2nd_delay3(int ac_index, + int pitch_delay_min) +{ + if (ac_index < 4) + return 3 * (ac_index + pitch_delay_min); + else if (ac_index < 12) + return 3 * pitch_delay_min + ac_index + 6; + else + return 3 * (ac_index + pitch_delay_min) - 18; +} /** * @brief Decode pitch delay of the first subframe encoded by 9 bits @@ -95,7 +110,13 @@ int ff_acelp_decode_4bit_to_2nd_delay3( * * @remark The routine is used in AMR @@12.2k for the first and third subframes. */ -int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); +static inline int ff_acelp_decode_9bit_to_1st_delay6(int ac_index) +{ + if (ac_index < 463) + return ac_index + 105; + else + return 6 * (ac_index - 368); +} /** * @brief Decode pitch delay of the second subframe encoded by 6 bits @@ -111,9 +132,11 @@ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); * * @remark The routine is used in AMR @@12.2k for the second and fourth subframes. */ -int ff_acelp_decode_6bit_to_2nd_delay6( - int ac_index, - int pitch_delay_min); +static inline int ff_acelp_decode_6bit_to_2nd_delay6(int ac_index, + int pitch_delay_min) +{ + return 6 * pitch_delay_min + ac_index - 3; +} /** * @brief Update past quantized energies