diff mbox series

[FFmpeg-devel,5/5] tests: add coverage for libavfilter's format negotiation

Message ID 20220302184023.285022-5-george@nsup.org
State New
Headers show
Series [FFmpeg-devel,1/5] lavfi/graphdump: add plain listing output | expand

Checks

Context Check Description
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Nicolas George March 2, 2022, 6:40 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 tests/Makefile                               |  1 +
 tests/fate-run.sh                            |  4 ++++
 tests/fate/libavfilter.mak                   |  9 +++++++++
 tests/ref/fate/libavfilter-negotiation-alpha | 20 ++++++++++++++++++++
 4 files changed, 34 insertions(+)
 create mode 100644 tests/fate/libavfilter.mak
 create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha


This is not to be the only test, I intend to cover all the logic in
pick_format() and the logic in swap_*().

But I would rather have you have a quick look at the makefile hackery
before writing too many tests that would need changing.

Comments

Paul B Mahol March 3, 2022, 6:22 p.m. UTC | #1
On 3/2/22, Nicolas George <george@nsup.org> wrote:
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  tests/Makefile                               |  1 +
>  tests/fate-run.sh                            |  4 ++++
>  tests/fate/libavfilter.mak                   |  9 +++++++++
>  tests/ref/fate/libavfilter-negotiation-alpha | 20 ++++++++++++++++++++
>  4 files changed, 34 insertions(+)
>  create mode 100644 tests/fate/libavfilter.mak
>  create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha
>
>
> This is not to be the only test, I intend to cover all the logic in
> pick_format() and the logic in swap_*().
>
> But I would rather have you have a quick look at the makefile hackery
> before writing too many tests that would need changing.
>
>
> diff --git a/tests/Makefile b/tests/Makefile
> index c4c31ae871..2bff4b339d 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -157,6 +157,7 @@ include $(SRC_PATH)/tests/fate/imf.mak
>  include $(SRC_PATH)/tests/fate/indeo.mak
>  include $(SRC_PATH)/tests/fate/libavcodec.mak
>  include $(SRC_PATH)/tests/fate/libavdevice.mak
> +include $(SRC_PATH)/tests/fate/libavfilter.mak
>  include $(SRC_PATH)/tests/fate/libavformat.mak
>  include $(SRC_PATH)/tests/fate/libavutil.mak
>  include $(SRC_PATH)/tests/fate/libswresample.mak
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index fbfc0a925d..82d40f5ebc 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> @@ -509,6 +509,10 @@ venc_data(){
>      run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames}
> ${threads} ${thread_type}
>  }
>
> +lavfi_dump(){
> +    run ffmpeg${PROGSUF}${EXECSUF} -lavfi_dump -lavfi "$@" -f null -
> +}
> +
>  null(){
>      :
>  }
> diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak
> new file mode 100644
> index 0000000000..692f1d4960
> --- /dev/null
> +++ b/tests/fate/libavfilter.mak
> @@ -0,0 +1,9 @@
> +# avfiltergraph.c : pick_format() : video / don't lose alpha
> +FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha
> +fate-libavfilter-negotiation-alpha: CMD = lavfi_dump
> testsrc2=d=0,format=rgba,scale,format=yuv444p/yuva444p
> +
> +FATE_LIBAVFILTER-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER)
> += $(FATE_LIBAVFILTER_NEGOTIATION_VIDEO)
> +
> +fate-libavfilter: $(FATE_LIBAVFILTER) $(FATE_LIBAVFILTER-yes)
> +fate-libavfilter-negotiation: $(FATE_LIBAVFILTER_NEGOTIATION)
> $(FATE_LIBAVFILTER_NEGOTIATION-yes)
> +FATE_FFMPEG += $(FATE_LIBAVFILTER-yes)
> diff --git a/tests/ref/fate/libavfilter-negotiation-alpha
> b/tests/ref/fate/libavfilter-negotiation-alpha
> new file mode 100644
> index 0000000000..00175f65cb
> --- /dev/null
> +++ b/tests/ref/fate/libavfilter-negotiation-alpha
> @@ -0,0 +1,20 @@
> +Dump of complex filter graph #0:
> +
> +Filter: Parsed_testsrc2_0 (testsrc2)
> +  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgba]
> +
> +Filter: Parsed_format_1 (format)
> +  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgba]
> +  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgba]
> +
> +Filter: Parsed_scale_2 (scale)
> +  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgba]
> +  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p]
> +
> +Filter: Parsed_format_3 (format)
> +  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p]
> +  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p]
> +
> +Filter: out_0_0 (buffersink)
> +  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p]
> +
> --
> 2.34.1
>


Changes in this set seems logical and useful.
James Almer March 3, 2022, 6:31 p.m. UTC | #2
On 3/2/2022 3:40 PM, Nicolas George wrote:
> diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak
> new file mode 100644
> index 0000000000..692f1d4960
> --- /dev/null
> +++ b/tests/fate/libavfilter.mak
> @@ -0,0 +1,9 @@
> +# avfiltergraph.c : pick_format() : video / don't lose alpha
> +FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha
> +fate-libavfilter-negotiation-alpha: CMD = lavfi_dump testsrc2=d=0,format=rgba,scale,format=yuv444p/yuva444p
> +
> +FATE_LIBAVFILTER-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER) += $(FATE_LIBAVFILTER_NEGOTIATION_VIDEO)
> +
> +fate-libavfilter: $(FATE_LIBAVFILTER) $(FATE_LIBAVFILTER-yes)
> +fate-libavfilter-negotiation: $(FATE_LIBAVFILTER_NEGOTIATION) $(FATE_LIBAVFILTER_NEGOTIATION-yes)
> +FATE_FFMPEG += $(FATE_LIBAVFILTER-yes)

This can be simplified as such:

> # avfiltergraph.c : pick_format() : video / don't lose alpha
> FATE_LIBAVFILTER-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER) += fate-libavfilter-negotiation-alpha
> fate-libavfilter-negotiation-alpha: CMD = lavfi_dump testsrc2=d=0,format=rgba,scale,format=yuv444p/yuva444p
> 
> fate-libavfilter: $(FATE_LIBAVFILTER-yes)
> FATE_FFMPEG += $(FATE_LIBAVFILTER-yes)

No need to add a fate-libavfilter-negotiation target until there are 
more such tests.
Nicolas George March 3, 2022, 6:37 p.m. UTC | #3
James Almer (12022-03-03):
> No need to add a fate-libavfilter-negotiation target until there are more
> such tests.

Thanks for the review. I know these targets are not necessary, but I
want them. I do intend to write more tests:

>> This is not to be the only test, I intend to cover all the logic in
>> pick_format() and the logic in swap_*().

And having submodule-specific fate targets is convenient even if there
are only one test.

Please read the code assuming there are several tests, including tests
using aresample rather than scale.

Regards,
diff mbox series

Patch

diff --git a/tests/Makefile b/tests/Makefile
index c4c31ae871..2bff4b339d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -157,6 +157,7 @@  include $(SRC_PATH)/tests/fate/imf.mak
 include $(SRC_PATH)/tests/fate/indeo.mak
 include $(SRC_PATH)/tests/fate/libavcodec.mak
 include $(SRC_PATH)/tests/fate/libavdevice.mak
+include $(SRC_PATH)/tests/fate/libavfilter.mak
 include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index fbfc0a925d..82d40f5ebc 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -509,6 +509,10 @@  venc_data(){
     run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
 }
 
+lavfi_dump(){
+    run ffmpeg${PROGSUF}${EXECSUF} -lavfi_dump -lavfi "$@" -f null -
+}
+
 null(){
     :
 }
diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak
new file mode 100644
index 0000000000..692f1d4960
--- /dev/null
+++ b/tests/fate/libavfilter.mak
@@ -0,0 +1,9 @@ 
+# avfiltergraph.c : pick_format() : video / don't lose alpha
+FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha
+fate-libavfilter-negotiation-alpha: CMD = lavfi_dump testsrc2=d=0,format=rgba,scale,format=yuv444p/yuva444p
+
+FATE_LIBAVFILTER-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER) += $(FATE_LIBAVFILTER_NEGOTIATION_VIDEO)
+
+fate-libavfilter: $(FATE_LIBAVFILTER) $(FATE_LIBAVFILTER-yes)
+fate-libavfilter-negotiation: $(FATE_LIBAVFILTER_NEGOTIATION) $(FATE_LIBAVFILTER_NEGOTIATION-yes)
+FATE_FFMPEG += $(FATE_LIBAVFILTER-yes)
diff --git a/tests/ref/fate/libavfilter-negotiation-alpha b/tests/ref/fate/libavfilter-negotiation-alpha
new file mode 100644
index 0000000000..00175f65cb
--- /dev/null
+++ b/tests/ref/fate/libavfilter-negotiation-alpha
@@ -0,0 +1,20 @@ 
+Dump of complex filter graph #0:
+
+Filter: Parsed_testsrc2_0 (testsrc2)
+  out 0: default → Parsed_format_1.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_format_1 (format)
+  in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgba]
+
+Filter: Parsed_scale_2 (scale)
+  in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgba]
+  out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p]
+
+Filter: Parsed_format_3 (format)
+  in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p]
+  out 0: default → out_0_0.0:default [320x240 1:1 yuva444p]
+
+Filter: out_0_0 (buffersink)
+  in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p]
+