[pitivi: 2/5] fix bug 605445 - Pitivi does not work on big endian machines
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 2/5] fix bug 605445 - Pitivi does not work on big endian machines
- Date: Fri, 3 Dec 2010 17:05:51 +0000 (UTC)
commit 822818aad531ea85081a48e1a4e4a1523120ebac
Author: Benjamin Berg <benjamin sipsolutions net>
Date: Mon Nov 29 11:24:40 2010 +0000
fix bug 605445 - Pitivi does not work on big endian machines
pitivi/elements/arraysink.py | 4 +++-
pitivi/elements/mixer.py | 3 ++-
pitivi/elements/thumbnailsink.py | 17 +++++++++++------
pitivi/utils.py | 9 +++++++++
4 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/elements/arraysink.py b/pitivi/elements/arraysink.py
index 303146b..5a1b8f3 100644
--- a/pitivi/elements/arraysink.py
+++ b/pitivi/elements/arraysink.py
@@ -27,6 +27,7 @@ gobject.threads_init()
import gst
import gtk
import array
+from pitivi.utils import native_endianness
class ArraySink(gst.BaseSink):
@@ -35,9 +36,10 @@ class ArraySink(gst.BaseSink):
"""
caps = gst.Caps(
"audio/x-raw-float, width=(int) 32, "
- "endianness = (int) LITTLE_ENDIAN, "
+ "endianness = (int) %s, "
"channels = (int) 1,"
"rate = (int) [1, 96000]"
+ % native_endianness
)
__gsttemplates__ = (
diff --git a/pitivi/elements/mixer.py b/pitivi/elements/mixer.py
index f03cdc3..bf7a4d4 100644
--- a/pitivi/elements/mixer.py
+++ b/pitivi/elements/mixer.py
@@ -25,6 +25,7 @@ Audio and Video mixers
import gobject
import gst
+from pitivi.utils import native_endianness
from pitivi.signalinterface import Signallable
@@ -51,7 +52,7 @@ class SmartAdderBin(gst.Bin):
self.adder = gst.element_factory_make("adder", "real-adder")
# FIXME : USE THE PROJECT SETTINGS FOR THESE CAPS !
csp = gst.element_factory_make("capsfilter")
- csp.props.caps = gst.Caps("audio/x-raw-int,depth=32,width=32,signed=True,rate=44100,channels=2,endianness=1234")
+ csp.props.caps = gst.Caps("audio/x-raw-int,depth=32,width=32,signed=True,rate=44100,channels=2,endianness=%s" % native_endianness)
self.add(self.adder, csp)
self.adder.link_pads_full("src", csp, "sink", gst.PAD_LINK_CHECK_NOTHING)
srcpad = gst.GhostPad("src", csp.get_pad("src"))
diff --git a/pitivi/elements/thumbnailsink.py b/pitivi/elements/thumbnailsink.py
index 2bc4ed9..0f51041 100644
--- a/pitivi/elements/thumbnailsink.py
+++ b/pitivi/elements/thumbnailsink.py
@@ -26,6 +26,7 @@ import gobject
import gst
import cairo
import array
+from pitivi.utils import big_to_cairo_alpha_mask, big_to_cairo_red_mask, big_to_cairo_green_mask, big_to_cairo_blue_mask
class CairoSurfaceThumbnailSink(gst.BaseSink):
"""
@@ -47,13 +48,17 @@ class CairoSurfaceThumbnailSink(gst.BaseSink):
gst.Caps("video/x-raw-rgb,"
"bpp = (int) 32, depth = (int) 32,"
"endianness = (int) BIG_ENDIAN,"
- "blue_mask = (int) 0xFF000000, "
- "green_mask = (int) 0x00FF0000, "
- "red_mask = (int) 0x0000FF00, "
- "alpha_mask = (int) 0x000000FF, "
+ "alpha_mask = (int) %i, "
+ "red_mask = (int) %i, "
+ "green_mask = (int) %i, "
+ "blue_mask = (int) %i, "
"width = (int) [ 1, max ], "
"height = (int) [ 1, max ], "
- "framerate = (fraction) [ 0, max ]"))
+ "framerate = (fraction) [ 0, max ]"
+ % (big_to_cairo_alpha_mask,
+ big_to_cairo_red_mask,
+ big_to_cairo_green_mask,
+ big_to_cairo_blue_mask)))
)
def __init__(self):
@@ -74,7 +79,7 @@ class CairoSurfaceThumbnailSink(gst.BaseSink):
def do_render(self, buf):
self.log("buffer %s %d" % (gst.TIME_ARGS(buf.timestamp),
len(buf.data)))
- b = array.array("B")
+ b = array.array("b")
b.fromstring(buf)
pixb = cairo.ImageSurface.create_for_data(b,
cairo.FORMAT_ARGB32,
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 6dc0bb8..f0309ad 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -27,6 +27,7 @@ import sys
import gobject
import gst, bisect
import os
+import struct
from pitivi.signalinterface import Signallable
import pitivi.log.log as log
from gettext import ngettext
@@ -498,3 +499,11 @@ def profile(func, profiler_filename="result.prof"):
def formatPercent(value):
return "%3d%%" % (value * 100)
+
+
+native_endianness = struct.pack('=I', 0x34333231)
+
+big_to_cairo_alpha_mask = struct.unpack('=i', '\xFF\x00\x00\x00')[0]
+big_to_cairo_red_mask = struct.unpack('=i', '\x00\xFF\x00\x00')[0]
+big_to_cairo_green_mask = struct.unpack('=i', '\x00\x00\xFF\x00')[0]
+big_to_cairo_blue_mask = struct.unpack('=i', '\x00\x00\x00\xFF')[0]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]