summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
Diffstat (limited to 'TOOLS')
-rwxr-xr-xTOOLS/svg2ico.sh64
-rwxr-xr-xTOOLS/umpv91
-rwxr-xr-xTOOLS/vdpau_functions.pl74
3 files changed, 155 insertions, 74 deletions
diff --git a/TOOLS/svg2ico.sh b/TOOLS/svg2ico.sh
new file mode 100755
index 0000000000..84aadf212b
--- /dev/null
+++ b/TOOLS/svg2ico.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+set -e
+
+if [ $# -ne 2 ]; then
+ echo >&2 "Usage: $0 input.svg output.ico"
+ exit 1
+fi
+
+# For smooth rendering on high-DPI displays, the standard three app icon sizes
+# (16x16, 32x32 and 48x48) have to be scaled to the four Windows DPI settings
+# as in the table below:
+
+# Small Regular Tiles
+# 96 DPI (100%) 16x16 32x32 48x48
+# 120 DPI (125%) 20x20 40x40 60x60
+# 144 DPI (150%) 24x24 48x48 72x72
+# 196 DPI (200%) 32x32 64x64 96x96
+
+# Also, there should also be an extra large 256x256 icon and some low colour
+# 8-bit and 4-bit variants, which are still used in Remote Desktop.
+
+# Note: Windows Vista has a bug in its icon scaling that makes no sense.
+# Instead of following the DPI setting, small icons are always a bit larger
+# than they should be at 22x22, 26x26 and 36x36 for 120, 144 and 196 DPI. This
+# script doesn't generate icons with those sizes, since computers with Vista
+# and a high-DPI display are probably fairly rare these days.
+
+temppng=".$(basename "$1" .svg)-temp.png"
+
+inkscape --without-gui --export-png="$temppng" --export-dpi=72 \
+ --export-background-opacity=0 --export-width=512 --export-height=512 \
+ "$1" >/dev/null 2>&1
+
+# Old versions of ImageMagick (like the one in Cygwin) use the wrong gamma when
+# exporting icon files. To fix, add -gamma 2.2 after the input file.
+
+convert png:"$temppng" -filter lanczos2 \
+ \( -clone 0 -resize 96x96 \) \
+ \( -clone 0 -resize 72x72 \) \
+ \( -clone 0 -resize 64x64 \) \
+ \( -clone 0 -resize 60x60 \) \
+ \( -clone 0 -resize 48x48 \) \
+ \( -clone 0 -resize 40x40 \) \
+ \( -clone 0 -resize 32x32 \) \
+ \( -clone 0 -resize 24x24 \) \
+ \( -clone 0 -resize 20x20 \) \
+ \( -clone 0 -resize 16x16 \) \
+ \( -clone 0 -resize 256x256 \) \
+ \( -clone 0 -resize 32x32 \( -clone 0 -alpha opaque -colors 255 \) \
+ \( -clone 0 -channel A -threshold 50% \) \
+ -delete 0 -compose CopyOpacity -composite -colors 256 \) \
+ \( -clone 0 -resize 16x16 \( -clone 0 -alpha opaque -colors 255 \) \
+ \( -clone 0 -channel A -threshold 50% \) \
+ -delete 0 -compose CopyOpacity -composite -colors 256 \) \
+ \( -clone 0 -resize 32x32 \( -clone 0 -alpha opaque -colors 15 \) \
+ \( -clone 0 -channel A -threshold 50% \) \
+ -delete 0 -compose CopyOpacity -composite -colors 16 \) \
+ \( -clone 0 -resize 16x16 \( -clone 0 -alpha opaque -colors 15 \) \
+ \( -clone 0 -channel A -threshold 50% \) \
+ -delete 0 -compose CopyOpacity -composite -colors 16 \) \
+ -delete 0 \
+ -define png:compression-level=9 -define png:include-chunk=none ico:"$2"
+
+rm "$temppng"
diff --git a/TOOLS/umpv b/TOOLS/umpv
new file mode 100755
index 0000000000..df1c089bc1
--- /dev/null
+++ b/TOOLS/umpv
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+
+"""
+This script emulates "unique application" functionality on Linux. When starting
+playback with this script, it will try to reuse an already running instance of
+mpv (but only if that was started with umpv).
+
+This script only uses mpv instances started with umpv. Other instances are
+ignored, and don't exist for the script.
+
+This only takes filenames as arguments. If mpv is already running, they are
+appended to mpv's internal playlist. If the file does not exist or is otherwise
+not playable, mpv will skip the playlist entry when attempting to play it (from
+the GUI perspective, it's silently ignored).
+
+If mpv isn't running yet, this script will start mpv and let it control the
+current terminal. If you play an audio-only file, mpv will not open a window
+(that is its normal behavior; but it might not be what a user expects if this
+script is used in a GUI setting).
+
+mpv will terminate if there are no more files to play, and running the umpv
+script after that will start a new mpv instance.
+
+Note that you can control the mpv instance by writing to the command fifo:
+
+ echo "cycle fullscreen" > /tmp/umpv-fifo-*
+
+Warning:
+
+The script attempts to make sure the FIFO is safely created (i.e. not world-
+readable, not trying to open a bogus
+"""
+
+import sys
+import os
+import errno
+import subprocess
+import fcntl
+import stat
+
+if len(sys.argv) < 2:
+ print("error: needs at least one file as argument.")
+ sys.exit(1)
+files = sys.argv[1:]
+# make them absolute; also makes them safe against interpretation as options
+files = [os.path.abspath(f) for f in files]
+
+FIFO = "/tmp/umpv-fifo-" + os.getenv("USER")
+
+fifo_fd = -1
+try:
+ fifo_fd = os.open(FIFO, os.O_NONBLOCK | os.O_WRONLY)
+except OSError as e:
+ if e.errno == errno.ENXIO:
+ pass # pipe has no writer
+ elif e.errno == errno.ENOENT:
+ pass # doesn't exist
+ else:
+ raise e
+
+if fifo_fd >= 0:
+ st = os.fstat(fifo_fd)
+ if (((st.st_mode & (stat.S_IRWXG | stat.S_IRWXO)) != 0) or
+ (not stat.S_ISFIFO(st.st_mode)) or
+ (st.st_uid != os.getuid())):
+ print("error: command FIFO is not a FIFO or has bogus permissions")
+ sys.exit(1)
+
+if fifo_fd >= 0:
+ # Unhandled race condition: what if mpv is terminating right now?
+ fcntl.fcntl(fifo_fd, fcntl.F_SETFL, 0) # set blocking mode
+ fifo = os.fdopen(fifo_fd, "w")
+ for f in files:
+ # escape: \ \n "
+ f = f.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
+ f = "\"" + f + "\""
+ fifo.write("raw loadfile " + f + " append\n")
+else:
+ # Recreate pipe if it doesn't already exist.
+ # Also makes sure it's safe, and no other user can create a bogus pipe
+ # that breaks security.
+ try:
+ os.unlink(FIFO)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+ os.mkfifo(FIFO, 0600)
+
+ subprocess.check_call(["mpv", "--input-file=" + FIFO] + files)
diff --git a/TOOLS/vdpau_functions.pl b/TOOLS/vdpau_functions.pl
deleted file mode 100755
index 8bab4e533b..0000000000
--- a/TOOLS/vdpau_functions.pl
+++ /dev/null
@@ -1,74 +0,0 @@
-#! /usr/bin/env perl
-
-# Generates vdpau_template.c
-
-use strict;
-use warnings;
-
-sub camelize($) {
- my $s = shift;
- $s =~ s/(?:^|_)([a-z])/\u$1/g;
- $s;
-}
-
-print <<EOF;
-/* Lists the VDPAU functions used by MPV.
- * Generated by vdpau_functions.pl.
- * First argument on each line is the VDPAU function type name,
- * second is the macro name needed to get the function address,
- * third is the name MPV uses for the function.
- */
-
-EOF
-
-while (my $f = <DATA>) {
- # strip whitespace, ignore anything after a '#'
- $f =~ /^\s*(.*?)\s*(?:(?<!\\)#.*)?$/;
- $f = $1;
- next unless $f; # empty / comment line
-
- my ($mp_name, $vdpau_name) = split /\s+/, $f;
- $vdpau_name = camelize $mp_name unless $vdpau_name;
-
- print "VDP_FUNCTION(Vdp$vdpau_name, VDP_FUNC_ID_\U$mp_name\E, $mp_name)\n";
-}
-
-__DATA__
-# get_error_string should be first, because the function lookup loop should
-# have it available to print errors for other functions
-get_error_string
-
-bitmap_surface_create
-bitmap_surface_destroy
-bitmap_surface_put_bits_native
-bitmap_surface_query_capabilities
-decoder_create
-decoder_destroy
-decoder_render
-device_destroy
-generate_csc_matrix GenerateCSCMatrix # CSC completely capitalized
-output_surface_create
-output_surface_destroy
-output_surface_get_bits_native
-output_surface_put_bits_indexed
-output_surface_put_bits_native
-output_surface_render_bitmap_surface
-output_surface_render_output_surface
-preemption_callback_register
-presentation_queue_block_until_surface_idle
-presentation_queue_create
-presentation_queue_destroy
-presentation_queue_display
-presentation_queue_get_time
-presentation_queue_query_surface_status
-presentation_queue_target_create_x11
-presentation_queue_target_destroy
-video_mixer_create
-video_mixer_destroy
-video_mixer_query_feature_support
-video_mixer_render
-video_mixer_set_attribute_values
-video_mixer_set_feature_enables
-video_surface_create
-video_surface_destroy
-video_surface_put_bits_y_cb_cr