From fef6a90d2b2f21d885b2ec2d348bfcdb7751c118 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 14 Jun 2016 05:25:33 +0300 Subject: vsp-lib: Use gen-image to generate frames at runtime Replace the build time reference frames generation system by runtime generation of the frames. This saves a lot of disk space and allows tests to easily use new reference frames. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 106 ++++++++++++++++++++++++++++++++++++++------------ scripts/vsp-runner.sh | 33 ++++++++++------ 2 files changed, 104 insertions(+), 35 deletions(-) (limited to 'scripts') diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 6a59505..2c9e729 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -1,5 +1,6 @@ #!/bin/sh +genimage='./gen-image' mediactl='media-ctl' yavta='yavta' @@ -38,6 +39,65 @@ vsp1_entity_get_size() { sed 's/.*\/\([0-9x]*\).*/\1/' } +# ----------------------------------------------------------------------------- +# Referance frame generation +# + +reference_frame() { + local file=$1 + local reftype=$2 + local format=$3 + local size=$4 + + local alpha= + local options= + + case $reftype in + reference | scaled) + ;; + composed-*) + options="$options -c ${reftype/composed-/}" + ;; + esac + + case $format in + ARGB555) + alpha=255 + ;; + ABGR32 | ARGB32) + alpha=200 + ;; + XRGB555) + # XRGB555 has the X bit hardcoded to 0 + alpha=0 + ;; + XBGR32 | XRGB32) + # The X bits are configurable with a default value of 255 + alpha=255 + ;; + *) + alpha=255 + ;; + esac + + $(format_v4l2_is_yuv $format) && options="$options -y" + + $genimage -f $format -s $size -a $alpha $options -o $file \ + frames/frame-reference-1024x768.pnm +} + +reference_histogram() { + local file=$1 + local format=$2 + local size=$3 + + local yuv= + $(format_v4l2_is_yuv $format) && yuv="-y" + + $genimage -f $format $yuv -s $size -H $file \ + frames/frame-reference-1024x768.pnm +} + # ------------------------------------------------------------------------------ # Image and histogram comparison # @@ -108,35 +168,21 @@ compare_frames() { fmt=$(echo $format | tr '[:upper:]' '[:lower:]') size=$(vsp1_entity_get_size wpf.$wpf 1) - case $format in - ARGB555) - reference="frame-$reftype-$fmt-$size-alpha255.bin" - ;; - ABGR32 | ARGB32) - reference="frame-$reftype-$fmt-$size-alpha200.bin" - ;; - XRGB555) - # XRGB555 has the X bit hardcoded to 0 - reference="frame-$reftype-$fmt-$size-alpha0.bin" - ;; - XBGR32 | XRGB32) - # The X bits are configurable with a default value of 255 - reference="frame-$reftype-$fmt-$size-alpha255.bin" - ;; - *) - reference="frame-$reftype-$fmt-$size.bin" - ;; - esac + reference_frame ref-frame.bin $reftype $format $size result="pass" for frame in frame-*.bin ; do - (compare_frame_$method $format $size $frame frames/$reference) || { - mv $frame ${0/.sh/}-${frame/.bin/-$reftype-$fmt-$size.bin} ; + (compare_frame_$method $format $size $frame ref-frame.bin) || { + mv $frame ${0/.sh/}-${frame/.bin/-$fmt-$size.bin} ; result="fail" } done - rm -f frames/$reference + if [ $result = "fail" ] ; then + mv ref-frame.bin ${0/.sh/}-ref-frame-$fmt-$size.bin + else + rm -f ref-frame.bin + fi echo $result } @@ -163,16 +209,23 @@ compare_histograms() { fmt=$(echo $format | tr '[:upper:]' '[:lower:]') size=$(vsp1_entity_get_size wpf.$wpf 1) - reference="histo-reference-$fmt-$size.bin" + + reference_histogram ref-histogram.bin $format $size result="pass" for histo in histo-*.bin ; do - (compare_histogram $histo frames/$reference) || { + (compare_histogram $histo ref-histogram.bin) || { mv $histo ${0/.sh/}-${histo/.bin/-$fmt.bin} ; result="fail" } done + if [ $result = "fail" ] ; then + mv ref-histogram.bin ${0/.sh/}-ref-histogram-$fmt.bin + else + rm -f ref-histogram.bin + fi + echo $result } @@ -271,6 +324,11 @@ format_v4l2_to_mbus() { esac } +format_v4l2_is_yuv() { + local format=$(format_v4l2_to_mbus $1) + [ $format = 'AYUV32' ] +} + format_rpf() { format=$(format_v4l2_to_mbus $1) size=$2 diff --git a/scripts/vsp-runner.sh b/scripts/vsp-runner.sh index e92eda1..6aa72a2 100755 --- a/scripts/vsp-runner.sh +++ b/scripts/vsp-runner.sh @@ -4,33 +4,41 @@ set -e source vsp-lib.sh +genimage='./gen-image' mediactl='media-ctl' yavta='yavta' -# ------------------------------------------------------------------------------ -# Format retrieval +# ----------------------------------------------------------------------------- +# Input frame generation # -frame_reference() { - format=$1 - size=$2 +generate_input_frame() { + local file=$1 + local format=$2 + local size=$3 - lcfmt=`echo $infmt | tr '[:upper:]' '[:lower:]'` + local alpha= + local options= case $format in ARGB555) - echo "frames/frame-reference-$lcfmt-$size-alpha255.bin" + alpha=255 ;; ABGR32 | ARGB32) - echo "frames/frame-reference-$lcfmt-$size-alpha200.bin" + alpha=200 ;; XRGB555 | XBGR32 | XRGB32) - echo "frames/frame-reference-$lcfmt-$size-alpha0.bin" + alpha=0 ;; *) - echo "frames/frame-reference-$lcfmt-$size.bin" + alpha=255 ;; esac + + $(format_v4l2_is_yuv $format) && options="$options -y" + + $genimage -f $format -s $size -a $alpha $options -o $file \ + frames/frame-reference-1024x768.pnm } # ------------------------------------------------------------------------------ @@ -105,8 +113,9 @@ execute() { input) rpf=rpf.$index size=$(vsp1_entity_get_size $rpf 0) + file=${rpf}.bin - file=$(frame_reference $infmt $size) + generate_input_frame $file $infmt $size if [ "x$options" = xinfinite ] ; then $yavta -c -n 4 -f $infmt -s $size --file=$file $options \ @@ -115,6 +124,8 @@ execute() { $yavta -c10 -n 4 -f $infmt -s $size --file=$file $options \ `$mediactl -d $mdev -e "$dev $rpf input"` fi + + rm -f $file ;; output) -- cgit v1.2.3