diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2025-04-08 02:18:49 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2025-04-09 02:29:59 +0300 |
commit | 08a53ffa12dca18535ee9e546a3027896d694f4b (patch) | |
tree | 9419c5fcc7d5bd4ab2e985e9efdf55f0137b497e | |
parent | d67d4218f2cb65f79907110b2c1a5b91cad1467a (diff) |
vsp-lib: Add support for color space
Support configuring the color space when setting formats on subdev pads
and on video devices. As the VSP only cares about the encoding and
quantization, the colorspace and transfer function parameters are not
handled.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rwxr-xr-x | scripts/vsp-lib.sh | 82 |
1 files changed, 76 insertions, 6 deletions
diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index 85f3fde..4782829 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -85,6 +85,12 @@ vsp1_entity_set_format() { shift 4 local options="$*" + if [ $format = 'AYUV8_1X32' ] ; then + options="$options ycbcr:$__vsp_encoding quantization:$__vsp_quantization" + else + options="$options ycbcr:601 quantization:full-range" + fi + $mediactl -d $mdev -V "'$dev $entity':$pad [fmt:$format/$size $options]" } @@ -115,6 +121,30 @@ vsp1_reset_controls() { $yavta --no-query --reset-controls $subdev | ./logger.sh "$entity" >> $logfile } +gen_image_csc_options() { + local options= + + case $__vsp_encoding in + 601) + options="$options -e BT.601" + ;; + 709) + options="$options -e REC.709" + ;; + esac + + case $__vsp_quantization in + lim-range) + options="$options -q limited" + ;; + full-range) + options="$options -q full" + ;; + esac + + echo "$options" +} + # ----------------------------------------------------------------------------- # Reference frame generation # @@ -206,6 +236,11 @@ reference_frame() { [ x$__vsp_brx_inputs != x ] && options="$options -c $__vsp_brx_inputs" + options="$options $(gen_image_csc_options)" + + echo "Generating reference frame with $genimage -i $in_format -f $out_format -s $size -a $alpha $options" | \ + ./logger.sh check >> $logfile + $genimage -i $in_format -f $out_format -s $size -a $alpha $options -o $file \ frames/frame-reference-1024x768.ppm } @@ -512,6 +547,8 @@ pipe_reset() { __vsp_rpf_format= __vsp_wpf_index=0 __vsp_wpf_format= + __vsp_encoding=601 + __vsp_quantization=lim-range __vsp_pixel_perfect=true } @@ -866,7 +903,23 @@ format_configure() { local pipe=${1//-/_} shift 1 - format_$pipe $* + local options + local arg + + for arg in $* ; do + case $arg in + --encoding=*) + local encoding=${arg/--encoding=/} + __vsp_encoding=${encoding%:*} + __vsp_quantization=${encoding#*:} + ;; + *) + options="$options $arg" + ;; + esac + done + + format_$pipe $options } # ------------------------------------------------------------------------------ @@ -886,9 +939,10 @@ hgt_configure() { # generate_input_frame() { - local file=$1 - local format=$2 - local size=$3 + local entity=$1 + local file=$2 + local format=$3 + local size=$4 local alpha= local options= @@ -910,6 +964,11 @@ generate_input_frame() { $(format_v4l2_is_yuv $format) && options="$options -C -i YUV444M" + options="$options $(gen_image_csc_options)" + + echo "Generating input frame with $genimage -f $format -s $size -a $alpha $options" | \ + ./logger.sh $entity >> $logfile + $genimage -f $format -s $size -a $alpha $options -o $file \ frames/frame-reference-1024x768.ppm } @@ -952,6 +1011,7 @@ vsp_runner() { local videodev local format local size + local csc case $entity in hgo) @@ -971,7 +1031,7 @@ vsp_runner() { format=$__vsp_rpf_format size=$(vsp1_entity_get_size $entity 0) file=${frames_dir}${entity}.bin - generate_input_frame $file $format $size + generate_input_frame $entity $file $format $size ;; wpf.*) @@ -982,7 +1042,17 @@ vsp_runner() { ;; esac - $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} \ + if [ x$format != 'x' ] ; then + if [ $(format_v4l2_to_mbus $format) = 'AYUV8_1X32' ] ; then + local encoding=$(echo $__vsp_encoding | tr '[:lower:]-' '[:upper:]_') + local quantization=$(echo $__vsp_quantization | tr '[:lower:]-' '[:upper:]_') + csc="--encoding $encoding --quantization $quantization" + else + csc="--encoding 601 --quantization FULL_RANGE" + fi + fi + + $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} $csc \ ${skip:+--skip $skip} ${file:+--file=$file} ${pause:+-p$pause} \ $videodev | ./logger.sh $entity >> $logfile } |