Skip to content

Commit

Permalink
#832: allow us to build the vpx encoder against libvpx versions older…
Browse files Browse the repository at this point in the history
… than 1.4: add IFdef statement via constant file

git-svn-id: https://xpra.org/svn/Xpra/trunk@8960 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 8, 2015
1 parent dbd2445 commit 765ac67
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
49 changes: 26 additions & 23 deletions src/setup.py
Expand Up @@ -456,31 +456,33 @@ def make_constants_pxi(constants_path, pxi_path, **kwargs):
constants.append(data)

with open(pxi_path, "w") as out:
out.write("cdef extern from *:\n")
### Apparently you can't use | on enum's?!
# out.write(" enum MagicNumbers:\n")
# for const in constants:
# if isinstance(const, tuple):
# out.write(' %s %s\n' % const)
# else:
# out.write(' %s\n' % (const,))
for const in constants:
if isinstance(const, tuple):
out.write(' unsigned int %s %s\n' % const)
else:
out.write(' unsigned int %s\n' % (const,))

out.write("constants = {\n")
for const in constants:
if isinstance(const, tuple):
pyname = const[0]
else:
pyname = const
out.write(' "%s": %s,\n' % (pyname, pyname))
out.write("}\n")
if constants:
out.write("cdef extern from *:\n")
### Apparently you can't use | on enum's?!
# out.write(" enum MagicNumbers:\n")
# for const in constants:
# if isinstance(const, tuple):
# out.write(' %s %s\n' % const)
# else:
# out.write(' %s\n' % (const,))
for const in constants:
if isinstance(const, tuple):
out.write(' unsigned int %s %s\n' % const)
else:
out.write(' unsigned int %s\n' % (const,))

out.write("constants = {\n")
for const in constants:
if isinstance(const, tuple):
pyname = const[0]
else:
pyname = const
out.write(' "%s": %s,\n' % (pyname, pyname))
out.write("}\n")
if kwargs:
out.write("\n\n")

if kwargs:
out.write("\n\n")
for k, v in kwargs.items():
out.write('DEF %s = %s\n' % (k, v))

Expand Down Expand Up @@ -1893,6 +1895,7 @@ def cython_add(*args, **kwargs):

toggle_packages(vpx_ENABLED, "xpra.codecs.vpx")
if vpx_ENABLED:
make_constants("xpra", "codecs", "vpx", "constants", LIBVPX14=pkg_config_ok("--atleast-version=1.4", "libvpx"))
vpx_pkgconfig = pkgconfig("vpx")
cython_add(Extension("xpra.codecs.vpx.encoder",
["xpra/codecs/vpx/encoder.pyx"]+membuffers_c,
Expand Down
8 changes: 8 additions & 0 deletions src/xpra/codecs/vpx/constants.txt
@@ -0,0 +1,8 @@
# This file is part of Xpra.
# Copyright (C) 2015 Antoine Martin <antoine@devloop.org.uk>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

## This file is processed by setup.py to create a .pxi
## It is empty because the only constant we are interested in is
## 'LIBVPX14' which is generated by setup.py on the fly using a pkgconfig version check
13 changes: 9 additions & 4 deletions src/xpra/codecs/vpx/encoder.pyx
Expand Up @@ -25,6 +25,7 @@ VPX_THREADS = os.environ.get("XPRA_VPX_THREADS", max(1, cpus-1))

DEF ENABLE_VP8 = True
DEF ENABLE_VP9 = True
include "constants.pxi"

ENABLE_VP9_YUV444 = os.environ.get("XPRA_VP9_YUV444", "1")=="1"
ENABLE_VP9_TILING = os.environ.get("XPRA_VP9_TILING", "0")=="1"
Expand Down Expand Up @@ -99,8 +100,9 @@ cdef extern from "vpx/vpx_encoder.h":
int VP9E_SET_TILE_COLUMNS
#function to set encoder internal speed settings:
int VP8E_SET_CPUUSED
#function to enable/disable periodic Q boost:
int VP9E_SET_FRAME_PERIODIC_BOOST
IF LIBVPX14:
#function to enable/disable periodic Q boost:
int VP9E_SET_FRAME_PERIODIC_BOOST
int VP9E_SET_LOSSLESS
#vpx_enc_pass:
int VPX_RC_ONE_PASS
Expand Down Expand Up @@ -255,6 +257,8 @@ def get_info():
"build_config" : vpx_codec_build_config()}
for k,v in COLORSPACES.items():
info["%s.colorspaces" % k] = v
IF LIBVPX14:
info["libvpx14"] = True
return info


Expand Down Expand Up @@ -386,8 +390,9 @@ cdef class Encoder:
elif width>=1024:
tile_columns = 3
self.codec_control("tile columns", VP9E_SET_TILE_COLUMNS, tile_columns)
#disable periodic Q boost which causes latency spikes:
self.codec_control("periodic Q boost", VP9E_SET_FRAME_PERIODIC_BOOST, 0)
IF LIBVPX14:
#disable periodic Q boost which causes latency spikes:
self.codec_control("periodic Q boost", VP9E_SET_FRAME_PERIODIC_BOOST, 0)


def codec_control(self, info, int attr, int value):
Expand Down

0 comments on commit 765ac67

Please sign in to comment.