Files
moyuhai 41a602f89c V1.0
2026-06-09 16:39:17 +08:00

71 lines
2.2 KiB
C

#ifndef __MSBC_DECODER_PORT_H_
#define __MSBC_DECODER_PORT_H_
#include "oi_codec_sbc.h"
#include <stdint.h>
#define DECODER_DATA_SIZE (SBC_MAX_CHANNELS*SBC_MAX_BLOCKS*SBC_MAX_BANDS * 4 + \
SBC_CODEC_MIN_FILTER_BUFFERS*SBC_MAX_BANDS*SBC_MAX_CHANNELS * 2)
#define SBC_FS 120 /* SBC Frame Size */
#define SBC_N 512 /* 32ms - Window Length for pattern matching */
#define SBC_M 64 /* 4ms - Template for matching */
#define SBC_LHIST (SBC_N+SBC_FS-1) /* Length of history buffer required */
#define SBC_RT 36 /* SBC Reconvergence Time (samples) */
#define SBC_OLAL 16 /* OverLap-Add Length (samples) */
#define mSBC_SYNCWORD 0xad
static float rcos[8] = {
0.99148655f,0.92510857f,
0.80131732f,0.63683150f,
0.45386582f,0.27713082f,
0.13049554f,0.03376389f,
};
/* PLC State Information */
struct sbc_plc_state {
int16_t hist[SBC_LHIST+SBC_FS+SBC_RT+SBC_OLAL];
int16_t bestlag;
int nbf;
// summary of processed good and bad frames
int good_frames_nr;
int bad_frames_nr;
int frame_count;
int max_consecutive_bad_frames_nr;
} __attribute__((packed));
struct sbc_decoder_state {
void *context;
struct sbc_plc_state plc_state;
void (*handle_pcm_data)(int16_t * data, int num_samples, int num_channels, int sample_rate, void * context);
uint32_t bytes_in_frame_buffer;
OI_CODEC_SBC_DECODER_CONTEXT decoder_context;
uint8_t frame_buffer[SBC_MAX_FRAME_LEN];
int16_t pcm_plc_data[SBC_MAX_CHANNELS * SBC_MAX_BANDS * SBC_MAX_BLOCKS];
int16_t pcm_data[SBC_MAX_CHANNELS * SBC_MAX_BANDS * SBC_MAX_BLOCKS];
uint32_t pcm_bytes;
uint32_t decoder_data[(DECODER_DATA_SIZE+3)/4];
int first_good_frame_found;
int h2_sequence_nr;
uint16_t msbc_bad_bytes;
// summary of processed good, bad and zero frames
int good_frames_nr;
int bad_frames_nr;
int zero_frames_nr;
};
typedef void (*msbc_decoder_data_cb)(int16_t * data, int num_samples,int num_channels,
int sample_rate, void * context);
void msbc_decoder_process_msbc_data(int packet_status_flag, uint8_t * buffer, int size);
int msbc_decoder_init(msbc_decoder_data_cb cb);
#endif