xpra icon
Bug tracker and wiki

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


Ticket #784: bpg-v2.patch

File bpg-v2.patch, 22.6 KB (added by Antoine Martin, 5 years ago)

updated bpg patch with decoder complete and more integration

  • setup.py

     
    180180enc_x264_ENABLED        = DEFAULT and pkg_config_ok("--exists", "x264", fallback=WIN32)
    181181enc_x265_ENABLED        = DEFAULT and pkg_config_ok("--exists", "x265")
    182182pillow_ENABLED          = DEFAULT
     183bpg_ENABLED             = DEFAULT
    183184vpx_ENABLED             = DEFAULT and pkg_config_version("1.3", "vpx", fallback=WIN32)
    184185enc_ffmpeg_ENABLED      = DEFAULT and pkg_config_version("56", "libavcodec")
    185186webcam_ENABLED          = DEFAULT and not OSX
     
    214215#allow some of these flags to be modified on the command line:
    215216SWITCHES = ["enc_x264", "enc_x265", "enc_ffmpeg",
    216217            "nvenc7", "cuda_rebuild",
    217             "vpx", "pillow",
     218            "vpx", "pillow", "bpg",
    218219            "v4l2",
    219220            "dec_avcodec2", "csc_swscale",
    220221            "csc_libyuv",
     
    941942                   "xpra/codecs/cuda_common/BGRA_to_YUV444.fatbin",
    942943                   "xpra/codecs/enc_x264/encoder.c",
    943944                   "xpra/codecs/enc_x265/encoder.c",
     945                   "xpra/codecs/bpg/encode.c",
     946                   "xpra/codecs/bpg/decode.c",
    944947                   "xpra/codecs/enc_ffmpeg/encoder.c",
    945948                   "xpra/codecs/v4l2/constants.pxi",
    946949                   "xpra/codecs/v4l2/pusher.c",
     
    23352338if pillow_ENABLED:
    23362339    external_includes += ["PIL", "PIL.Image", "PIL.WebPImagePlugin"]
    23372340
     2341toggle_packages(bpg_ENABLED, "xpra.codecs.bpg")
     2342if bpg_ENABLED:
     2343    bpg_pkgconfig = pkgconfig()
     2344    cython_add(Extension("xpra.codecs.bpg.encode",
     2345                ["xpra/codecs/bpg/encode.pyx", buffers_c],
     2346                **bpg_pkgconfig))
     2347    cython_add(Extension("xpra.codecs.bpg.decode",
     2348                ["xpra/codecs/bpg/decode.pyx"]+membuffers_c,
     2349                **bpg_pkgconfig))
     2350
    23382351#swscale and avcodec2 use libav_common/av_log:
    23392352libav_common = dec_avcodec2_ENABLED or csc_swscale_ENABLED
    23402353toggle_packages(libav_common, "xpra.codecs.libav_common")
  • xpra/codecs/bpg/__init__.py

     
     1# This file is part of Xpra.
     2# Copyright (C) 2015-2017 Antoine Martin <antoine@devloop.org.uk>
     3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
     4# later version. See the file COPYING for details.
  • xpra/codecs/bpg/decode.pyx

     
     1# This file is part of Xpra.
     2# Copyright (C) 2015-2017 Antoine Martin <antoine@devloop.org.uk>
     3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
     4# later version. See the file COPYING for details.
     5
     6from xpra.log import Logger
     7log = Logger("encoder", "bpg")
     8
     9from xpra.buffers.membuf cimport getbuf, MemBuf
     10from xpra.codecs.image_wrapper import ImageWrapper
     11from libc.stdint cimport uint8_t, uint16_t, uint32_t, uintptr_t
     12
     13
     14cdef extern from "libbpg.h":
     15    int BPG_FORMAT_GRAY
     16    int BPG_FORMAT_420          # chroma at offset (0.5, 0.5) (JPEG)
     17    int BPG_FORMAT_422          # chroma at offset (0.5, 0) (JPEG)
     18    int BPG_FORMAT_444
     19    int BPG_FORMAT_420_VIDEO    # chroma at offset (0, 0.5) (MPEG2)
     20    int BPG_FORMAT_422_VIDEO    # chroma at offset (0, 0) (MPEG2)
     21
     22    int BPG_CS_YCbCr
     23    int BPG_CS_RGB
     24    int BPG_CS_YCgCo
     25    int BPG_CS_YCbCr_BT709
     26    int BPG_CS_YCbCr_BT2020
     27    int BPG_CS_COUNT
     28
     29    ctypedef struct BPGImageInfo:
     30        uint32_t width
     31        uint32_t height
     32        uint8_t format          # BPG_FORMAT_*
     33        uint8_t has_alpha       # TRUE if an alpha plane is present
     34        uint8_t color_space     # see BPG_CS_*
     35        uint8_t bit_depth
     36        uint8_t premultiplied_alpha # TRUE if the color is alpha premultiplied
     37        uint8_t has_w_plane         # TRUE if a W plane is present (for CMYK encoding)
     38        uint8_t limited_range       # TRUE if limited range for the color
     39        uint8_t has_animation       # TRUE if the image contains animations
     40        uint16_t loop_count         # animations: number of loop, 0 = infinity
     41
     42    int BPG_EXTENSION_TAG_EXIF = 1
     43    int BPG_EXTENSION_TAG_ICCP = 2
     44    int BPG_EXTENSION_TAG_XMP = 3
     45    int BPG_EXTENSION_TAG_THUMBNAIL = 4
     46    int BPG_EXTENSION_TAG_ANIM_CONTROL = 5
     47
     48    ctypedef struct BPGExtensionData:
     49        int tag
     50        uint32_t buf_len
     51        uint8_t *buf
     52        BPGExtensionData *next
     53
     54    ctypedef int BPGDecoderOutputFormat
     55    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_RGB24
     56    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_RGBA32    # not premultiplied alpha
     57    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_RGB48
     58    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_RGBA64    # not premultiplied alpha
     59    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_CMYK32
     60    BPGDecoderOutputFormat BPG_OUTPUT_FORMAT_CMYK64
     61
     62    ctypedef struct BPGDecoderContext:
     63        pass
     64    BPGDecoderContext *bpg_decoder_open()
     65    # If enable is true, extension data are kept during the image
     66    # decoding and can be accessed after bpg_decoder_decode() with
     67    # bpg_decoder_get_extension(). By default, the extension data are
     68    # discarded.
     69    void bpg_decoder_keep_extension_data(BPGDecoderContext *s, int enable)
     70
     71    # return 0 if 0K, < 0 if error
     72    int bpg_decoder_decode(BPGDecoderContext *s, const uint8_t *buf, int buf_len)
     73
     74    # Return the first element of the extension data list
     75    BPGExtensionData *bpg_decoder_get_extension_data(BPGDecoderContext *s)
     76
     77    # return 0 if 0K, < 0 if error
     78    int bpg_decoder_get_info(BPGDecoderContext *s, BPGImageInfo *p)
     79
     80    # return 0 if 0K, < 0 if error
     81    int bpg_decoder_start(BPGDecoderContext *s, BPGDecoderOutputFormat out_fmt)
     82
     83    # return the frame delay for animations as a fraction (*pnum) / (*pden)
     84    # in seconds. In case there is no animation, 0 / 1 is returned.
     85    void bpg_decoder_get_frame_duration(BPGDecoderContext *s, int *pnum, int *pden)
     86
     87    # return 0 if 0K, < 0 if error
     88    int bpg_decoder_get_line(BPGDecoderContext *s, void *buf)
     89
     90    void bpg_decoder_close(BPGDecoderContext *s)
     91
     92    # only useful for low level access to the image data
     93    uint8_t *bpg_decoder_get_data(BPGDecoderContext *s, int *pline_size, int plane)
     94
     95    # Get information from the start of the image data in 'buf' (at least
     96    # min(BPG_DECODER_INFO_BUF_SIZE, file_size) bytes must be given).
     97    # If pfirst_md != NULL, the extension data are also parsed and the
     98    # first element of the list is returned in *pfirst_md. The list must
     99    # be freed with bpg_decoder_free_extension_data().
     100    # BPGImageInfo.loop_count is only set if extension data are parsed.
     101    # Return 0 if OK, < 0 if unrecognized data.
     102    int bpg_decoder_get_info_from_buf(BPGImageInfo *p,
     103                                  BPGExtensionData **pfirst_md,
     104                                  const uint8_t *buf, int buf_len)
     105    # Free the extension data returned by bpg_decoder_get_info_from_buf()
     106    void bpg_decoder_free_extension_data(BPGExtensionData *first_md);
     107
     108cdef extern from "stdlib.h":
     109    void free(void *ptr)
     110
     111
     112cdef extern from "../../buffers/memalign.h":
     113    void *xmemalign(size_t size)
     114
     115cdef extern from "../../buffers/buffers.h":
     116    object memory_as_pybuffer(void* ptr, Py_ssize_t buf_len, int readonly)
     117    int    object_as_buffer(object obj, const void ** buffer, Py_ssize_t * buffer_len)
     118
     119
     120FORMAT_STR = {
     121    BPG_FORMAT_GRAY         : "GRAY",
     122    BPG_FORMAT_420          : "420",
     123    BPG_FORMAT_422          : "422",
     124    BPG_FORMAT_444          : "444",
     125    BPG_FORMAT_420_VIDEO    : "420 VIDEO",
     126    BPG_FORMAT_422_VIDEO    : "422 VIDEO",
     127    }
     128
     129CS_STR = {
     130    BPG_CS_YCbCr            : "YCbCr",
     131    BPG_CS_RGB              : "RGB",
     132    BPG_CS_YCgCo            : "YCgCo",
     133    BPG_CS_YCbCr_BT709      : "YCbCr_BT709",
     134    BPG_CS_YCbCr_BT2020     : "YCbCr_BT2020",
     135    }
     136
     137
     138def get_version():
     139    return 1
     140
     141def get_encodings():
     142    return ["bpg"]
     143
     144
     145cdef inline uint32_t roundup(uint32_t n, uint32_t m):
     146    return (n + m - 1) & ~(m - 1)
     147
     148
     149def decompress(data, has_alpha, rgb_format=None):
     150    cdef BPGDecoderContext *context
     151    cdef BPGImageInfo info
     152    cdef uint32_t w, h, i
     153    cdef int r
     154    cdef const uint8_t *buf
     155    cdef Py_ssize_t buf_len
     156    assert object_as_buffer(data, <const void**> &buf, &buf_len)==0, "unable to convert %s to a buffer" % type(data)
     157    cdef uint32_t stride
     158    cdef size_t out_buf_len
     159    cdef MemBuf output_buf
     160    cdef uintptr_t out_ptr
     161    try:
     162        context = bpg_decoder_open()
     163        r = bpg_decoder_decode(context, buf, buf_len)
     164        if r:
     165            log.error("Error: BPG decoding failure, error code %i", r)
     166            return None
     167        r = bpg_decoder_get_info(context, &info)
     168        if r:
     169            log.error("Error: BPG decoding failure: cannot get info, error code %i", r)
     170            return None
     171        w = info.width
     172        h = info.height
     173        log("decoded image info: %ix%i, format=%s, alpha=%s, colorspace=%s, bit depth=%i, premultiplied alpha=%s",
     174            w, h, FORMAT_STR.get(info.format, info.format), CS_STR.get(info.color_space, info.color_space), info.bit_depth, bool(info.premultiplied_alpha))
     175        assert info.bit_depth==8, "unsupported bit depth %i" % info.bit_depth
     176        stride = roundup(w, 4)
     177        out_buf_len = stride * (h+1)
     178        rgb = getbuf(out_buf_len)
     179        out_ptr = <uintptr_t> rgb.get_mem()
     180        for i in range(h):
     181            bpg_decoder_get_line(context, <void*> out_ptr)
     182            out_ptr += stride
     183        return ImageWrapper(0, 0, w, h, rgb, "RGB24", 24, stride, ImageWrapper.PACKED)
     184    finally:
     185        if context:
     186            bpg_decoder_close(context)
     187
     188
     189def selftest(full=False):
     190    try:
     191        log("bpg selftest")
     192    finally:
     193        pass
  • xpra/codecs/bpg/encode.pyx

     
     1# This file is part of Xpra.
     2# Copyright (C) 2015-2017 Antoine Martin <antoine@devloop.org.uk>
     3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
     4# later version. See the file COPYING for details.
     5
     6import os
     7
     8from xpra.log import Logger
     9log = Logger("encoder", "bpg")
     10
     11from xpra.util import envbool
     12from libc.stdint cimport uint8_t, uint16_t, uint32_t, uintptr_t
     13
     14BPG_DEBUG = envbool("XPRA_BPG_DEBUG", False)
     15
     16
     17cdef extern from "libbpg.h":
     18    ctypedef int BPGImageFormatEnum
     19    BPGImageFormatEnum BPG_FORMAT_GRAY
     20    BPGImageFormatEnum BPG_FORMAT_420          # chroma at offset (0.5, 0.5) (JPEG)
     21    BPGImageFormatEnum BPG_FORMAT_422          # chroma at offset (0.5, 0) (JPEG)
     22    BPGImageFormatEnum BPG_FORMAT_444
     23    BPGImageFormatEnum BPG_FORMAT_420_VIDEO    # chroma at offset (0, 0.5) (MPEG2)
     24    BPGImageFormatEnum BPG_FORMAT_422_VIDEO    # chroma at offset (0, 0) (MPEG2)
     25
     26    ctypedef int BPGColorSpaceEnum
     27    BPGColorSpaceEnum BPG_CS_YCbCr
     28    BPGColorSpaceEnum BPG_CS_RGB
     29    BPGColorSpaceEnum BPG_CS_YCgCo
     30    BPGColorSpaceEnum BPG_CS_YCbCr_BT709
     31    BPGColorSpaceEnum BPG_CS_YCbCr_BT2020
     32    BPGColorSpaceEnum BPG_CS_COUNT
     33
     34    ctypedef struct BPGImageInfo:
     35        uint32_t width
     36        uint32_t height
     37        uint8_t format          # BPG_FORMAT_*
     38        uint8_t has_alpha       # TRUE if an alpha plane is present
     39        uint8_t color_space     # see BPG_CS_*
     40        uint8_t bit_depth
     41        uint8_t premultiplied_alpha # TRUE if the color is alpha premultiplied
     42        uint8_t has_w_plane         # TRUE if a W plane is present (for CMYK encoding)
     43        uint8_t limited_range       # TRUE if limited range for the color
     44        uint8_t has_animation       # TRUE if the image contains animations
     45        uint16_t loop_count         # animations: number of loop, 0 = infinity
     46
     47    int BPG_EXTENSION_TAG_EXIF = 1
     48    int BPG_EXTENSION_TAG_ICCP = 2
     49    int BPG_EXTENSION_TAG_XMP = 3
     50    int BPG_EXTENSION_TAG_THUMBNAIL = 4
     51    int BPG_EXTENSION_TAG_ANIM_CONTROL = 5
     52
     53    ctypedef struct BPGExtensionData:
     54        int tag
     55        uint32_t buf_len
     56        uint8_t *buf
     57        BPGExtensionData *next
     58
     59    int BPG_OUTPUT_FORMAT_RGB24
     60    int BPG_OUTPUT_FORMAT_RGBA32    # not premultiplied alpha
     61    int BPG_OUTPUT_FORMAT_RGB48
     62    int BPG_OUTPUT_FORMAT_RGBA64    # not premultiplied alpha
     63    int BPG_OUTPUT_FORMAT_CMYK32
     64    int BPG_OUTPUT_FORMAT_CMYK64
     65
     66cdef extern from "bpgenc.h":
     67    ctypedef struct Image:
     68        int w, h
     69        BPGImageFormatEnum format   # x_VIDEO values are forbidden here
     70        uint8_t c_h_phase           # 4:2:2 or 4:2:0 : give the horizontal chroma position. 0=MPEG2, 1=JPEG
     71        uint8_t has_alpha
     72        uint8_t has_w_plane
     73        uint8_t limited_range
     74        uint8_t premultiplied_alpha
     75        BPGColorSpaceEnum color_space
     76        uint8_t bit_depth
     77        uint8_t pixel_shift         # (1 << pixel_shift) bytes per pixel
     78        uint8_t *data[4]
     79        int linesize[4]
     80
     81    ctypedef struct HEVCEncodeParams:
     82        int width
     83        int height
     84        int chroma_format           # 0-3
     85        int bit_depth               # 8-14
     86        int intra_only              # 0-1
     87        int qp                      # quantizer 0-51
     88        int lossless                # 0-1 lossless mode
     89        int sei_decoded_picture_hash    # 0=no hash, 1=MD5 hash
     90        int compress_level          # 1-9
     91        int verbose
     92
     93    ctypedef struct HEVCEncoderContext:
     94        pass
     95
     96    ctypedef struct HEVCEncoder:
     97        HEVCEncoderContext *(*open)(const HEVCEncodeParams *params)
     98        int (*encode)(HEVCEncoderContext *s, Image *img)
     99        int (*close)(HEVCEncoderContext *s, uint8_t **pbuf)
     100
     101    #extern HEVCEncoder jctvc_encoder
     102    HEVCEncoder x265_hevc_encoder
     103
     104    int x265_encode_picture(uint8_t **pbuf, Image *img,
     105                        const HEVCEncodeParams *params)
     106    #void save_yuv1(Image *img, FILE *f)
     107    #void save_yuv(Image *img, const char *filename)
     108
     109
     110cdef extern from "stdlib.h":
     111    void free(void *ptr)
     112
     113
     114cdef extern from "../../buffers/buffers.h":
     115    int    object_as_buffer(object obj, const void ** buffer, Py_ssize_t * buffer_len)
     116
     117
     118def get_encodings():
     119    return ["bpg"]
     120
     121def get_version():
     122    return 1
     123
     124def compress(pixels, width, height, stride=0, quality=50, speed=50, has_alpha=False):
     125    cdef HEVCEncodeParams params
     126    params.width = width
     127    params.height = height
     128    params.chroma_format = BPG_FORMAT_420
     129    params.bit_depth = 8
     130    params.intra_only = 1
     131    params.qp = max(0, min(51, quality//2))
     132    params.lossless = int(quality>=100)
     133    params.sei_decoded_picture_hash = 0
     134    params.compress_level = max(1, min(9, 9-(speed//12)))
     135    params.verbose = int(BPG_DEBUG)
     136
     137    cdef Image image
     138    image.w = width
     139    image.h = height
     140    #BPGImageFormatEnum format   # x_VIDEO values are forbidden here
     141    image.c_h_phase = 1
     142    image.has_alpha = has_alpha
     143    image.has_w_plane = 0
     144    image.limited_range = 0
     145    image.premultiplied_alpha = 1
     146    image.color_space = BPG_CS_RGB
     147    image.bit_depth = 8
     148    image.pixel_shift = 32
     149    #image.data[0] = ?
     150    #int linesize[4]
     151
     152    cdef HEVCEncoderContext *context
     153    try:
     154        context = x265_hevc_encoder.open(&params)
     155        log("compress: %#x", <uintptr_t> &image)
     156    finally:
     157        if context:
     158            x265_hevc_encoder.close(context, pbuf)
     159    return None
     160
     161
     162def selftest(full=False):
     163    try:
     164        log("bpg selftest")
     165    finally:
     166        pass
  • xpra/codecs/bpg

  • xpra/codecs/loader.py

    Property changes on: xpra/codecs/bpg
    ___________________________________________________________________
    Added: svn:ignore
    ## -0,0 +1,4 ##
    +decode.html
    +decode.c
    +encode.c
    +encode.html
     
    152152        codec_import_check("enc_pillow", "Pillow encoder", "xpra.codecs.pillow", "xpra.codecs.pillow.encode", "encode")
    153153        add_codec_version("enc_pillow", "xpra.codecs.pillow.encode")
    154154
     155        codec_import_check("enc_bpg", "BPG encoder", "xpra.codecs.bpg", "xpra.codecs.bpg.encode", "encode")
     156        add_codec_version("enc_bpg", "xpra.codecs.bpg.encode")
     157
    155158        if not OSX:
    156159            #causes crashes with osx shadow servers, disabled in setup.py:
    157160            codec_import_check("enc_vpx", "vpx encoder", "xpra.codecs.vpx", "xpra.codecs.vpx.encoder", "Encoder")
     
    183186        codec_import_check("dec_pillow", "Pillow decoder", "xpra.codecs.pillow", "xpra.codecs.pillow.decode", "decode")
    184187        add_codec_version("dec_pillow", "xpra.codecs.pillow.decode")
    185188
     189        codec_import_check("dec_bpg", "BPG decoder", "xpra.codecs.bpg", "xpra.codecs.bpg.decode", "decode")
     190        add_codec_version("dec_bpg", "xpra.codecs.bpg.decode")
     191
    186192        codec_import_check("dec_vpx", "vpx decoder", "xpra.codecs.vpx", "xpra.codecs.vpx.decoder", "Decoder")
    187193        add_codec_version("vpx", "xpra.codecs.vpx.encoder")
    188194
     
    232238
    233239#note: this is just for defining the order of encodings,
    234240#so we have both core encodings (rgb24/rgb32) and regular encodings (rgb) in here:
    235 PREFERED_ENCODING_ORDER = ["h264", "vp9", "vp8", "mpeg4", "mpeg4+mp4", "h264+mp4", "mpeg4+mp4", "vp8+webm", "vp9+webm", "png", "png/P", "png/L", "rgb", "rgb24", "rgb32", "jpeg", "h265"]
     241PREFERED_ENCODING_ORDER = ["h264", "vp9", "vp8", "mpeg4", "mpeg4+mp4", "h264+mp4", "mpeg4+mp4", "vp8+webm", "vp9+webm", "bpg", "png", "png/P", "png/L", "rgb", "rgb24", "rgb32", "jpeg", "h265"]
    236242#encoding order for edges (usually one pixel high or wide):
    237 EDGE_ENCODING_ORDER = ["rgb24", "rgb32", "jpeg", "png", "png/P", "png/L", "rgb"]
     243EDGE_ENCODING_ORDER = ["rgb24", "rgb32", "jpeg", "bpg", "png", "png/P", "png/L", "rgb"]
    238244
    239245
    240246from xpra.net import compression
     
    249255      "mpeg4"   : "MPEG4",
    250256      "vp8"     : "VP8",
    251257      "vp9"     : "VP9",
     258      "bpg"     : "BPG",
    252259      "png"     : "PNG (24/32bpp)",
    253260      "png/P"   : "PNG (8bpp colour)",
    254261      "png/L"   : "PNG (8bpp grayscale)",
     
    263270      "vp8"     : "VP8 video codec",
    264271      "vp9"     : "VP9 video codec",
    265272      "mpeg4"   : "MPEG-4 video codec",
     273      "bpg"     : "Better Portable Graphics",
    266274      "png"     : "Portable Network Graphics (lossless, 24bpp or 32bpp for transparency)",
    267275      "png/P"   : "Portable Network Graphics (lossy, 8bpp colour)",
    268276      "png/L"   : "Portable Network Graphics (lossy, 8bpp grayscale)",
     
    270278      "rgb"     : "Raw RGB pixels, lossless, compressed using %s (24bpp or 32bpp for transparency)" % (" or ".join(compression.get_enabled_compressors())),
    271279      }
    272280
    273 HELP_ORDER = ("auto", "h264", "h265", "vp8", "vp9", "mpeg4", "png", "png/P", "png/L", "rgb", "jpeg")
     281HELP_ORDER = ("auto", "h264", "h265", "vp8", "vp9", "mpeg4", "bpg", "png", "png/P", "png/L", "rgb", "jpeg")
    274282
    275283#those are currently so useless that we don't want the user to select them by mistake
    276284PROBLEMATIC_ENCODINGS = ("h265", )
  • xpra/log.py

     
    208208                ("libav"        , "libav common code (used by swscale, avcodec and ffmpeg)"),
    209209                ("ffmpeg"       , "ffmpeg encoder"),
    210210                ("pillow"       , "Pillow encoder and decoder"),
     211                ("bpg"          , "Better Portable Graphics"),
    211212                ("vpx"          , "libvpx encoder and decoder"),
    212213                ("nvenc"        , "nvenc encoder (all versions)"),
    213214                ("x264"         , "libx264 encoder"),
  • xpra/server/window/window_source.py

     
    717717            are = self.client_refresh_encodings
    718718        else:
    719719            #sane defaults:
    720             ropts = set(("png", "rgb24", "rgb32"))          #default encodings for auto-refresh
     720            ropts = set(("bpg", "png", "rgb24", "rgb32"))          #default encodings for auto-refresh
    721721            if AUTO_REFRESH_QUALITY<100:
    722722                ropts.add("jpeg")
    723723            are = [x for x in PREFERED_ENCODING_ORDER if x in ropts]
     
    755755        elif self._want_alpha:
    756756            if self.encoding in ("rgb", "rgb32") and "rgb32" in self.common_encodings:
    757757                return self.encoding_is_rgb32
    758             if self.encoding in ("png", "png/P"):
     758            if self.encoding in ("bpg", "png", "png/P"):
    759759                #chosen encoding does alpha, stick to it:
    760760                #(prevents alpha bleeding artifacts,
    761761                # as different encoders may encode alpha differently)
     
    802802    def get_auto_encoding(self, pixel_count, ww, wh, speed, quality, *args):
    803803        if pixel_count<self._rgb_auto_threshold:
    804804            return "rgb24"
    805         if "png" in self.common_encodings and quality>=80 and speed<80:
     805        if "bpg" in self.common_encodings and quality>=60:
    806806            return "png"
     807        elif "png" in self.common_encodings and quality>=80 and speed<80:
     808            return "png"
    807809        if "jpeg" in self.common_encodings:
    808810            return "jpeg"
    809811        return self.common_encodings[0]
  • xpra/server/window/window_video_source.py

     
    5555    log.warn("invalid value for XPRA_SAVE_VIDEO_FRAMES: must be 'png' or 'jpeg'")
    5656    SAVE_VIDEO_FRAMES = None
    5757
    58 FAST_ORDER = ["jpeg", "rgb32", "rgb24", "png"] + PREFERED_ENCODING_ORDER
     58FAST_ORDER = ["jpeg", "rgb32", "rgb24", "bpg", "png"] + PREFERED_ENCODING_ORDER
    5959
    6060
    6161class WindowVideoSource(WindowSource):
     
    450450        else:
    451451            #lossless options:
    452452            #avoid very small and very large areas (both slow)
    453             if speed>75:
     453            if speed>85:
    454454                if "rgb24" in options:
    455455                    return "rgb24"
    456456                if "rgb32" in options:
    457457                    return "rgb32"
     458            if speed>60 and "bpg" in options:
     459                return "bpg"
    458460            if "png" in options:
    459461                return "png"
    460462        #we failed to find a good match, default to the first of the options..