[PATCH v1] avfilter/vf_minterpolate: correct the mafd calculation
From: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- libavfilter/vf_minterpolate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index b0bb238..fc8054b 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -185,6 +185,7 @@ typedef struct MIContext { int64_t out_pts; int b_width, b_height, b_count; int log2_mb_size; + int bitdepth; int scd_method; int scene_changed; @@ -343,6 +344,7 @@ static int config_input(AVFilterLink *inlink) mi_ctx->log2_chroma_h = desc->log2_chroma_h; mi_ctx->log2_chroma_w = desc->log2_chroma_w; + mi_ctx->bitdepth = desc->comp[0].depth; mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format); @@ -383,7 +385,7 @@ static int config_input(AVFilterLink *inlink) } if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { - mi_ctx->sad = ff_scene_sad_get_fn(8); + mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16); if (!mi_ctx->sad) return AVERROR(EINVAL); } @@ -836,7 +838,7 @@ static int detect_scene_change(MIContext *mi_ctx) uint64_t sad; mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); emms_c(); - mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); + mafd = (double) sad * 100.0 / (me_ctx->height * me_ctx->width) / (1 << mi_ctx->bitdepth); diff = fabs(mafd - mi_ctx->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); mi_ctx->prev_mafd = mafd; -- 2.6.4
From: Limin Wang <lance.lmwang@gmail.com> ./ffmpeg -loglevel debug -i ../fate-suite/svq3/Vertical400kbit.sorenson3.mov -vf minterpolate=fps=60:mi_mode=blend -an -f null - [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 1600 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 4120 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 5780 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 6700 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 8140 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 9740 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 14060 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 15680 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 18480 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 20020 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 21740 The results are consistent with tests/ref/fate/filter-metadata-scenedetect For the master, it'll detect more than 20 scene change for the same source. Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- libavfilter/vf_minterpolate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index fc8054b..c9ce804 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -230,7 +230,7 @@ static const AVOption minterpolate_options[] = { { "scd", "scene change detection method", OFFSET(scd_method), AV_OPT_TYPE_INT, {.i64 = SCD_METHOD_FDIFF}, SCD_METHOD_NONE, SCD_METHOD_FDIFF, FLAGS, "scene" }, CONST("none", "disable detection", SCD_METHOD_NONE, "scene"), CONST("fdiff", "frame difference", SCD_METHOD_FDIFF, "scene"), - { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 5.0}, 0, 100.0, FLAGS }, + { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 10.}, 0, 100.0, FLAGS }, { NULL } }; @@ -1097,6 +1097,7 @@ static void interpolate(AVFilterLink *inlink, AVFrame *avf_out) } if (mi_ctx->scene_changed) { + av_log(ctx, AV_LOG_DEBUG, "scene changed, input pts %"PRId64"\n", mi_ctx->frames[1].avf->pts); /* duplicate frame */ av_frame_copy(avf_out, alpha > ALPHA_MAX / 2 ? mi_ctx->frames[2].avf : mi_ctx->frames[1].avf); return; -- 2.6.4
From: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- libavfilter/vf_minterpolate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index b0bb238..fc8054b 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -185,6 +185,7 @@ typedef struct MIContext { int64_t out_pts; int b_width, b_height, b_count; int log2_mb_size; + int bitdepth; int scd_method; int scene_changed; @@ -343,6 +344,7 @@ static int config_input(AVFilterLink *inlink) mi_ctx->log2_chroma_h = desc->log2_chroma_h; mi_ctx->log2_chroma_w = desc->log2_chroma_w; + mi_ctx->bitdepth = desc->comp[0].depth; mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format); @@ -383,7 +385,7 @@ static int config_input(AVFilterLink *inlink) } if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { - mi_ctx->sad = ff_scene_sad_get_fn(8); + mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16); if (!mi_ctx->sad) return AVERROR(EINVAL); } @@ -836,7 +838,7 @@ static int detect_scene_change(MIContext *mi_ctx) uint64_t sad; mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); emms_c(); - mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); + mafd = (double) sad * 100.0 / (me_ctx->height * me_ctx->width) / (1 << mi_ctx->bitdepth); diff = fabs(mafd - mi_ctx->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); mi_ctx->prev_mafd = mafd; -- 2.6.4
From: Limin Wang <lance.lmwang@gmail.com> ./ffmpeg -loglevel debug -i ../fate-suite/svq3/Vertical400kbit.sorenson3.mov -vf minterpolate=fps=60:mi_mode=blend -an -f null - [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 1600 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 4120 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 5780 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 6700 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 8140 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 9740 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 14060 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 15680 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 18480 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 20020 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 21740 The results are consistent with tests/ref/fate/filter-metadata-scenedetect For the master, it'll detect more than 20 scene change for the same source. Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- doc/filters.texi | 2 +- libavfilter/vf_minterpolate.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 9d500e4..a39785d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -12743,7 +12743,7 @@ Frame difference. Corresponding pixel values are compared and if it satisfies @v Default method is @samp{fdiff}. @item scd_threshold -Scene change detection threshold. Default is @code{5.0}. +Scene change detection threshold. Default is @code{10.}. @end table @section mix diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index fc8054b..c9ce804 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -230,7 +230,7 @@ static const AVOption minterpolate_options[] = { { "scd", "scene change detection method", OFFSET(scd_method), AV_OPT_TYPE_INT, {.i64 = SCD_METHOD_FDIFF}, SCD_METHOD_NONE, SCD_METHOD_FDIFF, FLAGS, "scene" }, CONST("none", "disable detection", SCD_METHOD_NONE, "scene"), CONST("fdiff", "frame difference", SCD_METHOD_FDIFF, "scene"), - { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 5.0}, 0, 100.0, FLAGS }, + { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 10.}, 0, 100.0, FLAGS }, { NULL } }; @@ -1097,6 +1097,7 @@ static void interpolate(AVFilterLink *inlink, AVFrame *avf_out) } if (mi_ctx->scene_changed) { + av_log(ctx, AV_LOG_DEBUG, "scene changed, input pts %"PRId64"\n", mi_ctx->frames[1].avf->pts); /* duplicate frame */ av_frame_copy(avf_out, alpha > ALPHA_MAX / 2 ? mi_ctx->frames[2].avf : mi_ctx->frames[1].avf); return; -- 2.6.4
From: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le +FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down +fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1 + FATE_FILTER_VSYNTH-$(CONFIG_BOXBLUR_FILTER) += fate-filter-boxblur fate-filter-boxblur: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf boxblur=2:1 diff --git a/tests/ref/fate/filter-minterpolate-down b/tests/ref/fate/filter-minterpolate-down new file mode 100644 index 0000000..4eab7aa --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-down @@ -0,0 +1,6 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed diff --git a/tests/ref/fate/filter-minterpolate-up b/tests/ref/fate/filter-minterpolate-up new file mode 100644 index 0000000..a276bf6 --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-up @@ -0,0 +1,15 @@ +#tb 0: 1/10 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed +0, 1, 1, 1, 115200, 0xec1fdfa0 +0, 2, 2, 1, 115200, 0xa17f0d74 +0, 3, 3, 1, 115200, 0xd72532a9 +0, 4, 4, 1, 115200, 0x032e60f8 +0, 5, 5, 1, 115200, 0x6e318ba0 +0, 6, 6, 1, 115200, 0x76018292 +0, 7, 7, 1, 115200, 0x89e27599 +0, 8, 8, 1, 115200, 0x68536eac +0, 9, 9, 1, 115200, 0xc3ac62a8 -- 2.6.4
On Sat, Sep 14, 2019 at 11:37:31AM +0800, lance.lmwang@gmail.com wrote:
From: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1
tested on linux x86_32/64, mingw32/64 arm & mips qemu [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
On Sun, Sep 15, 2019 at 07:05:35PM +0200, Michael Niedermayer wrote:
On Sat, Sep 14, 2019 at 11:37:31AM +0800, lance.lmwang@gmail.com wrote:
From: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1
tested on linux x86_32/64, mingw32/64 arm & mips qemu
Michael, thanks for the testing, I update the commit message to include the testing result.
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
_______________________________________________ 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".
ping, please help to push it or comments. On Sun, Sep 15, 2019 at 07:05:35PM +0200, Michael Niedermayer wrote:
On Sat, Sep 14, 2019 at 11:37:31AM +0800, lance.lmwang@gmail.com wrote:
From: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1
tested on linux x86_32/64, mingw32/64 arm & mips qemu
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
_______________________________________________ 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".
Hi. Replying to a very old patch already applied. lance.lmwang@gmail.com (12019-09-14):
From: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1
The patch says minterpolate, but the test is an exact copy of the framerate test, and still testing framerate. Please fix. Regards, -- Nicolas George
On Thu, Aug 13, 2020 at 10:55:07PM +0200, Nicolas George wrote:
Hi. Replying to a very old patch already applied.
lance.lmwang@gmail.com (12019-09-14):
From: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72..ab7b624 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down
+fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1
The patch says minterpolate, but the test is an exact copy of the framerate test, and still testing framerate. Please fix.
sorry, will fix it.
Regards,
-- Nicolas George
-- Thanks, Limin Wang
From: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- libavfilter/vf_minterpolate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index b0bb238ade..fc8054b710 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -185,6 +185,7 @@ typedef struct MIContext { int64_t out_pts; int b_width, b_height, b_count; int log2_mb_size; + int bitdepth; int scd_method; int scene_changed; @@ -343,6 +344,7 @@ static int config_input(AVFilterLink *inlink) mi_ctx->log2_chroma_h = desc->log2_chroma_h; mi_ctx->log2_chroma_w = desc->log2_chroma_w; + mi_ctx->bitdepth = desc->comp[0].depth; mi_ctx->nb_planes = av_pix_fmt_count_planes(inlink->format); @@ -383,7 +385,7 @@ static int config_input(AVFilterLink *inlink) } if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { - mi_ctx->sad = ff_scene_sad_get_fn(8); + mi_ctx->sad = ff_scene_sad_get_fn(mi_ctx->bitdepth == 8 ? 8 : 16); if (!mi_ctx->sad) return AVERROR(EINVAL); } @@ -836,7 +838,7 @@ static int detect_scene_change(MIContext *mi_ctx) uint64_t sad; mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); emms_c(); - mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); + mafd = (double) sad * 100.0 / (me_ctx->height * me_ctx->width) / (1 << mi_ctx->bitdepth); diff = fabs(mafd - mi_ctx->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); mi_ctx->prev_mafd = mafd; -- 2.21.0
From: Limin Wang <lance.lmwang@gmail.com> ./ffmpeg -loglevel debug -i ../fate-suite/svq3/Vertical400kbit.sorenson3.mov -vf minterpolate=fps=60:mi_mode=blend -an -f null - [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 1600 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 4120 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 5780 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 6700 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 8140 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 9740 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 14060 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 15680 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 18480 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 20020 [Parsed_minterpolate_0 @ 0x7fe7f3e193c0] scene changed, input pts 21740 The results are consistent with tests/ref/fate/filter-metadata-scenedetect For the master, it'll detect more than 20 scene change for the same source. Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- doc/filters.texi | 2 +- libavfilter/vf_minterpolate.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 06ce7ec069..fc299f1405 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -12743,7 +12743,7 @@ Frame difference. Corresponding pixel values are compared and if it satisfies @v Default method is @samp{fdiff}. @item scd_threshold -Scene change detection threshold. Default is @code{5.0}. +Scene change detection threshold. Default is @code{10.}. @end table @section mix diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c index fc8054b710..c9ce80420d 100644 --- a/libavfilter/vf_minterpolate.c +++ b/libavfilter/vf_minterpolate.c @@ -230,7 +230,7 @@ static const AVOption minterpolate_options[] = { { "scd", "scene change detection method", OFFSET(scd_method), AV_OPT_TYPE_INT, {.i64 = SCD_METHOD_FDIFF}, SCD_METHOD_NONE, SCD_METHOD_FDIFF, FLAGS, "scene" }, CONST("none", "disable detection", SCD_METHOD_NONE, "scene"), CONST("fdiff", "frame difference", SCD_METHOD_FDIFF, "scene"), - { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 5.0}, 0, 100.0, FLAGS }, + { "scd_threshold", "scene change threshold", OFFSET(scd_threshold), AV_OPT_TYPE_DOUBLE, {.dbl = 10.}, 0, 100.0, FLAGS }, { NULL } }; @@ -1097,6 +1097,7 @@ static void interpolate(AVFilterLink *inlink, AVFrame *avf_out) } if (mi_ctx->scene_changed) { + av_log(ctx, AV_LOG_DEBUG, "scene changed, input pts %"PRId64"\n", mi_ctx->frames[1].avf->pts); /* duplicate frame */ av_frame_copy(avf_out, alpha > ALPHA_MAX / 2 ? mi_ctx->frames[2].avf : mi_ctx->frames[1].avf); return; -- 2.21.0
From: Limin Wang <lance.lmwang@gmail.com> have tested on linux x86_32/64, mingw32/64 arm & mips qemu Tested-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72432..ab7b6245a1 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le +FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down +fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1 + FATE_FILTER_VSYNTH-$(CONFIG_BOXBLUR_FILTER) += fate-filter-boxblur fate-filter-boxblur: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf boxblur=2:1 diff --git a/tests/ref/fate/filter-minterpolate-down b/tests/ref/fate/filter-minterpolate-down new file mode 100644 index 0000000000..4eab7aab85 --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-down @@ -0,0 +1,6 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed diff --git a/tests/ref/fate/filter-minterpolate-up b/tests/ref/fate/filter-minterpolate-up new file mode 100644 index 0000000000..a276bf660d --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-up @@ -0,0 +1,15 @@ +#tb 0: 1/10 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed +0, 1, 1, 1, 115200, 0xec1fdfa0 +0, 2, 2, 1, 115200, 0xa17f0d74 +0, 3, 3, 1, 115200, 0xd72532a9 +0, 4, 4, 1, 115200, 0x032e60f8 +0, 5, 5, 1, 115200, 0x6e318ba0 +0, 6, 6, 1, 115200, 0x76018292 +0, 7, 7, 1, 115200, 0x89e27599 +0, 8, 8, 1, 115200, 0x68536eac +0, 9, 9, 1, 115200, 0xc3ac62a8 -- 2.21.0
On Fri, Sep 20, 2019 at 11:08:36AM +0800, lance.lmwang@gmail.com wrote:
From: Limin Wang <lance.lmwang@gmail.com>
have tested on linux x86_32/64, mingw32/64 arm & mips qemu
will apply it tomorrow if no comments
Tested-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> --- tests/fate/filter-video.mak | 4 ++++ tests/ref/fate/filter-minterpolate-down | 6 ++++++ tests/ref/fate/filter-minterpolate-up | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/filter-minterpolate-down create mode 100644 tests/ref/fate/filter-minterpolate-up
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 0c6ee72432..ab7b6245a1 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -122,6 +122,10 @@ FATE_FILTER-$(call ALLYES, FRAMERATE_FILTER TESTSRC2_FILTER FORMAT_FILTER) += fa fate-filter-framerate-12bit-up: CMD = framecrc -lavfi testsrc2=r=50:d=1,format=pix_fmts=yuv422p12le,framerate=fps=60 -t 1 -pix_fmt yuv422p12le fate-filter-framerate-12bit-down: CMD = framecrc -lavfi testsrc2=r=60:d=1,format=pix_fmts=yuv422p12le,framerate=fps=50 -t 1 -pix_fmt yuv422p12le
+FATE_FILTER-$(call ALLYES, MINTERPOLATE_FILTER TESTSRC2_FILTER) += fate-filter-minterpolate-up fate-filter-minterpolate-down +fate-filter-minterpolate-up: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=10 -t 1 +fate-filter-minterpolate-down: CMD = framecrc -lavfi testsrc2=r=2:d=10,framerate=fps=1 -t 1 + FATE_FILTER_VSYNTH-$(CONFIG_BOXBLUR_FILTER) += fate-filter-boxblur fate-filter-boxblur: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf boxblur=2:1
diff --git a/tests/ref/fate/filter-minterpolate-down b/tests/ref/fate/filter-minterpolate-down new file mode 100644 index 0000000000..4eab7aab85 --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-down @@ -0,0 +1,6 @@ +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed diff --git a/tests/ref/fate/filter-minterpolate-up b/tests/ref/fate/filter-minterpolate-up new file mode 100644 index 0000000000..a276bf660d --- /dev/null +++ b/tests/ref/fate/filter-minterpolate-up @@ -0,0 +1,15 @@ +#tb 0: 1/10 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x3744b3ed +0, 1, 1, 1, 115200, 0xec1fdfa0 +0, 2, 2, 1, 115200, 0xa17f0d74 +0, 3, 3, 1, 115200, 0xd72532a9 +0, 4, 4, 1, 115200, 0x032e60f8 +0, 5, 5, 1, 115200, 0x6e318ba0 +0, 6, 6, 1, 115200, 0x76018292 +0, 7, 7, 1, 115200, 0x89e27599 +0, 8, 8, 1, 115200, 0x68536eac +0, 9, 9, 1, 115200, 0xc3ac62a8 -- 2.21.0
-- Thanks, Limin Wang
participants (4)
-
lance.lmwang@gmail.com -
Limin Wang -
Michael Niedermayer -
Nicolas George