[FFmpeg-cvslog] tests/checkasm/vvc_mc: for SAD, only test valid subblock sizes

2024-05-29 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Tue May 28 
15:09:02 2024 -0400| [d82c5035558730f0d1f2e5aec66df6d0db7f4e6f] | committer: 
Nuo Mi

tests/checkasm/vvc_mc: for SAD, only test valid subblock sizes

According to the VVC specification (section 8.5.1), the maximum width/height of 
a subblock passed for DMVR SAD is 16. This along with previous constraint 
requiring width * height >= 128 means that  8x16, 16x8, and 16x16 are the only 
allowed sizes.

This changes check_vvc_sad() to only test and benchmark those sizes.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d82c5035558730f0d1f2e5aec66df6d0db7f4e6f
---

 tests/checkasm/vvc_mc.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index 1e889e2cff..09cac82edb 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -337,11 +337,12 @@ static void check_vvc_sad(void)
 memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
 
 randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4);
- for (int h = 8; h <= MAX_CTU_SIZE; h *= 2) {
-for (int w = 8; w <= MAX_CTU_SIZE; w *= 2) {
+for (int h = 8; h <= 16; h *= 2) {
+for (int w = 8; w <= 16; w *= 2) {
 for(int offy = 0; offy <= 4; offy++) {
 for(int offx = 0; offx <= 4; offx++) {
-if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
+if(w * h >= 128) {
+if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
 int result0;
 int result1;
 
@@ -350,13 +351,14 @@ static void check_vvc_sad(void)
 
 if (result1 != result0)
 fail();
-if(w == h && offx == 0 && offy == 0)
+if(offx == 0 && offy == 0)
 bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 + 
PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
+}
 }
 }
 }
 }
- }
+}
 
 report("sad");
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] libavcode/x86/vvc: change label to vvc_sad_16 to reflect block sizes

2024-05-29 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Tue May 28 
15:09:00 2024 -0400| [55e9c758f07de6f40489a2fc5f2b35ab368329f0] | committer: 
Nuo Mi

libavcode/x86/vvc: change label to vvc_sad_16 to reflect block sizes

According to the VVC specification (section 8.5.1), the maximum width/height of 
a subblock passed for DMVR SAD is 16. This along with previous constraint 
requiring width * height >= 128 means that  8x16, 16x8, and 16x16 are the only 
allowed sizes. This re-labels vvc_sad_16_128 to vvc_sad_16 to reflect this and 
adds a comment about the block size constraints. There's no functionality 
change.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55e9c758f07de6f40489a2fc5f2b35ab368329f0
---

 libavcodec/x86/vvc/vvc_sad.asm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/x86/vvc/vvc_sad.asm b/libavcodec/x86/vvc/vvc_sad.asm
index b468d89ac2..982951a370 100644
--- a/libavcodec/x86/vvc/vvc_sad.asm
+++ b/libavcodec/x86/vvc/vvc_sad.asm
@@ -29,6 +29,7 @@ SECTION_RODATA
 pw_1: times 2 dw 1
 
 ; DMVR SAD is only calculated on even rows to reduce complexity
+; Additionally the only valid sizes are 8x16, 16x8, and 16x16
 SECTION .text
 
 %macro MIN_MAX_SAD 3
@@ -77,7 +78,7 @@ cglobal vvc_sad, 6, 9, 5, src1, src2, dx, dy, block_w, 
block_h, off1, off2, row_
 vpbroadcastd   m4, [pw_1]
 
 cmp  block_wd, 16
-jgevvc_sad_16_128
+je vvc_sad_16
 
 vvc_sad_8:
 .loop_height:
@@ -100,7 +101,7 @@ cglobal vvc_sad, 6, 9, 5, src1, src2, dx, dy, block_w, 
block_h, off1, off2, row_
 movd  eax, xm0
 RET
 
-vvc_sad_16_128:
+vvc_sad_16:
 sar  block_wd, 4
 .loop_height:
 mov off1q, src1q

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] tests/checkasm: Add check_vvc_sad to vvc_mc.c

2024-05-22 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Tue May 21 
20:00:34 2024 -0400| [2e877090f958131accb8c7e5ac10e5b9865d1735] | committer: 
James Almer

tests/checkasm: Add check_vvc_sad to vvc_mc.c

Adds checkasm for DMVR SAD AVX2 implementation.

Benchmarks ( AMD 7940HS )
vvc_sad_8x8_c: 50.3
vvc_sad_8x8_avx2: 0.3
vvc_sad_16x16_c: 250.3
vvc_sad_16x16_avx2: 10.3
vvc_sad_32x32_c: 1020.3
vvc_sad_32x32_avx2: 60.3
vvc_sad_64x64_c: 3850.3
vvc_sad_64x64_avx2: 220.3
vvc_sad_128x128_c: 14100.3
vvc_sad_128x128_avx2: 840.3

Reviewed-by: Ronald S. Bultje 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e877090f958131accb8c7e5ac10e5b9865d1735
---

 tests/checkasm/vvc_mc.c | 40 +++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
index a5ec7b7869..1e889e2cff 100644
--- a/tests/checkasm/vvc_mc.c
+++ b/tests/checkasm/vvc_mc.c
@@ -45,7 +45,7 @@ static const int sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
 #define randomize_buffers(buf0, buf1, size, mask)   \
 do {\
 int k;  \
-for (k = 0; k < size; k += 4) { \
+for (k = 0; k < size; k += 4 / sizeof(*buf0)) { \
 uint32_t r = rnd() & mask;  \
 AV_WN32A(buf0 + k, r);  \
 AV_WN32A(buf1 + k, r);  \
@@ -324,8 +324,46 @@ static void check_avg(void)
 report("avg");
 }
 
+static void check_vvc_sad(void)
+{
+const int bit_depth = 10;
+VVCDSPContext c;
+LOCAL_ALIGNED_32(uint16_t, src0, [MAX_CTU_SIZE * MAX_CTU_SIZE * 4]);
+LOCAL_ALIGNED_32(uint16_t, src1, [MAX_CTU_SIZE * MAX_CTU_SIZE * 4]);
+declare_func(int, const int16_t *src0, const int16_t *src1, int dx, int 
dy, int block_w, int block_h);
+
+ff_vvc_dsp_init(, bit_depth);
+memset(src0, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
+memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
+
+randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4);
+ for (int h = 8; h <= MAX_CTU_SIZE; h *= 2) {
+for (int w = 8; w <= MAX_CTU_SIZE; w *= 2) {
+for(int offy = 0; offy <= 4; offy++) {
+for(int offx = 0; offx <= 4; offx++) {
+if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
+int result0;
+int result1;
+
+result0 =  call_ref(src0 + PIXEL_STRIDE * 2 + 2, src1 
+ PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
+result1 =  call_new(src0 + PIXEL_STRIDE * 2 + 2, src1 
+ PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
+
+if (result1 != result0)
+fail();
+if(w == h && offx == 0 && offy == 0)
+bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 + 
PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
+}
+}
+}
+}
+ }
+
+report("sad");
+}
+
 void checkasm_check_vvc_mc(void)
 {
+check_vvc_sad();
 check_put_vvc_luma();
 check_put_vvc_luma_uni();
 check_put_vvc_chroma();

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-22 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Tue May 21 
20:00:32 2024 -0400| [0e52a4e4347550ca1ccc1bf896b52824ed259158] | committer: 
James Almer

libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

Implements AVX2 DMVR (decoder-side motion vector refinement) SAD functions. 
DMVR SAD is only calculated if w >= 8, h >= 8, and w * h > 128. To reduce 
complexity, SAD is only calculated on even rows. This is calculated for all 
video bitdepths, but the values passed to the function are always 16bit (even 
if the original video bitdepth is 8). The AVX2 implementation uses min/max/sub.

Additionally this changes parameters dx and dy from int to intptr_t. This 
allows dx & dy to be used as pointer offsets without needing to use movsxd.

Benchmarks ( AMD 7940HS )
Before:
BQTerrace_1920x1080_60_10_420_22_RA.vvc | 106.0 |
Chimera_8bit_1080P_1000_frames.vvc | 204.3 |
NovosobornayaSquare_1920x1080.bin | 197.3 |
RitualDance_1920x1080_60_10_420_37_RA.266 | 174.0 |

After:
BQTerrace_1920x1080_60_10_420_22_RA.vvc | 109.3 |
Chimera_8bit_1080P_1000_frames.vvc | 216.0 |
NovosobornayaSquare_1920x1080.bin | 204.0|
RitualDance_1920x1080_60_10_420_37_RA.266 | 181.7 |

Reviewed-by: Ronald S. Bultje 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e52a4e4347550ca1ccc1bf896b52824ed259158
---

 libavcodec/x86/vvc/Makefile  |   1 +
 libavcodec/x86/vvc/vvc_sad.asm   | 133 +++
 libavcodec/x86/vvc/vvcdsp_init.c |   6 ++
 3 files changed, 140 insertions(+)

diff --git a/libavcodec/x86/vvc/Makefile b/libavcodec/x86/vvc/Makefile
index d6a66f860a..832d802daf 100644
--- a/libavcodec/x86/vvc/Makefile
+++ b/libavcodec/x86/vvc/Makefile
@@ -5,4 +5,5 @@ OBJS-$(CONFIG_VVC_DECODER) += x86/vvc/vvcdsp_init.o 
\
   x86/h26x/h2656dsp.o
 X86ASM-OBJS-$(CONFIG_VVC_DECODER)  += x86/vvc/vvc_alf.o  \
   x86/vvc/vvc_mc.o   \
+  x86/vvc/vvc_sad.o  \
   x86/h26x/h2656_inter.o
diff --git a/libavcodec/x86/vvc/vvc_sad.asm b/libavcodec/x86/vvc/vvc_sad.asm
new file mode 100644
index 00..13224583a5
--- /dev/null
+++ b/libavcodec/x86/vvc/vvc_sad.asm
@@ -0,0 +1,133 @@
+; /*
+; * Provide SIMD DMVR SAD functions for VVC decoding
+; *
+; * Copyright (c) 2024 Stone Chen
+; *
+; * This file is part of FFmpeg.
+; *
+; * FFmpeg is free software; you can redistribute it and/or
+; * modify it under the terms of the GNU Lesser General Public
+; * License as published by the Free Software Foundation; either
+; * version 2.1 of the License, or (at your option) any later version.
+; *
+; * FFmpeg is distributed in the hope that it will be useful,
+; * but WITHOUT ANY WARRANTY; without even the implied warranty of
+; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+; * Lesser General Public License for more details.
+; *
+; * You should have received a copy of the GNU Lesser General Public
+; * License along with FFmpeg; if not, write to the Free Software
+; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
+; */
+
+%include "libavutil/x86/x86util.asm"
+%define MAX_PB_SIZE 128
+%define ROWS 2
+
+SECTION_RODATA
+
+pw_1: times 2 dw 1
+
+; DMVR SAD is only calculated on even rows to reduce complexity
+SECTION .text
+
+%macro MIN_MAX_SAD 3
+pminuw   %3, %2, %1
+pmaxuw   %1, %2, %1
+psubusw  %1, %1, %3
+%endmacro
+
+%macro HORIZ_ADD 3  ; xm0, xm1, m1
+vextracti128 %1, %3, q0001  ;32  1  0
+paddd%1, %2 ; xm0 (7 + 3) (6 + 2) (5 + 1)   (4 + 0)
+pshufd   %2, %1, q0032  ; xm1-  - (7 + 3)   (6 + 2)
+paddd%1, %1, %2 ; xm0_  _ (5 1 7 3) (4 0 6 2)
+pshufd   %2, %1, q0001  ; xm1_  _ (5 1 7 3) (5 1 7 3)
+paddd%1, %1, %2 ;   (01234567)
+%endmacro
+
+%if ARCH_X86_64
+%if HAVE_AVX2_EXTERNAL
+
+INIT_YMM avx2
+
+cglobal vvc_sad, 6, 9, 5, src1, src2, dx, dy, block_w, block_h, off1, off2, 
row_idx
+movsxdifnidndxq, dxd
+movsxdifnidndyq, dyd
+
+sub dxq, 2
+sub dyq, 2
+
+mov off1q, 2
+mov off2q, 2
+
+add off1q, dyq
+sub off2q, dyq
+
+shl off1q, 7
+shl off2q, 7
+
+add off1q, dxq
+sub off2q, dxq
+
+lea src1q, [src1q + off1q * 2 + 2 * 2]
+lea src2q, [src2q + off2q * 2 + 2 * 2]
+
+pxor   m3, m3
+vpbroadcastd   m4, [pw_1]
+
+cmp  block_wd, 16
+jgevvc_sad_16_128
+
+vvc_sad_8:
+.loop_height:
+movu  xm0, [src1q]
+vinserti128m0, [src1q + MAX_PB_SIZE * 

[FFmpeg-cvslog] avfilter/vf_convolution: add float user_rdiv[4] to allow user options to apply correctly

2024-03-19 Thread Stone Chen
ffmpeg | branch: release/6.1 | Stone Chen  | Sat Feb 
24 11:08:02 2024 -0500| [fafdcb2a35bf773526ccc24e26209c13d5c4bfff] | committer: 
Marton Balint

avfilter/vf_convolution: 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 ticket #10294, #10867.

Signed-off-by: Stone Chen 
Signed-off-by: Marton Balint 
(cherry picked from commit ef917950f0298a812bebfed2443626972a7d8f29)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fafdcb2a35bf773526ccc24e26209c13d5c4bfff
---

 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 c1a63c9aa9..839621bc33 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) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] doc/filters: Change rdiv (vf_convolution) documentation to reflect actual behavior

2024-03-16 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Thu Mar 14 
12:47:45 2024 -0400| [de2fb43e785773738c660cdafb9309b1ef1bc80d] | committer: 
Marton Balint

doc/filters: Change rdiv (vf_convolution) documentation to reflect actual 
behavior

The documentation correctly states that the rdiv is a multiplier but 
incorrectly states the default behavior is to multiply by the sum of all matrix 
elements - it multiplies by 1/sum.

This changes the documentation to match the code.

Address trac #10889

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de2fb43e785773738c660cdafb9309b1ef1bc80d
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e0436a5755..913365671d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10497,7 +10497,7 @@ and from 1 to 49 odd number of signed integers in 
@var{row} mode.
 @item 2rdiv
 @item 3rdiv
 Set multiplier for calculated value for each plane.
-If unset or 0, it will be sum of all matrix elements.
+If unset or 0, it will be 1/sum of all matrix elements.
 
 @item 0bias
 @item 1bias

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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


[FFmpeg-cvslog] avfilter/vf_convolution: add float user_rdiv[4] to allow user options to apply correctly

2024-02-25 Thread Stone Chen
ffmpeg | branch: master | Stone Chen  | Sat Feb 24 
11:08:02 2024 -0500| [ef917950f0298a812bebfed2443626972a7d8f29] | committer: 
Marton Balint

avfilter/vf_convolution: 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 ticket #10294, #10867.

Signed-off-by: Stone Chen 
Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef917950f0298a812bebfed2443626972a7d8f29
---

 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) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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