1 /* 2 * mpadec - MPEG audio decoder 3 * Copyright (C) 2002-2004 Dmitriy Startsev (dstartsev@rambler.ru) 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 /* $Id$ */ 21 22 #ifndef __MPADEC_H 23 #define __MPADEC_H 24 25 #undef FALSE 26 #undef TRUE 27 #define FALSE 0 28 #define TRUE 1 29 30 #define MPADEC_VERSION 0x0900 31 32 #define MPADEC_RETCODE_OK 0 33 #define MPADEC_RETCODE_INVALID_HANDLE 1 34 #define MPADEC_RETCODE_NOT_ENOUGH_MEMORY 2 35 #define MPADEC_RETCODE_BAD_STATE 3 36 #define MPADEC_RETCODE_INVALID_PARAMETERS 4 37 #define MPADEC_RETCODE_NEED_MORE_DATA 5 38 #define MPADEC_RETCODE_BUFFER_TOO_SMALL 6 39 #define MPADEC_RETCODE_NO_SYNC 7 40 #define MPADEC_RETCODE_UNKNOWN 8 41 42 #define MPADEC_CONFIG_FULL_QUALITY 0 43 #define MPADEC_CONFIG_HALF_QUALITY 1 44 45 #define MPADEC_CONFIG_AUTO 0 46 #define MPADEC_CONFIG_MONO 1 47 #define MPADEC_CONFIG_STEREO 2 48 #define MPADEC_CONFIG_CHANNEL1 3 49 #define MPADEC_CONFIG_CHANNEL2 4 50 51 #define MPADEC_CONFIG_16BIT 0 52 #define MPADEC_CONFIG_24BIT 1 53 #define MPADEC_CONFIG_32BIT 2 54 #define MPADEC_CONFIG_FLOAT 3 55 56 #define MPADEC_CONFIG_LITTLE_ENDIAN 0 57 #define MPADEC_CONFIG_BIG_ENDIAN 1 58 59 #define MPADEC_CONFIG_REPLAYGAIN_NONE 0 60 #define MPADEC_CONFIG_REPLAYGAIN_RADIO 1 61 #define MPADEC_CONFIG_REPLAYGAIN_AUDIOPHILE 2 62 #define MPADEC_CONFIG_REPLAYGAIN_CUSTOM 3 63 64 #define MPADEC_INFO_STREAM 0 65 #define MPADEC_INFO_TAG 1 66 #define MPADEC_INFO_CONFIG 2 67 68 typedef struct { 69 uint8_t quality; 70 uint8_t mode; 71 uint8_t format; 72 uint8_t endian; 73 uint8_t replaygain; 74 uint8_t skip; 75 uint8_t crc; 76 uint8_t dblsync; 77 float gain; 78 } mpadec_config_t; 79 80 typedef struct { 81 int32_t layer; 82 int32_t channels; 83 int32_t frequency; 84 int32_t bitrate; 85 uint8_t mode; 86 uint8_t copyright; 87 uint8_t original; 88 uint8_t emphasis; 89 int32_t frames; 90 int32_t frame_size; 91 int32_t frame_samples; 92 int32_t decoded_channels; 93 int32_t decoded_frequency; 94 int32_t decoded_sample_size; 95 int32_t decoded_frame_samples; 96 int32_t duration; 97 } mpadec_info_t; 98 99 typedef struct { 100 uint32_t flags; 101 uint32_t frames; 102 uint32_t bytes; 103 uint8_t toc[100]; 104 int32_t replay_gain[2]; 105 int32_t enc_delay; 106 int32_t enc_padding; 107 } mp3tag_info_t; 108 109 typedef void *mpadec_t; 110 typedef void *mpadec2_t; 111 112 #ifdef __cplusplus 113 extern "C" { 114 #endif 115 116 mpadec_t mpadec_init(void); 117 int mpadec_uninit(mpadec_t mpadec); 118 int mpadec_reset(mpadec_t mpadec); 119 int mpadec_configure(mpadec_t mpadec, mpadec_config_t *cfg); 120 int mpadec_get_info(mpadec_t mpadec, void *info, int info_type); 121 int mpadec_decode(mpadec_t mpadec, uint8_t *srcbuf, uint32_t srcsize, 122 uint8_t *dstbuf, uint32_t dstsize, uint32_t *srcused, 123 uint32_t *dstused); 124 char *mpadec_error(int code); 125 126 mpadec2_t mpadec2_init(void); 127 int mpadec2_uninit(mpadec2_t mpadec); 128 int mpadec2_reset(mpadec2_t mpadec); 129 int mpadec2_configure(mpadec2_t mpadec, mpadec_config_t *cfg); 130 int mpadec2_get_info(mpadec2_t mpadec, void *info, int info_type); 131 int mpadec2_decode(mpadec2_t mpadec, uint8_t *srcbuf, uint32_t srcsize, 132 uint8_t *dstbuf, uint32_t dstsize, uint32_t *dstused); 133 #define mpadec2_error(x) mpadec_error(x) 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif 140