16
def pack_color_32(red, green, blue, alpha = 0xFFFF):
21
return (red << 24 | green << 16 | blue << 8 | alpha)
23
def pack_color_64(red, green, blue, alpha = 0xFFFF):
24
return (red << 48 | green << 32 | blue << 16 | alpha)
21
def pack_color_32(red, green, blue, alpha=0xFFFF):
22
"""Packs the specified 16bit color values in a 32bit RGBA value."""
27
return (red << 24 | green << 16 | blue << 8 | alpha)
29
def pack_color_64(red, green, blue, alpha=0xFFFF):
30
"""Packs the specified 16bit color values in a 64bit RGBA value."""
31
return (red << 48 | green << 32 | blue << 16 | alpha)
26
33
def unpack_color(value):
34
"""Unpacks the specified RGBA value into four 16bit color values.
37
value: A 32bit or 64bit RGBA value.
27
39
if not (value >> 32):
28
40
return unpack_color_32(value)
30
42
return unpack_color_64(value)
32
44
def unpack_color_32(value):
33
red = (value >> 24); red = red | red << 8
34
green = (value >> 16) & 0xFF; green = green | green << 8
35
blue = (value >> 8) & 0xFF; blue = blue | blue << 8
36
alpha = value & 0xFF; alpha = alpha | alpha << 8
45
"""Unpacks the specified 32bit RGBA value into four 16bit color values."""
46
red = (value >> 24) << 8
47
green = ((value >> 16) & 0xFF) << 8
48
blue = ((value >> 8) & 0xFF) << 8
49
alpha = (value & 0xFF) << 8
37
50
return red, green, blue, alpha
39
52
def unpack_color_64(value):
53
"""Unpacks the specified 64bit RGBA value into four 16bit color values."""
40
54
red = (value >> 48) & 0xFFFF
41
55
green = (value >> 32) & 0xFFFF
42
56
blue = (value >> 16) & 0xFFFF
44
58
return red, green, blue, alpha
46
60
def unpack_cairo_pattern(value):
61
"""Transforms the specified RGBA value into a SolidPattern object."""
47
62
red, green, blue, alpha = unpack_color(value)
48
63
return cairo.SolidPattern(
54
69
def unpack_cairo_gradient(value):
70
"""Creates a LinearGradient object out of the specified RGBA value."""
55
71
red, green, blue, alpha = unpack_color(value)
56
ret = cairo.LinearGradient(0,0, 0, 50)
57
ret.add_color_stop_rgba(50,
72
gradient = cairo.LinearGradient(0, 0, 0, 50)
73
gradient.add_color_stop_rgba(
62
ret.add_color_stop_rgba(0,
79
gradient.add_color_stop_rgba(
63
81
(red / 65535.0) * 1.5,
64
82
(green / 65535.0) * 1.5,
65
83
(blue / 65535.0) * 1.5,
69
def beautify_factory(factory):
70
ranks = {VideoStream: 0, AudioStream: 1, TextStream: 2, MultimediaStream: 3}
71
def stream_sort_key(stream):
72
return ranks[type(stream)]
74
streams = factory.getOutputStreams()
75
streams.sort(key=stream_sort_key)
76
return ("<b>" + escape(unquote(factory.name)) + "</b>\n" +
77
"\n".join((beautify_stream(stream) for stream in streams)))
79
def factory_name(factory):
80
return escape(unquote(factory.name))
83
def beautify_stream(stream):
84
if type(stream) == AudioStream:
86
templ = ngettext("<b>Audio:</b> %d channel at %d <i>Hz</i> (%d <i>bits</i>)",
87
"<b>Audio:</b> %d channels at %d <i>Hz</i> (%d <i>bits</i>)",
89
templ = templ % (stream.channels, stream.rate, stream.width)
92
return _("<b>Unknown Audio format:</b> %s") % stream.audiotype
94
elif type(stream) == VideoStream:
96
if stream.framerate.num:
97
templ = _("<b>Video:</b> %d x %d <i>pixels</i> at %.2f<i>fps</i>")
98
templ = templ % (stream.par * stream.width , stream.height,
99
float(stream.framerate))
101
templ = _("<b>Image:</b> %d x %d <i>pixels</i>")
102
templ = templ % (stream.par * stream.width, stream.height)
104
return _("<b>Unknown Video format:</b> %s") % stream.videotype
106
elif type(stream) == TextStream:
107
return _("<b>Text:</b> %s") % stream.texttype
109
raise NotImplementedError
111
87
def beautify_factory(factory):
112
88
ranks = {VideoStream: 0, AudioStream: 1, TextStream: 2, MultimediaStream: 3}
170
146
context.curve_to(x,y,x,y,x+r,y) # Curve to A
149
def model(columns, data):
150
ret = gtk.ListStore(*columns)
155
frame_rates = model((str, object), (
156
(_("12 fps"), gst.Fraction(12.0, 1.0)),
157
(_("15 fps"), gst.Fraction(15.0, 1.0)),
158
(_("20 fps"), gst.Fraction(20.0, 1.0)),
159
(_("23,976 fps"), gst.Fraction(24000.0, 1001.0)),
160
(_("24 fps"), gst.Fraction(24.0, 1.0)),
161
(_("25 fps"), gst.Fraction(25.0, 1.0)),
162
(_("29,97 fps"), gst.Fraction(30000.0, 1001.0)),
163
(_("30 fps"), gst.Fraction(30.0, 1.0)),
164
(_("50 fps"), gst.Fraction(50.0, 1.0)),
165
(_("59,94 fps"), gst.Fraction(60000.0, 1001.0)),
166
(_("60 fps"), gst.Fraction(60.0, 1.0)),
167
(_("120 fps"), gst.Fraction(120.0, 1.0)),
170
audio_rates = model((str, int), (
172
(_("11 KHz"), 11025),
173
(_("22 KHz"), 22050),
174
(_("44.1 KHz"), 44100),
175
(_("48 KHz"), 48000),
179
audio_depths = model((str, int), (
186
audio_channels = model((str, int), (
187
(_("6 Channels (5.1)"), 6),
188
(_("4 Channels (4.0)"), 4),
193
def set_combo_value(combo, value, default_index=-1):
194
model = combo.props.model
195
for i, row in enumerate(model):
199
combo.set_active(default_index)
201
def get_combo_value(combo):
202
active = combo.get_active()
203
return combo.props.model[active][1]