int nb_samples; int nb_frames;
nb_frames = opus_packet_get_nb_frames(data, len); if (nb_frames < 1)
return nb_frames;
nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames;
一般的编码和解码过程执行完全相同的标准Opus Encoder 和 Opus Decoder API。如何使用相应的多流函数可以查阅它们的说明文档。
The general encoding and decoding process proceeds exactly the same as in the normal Opus Encoder and Opus Decoder APIs. See their documentation for an overview of how to use the corresponding multistream functions.
类型定义文档
typedef struct OpusMSDecoder OpusMSDecoder Opus多流解码器状态。 Opus multistream decoder state.
这包含了一个Opus多流解码器的完整状态。它是位置独立的,并且可以自由复制。
This contains the complete state of a multistream Opus decoder. It is position independent and can be freely copied.
参见:
opus_multistream_decoder_create opus_multistream_decoder_init
typedef struct OpusMSEncoder OpusMSEncoder Opus多流编码器状态。 Opus multistream encoder state.
这包含了一个Opus多流编码器的完整状态。它是位置独立的,并且可以自由复制。
This contains the complete state of a multistream Opus encoder. It is position independent and can be freely copied.
37
参见:
opus_multistream_encoder_create opus_multistream_encoder_init
函数文档
int opus_multistream_decode
( OpusMSDecoder * st,
const unsigned char * data, opus_int32
len,
opus_int16 * pcm, int int
frame_size, decode_fec
)
解码一个多流Opus包。
Decode a multistream Opus packet. 参数:
st OpusMSDecoder*: Opus多流解码器状态。Multistream
decoder state.
[in] data
const unsigned char*:输入负载.对包丢失使用一个空指针
来表示。 Input payload. Use a NULL pointer to indicate packet loss.
payload.
[out]
pcmopus_int16*:使用交叉样本的输出信号。必须有容纳len opus_int32: 在输入负载中的字节数。Number of bytes in
frame_size*channels样本数的空间。Output signal, with interleaved samples. This must contain room for frame_size*channels samples.
frame_size int: 在PCM可用空间中每通道的样本数。如果小于
最大包的时长(120毫秒,4848kHz5760个),这个函数将不能解码一些包。如果是PLC (data==NULL) 或 FEC (decode_fec=1)的情况,那么frame_size必须正好是丢失音频的时长,否则解码器无法在解码下一个包时进入优化状态。
38
对于PLC 和 FEC 的情况,frame_size必须是2.5毫秒的倍数。The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.
decode_fec int: 对于请求任何带内前向错误纠正数据进行解码
的状态标志 (0 or 1) 。如果没有这样的数据可用,帧在解码时被认为已经丢失。 Flag (0 or 1) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.
返回:
成功,解码样本的数量,失败,负的错误代码。Number of samples decoded on success or a negative error code (see Error codes) on failure.
int opus_multistream_decode_float ( OpusMSDecoder * st,
const unsigned char * data, opus_int32 float * int int
len,
pcm,
frame_size, decode_fec
)
用浮点输出格式解码一个多流Opus包。
Decode a multistream Opus packet with floating point output. 参数:
st OpusMSDecoder*: Opus多流解码器状态。Multistream
decoder state.
[in] data
const unsigned char*::输入负载.对包丢失使用一个空指
39
针来表示。 Input payload. Use a NULL pointer to indicate packet loss.
payload.
[out]
pcmopus_int16*:使用交叉样本的输出信号。必须有容纳len opus_int32: 在输入负载中的字节数。 Number of bytes in
frame_size*channels样本数的空间。Output signal, with interleaved samples. This must contain room for frame_size*channels samples.
frame_size int: 在PCM可用空间中每通道的样本数。如果小于
最大包的时长(120毫秒,4848kHz5760个),这个函数将不能解码一些包。如果是PLC (data==NULL) 或 FEC (decode_fec=1)的情况,那么frame_size必须正好是丢失音频的时长,否则解码器无法在解码下一个包时进入优化状态。对于PLC 和 FEC 的情况,frame_size必须是2.5毫秒的倍数。The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.
decode_fec int: 对于请求任何带内前向错误纠正数据进行解码
的状态标志 (0 or 1) 。如果没有这样的数据可用,帧在解码时被认为已经丢失。 Flag (0 or 1) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.
返回:
成功,解码样本的数量,失败,负的错误代码。Number of samples decoded on success or a negative error code (see Error codes) on failure.
OpusMSDecoder* opus_multistream_decoder_create ( opus_int32
Fs,
int int
channels, streams,
40
相关推荐: