xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #393: support-old-libwebp.patch

File support-old-libwebp.patch, 4.0 KB (added by Antoine Martin, 8 years ago)

with this patch we should be able to run

  • xpra/codecs/webm/encode.py

     
    5353_LIBRARY.WebPEncodeRGBA.argtypes = LOSSY_ARGS
    5454_LIBRARY.WebPEncodeBGRA.argtypes = LOSSY_ARGS
    5555
    56 LOSSLESS_ARGS = [c_void_p, c_int, c_int, c_int, c_void_p]
    57 _LIBRARY.WebPEncodeLosslessRGB.argtypes = LOSSLESS_ARGS
    58 _LIBRARY.WebPEncodeLosslessBGR.argtypes = LOSSLESS_ARGS
    59 _LIBRARY.WebPEncodeLosslessRGBA.argtypes = LOSSLESS_ARGS
    60 _LIBRARY.WebPEncodeLosslessBGRA.argtypes = LOSSLESS_ARGS
     56HAS_LOSSLESS = False
     57try:
     58    LOSSLESS_ARGS = [c_void_p, c_int, c_int, c_int, c_void_p]
     59    _LIBRARY.WebPEncodeLosslessRGB.argtypes = LOSSLESS_ARGS
     60    _LIBRARY.WebPEncodeLosslessBGR.argtypes = LOSSLESS_ARGS
     61    _LIBRARY.WebPEncodeLosslessRGBA.argtypes = LOSSLESS_ARGS
     62    _LIBRARY.WebPEncodeLosslessBGRA.argtypes = LOSSLESS_ARGS
     63   
     64    # Set return types
     65    _LIBRARY.WebPEncodeRGB.restype = c_int
     66    _LIBRARY.WebPEncodeBGR.restype = c_int
     67    _LIBRARY.WebPEncodeRGBA.restype = c_int
     68    _LIBRARY.WebPEncodeBGRA.restype = c_int
     69    _LIBRARY.WebPEncodeLosslessRGB.restype = c_int
     70    _LIBRARY.WebPEncodeLosslessBGR.restype = c_int
     71    _LIBRARY.WebPEncodeLosslessRGBA.restype = c_int
     72    _LIBRARY.WebPEncodeLosslessBGRA.restype = c_int
    6173
    62 # Set return types
    63 _LIBRARY.WebPEncodeRGB.restype = c_int
    64 _LIBRARY.WebPEncodeBGR.restype = c_int
    65 _LIBRARY.WebPEncodeRGBA.restype = c_int
    66 _LIBRARY.WebPEncodeBGRA.restype = c_int
    67 _LIBRARY.WebPEncodeLosslessRGB.restype = c_int
    68 _LIBRARY.WebPEncodeLosslessBGR.restype = c_int
    69 _LIBRARY.WebPEncodeLosslessRGBA.restype = c_int
    70 _LIBRARY.WebPEncodeLosslessBGRA.restype = c_int
     74    HAS_LOSSLESS = True
     75except AttributeError:
     76    #lossless is missing!
     77    pass
    7178
    7279
    7380def _lossy(func, image, quality):
     
    116123    :type function: function
    117124    :type image: BitmapHandler
    118125    """
     126    assert HAS_LOSSLESS, "this version of the webp library does not support lossless modes!"
    119127    # Call encode function
    120128    data = str(image.bitmap)
    121129    width = c_int(image.width)
     
    191199    """
    192200    return _lossy(_LIBRARY.WebPEncodeBGR, image, quality)
    193201
     202
    194203def EncodeLosslessRGB(image):
    195204    """
    196205    Encode the given RGB image losslessly
  • xpra/scripts/config.py

     
    7979    #python >=2.6 only and required for webp to work:
    8080    bytearray()
    8181    try:
     82        #these symbols are all available upstream as of libwebp 0.2:
    8283        enc_webp = codec_import_check("webp encoder", "xpra.codecs.webm", "xpra.codecs.webm.encode", "EncodeRGB", "EncodeRGBA", "EncodeBGR", "EncodeBGRA")
    8384        dec_webp = codec_import_check("webp encoder", "xpra.codecs.webm", "xpra.codecs.webm.decode", "DecodeRGB", "DecodeRGBA", "DecodeBGR", "DecodeBGRA")
    84         has_enc_webp_lossless = codec_import_check("webp encoder", "xpra.codecs.webm", "xpra.codecs.webm.encode", "EncodeLosslessRGB", "EncodeLosslessRGBA", "EncodeLosslessBGRA", "EncodeLosslessBGR")
     85        #these symbols were added in libwebp 0.4, and we added HAS_LOSSLESS to the wrapper:
     86        _enc_webp_lossless = codec_import_check("webp encoder", "xpra.codecs.webm", "xpra.codecs.webm.encode", "HAS_LOSSLESS", "EncodeLosslessRGB", "EncodeLosslessRGBA", "EncodeLosslessBGRA", "EncodeLosslessBGR")
     87        if _enc_webp_lossless:
     88            #the fact that the python functions are defined is not enough
     89            #we need to check if the underlying C functiosn actually exist:
     90            has_enc_webp_lossless = _enc_webp_lossless.HAS_LOSSLESS
    8591        add_codec_version("webp", "xpra.codecs.webm", "__VERSION__")
    8692        webp_handlers = codec_import_check("webp bitmap handler", "xpra.codecs.webm", "xpra.codecs.webm.handlers", "BitmapHandler")
    8793    except Exception, e:
    8894        warn("cannot load webp: " % e)
    8995except:
     96    #no bytearray, no webp
    9097    pass
    9198has_enc_webp = enc_webp is not None
    9299has_dec_webp = dec_webp is not None