Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avfilter/volume: optimize redundant code for af_volume
@ 2025-04-21  6:04 Shiqi Zhu
  2025-04-21  7:03 ` Zhao Zhili
  0 siblings, 1 reply; 2+ messages in thread
From: Shiqi Zhu @ 2025-04-21  6:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Shiqi Zhu

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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter/volume: optimize redundant code for af_volume
  2025-04-21  6:04 [FFmpeg-devel] [PATCH] avfilter/volume: optimize redundant code for af_volume Shiqi Zhu
@ 2025-04-21  7:03 ` Zhao Zhili
  0 siblings, 0 replies; 2+ messages in thread
From: Zhao Zhili @ 2025-04-21  7:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Shiqi Zhu



> On Apr 21, 2025, at 14:04, Shiqi Zhu <hiccupzhu@gmail.com> wrote:
> 
> 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)

NAK. They are incompatible function pointer types.

> -- 
> 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".

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-21  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-21  6:04 [FFmpeg-devel] [PATCH] avfilter/volume: optimize redundant code for af_volume Shiqi Zhu
2025-04-21  7:03 ` Zhao Zhili

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git