1/*
2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __AUDIO_MP3_ADP_H__
17#define __AUDIO_MP3_ADP_H__
18
19#include <stdio.h>
20
21#include "hi_comm_aio.h"
22#include "mpi_audio.h"
23#include "hi_comm_adec.h"
24#include "mp3dec.h"
25
26/* max length of MP3 stream by bytes */
27#define MAX_MP3_MAINBUF_SIZE    2048*2
28#define MP3_SAMPLES_PER_FRAME   1152
29#define NO_ENOUGH_MAIN_DATA_ERROR 11
30
31typedef enum hiMP3_BPS_E {
32    MP3_BPS_32K     = 32000,
33    MP3_BPS_40K     = 40000,
34    MP3_BPS_48K     = 48000,
35    MP3_BPS_56K     = 56000,
36    MP3_BPS_64K     = 64000,
37    MP3_BPS_80K     = 80000,
38    MP3_BPS_96K     = 96000,
39    MP3_BPS_112K    = 112000,
40    MP3_BPS_128K    = 128000,
41    MP3_BPS_160K    = 160000,
42    MP3_BPS_192K    = 192000,
43    MP3_BPS_224K    = 224000,
44    MP3_BPS_256K    = 256000,
45    MP3_BPS_320K    = 320000,
46} MP3_BPS_E;
47
48typedef enum hiMP3_LAYER_E {
49    MP3_LAYER_1     = 1,
50    MP3_LAYER_2     = 2,
51    MP3_LAYER_3     = 3,
52} MP3_LAYER_E;
53
54typedef enum hiMP3_VERSION_E {
55    MPEG_1          = 1,
56    MPEG_2          = 0,
57    MPEG_25         = 2,
58} MP3_VERSION_E;
59
60typedef struct hiMP3_FRAME_INFO_S {
61    HI_S32 s32BitRate;
62    HI_S32 s32Chans;                /* 1 or 2 */
63    HI_S32 s32SampRate;
64    HI_S32 s32BitsPerSample;        /* only support 16 bits */
65    HI_S32 s32OutPutSamps;          /* nChans*SamplePerFrame */
66    HI_S32 s32Layer;                /* layer,the infomation of stream's encode profile */
67    HI_S32 s32Version;              /* version,the infomation of stream's encode profile */
68} MP3_FRAME_INFO_S;
69
70typedef struct hiADEC_ATTR_MP3_S {
71    HI_U32 resv;
72} ADEC_ATTR_MP3_S;
73
74typedef struct hiADEC_MP3_DECODER_S {
75    ADEC_ATTR_MP3_S     stMP3Attr;
76    HMP3Decoder         pstMP3State;
77} ADEC_MP3_DECODER_S;
78
79HI_S32 HI_MPI_ADEC_Mp3Init(HI_VOID);
80
81#endif
82
83