On Tue, Jan 20, 2015 at 09:58:33PM +0100, Reimar Döffinger wrote: > On Mon, Jan 19, 2015 at 10:58:02PM +0100, Clément Bœsch wrote: > > - echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | > > bc > > + awk "BEGIN { v=$1-$2; printf \"%d\\n\", ((v<0?v:-v) > $3) ? 1 : 0 }" > > I'd suggest single quotes for the outer ones, then you do not need to > escape \ and ".
Done. I kind of forgot i could 'foo '$1' bar'... > Also it's broken, you inverted the absolute value condition. Oh derp... fixed, sorry. > Lastly, at least with gawk the last ?: is pointless, conditions evaluate > to 1/0 like in C. I originally tried it but probably did it wrong with the parenthesis. Seems it works fine indeed. New patch attached. Thanks. -- Clément B.
From b558464bc43787a2aa50c17373905ce146682595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <u...@pkh.me> Date: Mon, 19 Jan 2015 22:56:59 +0100 Subject: [PATCH] tests: drop bc dependency We already have a dependency on awk, bc is sometimes not found in the base system. --- tests/fate-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index f78e4fc..4a6d354 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -38,7 +38,7 @@ target_path(){ # $1=value1, $2=value2, $3=threshold # prints 0 if absolute difference between value1 and value2 is <= threshold compare(){ - echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc + awk 'BEGIN { v='$1'-'$2'; printf "%d\n", ((v<0?-v:v) > '$3') }' } do_tiny_psnr(){ -- 2.3.0
pgpS7KH39Qvem.pgp
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel