From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 7C7EB4007D
	for <ffmpegdev@gitmailbox.com>; Mon, 21 Apr 2025 06:05:14 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3F91688146;
	Mon, 21 Apr 2025 09:05:07 +0300 (EEST)
Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com
 [209.85.210.179])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DADE2687C32
 for <ffmpeg-devel@ffmpeg.org>; Mon, 21 Apr 2025 09:05:00 +0300 (EEST)
Received: by mail-pf1-f179.google.com with SMTP id
 d2e1a72fcca58-73bf5aa95e7so3244252b3a.1
 for <ffmpeg-devel@ffmpeg.org>; Sun, 20 Apr 2025 23:05:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745215498; x=1745820298; darn=ffmpeg.org;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=khDwI9IwFMWFf0uIPgk8MqH2PeO0vbGHAmmXwQaimW4=;
 b=CxSjlGDOIVFrM6GhjTxe431NnIbwzO2GpvP2hAx3eGYBrMhdWntg6BU5ZF5qS+FRGU
 a+TVLvKTa/FKRADtMMSN0M3+Uf8ec2FN6fN3y14MEUOZisp6lQ4oRWpkTY4X1Bhg1kK8
 VFpnFdeM/9EQEeU4b+dK9F+BSlTuXbup2fNeJBKLXvZ0kllhVdzlHhSfcaDJgzcbvpgv
 P01yTpCGeSmpHDwMzN1+N3KWJWvxMWe3o1hWLdPcmDDq2MsKo4N6L2Hk0gfJQ4gCYod+
 TmFEj81mX94gEO1DZlGp7feTtPs5UrEOYpHSkWj/oXTFCVvjam1kaSNwqvInKjC04Agr
 O7cw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745215498; x=1745820298;
 h=content-transfer-encoding:mime-version:message-id:date:subject:cc
 :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=khDwI9IwFMWFf0uIPgk8MqH2PeO0vbGHAmmXwQaimW4=;
 b=BIEzUMxWQhUXjIcz7gv7qN31gzQO0Za2Nizni2CE+XNaxIs5Vr7hyrZCw81ezQqCJF
 vf3FooABWXkc9SmzsNeCxCoVftAK4uIMoGkR8vjlwXJLwVPnF7Lvl1uIifsxUH6keo9Y
 ivPXBrt5S01fC6NxxBxpUItne5Ocdgx8Cv6/jC5HGo03K2C5PJPSDApPUnWeFGyV0wN9
 PO3FKryrzHZYpQmjknPas2skkq5gj7CK5cisiSAmD6SHGVzmBT4DzCMGzqN+TVv36yna
 d/8S2TMz4sp/XUMKqzYT1luVnz910IyA9sdDujZkcIbY5vz/Lz1G4d/qcnEYBghrhKYS
 ClJg==
X-Gm-Message-State: AOJu0YwMVDBMbDXDMQAEBHY58AmyusTJ5kDBRyENQKZl/I6kHCOJcwLz
 q/V69rMc4Og4Vn53J+ILjrcnBQDYVqMl8ZkhOaOkAA5I44dAnSAuqp7siA==
X-Gm-Gg: ASbGncsCjJ9COY+Zy+l9DXwrBrIZJxHGgzzNDcn8bmOqsRfydPzP5kqN2riCX8/W1b2
 4PK4np5jHLGf95TakgcKfL2AD+2IheTdbRiBAmQAE50nyprjLSAQKzQY4nBGxpyRMkBnKf9xEgx
 fuQGAYiNuvLRqBISQstdtk5wQGr0y9+PiImYRKR+in049o/tNGerH76NLGTRrKwq054/7my5E7O
 /OnILJTwvL5E58t4q+IvKVyHvrZIpQz61YplPQy/xu9Bw2EhipjdhVpB/onOYY6cnSyD+EX5CZq
 Vv6eXjR+ZqausgNHVRta3tQZo0ZOKO1OuTz4cCZqFwkBfGxvZjbAdNQ=
X-Google-Smtp-Source: AGHT+IG8pYi2u3Fk3n4GgMa50sWiCKfkrhyhgUS2iSQoimDTwuf6i0UM/aqoGdzi9ynV7finEpIFCA==
X-Received: by 2002:a05:6a00:2e84:b0:736:4ebd:e5a with SMTP id
 d2e1a72fcca58-73dc15ca18emr12192869b3a.20.1745215497862; 
 Sun, 20 Apr 2025 23:04:57 -0700 (PDT)
Received: from pc.mioffice.cn ([43.224.245.228])
 by smtp.gmail.com with ESMTPSA id
 d2e1a72fcca58-73dbf8bf79fsm5741533b3a.21.2025.04.20.23.04.56
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 20 Apr 2025 23:04:57 -0700 (PDT)
From: Shiqi Zhu <hiccupzhu@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Date: Mon, 21 Apr 2025 14:04:52 +0800
Message-Id: <20250421060452.4014124-1-hiccupzhu@gmail.com>
X-Mailer: git-send-email 2.34.1
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH] avfilter/volume: optimize redundant code for
 af_volume
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Shiqi Zhu <hiccupzhu@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250421060452.4014124-1-hiccupzhu@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

Signed-off-by: Shiqi Zhu <hiccupzhu@gmail.com>
---
 libavfilter/af_volume.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 471bffeceb..c16188524d 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -178,34 +178,28 @@ static inline void scale_samples_u8_small(uint8_t *dst, const uint8_t *src,
         dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
 }
 
-static inline void scale_samples_s16(uint8_t *dst, const uint8_t *src,
+static inline void scale_samples_s16(int16_t *dst, const int16_t *src,
                                      int nb_samples, int volume)
 {
     int i;
-    int16_t *smp_dst       = (int16_t *)dst;
-    const int16_t *smp_src = (const int16_t *)src;
     for (i = 0; i < nb_samples; i++)
-        smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
+        dst[i] = av_clip_int16(((int64_t)src[i] * volume + 128) >> 8);
 }
 
-static inline void scale_samples_s16_small(uint8_t *dst, const uint8_t *src,
+static inline void scale_samples_s16_small(int16_t *dst, const int16_t *src,
                                            int nb_samples, int volume)
 {
     int i;
-    int16_t *smp_dst       = (int16_t *)dst;
-    const int16_t *smp_src = (const int16_t *)src;
     for (i = 0; i < nb_samples; i++)
-        smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
+        dst[i] = av_clip_int16((src[i] * volume + 128) >> 8);
 }
 
-static inline void scale_samples_s32(uint8_t *dst, const uint8_t *src,
+static inline void scale_samples_s32(int32_t *dst, const int32_t *src,
                                      int nb_samples, int volume)
 {
     int i;
-    int32_t *smp_dst       = (int32_t *)dst;
-    const int32_t *smp_src = (const int32_t *)src;
     for (i = 0; i < nb_samples; i++)
-        smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
+        dst[i] = av_clipl_int32((((int64_t)src[i] * volume + 128) >> 8));
 }
 
 static av_cold void volume_init(VolumeContext *vol)
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".