Justin Ruggles <[email protected]> writes:

> This allows for testing floating-point audio encoders across different
> platforms where exact comparisons are unreliable due to float rounding
> differences.
> ---
>  tests/Makefile    |    2 +-
>  tests/fate-run.sh |   22 +++++++++++++++++++++-
>  2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/tests/Makefile b/tests/Makefile
> index 5c65237..79bbba5 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -116,7 +116,7 @@ fate: $(FATE)
>
>  $(FATE): avconv$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
>       @echo "TEST    $(@:fate-%=%)"
> -     $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" 
> "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' 
> '$(THREAD_TYPE)' '$(CPUFLAGS)'
> +     $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" 
> "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' 
> '$(THREAD_TYPE)' '$(CPUFLAGS)' '$(PSNR_SHIFT)'
>
>  fate-list:
>       @printf '%s\n' $(sort $(FATE))
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index 1d1540e..b48be6d 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> @@ -18,6 +18,7 @@ fuzz=${8:-1}
>  threads=${9:-1}
>  thread_type=${10:-frame+slice}
>  cpuflags=${11:-all}
> +psnr_shift=${12:-0}
>
>  outdir="tests/data/fate"
>  outfile="${outdir}/${test}"
> @@ -26,7 +27,7 @@ cmpfile="${outdir}/${test}.diff"
>  repfile="${outdir}/${test}.rep"
>
>  do_tiny_psnr(){
> -    psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
> +    psnr=$(tests/tiny_psnr "$1" "$2" 2 $psnr_shift 0)
>      val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
>      size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
>      size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
> @@ -46,6 +47,12 @@ stddev(){
>      do_tiny_psnr "$1" "$2" stddev 0 1
>  }
>
> +stddev2(){
> +    psnr1=$(cat $psnr_ref)
> +    ref_val=$(expr "$psnr1" : ".*stddev: *\([0-9.]*\)")

Why so complicated?  Why not simply pass the reference value directly
instead of storing the full tiny_psnr output?

> +    do_tiny_psnr "$1" "$2" stddev $ref_val 0
> +}

I also don't see the need for this being a separate function.  The same
can be achieved using a few extra parameters to the existing one, with
default values giving the current behaviour.

>  run(){
>      test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
>      $target_exec $target_path/"$@"
> @@ -75,6 +82,18 @@ pcm(){
>      avconv "$@" -vn -f s16le -
>  }
>
> +enc_dec_pcm(){
> +    psnr_ref="${base}/ref/fate/${test}"
> +    out_fmt=$1
> +    in_ch=$2
> +    in_sr=$3
> +    in_fmt=$4
> +    shift 4
> +    encfile="${outdir}/${test}.${out_fmt}"

$encfile should be added to $cleanfiles so it gets deleted after the
test is run.

> +    avconv -channels $in_ch -sample_rate $in_sr -f $in_fmt -i $ref "$@" -f 
> $out_fmt -y $encfile
> +    avconv -i $encfile -vn -f $in_fmt -
> +}

Perhaps this should abort if the encoding fails.

>  regtest(){
>      t="${test#$2-}"
>      ref=${base}/ref/$2/$t
> @@ -125,6 +144,7 @@ if test -e "$ref"; then
>          diff)   diff -u -w "$ref" "$outfile"            >$cmpfile ;;
>          oneoff) oneoff     "$ref" "$outfile"            >$cmpfile ;;
>          stddev) stddev     "$ref" "$outfile"            >$cmpfile ;;
> +        stddev2) stddev2   "$ref" "$outfile"            >$cmpfile ;;
>          null)   cat               "$outfile"            >$cmpfile ;;
>      esac
>      cmperr=$?
> -- 
> 1.7.1
>

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to