📄 fmad.h
字号:
//****************************************************************************
//
// Faraday Technology Coporation
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//*--------------------------------------------------------------------------*
//* Name:FMAD.h *
//* Description: MPEG-1/2 Audio Layer 3 Decoder API definition *
//* Author: Shawn, Hsiao *
//* Date: 2006/06/06 *
//* Version:1.0 *
//****************************************************************************
#ifndef FMP3D_H_INCLUDED
#define FMP3D_H_INCLUDED
struct MP3dec_info;
//============================================================================
// Definition
//============================================================================
//******************************************************************************
//
#define IN_SIZE 1024
//
//******************************************************************************
//
// Define input buffer size as 1024
//
//******************************************************************************
//******************************************************************************
//
#define OUT_SIZE 4608
//
//******************************************************************************
//
// Define output buffer size as 4608
//
//******************************************************************************
//******************************************************************************
//
#define FARADAY_EQ
//
//******************************************************************************
//
// If define this term, the Equalizer (EQ) is inserted.
//
//******************************************************************************
//******************************************************************************
//
#define DISPLAYSET_MP3DEC_BY_FRAME
//
//******************************************************************************
//
// If define this term, the decoder will call call-back function
// "DisplaySet_MP3dec_type" once in a frame. Decoder may give response
// frequently. It might consume more computing power because the function is calling.
// If non-define, the default case is once per input data.
//
//******************************************************************************
//******************************************************************************
//
#define DISPLAY_AACDEC_INFO
//
//******************************************************************************
//
// If define this term, the decoder will get AAC decoder information.
//
//******************************************************************************
//******************************************************************************
//
#define DISPLAY_TIME_INFO
//
//******************************************************************************
//
// If define this term, the decoder will get time information.
//
//******************************************************************************
//============================================================================
// Call-back function type define
//============================================================================
//******************************************************************************
//
typedef int (*OutputPCM_type)(char *, int, int);
//
//******************************************************************************
//
// input:
// parameter 1 -> output buffer pointer
// parameter 2 -> output data size in bytes
// parameter 3 -> output file ("0" means no file output)
// output: data size which is really output in bytes
//
// This call-back function is called when decoder decoded one frame data.
// For the case of MP3 decoder, the data in one frame is fixed to 9216 bytes
// (32-bits output sample) or 4608 bytes (16-bits output sample).
// It is suggested that when the function is called, the main program must
// get all output samples at once. Otherwise, the decoder will keep calling
// until all output samples are got.
// The correct size of output data, which is really got from output buffer, must be
// given to make sure the decoder works normally.
//
//******************************************************************************
//******************************************************************************
//
typedef int (*InputData_type)(char *, int, int);
//
//******************************************************************************
//
// input:
// parameter 1 -> input buffer pointer
// parameter 2 -> input size
// parameter 3 -> input file ("0" means no file input)
// output: data size which is really input in bytes
//
// This call-back function is called when decoder needs more data to input buffer.
// The decoder gives an expected data size and a pointer, which the data must be placed at.
// The correct size of input data, which is really placed to input buffer, must be
// given to make sure the decoder works normally.
//
//******************************************************************************
//******************************************************************************
//
typedef int (*DataSeek_type)(int, int, int);
//
//******************************************************************************
//
// input:
// parameter 1 -> data seek size
// parameter 2 -> seek type 0: seek from start, 1: seek from current, 2: seek from end
// parameter 3 -> input file ("0" means no file input)
// output: error message -> 0: ok, others: fail
//
// This function is called when the decoder want to seek to some specific point in
// the bitstream or file.
//
//******************************************************************************
//******************************************************************************
//
typedef void (*DisplaySet_MP3dec_type)(struct MP3dec_info *);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information pointer
// output: NA
//
// This function is called when the decoder can serve the display and set process.
// It can be defined 1) once per frame, or 2) once per input data.
// If the program does not need to display or set, this function must be sure as
// an empty function. Otherwise, it may does some unpredictable processing.
//
//******************************************************************************
//============================================================================
// Data structure
//============================================================================
//******************************************************************************
//
// struct MP3dec_info
//
//******************************************************************************
//
// This structure defines all MP3 decoder information with elements:
// 1) input_file: save the input file pointer. If no one, set it "0".
// 2) output_file: save the output file pointer. If no one, set it "0".
// 3) input_buf: save the pointer of input buffer.
// 4) output_buf: save the pointer of output buffer.
// 5) layer: information of layer.
// 6) bit_rate: information of bit rate.
// 7) sampling_frequency: information of sampling rate.
// 8) mode: information of channel mode -> 0: mono, 1: stereo.
// 9) mode_ext: information of extension channel mode.
// 10) EQ: information of EQ mode.
// 11) count: information of timer -> bits[31:26] is minute, bits[25:20] is second,
// bits[19:0] is counter which is used to count sum of output samples.
// 12) InputData_type: callback function.
// 13) OutputPCM_type: callback function.
// 14) DataSeek_type: callback function.
// 15) DisplaySet_MP3dec_type: callback function.
//
//******************************************************************************
struct MP3dec_info
{
int input_file; // input file
int output_file; // output file
char *input_buf; // input buffer
char *output_buf; // ouput buffer
int layer; // layer information
int bit_rate; // bit rate information
int sampling_frequency; // sampling rate information
int mode; // channel mode information
int mode_ext; // extension channel mode information
int EQ; // equalizer mode
unsigned int count; // [6-bits, 6-bits, 20-bits] = [minute, second, count]
InputData_type InputData; // call-back function
OutputPCM_type OutputPCM; // call-back function
DataSeek_type DataSeek; // call-back function
DisplaySet_MP3dec_type DisplaySet_MP3dec; // call-back function
};
//============================================================================
// Functions
//============================================================================
//******************************************************************************
//
int init_MP3dec_info(struct MP3dec_info *);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information
// output: error message -> 0: ok, others: fail
//
// This function is used to initialize MP3 decoder bit-stream information.
//
//******************************************************************************
//******************************************************************************
//
int init_Data(struct MP3dec_info *, int, int, char *, char *);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information
// parameter 2 -> input file pointer
// parameter 3 -> output file pointer
// parameter 4 -> input buffer pointer
// parameter 5 -> output buffer pointer
// output: error message -> 0: ok, others: fail
//
// This function is used to set all data information.
//
//******************************************************************************
//******************************************************************************
//
int init_CallbackFunction(struct MP3dec_info *, InputData_type, OutputPCM_type, DataSeek_type, DisplaySet_MP3dec_type);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information.
// parameter 2 -> Input data function pointer
// parameter 3 -> Output PCM function pointer
// parameter 4 -> Data seek function pointer
// parameter 5 -> Display and set function pointer
// output: error message -> 0: ok, others: fail
//
// This function is used to set all call-back functions.
//
//******************************************************************************
//******************************************************************************
//
int set_Faraday_EQ(int);
//
//******************************************************************************
//
// input:
// parameter 1 -> EQ mode
// output: EQ mode which is set
//
// This function is used to set Faraday EQ mode.
//
//******************************************************************************
//******************************************************************************
//
int init_Faraday_MP3dec(struct MP3dec_info *);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information
// output: error message -> 0: ok, 1: error
//
// This function is used to initial MP3 Decoder. There are three steps:
// 1) Check ID3 tag. If there is one, skip it.
// 2) Find the first valid header (frame) and ignore the data before it.
// 3) Initial MP3 decoder.
//
//******************************************************************************
//******************************************************************************
//
int do_Faraday_MP3dec(struct MP3dec_info *);
//
//******************************************************************************
//
// input:
// parameter 1 -> MP3 decoder information
// output: error message -> 0: ok, 1: input data error
//
// This function is the main decoding processing including:
// 1) input data
// 2) sync. the valid frame
// 3) decoding
// 4) output data when one frame is decoded
// 5) display and set once per frame or per input data
// 6) get time information per frame
//
//******************************************************************************
#endif //FMP3D_H_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -