X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=misc%2Ftools%2Fcached-converter.sh;h=e89a0f1890e63057d15c5fb28f42431c2b10b84d;hp=0eab3d6946f5ae9fc10048afd7704ffb38a35c97;hb=5cad1221bc09e1746b1b4a7c7d5588234e2b4535;hpb=fc00291a3cabd0fc24767a221a9231f27c1a3e97 diff --git a/misc/tools/cached-converter.sh b/misc/tools/cached-converter.sh index 0eab3d69..e89a0f18 100755 --- a/misc/tools/cached-converter.sh +++ b/misc/tools/cached-converter.sh @@ -41,6 +41,7 @@ cached() if ! $flag; then return 0 fi + #sleep 0.25 if [ x"$infile1" = x"$outfile1" ]; then keep=true fi @@ -49,9 +50,9 @@ cached() sum=$lastinfileshash else if [ -n "$git_src_repo" ]; then - sum=`( cd "$git_src_repo"; git rev-parse HEAD:"$infile1" )` + sum=`( cd "$git_src_repo"; git rev-parse --revs-only HEAD:"${infile1#./}" | grep . ) || git hash-object "$infile1"` if [ -n "$infile2" ]; then - sum=`( cd "$git_src_repo"; git rev-parse HEAD:"$infile2" )` + sum=$sum`( cd "$git_src_repo"; git rev-parse --revs-only HEAD:"${infile2#./}" | grep . ) || git hash-object "$infile2"` fi else sum=`git hash-object "$infile1"` @@ -113,10 +114,10 @@ reduce_ogg_ogg() { i=$1; shift; shift o=$1; shift; shift - tags=`vorbiscomment -R -l "$i"` + tags=`vorbiscomment -R -l "$i" || true` oggdec -o "$tmpdir/x.wav" "$i" && \ oggenc -q"$1" -o "$o" "$tmpdir/x.wav" - echo "$tags" | vorbiscomment -R -w "$o" + echo "$tags" | vorbiscomment -R -w "$o" || true } reduce_wav_ogg() @@ -157,7 +158,7 @@ reduce_rgb_jpeg() { i=$1; shift; shift o=$1; shift; shift - convert "$i" "$o" && \ + convert "$i" -quality 100 "$o" && \ jpegoptim --strip-all -m"$1" "$o" } @@ -181,6 +182,8 @@ for F in "$@"; do echo >&2 "Handling $F..." conv=false keep=false + jqual_rgb=$jpeg_qual_rgb + jqual_a=$jpeg_qual_a will_jpeg=$do_jpeg will_dds=$do_dds @@ -199,6 +202,21 @@ for F in "$@"; do ;; esac + # for deluxemaps, lightmaps and normalmaps, enforce high jpeg quality (like on alpha channels) + if [ "$jqual_a" -gt "$jqual_rgb" ]; then + case "$f" in + ./maps/*/lm_[0-9][0-9][0-9][13579]) # deluxemap + jqual_rgb=$jqual_a + ;; + ./maps/*/lm_[0-9][0-9][0-9][02468]) # lightmap + jqual_rgb=$jqual_a + ;; + *_norm) # normalmap + jqual_rgb=$jqual_a + ;; + esac + fi + if $do_jpeg_if_not_dds; then if $will_dds; then will_jpeg=false @@ -220,10 +238,10 @@ for F in "$@"; do *.jpg) if [ -f "${f}_alpha.jpg" ]; then cached "$will_dds" reduce_jpeg2_dds "$F" "${f}_alpha.jpg" "dds/${f}.dds" "" "$dds_flags" - cached "$will_jpeg" reduce_jpeg2_jpeg2 "$F" "${f}_alpha.jpg" "$F" "${f}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a" + cached "$will_jpeg" reduce_jpeg2_jpeg2 "$F" "${f}_alpha.jpg" "$F" "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a" else cached "$will_dds" reduce_rgb_dds "$F" "" "dds/${f}.dds" "" "$dds_flags" - cached "$will_jpeg" reduce_jpeg_jpeg "$F" "" "$F" "" "$jpeg_qual_rgb" + cached "$will_jpeg" reduce_jpeg_jpeg "$F" "" "$F" "" "$jqual_rgb" fi ;; *.png|*.tga) @@ -231,10 +249,10 @@ for F in "$@"; do conv=false if [ -s "$F.hasalpha" ]; then cached "$will_dds" reduce_rgba_dds "$F" "" "dds/${f}.dds" "" "$dds_flags" - cached "$will_jpeg" reduce_rgba_jpeg2 "$F" "" "${f}.jpg" "${f}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a" + cached "$will_jpeg" reduce_rgba_jpeg2 "$F" "" "${f}.jpg" "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a" else cached "$will_dds" reduce_rgb_dds "$F" "" "dds/${f}.dds" "" "$dds_flags" - cached "$will_jpeg" reduce_rgb_jpeg "$F" "" "${f}.jpg" "" "$jpeg_qual_rgb" + cached "$will_jpeg" reduce_rgb_jpeg "$F" "" "${f}.jpg" "" "$jqual_rgb" fi rm -f "$F.hasalpha" ;;