blob: 8d13c3ef244ca7090e14574f0a6c36f85f198691 [file] [log] [blame]
jimmy.chen83a88832025-03-06 16:56:01 +08001#ifndef _PROCESSV2_BLOCK_H_
2#define _PROCESSV2_BLOCK_H_
3
4
5#ifndef __FFT_BLOCK__
6#define __FFT_BLOCK__
7typedef void *FFT_BLOCK;
8#endif //End of __FFT_BLOCK__
9
10
11#ifndef __LHDC_STATUS__
12#define __LHDC_STATUS__
13typedef enum _lhdc_error {
14 LHDC_ST_OK,
15 LHDC_ST_ERR,
16 LHDC_ST_MAX
17} LHDC_STATE;
18#endif //End of __LHDC_STATUS__
19
20
21//int LossyEncoderLoadQualitySetting(FFT_BLOCK *fb, char *file_name);
22
23/**
24 * Allocate new LHDC control block.
25 */
26FFT_BLOCK LossyEncoderNewV2(void);
27
28/**
29 * Destroy LHDC control block.
30 */
31int LossyEncoderDeleteV2(FFT_BLOCK fb);
32
33/**
34 * Initial LHDC encoder.
35 * Input :
36 * fb: LHDC control block.
37 * sample_rate : The sampling rate setting value as you wanted. (Only support 44.1Khz/48Khz/96KHz)
38 * channels : Fixed to 2 channel.
39 * block_size : Fixed to 512.
40 * sink_buf_len: Fixed to 10 * 1024.
41 * target_byte_rate : The target byte rate.(eg. 400k bit per sec = 50k byte per sec, Only support 400kbps, 500kbps, 560kbps, 900kbps)
42 * fast_mode : Always fixed to 0.
43 * split : Fixed to 0.
44 * need_padding: Fixed to 0.
45 * process_size: Fixed to 256.
46 *
47 * Return value :
48 * LHDC_ST_ERR : Parameters of init have error.
49 * LHDC_ST_OK : LHDC encoder initial OK.
50 */
51LHDC_STATE LossyEncoderInitV2(FFT_BLOCK fb, int sample_rate, int bits_per_sample, int channels, int block_size, int sink_buf_len, int target_byte_rate, int fast_mode, int one_frame_per_channel, int need_min_byte_rate, int process_size);
52
53/**
54 * LHDC encode function
55 * fb: LHDC control block.
56 * wav : The PCM data. please input non-planer and compact PCM data.
57 * (eg. The input stream format is 96KHz/24bits stereo and the LHDC request 512 samples for each frame.
58 * So the PCM data length should be 512 * 2 * (24/8) = 3072 bytes. The data order should be L/R, L/R, L/R....).
59 * ns : The number of samples, not PCM data byte length. The LHDC encoder only supports 512.
60 * final : Fixed to 0.
61 * out : Output buffer pointer.
62 * out_len : The output buffer size to protect overwrite.
63 *
64 * Return value :
65 * The return value should be the encoded size, otherwise an error occurs (less than or equal to 0)
66 *
67 */
68int LossyEncoderProcessWavV2(FFT_BLOCK fb, unsigned char *wav, int ns, int final, unsigned char *out, int out_len);
69
70/**
71 * LHDC encode function
72 * fb: LHDC control block.
73 * pcm0 : The left channel PCM data.
74 * pcm1 : The right channel PCM data.
75 * ns : The number of samples, not PCM data byte length. The LHDC encoder only supports 512.
76 * final : Fixed to 0.
77 * out : Output buffer pointer.
78 * out_len : The output buffer size to protect overwrite.
79 *
80 * Return value :
81 * The return value should be the encoded size, otherwise an error occurs (less than or equal to 0)
82 *
83 */
84int LossyEncoderProcessPCMV2(FFT_BLOCK fb, int *pcm0, int *pcm1, int ns, int final, unsigned char *out, int out_len);
85
86/**
87 * To change target byte rate at runtime.
88 * (Only support 400kbps, 500kbps, 560kbps, 900kbps)
89 */
90void LossyEncoderSetTargetByteRateV2(FFT_BLOCK fb, int target_byte_rate);
91#endif // _PROCESSV2_BLOCK_H_