📄 mpegdec.h
字号:
/****************************************************************************//* * mpegdec.h -- MPEG Audio decoder definitions. * * Author : St閜hane TAVENARD * * (C) Copyright 1997-1998 St閜hane TAVENARD * All Rights Reserved * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//****************************************************************************/#ifndef MPEGDEC_H#define MPEGDEC_H/****************************************************************************/#include "bitstr.h"/* * Controls for decoding *//* * Qualities */#define MPEGDEC_QUALITY_LOW 0#define MPEGDEC_QUALITY_MEDIUM 1#define MPEGDEC_QUALITY_HIGH 2/* * Specify how to access the bitstream * open: open the bitstream, should return your file handle * (or NULL if failed), stream_size is the total size of * the stream (in bytes, could be 0 if unknown) * close: close the bitstream * read: read bytes from bitstream, return # of bytes read * or <=0 if EOF * seek: seek to an absolute byte position inside the bitstream, * return 0 if Ok */typedef struct { INT32 (*open)(char *stream_name, INT32 buffer_size, INT32 *stream_size); void (*close)(INT32 handle); INT32 (*read)(INT32 handle, void *buffer, INT32 num_bytes); int (*seek)(INT32 handle, INT32 abs_byte_seek_pos);} MPEGDEC_ACCESS;/* * Decoding output */typedef struct { INT16 freq_div; // 1, 2 or 4 INT16 quality; // 0 (low) .. 2 (high) INT32 freq_max; // for automatic freq_div (if mono_freq_div==0)} MPEGDEC_OUTPUT;/* * Decoding layer */typedef struct { INT16 force_mono; // 1 = stereo stream in mono, 0 otherwise MPEGDEC_OUTPUT mono; // mono settings MPEGDEC_OUTPUT stereo; // stereo settings} MPEGDEC_LAYER;/* * Control structure of MPEG Audio decoding */typedef struct { MPEGDEC_ACCESS *bs_access; // NULL for default access (file I/O) // or give your own bitstream access MPEGDEC_LAYER layer_1_2; // Layer I & II settings (#8) MPEGDEC_LAYER layer_3; // Layer III settings (#8) INT16 check_mpeg; // 1 to check for mpeg audio validity // at start of stream, 0 otherwise INT32 stream_buffer_size; // #7: size of bitstream buffer // in bytes (0 -> default size) // NOTE: stream_buffer_size must be // multiple of 4 bytes} MPEGDEC_CTRL;/* * Modes */#define MPEGDEC_MODE_STEREO 0#define MPEGDEC_MODE_J_STEREO 1#define MPEGDEC_MODE_DUAL 2#define MPEGDEC_MODE_MONO 3typedef struct { // Stream info INT16 norm; // 1 or 2 INT16 layer; // 1..3 INT16 mode; // 0..3 (MPEGDEC_MODE_xxx) INT16 bitrate; // in kbps INT32 frequency; // in Hz INT16 channels; // 1 or 2 UINT32 ms_duration; // stream duration in ms INT16 private_bit; // 0 or 1 INT16 copyright; // 0 or 1 INT16 original; // 0 or 1 // Decoding info according to MPEG control INT16 dec_channels; INT16 dec_quality; INT32 dec_frequency; // Private data void *handle;} MPEGDEC_STREAM;#define MPEGDEC_MAX_CHANNELS 2 // Max channels#define MPEGDEC_PCM_SIZE 1152 // Max samples per frame/* * Error codes. */#define MPEGDEC_ERR_NONE 0#define MPEGDEC_ERR_BASE 0#define MPEGDEC_ERR_EOF (MPEGDEC_ERR_BASE-1)#define MPEGDEC_ERR_BADFRAME (MPEGDEC_ERR_BASE-2)#define MPEGDEC_ERR_MEM (MPEGDEC_ERR_BASE-3)#define MPEGDEC_ERR_NO_SYNC (MPEGDEC_ERR_BASE-4)#define MPEGDEC_ERR_BADVALUE (MPEGDEC_ERR_BASE-5)/* * Exported functions. */extern MPEGDEC_STREAM *MPEGDEC_open(char *filename, MPEGDEC_CTRL *ctrl);extern void MPEGDEC_close(MPEGDEC_STREAM *mpds);extern int MPEGDEC_scale(MPEGDEC_STREAM *mpds, INT32 scale_percent);extern INT32 MPEGDEC_decode_frame(MPEGDEC_STREAM *mpds, INT16 *pcm[MPEGDEC_MAX_CHANNELS]);extern int MPEGDEC_seek(MPEGDEC_STREAM *mpds, UINT32 ms_time_position);extern int MPEGDEC_time(MPEGDEC_STREAM *mpds, UINT32 *ms_time_position);extern INT32 MPEGDEC_find_sync(INT8 *buffer, INT32 buffer_size);/****************************************************************************/#endif /* MPEGDEC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -