[Spice-commits] common/snd_codec.c common/snd_codec.h configure.ac .gitlab-ci.yml m4/spice-deps.m4 meson.build meson_options.txt
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 17 16:44:19 UTC 2020
.gitlab-ci.yml | 8 +-
common/snd_codec.c | 148 +----------------------------------------------------
common/snd_codec.h | 16 -----
configure.ac | 5 -
m4/spice-deps.m4 | 29 ----------
meson.build | 3 -
meson_options.txt | 6 --
7 files changed, 14 insertions(+), 201 deletions(-)
New commits:
commit 31a14b20d0f257e27a2c518a9defc30d94674a81
Author: Victor Toso <me at victortoso.com>
Date: Tue Mar 17 16:13:35 2020 +0100
sound: remove celt support
Follow up of spice-protocol's deprecation of celt mode.
See: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43f09cb..cafb9e2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ before_script:
dnf install git libtool make libasan
python3 python3-six python3-pyparsing glib-networking
meson ninja-build gdk-pixbuf2-devel
- glib2-devel celt051-devel pixman-devel openssl-devel libjpeg-devel
+ glib2-devel pixman-devel openssl-devel libjpeg-devel
libcacard-devel cyrus-sasl-devel lz4-devel opus-devel
gstreamer1-devel gstreamer1-plugins-base-devel
-y
@@ -17,7 +17,7 @@ makecheck:
- >
CFLAGS='-O2 -pipe -g -fsanitize=address -fno-omit-frame-pointer -Wframe-larger-than=40920'
LDFLAGS='-fsanitize=address -lasan'
- ./autogen.sh --enable-extra-checks --enable-celt051
+ ./autogen.sh --enable-extra-checks
- make
- make check || (cat tests/test-suite.log && exit 1)
@@ -26,7 +26,7 @@ meson-makecheck:
- >
CFLAGS='-O2 -pipe -g -fsanitize=address -fno-omit-frame-pointer -Wframe-larger-than=40920'
LDFLAGS='-fsanitize=address -lasan'
- meson build -Dextra-checks=true -Dcelt051=enabled || (cat build/meson-logs/meson-log.txt && exit 1)
+ meson build -Dextra-checks=true || (cat build/meson-logs/meson-log.txt && exit 1)
- ninja -C build
- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
@@ -42,6 +42,6 @@ make-win:
PYTHON=python3
CFLAGS='-O2 -pipe -g -fsanitize=address -fno-omit-frame-pointer -Wframe-larger-than=40920'
LDFLAGS='-fsanitize=address -lasan'
- mingw64-configure --enable-extra-checks --disable-celt051
+ mingw64-configure --enable-extra-checks
- make
- make LOG_COMPILER=wine check || (cat tests/test-suite.log && exit 1)
diff --git a/common/snd_codec.c b/common/snd_codec.c
index db840cb..2b55b91 100644
--- a/common/snd_codec.c
+++ b/common/snd_codec.c
@@ -20,10 +20,6 @@
General purpose sound codec routines for use by Spice.
These routines abstract the work of picking a codec and
encoding and decoding the buffers.
- Note: these routines have some peculiarities that come from
- wanting to provide full backwards compatibility with the original
- Spice celt 0.51 implementation. It has some hard requirements
- (fixed sample size, fixed compressed buffer size).
See below for documentation of the public routines.
*/
@@ -32,10 +28,6 @@
#include <stdio.h>
#include <string.h>
-#if HAVE_CELT051
-#include <celt051/celt.h>
-#endif
-
#if HAVE_OPUS
#include <opus.h>
#endif
@@ -51,11 +43,6 @@ typedef struct SndCodecInternal
{
int mode;
int frequency;
-#if HAVE_CELT051
- CELTMode *celt_mode;
- CELTEncoder *celt_encoder;
- CELTDecoder *celt_decoder;
-#endif
#if HAVE_OPUS
OpusEncoder *opus_encoder;
@@ -65,90 +52,6 @@ typedef struct SndCodecInternal
-/* celt 0.51 specific support routines */
-#if HAVE_CELT051
-static void snd_codec_destroy_celt051(SndCodecInternal *codec)
-{
- if (codec->celt_decoder) {
- celt051_decoder_destroy(codec->celt_decoder);
- codec->celt_decoder = NULL;
- }
-
- if (codec->celt_encoder) {
- celt051_encoder_destroy(codec->celt_encoder);
- codec->celt_encoder = NULL;
- }
-
- if (codec->celt_mode) {
- celt051_mode_destroy(codec->celt_mode);
- codec->celt_mode = NULL;
- }
-}
-
-static int snd_codec_create_celt051(SndCodecInternal *codec, int purpose)
-{
- int celt_error;
-
- codec->celt_mode = celt051_mode_create(codec->frequency,
- SND_CODEC_PLAYBACK_CHAN,
- SND_CODEC_CELT_FRAME_SIZE, &celt_error);
- if (! codec->celt_mode) {
- g_warning("create celt mode failed %d", celt_error);
- return SND_CODEC_UNAVAILABLE;
- }
-
- if (purpose & SND_CODEC_ENCODE) {
- codec->celt_encoder = celt051_encoder_create(codec->celt_mode);
- if (! codec->celt_encoder) {
- g_warning("create celt encoder failed");
- goto error;
- }
- }
-
- if (purpose & SND_CODEC_DECODE) {
- codec->celt_decoder = celt051_decoder_create(codec->celt_mode);
- if (! codec->celt_decoder) {
- g_warning("create celt decoder failed");
- goto error;
- }
- }
-
- codec->mode = SPICE_AUDIO_DATA_MODE_CELT_0_5_1;
- return SND_CODEC_OK;
-
-error:
- snd_codec_destroy_celt051(codec);
- return SND_CODEC_UNAVAILABLE;
-}
-
-static int snd_codec_encode_celt051(SndCodecInternal *codec, uint8_t *in_ptr, int in_size, uint8_t *out_ptr, int *out_size)
-{
- int n;
- if (in_size != SND_CODEC_CELT_FRAME_SIZE * SND_CODEC_PLAYBACK_CHAN * 2)
- return SND_CODEC_INVALID_ENCODE_SIZE;
- n = celt051_encode(codec->celt_encoder, (celt_int16_t *) in_ptr, NULL, out_ptr, *out_size);
- if (n < 0) {
- g_warning("celt051_encode failed %d", n);
- return SND_CODEC_ENCODE_FAILED;
- }
- *out_size = n;
- return SND_CODEC_OK;
-}
-
-static int snd_codec_decode_celt051(SndCodecInternal *codec, uint8_t *in_ptr, int in_size, uint8_t *out_ptr, int *out_size)
-{
- int n;
- n = celt051_decode(codec->celt_decoder, in_ptr, in_size, (celt_int16_t *) out_ptr);
- if (n < 0) {
- g_warning("celt051_decode failed %d", n);
- return SND_CODEC_DECODE_FAILED;
- }
- *out_size = SND_CODEC_CELT_FRAME_SIZE * SND_CODEC_PLAYBACK_CHAN * 2 /* 16 fmt */;
- return SND_CODEC_OK;
-}
-#endif
-
-
/* Opus support routines */
#if HAVE_OPUS
static void snd_codec_destroy_opus(SndCodecInternal *codec)
@@ -237,11 +140,6 @@ static int snd_codec_decode_opus(SndCodecInternal *codec, uint8_t *in_ptr, int i
*/
int snd_codec_is_capable(int mode, int frequency)
{
-#if HAVE_CELT051
- if (mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1)
- return TRUE;
-#endif
-
#if HAVE_OPUS
if (mode == SPICE_AUDIO_DATA_MODE_OPUS &&
(frequency == SND_CODEC_ANY_FREQUENCY ||
@@ -275,11 +173,6 @@ int snd_codec_create(SndCodec *codec, int mode, int frequency, int purpose)
*c = spice_new0(SndCodecInternal, 1);
(*c)->frequency = frequency;
-#if HAVE_CELT051
- if (mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1)
- rc = snd_codec_create_celt051(*c, purpose);
-#endif
-
#if HAVE_OPUS
if (mode == SPICE_AUDIO_DATA_MODE_OPUS)
rc = snd_codec_create_opus(*c, purpose);
@@ -298,10 +191,6 @@ void snd_codec_destroy(SndCodec *codec)
if (! c || ! *c)
return;
-#if HAVE_CELT051
- snd_codec_destroy_celt051(*c);
-#endif
-
#if HAVE_OPUS
snd_codec_destroy_opus(*c);
#endif
@@ -318,14 +207,8 @@ void snd_codec_destroy(SndCodec *codec)
*/
int snd_codec_frame_size(SndCodec codec)
{
-#if defined(HAVE_CELT051) || defined(HAVE_OPUS)
- SndCodecInternal *c = codec;
-#endif
-#if HAVE_CELT051
- if (c && c->mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1)
- return SND_CODEC_CELT_FRAME_SIZE;
-#endif
#if HAVE_OPUS
+ SndCodecInternal *c = codec;
if (c && c->mode == SPICE_AUDIO_DATA_MODE_OPUS)
return SND_CODEC_OPUS_FRAME_SIZE;
#endif
@@ -339,33 +222,19 @@ int snd_codec_frame_size(SndCodec codec)
Parameters:
1. codec Pointer to codec control previously allocated + created
2. in_ptr Pointer to uncompressed PCM data
- 3. in_size Input size (for celt, this must be a
- particular size, governed by the frame size)
+ 3. in_size Input size
4. out_ptr Pointer to area to write encoded data
5. out_size On input, the maximum size of the output buffer; on
successful return, it will hold the number of bytes
- returned. For celt, this must be set to a particular
- size to ensure compatibility.
+ returned.
Returns:
SND_CODEC_OK if all went well
*/
int snd_codec_encode(SndCodec codec, uint8_t *in_ptr, int in_size, uint8_t *out_ptr, int *out_size)
{
-#if defined(HAVE_CELT051) || defined(HAVE_OPUS)
- SndCodecInternal *c = codec;
-#endif
-#if HAVE_CELT051
- if (c && c->mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1) {
- /* The output buffer size in celt determines the compression,
- and so is essentially mandatory to use a certain value (47) */
- if (*out_size > SND_CODEC_CELT_COMPRESSED_FRAME_BYTES)
- *out_size = SND_CODEC_CELT_COMPRESSED_FRAME_BYTES;
- return snd_codec_encode_celt051(c, in_ptr, in_size, out_ptr, out_size);
- }
-#endif
-
#if HAVE_OPUS
+ SndCodecInternal *c = codec;
if (c && c->mode == SPICE_AUDIO_DATA_MODE_OPUS)
return snd_codec_encode_opus(c, in_ptr, in_size, out_ptr, out_size);
#endif
@@ -391,15 +260,8 @@ int snd_codec_encode(SndCodec codec, uint8_t *in_ptr, int in_size, uint8_t *out_
*/
int snd_codec_decode(SndCodec codec, uint8_t *in_ptr, int in_size, uint8_t *out_ptr, int *out_size)
{
-#if defined(HAVE_CELT051) || defined(HAVE_OPUS)
- SndCodecInternal *c = codec;
-#endif
-#if HAVE_CELT051
- if (c && c->mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1)
- return snd_codec_decode_celt051(c, in_ptr, in_size, out_ptr, out_size);
-#endif
-
#if HAVE_OPUS
+ SndCodecInternal *c = codec;
if (c && c->mode == SPICE_AUDIO_DATA_MODE_OPUS)
return snd_codec_decode_opus(c, in_ptr, in_size, out_ptr, out_size);
#endif
diff --git a/common/snd_codec.h b/common/snd_codec.h
index 596b2d3..aaba867 100644
--- a/common/snd_codec.h
+++ b/common/snd_codec.h
@@ -19,27 +19,15 @@
#ifndef H_SPICE_COMMON_SND_CODEC
#define H_SPICE_COMMON_SND_CODEC
-/* Spice uses a very fixed protocol when transmitting CELT audio;
- audio must be transmitted in frames of 256, and we must compress
- data down to a fairly specific size (47, computation below).
- While the protocol doesn't inherently specify this, the expectation
- of older clients and server mandates it.
-*/
-#define SND_CODEC_CELT_FRAME_SIZE 256
-#define SND_CODEC_CELT_BIT_RATE (64 * 1024)
-#define SND_CODEC_CELT_PLAYBACK_FREQ 44100
-#define SND_CODEC_CELT_COMPRESSED_FRAME_BYTES (SND_CODEC_CELT_FRAME_SIZE * SND_CODEC_CELT_BIT_RATE / \
- SND_CODEC_CELT_PLAYBACK_FREQ / 8)
-
#define SND_CODEC_OPUS_FRAME_SIZE 480
#define SND_CODEC_OPUS_PLAYBACK_FREQ 48000
#define SND_CODEC_OPUS_COMPRESSED_FRAME_BYTES 480
#define SND_CODEC_PLAYBACK_CHAN 2
-#define SND_CODEC_MAX_FRAME_SIZE (MAX(SND_CODEC_CELT_FRAME_SIZE, SND_CODEC_OPUS_FRAME_SIZE))
+#define SND_CODEC_MAX_FRAME_SIZE SND_CODEC_OPUS_FRAME_SIZE
#define SND_CODEC_MAX_FRAME_BYTES (SND_CODEC_MAX_FRAME_SIZE * SND_CODEC_PLAYBACK_CHAN * 2 /* FMT_S16 */)
-#define SND_CODEC_MAX_COMPRESSED_BYTES MAX(SND_CODEC_CELT_COMPRESSED_FRAME_BYTES, SND_CODEC_OPUS_COMPRESSED_FRAME_BYTES)
+#define SND_CODEC_MAX_COMPRESSED_BYTES SND_CODEC_OPUS_COMPRESSED_FRAME_BYTES
#define SND_CODEC_ANY_FREQUENCY -1
diff --git a/configure.ac b/configure.ac
index 2dba7c8..471ecac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,15 +57,14 @@ SPICE_CHECK_PYTHON_MODULES()
SPICE_CHECK_PIXMAN
SPICE_CHECK_SMARTCARD
-SPICE_CHECK_CELT051
SPICE_CHECK_GLIB2
SPICE_CHECK_OPUS
SPICE_CHECK_OPENSSL
SPICE_CHECK_GDK_PIXBUF
-SPICE_COMMON_CFLAGS='$(PIXMAN_CFLAGS) $(SMARTCARD_CFLAGS) $(CELT051_CFLAGS) $(GLIB2_CFLAGS) $(OPUS_CFLAGS) $(OPENSSL_CFLAGS)'
+SPICE_COMMON_CFLAGS='$(PIXMAN_CFLAGS) $(SMARTCARD_CFLAGS) $(GLIB2_CFLAGS) $(OPUS_CFLAGS) $(OPENSSL_CFLAGS)'
SPICE_COMMON_CFLAGS="$SPICE_COMMON_CFLAGS -DG_LOG_DOMAIN=\\\"Spice\\\""
-SPICE_COMMON_LIBS='$(PIXMAN_LIBS) $(CELT051_LIBS) $(GLIB2_LIBS) $(OPUS_LIBS) $(OPENSSL_LIBS)'
+SPICE_COMMON_LIBS='$(PIXMAN_LIBS) $(GLIB2_LIBS) $(OPUS_LIBS) $(OPENSSL_LIBS)'
AC_SUBST(SPICE_COMMON_CFLAGS)
AC_SUBST(SPICE_COMMON_LIBS)
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index ebe8893..f16266c 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -78,34 +78,6 @@ AC_DEFUN([SPICE_CHECK_SMARTCARD], [
])
-# SPICE_CHECK_CELT051
-# -------------------
-# Adds a --enable-celt051 switch in order to enable/disable CELT 0.5.1
-# support, and checks if the needed libraries are available. If found, it will
-# return the flags to use in the CELT051_CFLAGS and CELT051_LIBS variables, and
-# it will define a HAVE_CELT051 preprocessor symbol as well as a HAVE_CELT051
-# Makefile conditional.
-#--------------------
-AC_DEFUN([SPICE_CHECK_CELT051], [
- AC_ARG_ENABLE([celt051],
- AS_HELP_STRING([--enable-celt051],
- [Enable celt051 audio codec @<:@default=no@:>@]),,
- [enable_celt051="no"])
-
- if test "x$enable_celt051" != "xno"; then
- PKG_CHECK_MODULES([CELT051], [celt051 >= 0.5.1.1], [have_celt051=yes], [have_celt051=no])
- if test "x$enable_celt051" = "xyes" && test "x$have_celt051" != "xyes"; then
- AC_MSG_ERROR(["--enable-celt051 has been specified, but CELT 0.5.1 is missing"])
- fi
- else
- have_celt051=no
- fi
-
- AM_CONDITIONAL([HAVE_CELT051], [test "x$have_celt051" = "xyes"])
- AM_COND_IF([HAVE_CELT051], AC_DEFINE([HAVE_CELT051], 1, [Define if we have celt051 codec]))
-])
-
-
# SPICE_CHECK_OPUS
# ----------------
# Check for the availability of Opus. If found, it will return the flags to use
@@ -362,7 +334,6 @@ AC_DEFUN([SPICE_CHECK_INSTRUMENTATION], [
AC_DEFUN([SPICE_COMMON], [dnl
dnl These add some flags and checks to component using spice-common
dnl The flags are necessary in order to make included header working
- AC_REQUIRE([SPICE_CHECK_CELT051])dnl
AC_REQUIRE([SPICE_EXTRA_CHECKS])dnl
AC_REQUIRE([SPICE_CHECK_INSTRUMENTATION])dnl
dnl Get the required spice protocol version
diff --git a/meson.build b/meson.build
index 3123fb1..41a9419 100644
--- a/meson.build
+++ b/meson.build
@@ -109,8 +109,7 @@ endforeach
#
# Non-mandatory/optional dependencies
#
-optional_deps = {'celt051' : '>= 0.5.1.1',
- 'opus' : '>= 0.9.14'}
+optional_deps = {'opus' : '>= 0.9.14'}
foreach dep, version : optional_deps
d = dependency(dep, required : get_option(dep), version : version)
if d.found()
diff --git a/meson_options.txt b/meson_options.txt
index 561460f..d30858f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -10,12 +10,6 @@ option('extra-checks',
yield : true,
description : 'Enable extra checks on code')
-option('celt051',
- type : 'feature',
- value : 'disabled',
- yield : true,
- description: 'Enable celt051 audio codec')
-
option('opus',
type : 'feature',
yield : true,
More information about the Spice-commits
mailing list