[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250820-opus_codec_rfc_v1-v1-1-54d5c7560856@linaro.org>
Date: Wed, 20 Aug 2025 22:15:59 +0100
From: Alexey Klimov <alexey.klimov@...aro.org>
To: Vinod Koul <vkoul@...nel.org>, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, Srinivas Kandagatla <srini@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>
Cc: Patrick Lai <plai@....qualcomm.com>,
Annemarie Porter <annemari@...cinc.com>,
srinivas.kandagatla@....qualcomm.com, linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
kernel@....qualcomm.com, Ekansh Gupta <ekansh.gupta@....qualcomm.com>,
Alexey Klimov <alexey.klimov@...aro.org>,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.dev>
Subject: [PATCH 1/2] ALSA: compress: add raw opus codec define and opus
decoder structs
Adds a raw opus codec define and raw opus decoder structs.
This is for raw OPUS packets not packed in any type of container
(for instance OGG container). The decoder struct fields are
taken from corresponding RFC document: RFC 7845 Section 5.
Cc: Srinivas Kandagatla <srini@...nel.org>
Cc: Vinod Koul <vkoul@...nel.org>
Co-developed-by: Annemarie Porter <annemari@...cinc.com>
Signed-off-by: Annemarie Porter <annemari@...cinc.com>
Signed-off-by: Alexey Klimov <alexey.klimov@...aro.org>
---
include/uapi/sound/compress_params.h | 43 +++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/compress_params.h
index bc7648a30746f4632ecf6695868e79550a431dfa..faf4fa911f7fc2830c3ae42b93650fe40d8a776b 100644
--- a/include/uapi/sound/compress_params.h
+++ b/include/uapi/sound/compress_params.h
@@ -43,7 +43,8 @@
#define SND_AUDIOCODEC_BESPOKE ((__u32) 0x0000000E)
#define SND_AUDIOCODEC_ALAC ((__u32) 0x0000000F)
#define SND_AUDIOCODEC_APE ((__u32) 0x00000010)
-#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_APE
+#define SND_AUDIOCODEC_OPUS_RAW ((__u32) 0x00000011)
+#define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_OPUS_RAW
/*
* Profile and modes are listed with bit masks. This allows for a
@@ -324,6 +325,45 @@ struct snd_dec_ape {
__u32 seek_table_present;
} __attribute__((packed, aligned(4)));
+/**
+ * struct snd_dec_opus - Opus decoder parameters (raw opus packets)
+ * @version: Usually should be '1' but can be split into major (4 upper bits)
+ * and minor (4 lower bits) sub-fields.
+ * @num_channels: Number of output channels.
+ * @pre_skip: Number of samples to discard at 48 kHz.
+ * @sample_rate: Sample rate of original input.
+ * @output_gain: Gain to apply when decoding (in Q7.8 format).
+ * @mapping_family: Order and meaning of output channels. Only values 0 and 1
+ * are expected; values 2..255 are not recommended for playback.
+ *
+ * Optional channel mapping table. Describes mapping of opus streams to decoded
+ * channels.
+ * @struct snd_dec_opus_ch_map
+ * @stream_count: Number of streams encoded in each Ogg packet.
+ * @coupled_count: Number of streams whose decoders are used for two
+ * channels.
+ * @channel_map: describes which decoded channel to be used for each one.
+ * See RFC doc for details.
+ * This supports only mapping families 0 and 1, therefore max
+ * number of channels is 8.
+ *
+ * These options were extracted from RFC7845 Section 5.
+ */
+
+struct snd_dec_opus {
+ __u8 version;
+ __u8 num_channels;
+ __u16 pre_skip;
+ __u32 sample_rate;
+ __u16 output_gain;
+ __u8 mapping_family;
+ struct snd_dec_opus_ch_map {
+ __u8 stream_count;
+ __u8 coupled_count;
+ __u8 channel_map[8];
+ } chan_map;
+} __attribute__((packed, aligned(4)));
+
union snd_codec_options {
struct snd_enc_wma wma;
struct snd_enc_vorbis vorbis;
@@ -334,6 +374,7 @@ union snd_codec_options {
struct snd_dec_wma wma_d;
struct snd_dec_alac alac_d;
struct snd_dec_ape ape_d;
+ struct snd_dec_opus opus_d;
struct {
__u32 out_sample_rate;
} src_d;
--
2.47.2
Powered by blists - more mailing lists