mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 21:02:39 +02:00
This second member indicates the Opus encoder's entropy coder's final range. While nothing in the service actually does anything with the final range as far as I can tell, this is specified within RFC 6716 (https://tools.ietf.org/html/rfc6716, see section "6. Conformance") as a means of ensuring decoder conformance. States as follows: "In addition, a compliant decoder implementation MUST have the same final range decoder state as that of the reference decoder." So what is likely done when performing compliance testing is the data is encoded, and then the final range of the encoder is sent via this header, then during decoding, the final range would be checked against to ensure that it's valid.
44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
/**
|
|
* @file hwopus.h
|
|
* @brief Hardware Opus audio service.
|
|
* @author yellows8
|
|
* @copyright libnx Authors
|
|
*/
|
|
#pragma once
|
|
|
|
#include "../services/sm.h"
|
|
#include "../kernel/tmem.h"
|
|
|
|
typedef struct {
|
|
Service s;
|
|
TransferMemory tmem;
|
|
bool multistream;
|
|
} HwopusDecoder;
|
|
|
|
/// This structure is the start of opusin for \ref hwopusDecodeInterleaved, with the actual opus packet following this.
|
|
/// These fields are big-endian.
|
|
typedef struct {
|
|
u32 size; ///< Size of the packet following this header.
|
|
u32 final_range; ///< Indicates the final range of the codec encoder's entropy coder. This can be left at zero.
|
|
} HwopusHeader;
|
|
|
|
/// Used internally.
|
|
typedef struct {
|
|
s32 SampleRate;
|
|
s32 ChannelCount;
|
|
s32 TotalStreamCount;
|
|
s32 StereoStreamCount;
|
|
u8 channel_mapping[256];
|
|
} HwopusMultistreamState;
|
|
|
|
Result hwopusDecoderInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount);
|
|
void hwopusDecoderExit(HwopusDecoder* decoder);
|
|
|
|
/// Only available on 3.0.0+.
|
|
/// See libopus multistream docs.
|
|
Result hwopusDecoderMultistreamInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount, s32 TotalStreamCount, s32 StereoStreamCount, u8 *channel_mapping);
|
|
|
|
/// Decodes opus data.
|
|
Result hwopusDecodeInterleaved(HwopusDecoder* decoder, s32 *DecodedDataSize, s32 *DecodedSampleCount, const void* opusin, size_t opusin_size, s16 *pcmbuf, size_t pcmbuf_size);
|
|
|