a "lowdds" transform: keep ONLY dds textures
authorRudolf Polzer <divVerent@alientrap.org>
Thu, 5 Aug 2010 13:16:29 +0000 (15:16 +0200)
committerRudolf Polzer <divVerent@alientrap.org>
Thu, 5 Aug 2010 13:16:29 +0000 (15:16 +0200)
all
misc/tools/cached-converter.sh

diff --git a/all b/all
index 6380df5cb9534c1d3e2db6c7d48b1187cb631254..c0ed752479214f4e006dc4a7b952861e5f0c8cba 100755 (executable)
--- a/all
+++ b/all
@@ -999,6 +999,19 @@ case "$cmd" in
                export ogg_qual=1
                find models textures sound/cdtracks -type f -print0 | xargs -0 "$d0"/misc/tools/cached-converter.sh
                ;;
+       release-buildpk3-transform-lowdds)
+               dir=$1
+               cd "$dir"
+               # texture: convert to jpeg and dds
+               # music: reduce bitrate
+               export do_jpeg=false
+               export do_dds=true
+               export dds_flags=
+               export do_ogg=true
+               export ogg_qual=1
+               export del_src=true
+               find models textures sound/cdtracks -type f -print0 | xargs -0 "$d0"/misc/tools/cached-converter.sh
+               ;;
        release-buildpk3)
                src=$1
                dst=$2
@@ -1051,10 +1064,10 @@ case "$cmd" in
                ;;
        release-pack)
                "$SELF" release-buildpk3s data/font-nimbussansl.pk3dir             raw ''
-               "$SELF" release-buildpk3s data/xonotic-data.pk3dir       normal '' raw '-raw' low '-low'
-               "$SELF" release-buildpk3s data/xonotic-maps.pk3dir       normal '' raw '-raw' low '-low'
-               "$SELF" release-buildpk3s data/xonotic-music.pk3dir      normal '' raw '-raw' low '-low'
-               "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir                       low ''
+               "$SELF" release-buildpk3s data/xonotic-data.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
+               "$SELF" release-buildpk3s data/xonotic-maps.pk3dir       normal '' raw '-raw' low '-low' lowdds '-lowdds'
+               "$SELF" release-buildpk3s data/xonotic-music.pk3dir      normal '' raw '-raw' low '-low' lowdds '-lowdds'
+               "$SELF" release-buildpk3s data/xonotic-nexcompat.pk3dir                       low ''     lowdds '-lowdds'
                ;;
        release-pack-needsx11)
                case "$DISPLAY" in
index 80cdcc341c26f19a5d38d9cac6980319b97a459b..71709e5fe1b1f43b2e81f97c18f63a8fb97e3d09 100755 (executable)
@@ -10,6 +10,7 @@ set -e
 : ${dds_tool:=compressonator-dxtc}
 : ${do_ogg:=false}
 : ${ogg_qual:=1}
+: ${del_src:=false}
 
 me=$0
 case "$me" in
@@ -36,6 +37,9 @@ cached()
        if ! $flag; then
                return 0
        fi
+       if [ x"$infile1" = x"$outfile1" ]; then
+               keep=true
+       fi
        options=`echo "$*" | git hash-object --stdin`
        sum=`git hash-object "$infile1"`
        if [ -n "$infile2" ]; then
@@ -49,11 +53,13 @@ cached()
        if [ -f "$name1" ] && { [ -z "$outfile2" ] || [ -f "$name2" ]; }; then
                case "$outfile1" in */*) mkdir -p "${outfile1%/*}"; esac && { ln "$name1" "$outfile1" 2>/dev/null || cp "$name1" "$outfile1"; }
                [ -z "$outfile2" ] || { case "$outfile2" in */*) mkdir -p "${outfile2%/*}"; esac && { ln "$name2" "$outfile2" 2>/dev/null || cp "$name2" "$outfile2"; }; }
+               conv=true
        elif "$method" "$infile1" "$infile2" "$tempfile1" "$tempfile2" "$@"; then
                mv "$tempfile1" "$name1"
                [ -z "$outfile2" ] || mv "$tempfile2" "$name2"
                case "$outfile1" in */*) mkdir -p "${outfile1%/*}"; esac && { ln "$name1" "$outfile1" 2>/dev/null || cp "$name1" "$outfile1"; }
                [ -z "$outfile2" ] || { case "$outfile2" in */*) mkdir -p "${outfile2%/*}"; esac && { ln "$name2" "$outfile2" 2>/dev/null || cp "$name2" "$outfile2"; }; }
+               conv=true
        else
                rm -f "$tempfile1"
                rm -f "$tempfile2"
@@ -145,34 +151,47 @@ has_alpha()
 
 for F in "$@"; do
        echo >&2 "Handling $F..."
+       conv=false
+       keep=false
        case "$F" in
-       *_alpha.jpg)
-               # handle in *.jpg case
-               ;;
-       *.jpg)
-               if [ -f "${F%.jpg}_alpha.jpg" ]; then
-                       cached "$do_dds"  reduce_jpeg2_dds   "$F" "${F%.*}_alpha.jpg" "dds/${F%.*}.dds" ""                  "$dds_flags"
-                       cached "$do_jpeg" reduce_jpeg2_jpeg2 "$F" "${F%.*}_alpha.jpg" "$F"              "${F%.*}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a"
-               else                                   
-                       cached "$do_dds"  reduce_rgb_dds     "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
-                       cached "$do_jpeg" reduce_jpeg_jpeg   "$F" ""                  "$F"              ""                  "$jpeg_qual_rgb"
-               fi
-               ;;
-       *.png|*.tga)
-               cached true has_alpha "$F" "" "$F.hasalpha" ""
-               if [ -s "$F.hasalpha" ]; then
-                       cached "$do_dds"  reduce_rgba_dds    "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
-                       cached "$do_jpeg" reduce_rgba_jpeg2  "$F" ""                  "${F%.*}.jpg"     "${F%.*}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a"
-                       rm -f "$F"
-               else                                                             
-                       cached "$do_dds"  reduce_rgb_dds     "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
-                       cached "$do_jpeg" reduce_rgb_jpeg    "$F" ""                  "${F%.*}.jpg"     ""                  "$jpeg_qual_rgb"
-                       rm -f "$F"
-               fi
-               rm -f "$F.hasalpha"
-               ;;
-       *.ogg)
-               cached "$do_ogg" reduce_ogg "$F" "" "$F" "" "$ogg_qual"
-               ;;
+               *_alpha.jpg)
+                       # handle in *.jpg case
+
+                       # they always got converted, I assume
+                       conv=true
+                       keep=$do_jpeg
+                       ;;
+               *.jpg)
+                       if [ -f "${F%.jpg}_alpha.jpg" ]; then
+                               cached "$do_dds"  reduce_jpeg2_dds   "$F" "${F%.*}_alpha.jpg" "dds/${F%.*}.dds" ""                  "$dds_flags"
+                               cached "$do_jpeg" reduce_jpeg2_jpeg2 "$F" "${F%.*}_alpha.jpg" "$F"              "${F%.*}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a"
+                       else                                   
+                               cached "$do_dds"  reduce_rgb_dds     "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
+                               cached "$do_jpeg" reduce_jpeg_jpeg   "$F" ""                  "$F"              ""                  "$jpeg_qual_rgb"
+                       fi
+                       ;;
+               *.png|*.tga)
+                       cached true has_alpha "$F" "" "$F.hasalpha" ""
+                       if [ -s "$F.hasalpha" ]; then
+                               cached "$do_dds"  reduce_rgba_dds    "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
+                               cached "$do_jpeg" reduce_rgba_jpeg2  "$F" ""                  "${F%.*}.jpg"     "${F%.*}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a"
+                               rm -f "$F" # TGA becomes useless after JPEGging
+                       else                                                             
+                               cached "$do_dds"  reduce_rgb_dds     "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
+                               cached "$do_jpeg" reduce_rgb_jpeg    "$F" ""                  "${F%.*}.jpg"     ""                  "$jpeg_qual_rgb"
+                               rm -f "$F" # TGA becomes useless after JPEGging
+                       fi
+                       rm -f "$F.hasalpha"
+                       ;;
+               *.ogg)
+                       cached "$do_ogg" reduce_ogg "$F" "" "$F" "" "$ogg_qual"
+                       ;;
        esac
+       if $del_src; then
+               if $conv; then
+                       if ! $keep; then
+                               rm -f "$F"
+                       fi
+               fi
+       fi
 done