Commit Graph

751 Commits

Author SHA1 Message Date
Christophe Fergeau
5110dbcbb7 test-region: Add g_assert() checks
At the moment, test success/failure is only printed to stdout. This
commit adds some g_assert() so that test failures can be automatically
detected.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:55 +01:00
Christophe Fergeau
cfbae20c48 test-region: Replace spice_assert() with g_assert_true()
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:53 +01:00
Christophe Fergeau
968ce158f0 test-region: Remove unneeded printf
__FUNCTION__ will always be rect_is_valid, and there is a g_assert to
check the region is valid, so we will get notified anyway if the
validity check fails.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:51 +01:00
Christophe Fergeau
30ff9c3807 test-region: Don't call region_dump() by default
This prints to stdout, which is not desirable in an automated test.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:48 +01:00
Christophe Fergeau
3a6a84e172 test-region: Replace direct printf with g_debug() calls
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:45 +01:00
Christophe Fergeau
e13c1d66b7 test-region: Use GTest API
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-27 13:17:43 +01:00
Frediano Ziglio
0ac8e55ddf test-region: Create proper test for region from source code
region.c contained code to test the module.
Separate test code into a proper test.
Test is copied verbatim from the original code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-27 13:17:41 +01:00
Frediano Ziglio
8e8476d932 ssl_verify: Fix build for newer LibreSSL
LibreSSL 2.7 defines ASN1_STRING_get0_data, like OpenSSL 1.1.
This fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229044.
Original patch from Piotr Kubaj.

Reported-by: Jack L. <xxjack12xx@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 18:30:58 +01:00
Frediano Ziglio
3f04e2649d Revert "ssl_verify: Fix build for newer LibreSSL"
This reverts commit 638c77f3e6.
Commit had a misleading comment.
2018-06-26 18:30:58 +01:00
Frediano Ziglio
638c77f3e6 ssl_verify: Fix build for newer LibreSSL
LibreSSL 2.7 does not define ASN1_STRING_get0_data, like OpenSSL 1.1.
This fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229044.
Original patch from Piotr Kubaj.

Reported-by: Jack L. <xxjack12xx@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 17:58:44 +01:00
Frediano Ziglio
345557f044 test-quic: Increase test timeout using Meson
This test can take quite some amount of time to run.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 17:57:02 +01:00
Frediano Ziglio
818b820644 canvas_base: Rework DUMP_JPEG debugging
The DUMP_JPEG compile time flag is used to dump all jpeg images
to files.
The code was saving garbage instead of proper data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reported-by: 谢 昆明 <KunMing.Xie@hotmail.com>
Tested-by: 谢 昆明 <KunMing.Xie@hotmail.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 17:55:04 +01:00
Frediano Ziglio
656106b304 test-quic: Allows to specify multiple images to test
Make easier to test an entire set of files

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 10:45:46 +01:00
Christophe de Dinechin
258123318d Add SPICE_ATTR_NORETURN on prototype of error functions
The error functions are supposed to not return.  Using the attribute
documents that in the interface, and is better for the compiler
because most noreturn-related optimizations and spurious warning
eliminations happen at the call site.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-26 10:25:42 +01:00
Christophe Fergeau
0fc3d4209f test-logging: Improve debug level tests
These tests were checking that the expected messages were output, but
they were not checking that the messages we don't want are not output.
This commit adds this to make sure our log implementation does not
output unwanted debug messages.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-21 07:03:25 +01:00
Christophe Fergeau
82a5f19d99 log: Only install glib log handler if SPICE_DEBUG_LEVEL is set
Calling g_log_set_handler() is problematic as this means applications
using spice-server won't be able to use g_log_set_default_handler to
manage spice logging output themselves. Since this call is only needed
for backwards compatibility (so that calling g_log together with
SPICE_DEBUG_LEVEL set has the expected behaviour), we can install it
only when SPICE_DEBUG_LEVEL is set.
Then we should deprecate SPICE_DEBUG_LEVEL once and for all.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-20 17:35:43 +01:00
Snir Sheriber
a3598f62aa protocol: Add support for h265 video codec
Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-19 15:29:27 +01:00
Christophe Fergeau
32e2ed57b5 build: Add __pycache__/*.pyc to DISTCLEANFILES
Python 3 puts its .pyc files in a __pycache__ subdirectory, This commit
adds these to DISTCLEANFILES. My main motivation for doing this is so
that git.mk can then properly add them to .gitignore.

Acked-by: Victor Toso <victortoso@redhat.com>
2018-06-18 14:08:10 +01:00
Christophe Fergeau
a526fea413 build: Remove docs/.gitignore
It was added together with the meson build, but it's currently being
managed by git.mk, so it should not be in git

Acked-by: Victor Toso <victortoso@redhat.com>
2018-06-18 14:08:07 +01:00
Christophe Fergeau
26dce6fede build: Update git.mk to latest version
https://raw.githubusercontent.com/behdad/git.mk/master/git.mk has a
newer version than what we are using now.

Acked-by: Victor Toso <victortoso@redhat.com>
2018-06-18 14:08:03 +01:00
Eduardo Lima (Etrunko)
95743f40a2 Add .gitlab-ci.yml file
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-06-06 13:41:47 +01:00
Christophe Fergeau
a84f868e48 meson: Remove check for vfork
Nothing in spice-common calls vfork. The autotools-based build can
fallback to vfork if fork is not available/working through the
AC_FUNC_FORK macro, but the meson build is not implementing this magic.
However, fork() is only called once in backtrace.h, and this part of the
code is optional (it's not compiled in on Windows for example), and
anyway, I doubt anyone is going to try to compile SPICE code on a
platform without fork, so we can remove this check, it's always possible
to readd it when we have a clear bug report about what is
missing/needed.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-06 12:16:31 +01:00
Christophe Fergeau
e95f05452a meson: Support auto/true/false for optional dependencies
At the moment, missing optional dependencies will be silently ignored
when the corresponding configuration flag is 'true', and won't be tested
for when the flag is 'false'.
In the autotools build, this corresponds respectively to
--enable-foo=auto and --disable-foo.
Having a way to get an error when the package is enabled but missing is
quite desirable. f52247384 has some half-baked attempt at that, but this
was supposed to be removed from the series. This causes errors when
processing meson.build, breaking the meson build.
This commit adds 'true'/'false'/'auto' in a proper way.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-06 12:16:31 +01:00
Frediano Ziglio
1dcdefa8b3 quic: Use __builtin_clz if available
Different processors has specific instructions to count leading
zero bits. This includes: x86. x64, arm, ppc.
For portability reason the behaviour of __builtin_clz is not
defined if the value is zero so test for it.
Currently the function is not called with the value or 0.
This increase performance decoding of about 4-5% on a x64 machine
(code size decreases a little too, but about 0.1%).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-05 14:58:02 +01:00
Christophe Fergeau
b208389334 build: Move client sources to libspice_common_client_la_SOURCES
These sources are only used by the client, so they do not belong in
libspice_common_la_SOURCES.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:29 +01:00
Christophe Fergeau
992ebac6b5 build: Remove bitops.h
Nothing uses it since the GL backend was removed in 384698a

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:22 +01:00
Christophe Fergeau
f7d3a57ce4 build: Remove checks for functions which are never called
Grepping for 'pow', 'sqrt' or 'inet_ntoa' returns no results in
spice-common code base.
inet_ntoa use was removed in 9749e7e 'ssl-verify: Changed IPv4 hostname
to IPv6' and pow/sqrt use in 384698a 'Remove GL support'

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:14 +01:00
Christophe Fergeau
42795a6d00 build: Use AM_COND_IF
AM_COND_IF can be replaced in constructs like:

    AM_CONDITIONAL([HAVE_OPUS], [test "x$have_opus" = "xyes"])
    if test "x$have_opus" = "xyes" ; then
      AC_DEFINE([HAVE_OPUS], [1], [Define if we have OPUS])
    fi

which becomes:

    AM_CONDITIONAL([HAVE_OPUS], [test "x$have_opus" = "xyes"])
    AM_COND_IF([HAVE_OPUS], AC_DEFINE([HAVE_OPUS], [1], [Define if we have OPUS]))

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:07 +01:00
Christophe Fergeau
f522473842 build: By default, error out if Opus is missing
Following the commit disabling celt by default, it's quite easy to have
a build without both celt and opus. After this commit, Opus will have to
be installed for a successful build unless one passes --disable-opus.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:02 +01:00
Christophe Fergeau
72b0d603e1 build: Disable celt 0.5.1 by default
This version of the CELT codec has long been obsolete, and Opus support
has been added nearly 5 years ago. It's time we move on and try to stop
using Celt ;)
This commit disables CELT by default, but since this could be an
unexpected change for packagers, if CELT 0.5.1 development headers are
installed, it will error out unless --enable-celt051/--disable-celt051
has been explicitly specified.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:09:55 +01:00
Christophe Fergeau
e98f8a430f build: Ensure we link with -lm if needed
lines.c uses hypot(), which is found in libm on some systems. This means
we are currently relying on getting -lm indirectly through some other
means, as otherwise linking any binary with spice-common would fail.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:09:50 +01:00
Frediano Ziglio
349a74d7c2 quic: Fix endianness encoding
The image is going to network and network protocol is little endian
so the numbers has to be little endian. Note that this is already done
during decoding.
Tested on a ppc64 machine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-04 16:05:20 +01:00
Eduardo Lima (Etrunko)
55070333f6 Add support for building with meson/ninja
In a comparison with current autotools build system, meson/ninja
provides a huge improvement in build speed, while keeping the same
functionalities currently available and being considered more user
friendly.

The new system coexists within the same repository with the current one,
so we can do more extensive testing of its functionality before deciding
if the old system can be removed, or for some reason, has to stay for
good.

- Meson: https://mesonbuild.com

  This is the equivalent of autogen/configure step in autotools. It
  generates the files that will be used by ninja to actually build the
  source code.

  The project has received lots of traction recently, with many GNOME
  projects willing to move to this new build system. The following wiki
  page has more details of the status of the many projects being ported:

    https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting

  Meson has a python-like syntax, easy to read, and the documentation
  on the project is very complete, with a dedicated page on how to port
  from autotools, explaining how most common use cases can be
  implemented using meson.

    http://mesonbuild.com/Porting-from-autotools.html

  Other important sources of information:

    http://mesonbuild.com/howtox.html
    http://mesonbuild.com/Syntax.html
    http://mesonbuild.com/Reference-manual.html

- Ninja: https://ninja-build.org

  Ninja is the equivalent of make in an autotools setup, which actually
  builds the source code. It has being used by large and complex
  projects such as Google Chrome, Android and LLVM. There is not much to
  say about ninja (other than it is much faster than make) because we
  won't interact directly with it as much, as meson does the middle man
  job here. The reasoning for creating ninja in the first place is
  explained on the following post:

    http://neugierig.org/software/chromium/notes/2011/02/ninja.html

  Also its manual provides more in-depth information about the design
  principles:

    https://ninja-build.org/manual.html

- Basic workflow:

  Meson package is available for most if not all distros, so, taking
  Fedora as an example, we only need to run:

    # dnf -y install meson ninja-build.

  With Meson, building in-tree is not possible at all, so we need to
  pass a directory as argument to meson where we want the build to be
  done. This has the advantage of creating builds with different options
  under the same parent directory, e.g.:

    $ meson ./build --prefix=/usr
    $ meson ./build-extra -Dextra-checks=true -Dalignment-checks=true

  After configuration is done, we call ninja to actually do the build.

    $ ninja -C ./build
    $ ninja -C ./build install

  Ninja defaults to parallel builds, and this can be changed with the -j
  flag.

    $ ninja -j 10 -C ./build

- Hacking:

  * meson.build: Mandatory for the project root and usually found under
                 each directory you want something to be built.

  * meson_options.txt: Options that can interfere with the result of the
                       build.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-01 21:27:04 +01:00
Eduardo Lima (Etrunko)
836bbd0e41 test-quic: Fix -Wsign-compare warning
../tests/test-quic.c: In function ‘gdk_pixbuf_new_random’:
../tests/test-quic.c:205:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < gdk_pixbuf_get_byte_length(random_pixbuf); i++) {
                   ^

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-31 17:46:24 -03:00
Frediano Ziglio
68c0f93889 quic: Remove some too strict asserts in hot paths
Some assert in the code are doing some paranoid test and in code
paths quite hot.
The encoding time is reduced by 30-50% while the decoding time
is reduced by a 20-30%.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-05-31 07:34:17 +01:00
Frediano Ziglio
160232f8f6 quic: Remove 'no-inline' hack
The quic code goes through a function pointer in two places in order to
try to prevent the compiler from inlining code.
Doing performance measurements this trick does not work anymore
and just make code less readable.

This patch and message was based on a previous work of
Christophe Fergeau.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-05-28 11:27:01 +01:00
Christophe Fergeau
d58a5b6a5a quic: Add test case for compression/decompression
This only adds a basic test relying on gdk-pixbuf.
The main limitation is that gdk-pixbuf does not handle 16bpp images,
nor 32bpp/no alpha images. I should have picked something else instead ;)

This allows at least to exercise the QUIC_IMAGE_TYPE_RGB24 and
QUIC_IMAGE_TYPE_RGBA codepaths.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-25 17:04:23 +01:00
Frediano Ziglio
5312ea3f35 lz: Inline GET_{r,g,b} macros
With last changes are just used once and are straight forward.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: jonathon Jongsma <jjongsma@redhat.com>
2018-05-25 11:54:18 +01:00
Frediano Ziglio
70aa6d39b6 lz: Optimise SAME_PIXEL for RGB16
Do not extract all components and compare one by one, can be easily
compared together.
Performance measurements on a set of 16 bit images shown an improve of
about 10%.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-05-25 11:54:18 +01:00
Christophe Fergeau
a1f6f42a33 quic: Use channel->correlate_row in macros
This avoids the need for a local variable with the right name (which
was decorrelate_drow in some cases in quic_tmpl.c...)

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 17:20:38 +01:00
Christophe Fergeau
0e550416f1 quic: Remove unused argument in uncompress_row{0, }
'correlation_row' is always set to channel->colleration_row, and we
already pass 'channel' as an argument.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:49 +01:00
Christophe Fergeau
8152238618 quic: Add macros to make quic_tmpl.c much closer to quic_rgb_tmpl.c
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:44 +01:00
Christophe Fergeau
423518768e quic: s/decorrelate_drow/correlate_row
The naming is odd as this is just an alias for channel->correlate_row.
This will also help in subsequent commits to make things more
consistent with quic_rgb_tmpl.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:40 +01:00
Christophe Fergeau
4690e7239d quic: Introduce CommonState *state variable in templates
Most functions in quic_tmpl.c/quic_rgb_tmpl.c have only superficial
differences. One of them is using channel->state or encoder->rgb_state.

This commit adds a local CommonState *state in all template methods
which will be used instead of channel->state or encoder->rgb_state.
This makes it easier to spot the common code between the 2 template
files...

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:37 +01:00
Christophe Fergeau
b9dd7ed8f1 quic: Factor common code
We don't need 2 different implementations when the only difference is
the CommonState which is being used.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:33 +01:00
Christophe Fergeau
d240af18a4 quic: Get rid of RLE #define
It's always set, no need to have conditional compilation based on it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 11:01:31 +01:00
Christophe Fergeau
fce119be44 quic: Get rid of RLE_STAT #define
It's always set, no need to have conditional compilation based on it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 11:01:28 +01:00
Christophe Fergeau
7b2c2e620e quic: Get rid of QUIC_RGB #define
It's always set, no need to have conditional compilation based on it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 11:01:25 +01:00
Christophe Fergeau
763735d636 quic: Remove configurable PRED
It's hardcoded at compile-time, and I don't think it was changed in
years...

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 11:01:22 +01:00
Christophe Fergeau
0629153699 quic: Remove configurable RLE_PRED
It's hardcoded at compile-time, and I don't think it was changed in
years...

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 11:01:15 +01:00