Allow scripts use different a values for down / up
Change-Id: I7efc912cad2101433682759c4a7ac86610e1add1
diff --git a/tools/lanczos/lanczos_README.txt b/tools/lanczos/lanczos_README.txt
index f15b87e..c323ed0 100644
--- a/tools/lanczos/lanczos_README.txt
+++ b/tools/lanczos/lanczos_README.txt
@@ -169,10 +169,16 @@
<num_frames> is number of frames to process
<horz_resampling_config> is in the format:
<horz_p>:<horz_q>:<Lanczos_horz_a>[:<horz_x0>:<horz_ext>]
- similar to what is used by lanczos_resample_y4m utility.
+ similar to what is used by lanczos_resample_y4m utility,
+ with the optional enhancement that for <Lanczos_horz_a> two
+ comma-separated values of 'a' could be provided instead of one
+ for down and up-sampling operations respectively if different.
<vert_resampling_config> is in the format:
<vert_p>:<vert_q>:<Lanczos_vert_a>[:<vert_x0>:<vert_ext>]
- similar to what is used by lanczos_resample_y4m utility.
+ similar to what is used by lanczos_resample_y4m utility,
+ with the optional enhancement that for <Lanczos_vert_a> two
+ comma-separated values of 'a' could be provided instead of one
+ for down and up-sampling operations respectively if different.
<downup_y4m> is the output y4m video.
<down_y4m> provides the intermedite resampled file as an
optional parameter. If skipped the intermediate resampled
@@ -181,16 +187,22 @@
Example usages:
5. Similar to use case 1a and 1b above.
- From build directory run:
- /path/to/script/lanczos_downup.sh Boat_1920x1080_60fps_10bit_420.y4m \
- 20 2:3:6 3:4:6 /tmp/downup.y4m
- [Here the intermediate resampled files is not stored]
+(a) From build directory run:
+ /path/to/script/lanczos_downup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6 3:4:6 /tmp/downup.y4m
+ [Here the intermediate resampled files is not stored]
- From build directory run:
- /path/to/script/lanczos_downup.sh Boat_1920x1080_60fps_10bit_420.y4m \
- 20 2:3:6 3:4:6 /tmp/downup.y4m \
- /tmp/down.y4m
- [Here the intermediate resampled files is stored in /tmp/down.y4m]
+(b) From build directory run:
+ /path/to/script/lanczos_downup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6 3:4:6 /tmp/downup.y4m \
+ /tmp/down.y4m
+ [Here the intermediate resampled files is stored in /tmp/down.y4m]
+
+(c) From build directory run:
+ /path/to/script/lanczos_downup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:4,8 3:4:4,8 /tmp/downup.y4m
+ [Here Lanczos parameters 4 and 8 are used for down and upscaling
+ respectively]
lanczos_downcompup.sh
---------------------
@@ -212,10 +224,16 @@
<num_frames> is number of frames to process
<horz_resampling_config> is in the format:
<horz_p>:<horz_q>:<Lanczos_horz_a>[:<horz_x0>:<horz_ext>]
- similar to what is used by lanczos_resample_y4m utility.
+ similar to what is used by lanczos_resample_y4m utility,
+ with the optional enhancement that for <Lanczos_horz_a> two
+ comma-separated values of 'a' could be provided instead of one
+ for down and up-sampling operations respectively if different.
<vert_resampling_config> is in the format:
<vert_p>:<vert_q>:<Lanczos_vert_a>[:<vert_x0>:<vert_ext>]
- similar to what is used by lanczos_resample_y4m utility.
+ similar to what is used by lanczos_resample_y4m utility,
+ with the optional enhancement that for <Lanczos_vert_a> two
+ comma-separated values of 'a' could be provided instead of one
+ for down and up-sampling operations respectively if different.
<cq_level>[:<cpu_used>] provides the cq_level parameter of
compression along with an optional cpu_used parameter.
<downcompup_y4m> is the output y4m video.
@@ -233,22 +251,28 @@
Example usages:
6. Similar to use case 1a and 1b above with a compression step in between.
- From build directory run:
- /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
- 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m
- [Here no intermediate files are stored]
+(a) From build directory run:
+ /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m
+ [Here no intermediate files are stored]
- From build directory run:
- /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
- 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m \
- /tmp/down.y4m::/tmp/downrec.y4m
- [Here the resampled source and its compressed reconstruction are
- stoted in /tmp/down.y4m and /tmp/downrec.y4m respectively].
+(b) From build directory run:
+ /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m \
+ /tmp/down.y4m::/tmp/downrec.y4m
+ [Here the resampled source and its compressed reconstruction are
+ stoted in /tmp/down.y4m and /tmp/downrec.y4m respectively].
- From build directory run:
- /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
- 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m \
- /tmp/down.y4m:/tmp/down.bit:/tmp/downrec.y4m
- [Here the resampled source, its compressed bitstream, and the
- conpressed reconstruction are stoted in /tmp/down.y4m,
- /tmp/downcomp.bit and /tmp/downrec.y4m respectively].
+(c) From build directory run:
+ /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6 3:4:6 40:5 /tmp/downup.y4m \
+ /tmp/down.y4m:/tmp/down.bit:/tmp/downrec.y4m
+ [Here the resampled source, its compressed bitstream, and the
+ conpressed reconstruction are stoted in /tmp/down.y4m,
+ /tmp/downcomp.bit and /tmp/downrec.y4m respectively].
+
+(d) From build directory run:
+ /path/to/script/lanczos_downcompup.sh Boat_1920x1080_60fps_10bit_420.y4m \
+ 20 2:3:6,8 3:4:6,8 40:5 /tmp/downup.y4m
+ [Here Lanczos parameters 4 and 8 are used for down and upscaling
+ respectively]
diff --git a/tools/lanczos/lanczos_downcompup.sh b/tools/lanczos/lanczos_downcompup.sh
index f211777..b385693 100755
--- a/tools/lanczos/lanczos_downcompup.sh
+++ b/tools/lanczos/lanczos_downcompup.sh
@@ -13,10 +13,16 @@
# <num_frames> is number of frames to process
# <horz_resampling_config> is in the format:
# <horz_p>:<horz_q>:<Lanczos_horz_a>[:<horz_x0>:<horz_ext>]
-# similar to what is used by lanczos_resample_y4m utility.
+# similar to what is used by lanczos_resample_y4m utility,
+# with the optional enhancement that for <Lanczos_horz_a> two
+# comma-separated values of 'a' could be provided instead of one
+# for down and up-sampling operations respectively if different.
# <vert_resampling_config> is in the format:
# <vert_p>:<vert_q>:<Lanczos_vert_a>[:<vert_x0>:<vert_ext>]
-# similar to what is used by lanczos_resample_y4m utility.
+# similar to what is used by lanczos_resample_y4m utility,
+# with the optional enhancement that for <Lanczos_vert_a> two
+# comma-separated values of 'a' could be provided instead of one
+# for down and up-sampling operations respectively if different.
# <cq_level>[:<cpu_used>] provides the cq_level parameter of
# compression along with an optional cpu_used parameter.
# <downcompup_y4m> is the output y4m video.
@@ -34,6 +40,11 @@
set -e
+if [[ $# -lt "6" ]]; then
+ echo "Too few parameters $#"
+ exit 1;
+fi
+
tmpdir="/tmp"
AOMENC="${tmpdir}/aomenc_$$"
AOMDEC="${tmpdir}/aomdec_$$"
@@ -88,19 +99,38 @@
#Obtain the horizontal and vertical upsampling configs
hdconfig_arr=(${hdconfig//:/ })
-huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${hdconfig_arr[2]}"
+haparams=${hdconfig_arr[2]}
+OIFS="$IFS"; IFS=',' haparams_arr=($haparams); IFS="$OIFS"
+hdconfig="${hdconfig_arr[0]}:${hdconfig_arr[1]}:${haparams_arr[0]}"
+if [[ -z ${haparams_arr[1]} ]]; then
+ huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${haparams_arr[0]}"
+else
+ huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${haparams_arr[1]}"
+fi
if [[ -n ${hdconfig_arr[3]} ]]; then
+ hdconfig="${hdconfig}:${hdconfig_arr[3]}"
huconfig="${huconfig}:i${hdconfig_arr[3]}"
fi
if [[ -n ${hdconfig_arr[4]} ]]; then
+ hdconfig="${hdconfig}:${hdconfig_arr[4]}"
huconfig="${huconfig}:${hdconfig_arr[4]}"
fi
+
vdconfig_arr=(${vdconfig//:/ })
-vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vdconfig_arr[2]}"
+vaparams=${vdconfig_arr[2]}
+OIFS="$IFS"; IFS=',' vaparams_arr=($vaparams); IFS="$OIFS"
+vdconfig="${vdconfig_arr[0]}:${vdconfig_arr[1]}:${vaparams_arr[0]}"
+if [[ -z ${vaparams_arr[1]} ]]; then
+ vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vaparams_arr[0]}"
+else
+ vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vaparams_arr[1]}"
+fi
if [[ -n ${vdconfig_arr[3]} ]]; then
+ vdconfig="${vdconfig}:${vdconfig_arr[3]}"
vuconfig="${vuconfig}:i${vdconfig_arr[3]}"
fi
if [[ -n ${vdconfig_arr[4]} ]]; then
+ vdconfig="${vdconfig}:${vdconfig_arr[4]}"
vuconfig="${vuconfig}:${vdconfig_arr[4]}"
fi
diff --git a/tools/lanczos/lanczos_downup.sh b/tools/lanczos/lanczos_downup.sh
index 82b247c..4edf7fa 100755
--- a/tools/lanczos/lanczos_downup.sh
+++ b/tools/lanczos/lanczos_downup.sh
@@ -12,10 +12,16 @@
# <num_frames> is number of frames to process
# <horz_resampling_config> is in the format:
# <horz_p>:<horz_q>:<Lanczos_horz_a>[:<horz_x0>:<horz_ext>]
-# similar to what is used by lanczos_resample_y4m utility.
+# similar to what is used by lanczos_resample_y4m utility,
+# with the optional enhancement that for <Lanczos_horz_a> two
+# comma-separated values of 'a' could be provided instead of one
+# for down and up-sampling operations respectively if different.
# <vert_resampling_config> is in the format:
# <vert_p>:<vert_q>:<Lanczos_vert_a>[:<vert_x0>:<vert_ext>]
-# similar to what is used by lanczos_resample_y4m utility.
+# similar to what is used by lanczos_resample_y4m utility,
+# with the optional enhancement that for <Lanczos_vert_a> two
+# comma-separated values of 'a' could be provided instead of one
+# for down and up-sampling operations respectively if different.
# <downup_y4m> is the output y4m video.
# <down_y4m> provides the intermedite resampled file as an
# optional parameter. If skipped the intermediate resampled
@@ -34,6 +40,11 @@
trap 'echo "Exiting..."; rm -f ${AOMENC} ${AOMDEC} ${RESAMPLE}' EXIT
+if [[ $# -lt "5" ]]; then
+ echo "Too few parameters $#"
+ exit 1;
+fi
+
input_y4m=$1
nframes=$2
hdconfig=$3
@@ -56,19 +67,38 @@
#Obtain the horizontal and vertical upsampling configs
hdconfig_arr=(${hdconfig//:/ })
-huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${hdconfig_arr[2]}"
+haparams=${hdconfig_arr[2]}
+OIFS="$IFS"; IFS=',' haparams_arr=($haparams); IFS="$OIFS"
+hdconfig="${hdconfig_arr[0]}:${hdconfig_arr[1]}:${haparams_arr[0]}"
+if [[ -z ${haparams_arr[1]} ]]; then
+ huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${haparams_arr[0]}"
+else
+ huconfig="${hdconfig_arr[1]}:${hdconfig_arr[0]}:${haparams_arr[1]}"
+fi
if [[ -n ${hdconfig_arr[3]} ]]; then
+ hdconfig="${hdconfig}:${hdconfig_arr[3]}"
huconfig="${huconfig}:i${hdconfig_arr[3]}"
fi
if [[ -n ${hdconfig_arr[4]} ]]; then
+ hdconfig="${hdconfig}:${hdconfig_arr[4]}"
huconfig="${huconfig}:${hdconfig_arr[4]}"
fi
+
vdconfig_arr=(${vdconfig//:/ })
-vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vdconfig_arr[2]}"
+vaparams=${vdconfig_arr[2]}
+OIFS="$IFS"; IFS=',' vaparams_arr=($vaparams); IFS="$OIFS"
+vdconfig="${vdconfig_arr[0]}:${vdconfig_arr[1]}:${vaparams_arr[0]}"
+if [[ -z ${vaparams_arr[1]} ]]; then
+ vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vaparams_arr[0]}"
+else
+ vuconfig="${vdconfig_arr[1]}:${vdconfig_arr[0]}:${vaparams_arr[1]}"
+fi
if [[ -n ${vdconfig_arr[3]} ]]; then
+ vdconfig="${vdconfig}:${vdconfig_arr[3]}"
vuconfig="${vuconfig}:i${vdconfig_arr[3]}"
fi
if [[ -n ${vdconfig_arr[4]} ]]; then
+ vdconfig="${vdconfig}:${vdconfig_arr[4]}"
vuconfig="${vuconfig}:${vdconfig_arr[4]}"
fi