* [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly [not found] <3601973235488930945@unknownmsgid> @ 2024-02-24 15:49 ` Stone Chen 2024-02-24 16:16 ` Stone Chen 2024-02-24 20:56 ` Marton Balint 0 siblings, 2 replies; 7+ messages in thread From: Stone Chen @ 2024-02-24 15:49 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Stone Chen Previously to support dynamic reconfigurations of the matrix string (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv to be recalculated based on the new filter. This however had the side effect of always ignoring user specified rdiv values. Instead float user_rdiv[0] is added to ConvolutionContext which will store the user specified rdiv values. Then the original rdiv array will store either the user_rdiv or the automatically calculated 1/sum. This fixes trac #10294, #10867 --- libavfilter/convolution.h | 3 ++- libavfilter/vf_convolution.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h index e44bfb5da8..ee7477ef89 100644 --- a/libavfilter/convolution.h +++ b/libavfilter/convolution.h @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { const AVClass *class; char *matrix_str[4]; - float rdiv[4]; + float user_rdiv[4]; float bias[4]; int mode[4]; float scale; float delta; int planes; + float rdiv[4]; int size[4]; int depth; int max; diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c index a00bb2b3c4..96c478d791 100644 --- a/libavfilter/vf_convolution.c +++ b/libavfilter/vf_convolution.c @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, @@ -669,6 +669,7 @@ static int param_init(AVFilterContext *ctx) for (i = 0; i < 4; i++) { int *matrix = (int *)s->matrix[i]; char *orig, *p, *arg, *saveptr = NULL; + s->rdiv[i] = s->user_rdiv[i]; float sum = 1.f; p = orig = av_strdup(s->matrix_str[i]); -- 2.43.2 _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-24 15:49 ` [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly Stone Chen @ 2024-02-24 16:16 ` Stone Chen 2024-02-24 20:56 ` Marton Balint 1 sibling, 0 replies; 7+ messages in thread From: Stone Chen @ 2024-02-24 16:16 UTC (permalink / raw) To: ffmpeg-devel [-- Attachment #1: Type: text/plain, Size: 3776 bytes --] Sorry I just realized I messed up my git commit (new to git), I've attached a patch file with that correction. On Sat, Feb 24, 2024 at 10:49 AM Stone Chen <chen.stonechen@gmail.com> wrote: > Previously to support dynamic reconfigurations of the matrix string (e.g. > 0m), the rdiv values would always be cleared to 0.f, causing the rdiv to be > recalculated based on the new filter. This however had the side effect of > always ignoring user specified rdiv values. > > Instead float user_rdiv[0] is added to ConvolutionContext which will store > the user specified rdiv values. Then the original rdiv array will store > either the user_rdiv or the automatically calculated 1/sum. > > This fixes trac #10294, #10867 > --- > libavfilter/convolution.h | 3 ++- > libavfilter/vf_convolution.c | 9 +++++---- > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h > index e44bfb5da8..ee7477ef89 100644 > --- a/libavfilter/convolution.h > +++ b/libavfilter/convolution.h > @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { > const AVClass *class; > > char *matrix_str[4]; > - float rdiv[4]; > + float user_rdiv[4]; > float bias[4]; > int mode[4]; > float scale; > float delta; > int planes; > > + float rdiv[4]; > int size[4]; > int depth; > int max; > diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c > index a00bb2b3c4..96c478d791 100644 > --- a/libavfilter/vf_convolution.c > +++ b/libavfilter/vf_convolution.c > @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { > { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "0bias", "set bias for 1st plane", OFFSET(bias[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > @@ -669,6 +669,7 @@ static int param_init(AVFilterContext *ctx) > for (i = 0; i < 4; i++) { > int *matrix = (int *)s->matrix[i]; > char *orig, *p, *arg, *saveptr = NULL; > + s->rdiv[i] = s->user_rdiv[i]; > float sum = 1.f; > > p = orig = av_strdup(s->matrix_str[i]); > -- > 2.43.2 > > [-- Attachment #2: 0001-Add-float-user_rdiv-4-to-allow-user-options-to-apply.patch --] [-- Type: text/x-patch, Size: 3659 bytes --] From d489e66c7f1ea94ef302759566ee2b22b7895b86 Mon Sep 17 00:00:00 2001 From: Stone Chen <chen.stonechen@gmail.com> Date: Sat, 24 Feb 2024 11:08:02 -0500 Subject: [PATCH] Add float user_rdiv[4] to allow user options to apply correctly Previously to support dynamic reconfigurations of the matrix string (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv to be recalculated based on the new filter. This however had the side effect of always ignoring user specified rdiv values. Instead float user_rdiv[0] is added to ConvolutionContext which will store the user specified rdiv values. Then the original rdiv array will store either the user_rdiv or the automatically calculated 1/sum. This fixes trac #10294, #10867 Signed-off-by: Stone Chen <chen.stonechen@gmail.com> --- libavfilter/convolution.h | 3 ++- libavfilter/vf_convolution.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h index e44bfb5da8..ee7477ef89 100644 --- a/libavfilter/convolution.h +++ b/libavfilter/convolution.h @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { const AVClass *class; char *matrix_str[4]; - float rdiv[4]; + float user_rdiv[4]; float bias[4]; int mode[4]; float scale; float delta; int planes; + float rdiv[4]; int size[4]; int depth; int max; diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c index bf67f392f6..88b89289a9 100644 --- a/libavfilter/vf_convolution.c +++ b/libavfilter/vf_convolution.c @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, @@ -674,7 +674,7 @@ static int param_init(AVFilterContext *ctx) p = orig = av_strdup(s->matrix_str[i]); if (p) { s->matrix_length[i] = 0; - s->rdiv[i] = 0.f; + s->rdiv[i] = s->user_rdiv[i]; sum = 0.f; while (s->matrix_length[i] < 49) { -- 2.43.2 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-24 15:49 ` [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly Stone Chen 2024-02-24 16:16 ` Stone Chen @ 2024-02-24 20:56 ` Marton Balint 2024-02-24 22:09 ` Stone Chen 1 sibling, 1 reply; 7+ messages in thread From: Marton Balint @ 2024-02-24 20:56 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, 24 Feb 2024, Stone Chen wrote: > Previously to support dynamic reconfigurations of the matrix string (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv to be recalculated based on the new filter. This however had the side effect of always ignoring user specified rdiv values. > > Instead float user_rdiv[0] is added to ConvolutionContext which will store the user specified rdiv values. Then the original rdiv array will store either the user_rdiv or the automatically calculated 1/sum. > > This fixes trac #10294, #10867 Have you tested? Thanks, Marton > --- > libavfilter/convolution.h | 3 ++- > libavfilter/vf_convolution.c | 9 +++++---- > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h > index e44bfb5da8..ee7477ef89 100644 > --- a/libavfilter/convolution.h > +++ b/libavfilter/convolution.h > @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { > const AVClass *class; > > char *matrix_str[4]; > - float rdiv[4]; > + float user_rdiv[4]; > float bias[4]; > int mode[4]; > float scale; > float delta; > int planes; > > + float rdiv[4]; > int size[4]; > int depth; > int max; > diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c > index a00bb2b3c4..96c478d791 100644 > --- a/libavfilter/vf_convolution.c > +++ b/libavfilter/vf_convolution.c > @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { > { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > @@ -669,6 +669,7 @@ static int param_init(AVFilterContext *ctx) > for (i = 0; i < 4; i++) { > int *matrix = (int *)s->matrix[i]; > char *orig, *p, *arg, *saveptr = NULL; > + s->rdiv[i] = s->user_rdiv[i]; > float sum = 1.f; > > p = orig = av_strdup(s->matrix_str[i]); > -- > 2.43.2 > > _______________________________________________ > 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-24 20:56 ` Marton Balint @ 2024-02-24 22:09 ` Stone Chen 2024-02-24 23:34 ` Marton Balint 0 siblings, 1 reply; 7+ messages in thread From: Stone Chen @ 2024-02-24 22:09 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, Feb 24, 2024 at 3:56 PM Marton Balint <cus@passwd.hu> wrote: > > > On Sat, 24 Feb 2024, Stone Chen wrote: > > > Previously to support dynamic reconfigurations of the matrix string > (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv > to be recalculated based on the new filter. This however had the side > effect of always ignoring user specified rdiv values. > > > > Instead float user_rdiv[0] is added to ConvolutionContext which will > store the user specified rdiv values. Then the original rdiv array will > store either the user_rdiv or the automatically calculated 1/sum. > > > > This fixes trac #10294, #10867 > > Have you tested? > > Thanks, > Marton > Hi Marton, Yes I've tested that - the original behavior works (automatically calculate rdiv if user_rdiv = 0) - setting the rdiv value works - both work via sendcmd - make fate runs with no errors Cheers, Stone > > --- > > libavfilter/convolution.h | 3 ++- > > libavfilter/vf_convolution.c | 9 +++++---- > > 2 files changed, 7 insertions(+), 5 deletions(-) > > > > diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h > > index e44bfb5da8..ee7477ef89 100644 > > --- a/libavfilter/convolution.h > > +++ b/libavfilter/convolution.h > > @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { > > const AVClass *class; > > > > char *matrix_str[4]; > > - float rdiv[4]; > > + float user_rdiv[4]; > > float bias[4]; > > int mode[4]; > > float scale; > > float delta; > > int planes; > > > > + float rdiv[4]; > > int size[4]; > > int depth; > > int max; > > diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c > > index a00bb2b3c4..96c478d791 100644 > > --- a/libavfilter/vf_convolution.c > > +++ b/libavfilter/vf_convolution.c > > @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { > > { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > > { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > > { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), > AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, > > - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > { "0bias", "set bias for 1st plane", OFFSET(bias[0]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), > AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, > > @@ -669,6 +669,7 @@ static int param_init(AVFilterContext *ctx) > > for (i = 0; i < 4; i++) { > > int *matrix = (int *)s->matrix[i]; > > char *orig, *p, *arg, *saveptr = NULL; > > + s->rdiv[i] = s->user_rdiv[i]; > > float sum = 1.f; > > > > p = orig = av_strdup(s->matrix_str[i]); > > -- > > 2.43.2 > > > > _______________________________________________ > > 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". > _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-24 22:09 ` Stone Chen @ 2024-02-24 23:34 ` Marton Balint 2024-02-25 0:02 ` Stone Chen 0 siblings, 1 reply; 7+ messages in thread From: Marton Balint @ 2024-02-24 23:34 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, 24 Feb 2024, Stone Chen wrote: > On Sat, Feb 24, 2024 at 3:56 PM Marton Balint <cus@passwd.hu> wrote: > >> >> >> On Sat, 24 Feb 2024, Stone Chen wrote: >> >> > Previously to support dynamic reconfigurations of the matrix string >> (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv >> to be recalculated based on the new filter. This however had the side >> effect of always ignoring user specified rdiv values. >> > >> > Instead float user_rdiv[0] is added to ConvolutionContext which will >> store the user specified rdiv values. Then the original rdiv array will >> store either the user_rdiv or the automatically calculated 1/sum. >> > >> > This fixes trac #10294, #10867 >> >> Have you tested? >> >> Thanks, >> Marton >> > > > Hi Marton, > > Yes I've tested that > > - the original behavior works (automatically calculate rdiv if user_rdiv > = 0) > - setting the rdiv value works It does not work for me even after applying your patch. Regards, Marton > - both work via sendcmd > - make fate runs with no errors > > Cheers, > Stone > > > >> > --- >> > libavfilter/convolution.h | 3 ++- >> > libavfilter/vf_convolution.c | 9 +++++---- >> > 2 files changed, 7 insertions(+), 5 deletions(-) >> > >> > diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h >> > index e44bfb5da8..ee7477ef89 100644 >> > --- a/libavfilter/convolution.h >> > +++ b/libavfilter/convolution.h >> > @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { >> > const AVClass *class; >> > >> > char *matrix_str[4]; >> > - float rdiv[4]; >> > + float user_rdiv[4]; >> > float bias[4]; >> > int mode[4]; >> > float scale; >> > float delta; >> > int planes; >> > >> > + float rdiv[4]; >> > int size[4]; >> > int depth; >> > int max; >> > diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c >> > index a00bb2b3c4..96c478d791 100644 >> > --- a/libavfilter/vf_convolution.c >> > +++ b/libavfilter/vf_convolution.c >> > @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { >> > { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), >> AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, >> > { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), >> AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, >> > { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), >> AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, >> > - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > { "0bias", "set bias for 1st plane", OFFSET(bias[0]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), >> AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, >> > @@ -669,6 +669,7 @@ static int param_init(AVFilterContext *ctx) >> > for (i = 0; i < 4; i++) { >> > int *matrix = (int *)s->matrix[i]; >> > char *orig, *p, *arg, *saveptr = NULL; >> > + s->rdiv[i] = s->user_rdiv[i]; >> > float sum = 1.f; >> > >> > p = orig = av_strdup(s->matrix_str[i]); >> > -- >> > 2.43.2 >> > >> > _______________________________________________ >> > 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". >> > _______________________________________________ > 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-24 23:34 ` Marton Balint @ 2024-02-25 0:02 ` Stone Chen 2024-02-25 2:03 ` Marton Balint 0 siblings, 1 reply; 7+ messages in thread From: Stone Chen @ 2024-02-25 0:02 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 1488 bytes --] On Sat, Feb 24, 2024 at 6:34 PM Marton Balint <cus@passwd.hu> wrote: > > > On Sat, 24 Feb 2024, Stone Chen wrote: > > > On Sat, Feb 24, 2024 at 3:56 PM Marton Balint <cus@passwd.hu> wrote: > > > >> > >> > >> On Sat, 24 Feb 2024, Stone Chen wrote: > >> > >> > Previously to support dynamic reconfigurations of the matrix string > >> (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the > rdiv > >> to be recalculated based on the new filter. This however had the side > >> effect of always ignoring user specified rdiv values. > >> > > >> > Instead float user_rdiv[0] is added to ConvolutionContext which will > >> store the user specified rdiv values. Then the original rdiv array will > >> store either the user_rdiv or the automatically calculated 1/sum. > >> > > >> > This fixes trac #10294, #10867 > >> > >> Have you tested? > >> > >> Thanks, > >> Marton > >> > > > > > > Hi Marton, > > > > Yes I've tested that > > > > - the original behavior works (automatically calculate rdiv if > user_rdiv > > = 0) > > - setting the rdiv value works > > It does not work for me even after applying your patch. > > Regards, > Marton > Hi Marton, Sorry about that, was it with the attached patch in the second email? I had botched my initial patch, I've re-attached the second to this email. If it was, I'll need to investigate further then, would you be able to send me what you did to test? Regards, Stone [-- Attachment #2: 0001-Add-float-user_rdiv-4-to-allow-user-options-to-apply.patch --] [-- Type: text/x-patch, Size: 3659 bytes --] From d489e66c7f1ea94ef302759566ee2b22b7895b86 Mon Sep 17 00:00:00 2001 From: Stone Chen <chen.stonechen@gmail.com> Date: Sat, 24 Feb 2024 11:08:02 -0500 Subject: [PATCH] Add float user_rdiv[4] to allow user options to apply correctly Previously to support dynamic reconfigurations of the matrix string (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the rdiv to be recalculated based on the new filter. This however had the side effect of always ignoring user specified rdiv values. Instead float user_rdiv[0] is added to ConvolutionContext which will store the user specified rdiv values. Then the original rdiv array will store either the user_rdiv or the automatically calculated 1/sum. This fixes trac #10294, #10867 Signed-off-by: Stone Chen <chen.stonechen@gmail.com> --- libavfilter/convolution.h | 3 ++- libavfilter/vf_convolution.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h index e44bfb5da8..ee7477ef89 100644 --- a/libavfilter/convolution.h +++ b/libavfilter/convolution.h @@ -34,13 +34,14 @@ typedef struct ConvolutionContext { const AVClass *class; char *matrix_str[4]; - float rdiv[4]; + float user_rdiv[4]; float bias[4]; int mode[4]; float scale; float delta; int planes; + float rdiv[4]; int size[4]; int depth; int max; diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c index bf67f392f6..88b89289a9 100644 --- a/libavfilter/vf_convolution.c +++ b/libavfilter/vf_convolution.c @@ -40,10 +40,10 @@ static const AVOption convolution_options[] = { { "1m", "set matrix for 2nd plane", OFFSET(matrix_str[1]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "2m", "set matrix for 3rd plane", OFFSET(matrix_str[2]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, { "3m", "set matrix for 4th plane", OFFSET(matrix_str[3]), AV_OPT_TYPE_STRING, {.str="0 0 0 0 1 0 0 0 0"}, 0, 0, FLAGS }, - { "0rdiv", "set rdiv for 1st plane", OFFSET(rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "1rdiv", "set rdiv for 2nd plane", OFFSET(rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "2rdiv", "set rdiv for 3rd plane", OFFSET(rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, - { "3rdiv", "set rdiv for 4th plane", OFFSET(rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "0rdiv", "set rdiv for 1st plane", OFFSET(user_rdiv[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "1rdiv", "set rdiv for 2nd plane", OFFSET(user_rdiv[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "2rdiv", "set rdiv for 3rd plane", OFFSET(user_rdiv[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, + { "3rdiv", "set rdiv for 4th plane", OFFSET(user_rdiv[3]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "0bias", "set bias for 1st plane", OFFSET(bias[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "1bias", "set bias for 2nd plane", OFFSET(bias[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, { "2bias", "set bias for 3rd plane", OFFSET(bias[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, INT_MAX, FLAGS}, @@ -674,7 +674,7 @@ static int param_init(AVFilterContext *ctx) p = orig = av_strdup(s->matrix_str[i]); if (p) { s->matrix_length[i] = 0; - s->rdiv[i] = 0.f; + s->rdiv[i] = s->user_rdiv[i]; sum = 0.f; while (s->matrix_length[i] < 49) { -- 2.43.2 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly 2024-02-25 0:02 ` Stone Chen @ 2024-02-25 2:03 ` Marton Balint 0 siblings, 0 replies; 7+ messages in thread From: Marton Balint @ 2024-02-25 2:03 UTC (permalink / raw) To: FFmpeg development discussions and patches On Sat, 24 Feb 2024, Stone Chen wrote: > On Sat, Feb 24, 2024 at 6:34 PM Marton Balint <cus@passwd.hu> wrote: > >> >> >> On Sat, 24 Feb 2024, Stone Chen wrote: >> >>> On Sat, Feb 24, 2024 at 3:56 PM Marton Balint <cus@passwd.hu> wrote: >>> >>>> >>>> >>>> On Sat, 24 Feb 2024, Stone Chen wrote: >>>> >>>>> Previously to support dynamic reconfigurations of the matrix string >>>> (e.g. 0m), the rdiv values would always be cleared to 0.f, causing the >> rdiv >>>> to be recalculated based on the new filter. This however had the side >>>> effect of always ignoring user specified rdiv values. >>>>> >>>>> Instead float user_rdiv[0] is added to ConvolutionContext which will >>>> store the user specified rdiv values. Then the original rdiv array will >>>> store either the user_rdiv or the automatically calculated 1/sum. >>>>> >>>>> This fixes trac #10294, #10867 >>>> >>>> Have you tested? >>>> >>>> Thanks, >>>> Marton >>>> >>> >>> >>> Hi Marton, >>> >>> Yes I've tested that >>> >>> - the original behavior works (automatically calculate rdiv if >> user_rdiv >>> = 0) >>> - setting the rdiv value works >> >> It does not work for me even after applying your patch. >> >> Regards, >> Marton >> > > Hi Marton, > > Sorry about that, was it with the attached patch in the second email? I had > botched my initial patch, I've re-attached the second to this email. Oh, sorry, I missed that the second patch is different. Use versions in email subjects, such as [PATCH v2] for new versions of the same patch. Looking good now, will apply. Thanks, Marton _______________________________________________ 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] 7+ messages in thread
end of thread, other threads:[~2024-02-25 2:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <3601973235488930945@unknownmsgid> 2024-02-24 15:49 ` [FFmpeg-devel] [PATCH] Add float user_rdiv[4] to allow user options to apply correctly Stone Chen 2024-02-24 16:16 ` Stone Chen 2024-02-24 20:56 ` Marton Balint 2024-02-24 22:09 ` Stone Chen 2024-02-24 23:34 ` Marton Balint 2024-02-25 0:02 ` Stone Chen 2024-02-25 2:03 ` Marton Balint
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