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] vfilter: Speed up vf_mutiply with inlining
@ 2023-04-14 21:08 Suraj Shirvankar
  2023-04-14 23:32 ` Ronald S. Bultje
  0 siblings, 1 reply; 3+ messages in thread
From: Suraj Shirvankar @ 2023-04-14 21:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Suraj Shirvankar

Add inline to provide a slight speed up fo vf_multiply

Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
---
 libavfilter/vf_multiply.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_multiply.c b/libavfilter/vf_multiply.c
index 979b885eb1..b9ff92d8e1 100644
--- a/libavfilter/vf_multiply.c
+++ b/libavfilter/vf_multiply.c
@@ -72,9 +72,8 @@ static int config_input(AVFilterLink *inlink)
     return 0;
 }
 
-static void multiply(const uint8_t *ssrc, const uint8_t *rref, uint8_t *ddst,
-                     float scale, float offset, int w)
-{
+static inline void multiply(const uint8_t *ssrc, const uint8_t *rref,
+                            uint8_t *ddst, float scale, float offset, int w) {
     const float *src = (const float *)ssrc;
     const float *ref = (const float *)rref;
     float *dst = (float *)ddst;
@@ -86,8 +85,8 @@ static void multiply(const uint8_t *ssrc, const uint8_t *rref, uint8_t *ddst,
     }
 }
 
-static int multiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
-{
+static inline int multiply_slice(AVFilterContext *ctx, void *arg, int jobnr,
+                                 int nb_jobs) {
     MultiplyContext *s = ctx->priv;
     const float offset = s->offset;
     const float scale = s->scale;
-- 
2.40.0

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] vfilter: Speed up vf_mutiply with inlining
  2023-04-14 21:08 [FFmpeg-devel] [PATCH] vfilter: Speed up vf_mutiply with inlining Suraj Shirvankar
@ 2023-04-14 23:32 ` Ronald S. Bultje
  2023-04-15  6:22   ` Suraj Shirvankar
  0 siblings, 1 reply; 3+ messages in thread
From: Ronald S. Bultje @ 2023-04-14 23:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Suraj Shirvankar

Hi,

On Fri, Apr 14, 2023 at 5:08 PM Suraj Shirvankar <surajshirvankar@gmail.com>
wrote:

> Add inline to provide a slight speed up fo vf_multiply
>
> Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
> ---
>  libavfilter/vf_multiply.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/libavfilter/vf_multiply.c b/libavfilter/vf_multiply.c
> index 979b885eb1..b9ff92d8e1 100644
> --- a/libavfilter/vf_multiply.c
> +++ b/libavfilter/vf_multiply.c
> @@ -72,9 +72,8 @@ static int config_input(AVFilterLink *inlink)
>      return 0;
>  }
>
> -static void multiply(const uint8_t *ssrc, const uint8_t *rref, uint8_t
> *ddst,
> -                     float scale, float offset, int w)
> -{
> +static inline void multiply(const uint8_t *ssrc, const uint8_t *rref,
> +                            uint8_t *ddst, float scale, float offset, int
> w) {
>      const float *src = (const float *)ssrc;
>      const float *ref = (const float *)rref;
>      float *dst = (float *)ddst;
>

Please provide performance measurements to justify the change. Wouldn't it
be better to write SIMD?


> @@ -86,8 +85,8 @@ static void multiply(const uint8_t *ssrc, const uint8_t
> *rref, uint8_t *ddst,
>      }
>  }
>
> -static int multiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs)
> -{
> +static inline int multiply_slice(AVFilterContext *ctx, void *arg, int
> jobnr,
> +                                 int nb_jobs) {
>      MultiplyContext *s = ctx->priv;
>      const float offset = s->offset;
>      const float scale = s->scale;
>

This does nothing, since the function pointer is passed to
ff_filter_execute().

Ronald
_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] vfilter: Speed up vf_mutiply with inlining
  2023-04-14 23:32 ` Ronald S. Bultje
@ 2023-04-15  6:22   ` Suraj Shirvankar
  0 siblings, 0 replies; 3+ messages in thread
From: Suraj Shirvankar @ 2023-04-15  6:22 UTC (permalink / raw)
  To: Ronald S. Bultje; +Cc: FFmpeg development discussions and patches

Hi Ronald

On Sat, Apr 15, 2023, 1:33 AM Ronald S. Bultje <rsbultje@gmail.com> wrote:

> Hi,
>
> On Fri, Apr 14, 2023 at 5:08 PM Suraj Shirvankar <
> surajshirvankar@gmail.com> wrote:
>
>> Add inline to provide a slight speed up fo vf_multiply
>>
>> Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
>> ---
>>  libavfilter/vf_multiply.c | 9 ++++-----
>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavfilter/vf_multiply.c b/libavfilter/vf_multiply.c
>> index 979b885eb1..b9ff92d8e1 100644
>> --- a/libavfilter/vf_multiply.c
>> +++ b/libavfilter/vf_multiply.c
>> @@ -72,9 +72,8 @@ static int config_input(AVFilterLink *inlink)
>>      return 0;
>>  }
>>
>> -static void multiply(const uint8_t *ssrc, const uint8_t *rref, uint8_t
>> *ddst,
>> -                     float scale, float offset, int w)
>> -{
>> +static inline void multiply(const uint8_t *ssrc, const uint8_t *rref,
>> +                            uint8_t *ddst, float scale, float offset,
>> int w) {
>>      const float *src = (const float *)ssrc;
>>      const float *ref = (const float *)rref;
>>      float *dst = (float *)ddst;
>>
>
> Please provide performance measurements to justify the change. Wouldn't it
> be better to write SIMD?
>

I agree it would make more sense to use the SIMD version. Will attach
relative performance improvement.


>
>> @@ -86,8 +85,8 @@ static void multiply(const uint8_t *ssrc, const uint8_t
>> *rref, uint8_t *ddst,
>>      }
>>  }
>>
>> -static int multiply_slice(AVFilterContext *ctx, void *arg, int jobnr,
>> int nb_jobs)
>> -{
>> +static inline int multiply_slice(AVFilterContext *ctx, void *arg, int
>> jobnr,
>> +                                 int nb_jobs) {
>>      MultiplyContext *s = ctx->priv;
>>      const float offset = s->offset;
>>      const float scale = s->scale;
>>
>
> This does nothing, since the function pointer is passed to
> ff_filter_execute().
>

Ah yes my bad, will remove this change.

>
> Ronald
>
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2023-04-15  6:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 21:08 [FFmpeg-devel] [PATCH] vfilter: Speed up vf_mutiply with inlining Suraj Shirvankar
2023-04-14 23:32 ` Ronald S. Bultje
2023-04-15  6:22   ` Suraj Shirvankar

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