Changeset 68 for libmpcdec/branches/zorg/include
- Timestamp:
- 10/06/06 17:14:05 (18 years ago)
- Location:
- libmpcdec/branches/zorg/include
- Files:
-
- 1 added
- 4 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpcdec/branches/zorg/include/mpcdec/mpcdec.h
r37 r68 32 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 35 34 /// \file mpcdec.h 36 35 /// Top level include file for libmpcdec. 36 #ifndef _MPCDEC_H_ 37 #define _MPCDEC_H_ 38 #ifdef WIN32 39 #pragma once 40 #endif 37 41 38 #ifndef _mpcdec_h_ 39 #define _mpcdec_h_ 42 #include "streaminfo.h" 40 43 41 44 #ifdef __cplusplus … … 43 46 #endif 44 47 45 #include <stdio.h> 46 #include <stdlib.h> 47 #include <string.h> 48 49 #ifndef WIN32 50 #include "mpcdec/config_types.h" 51 #else 52 #include "mpcdec/config_win32.h" 53 #endif 54 55 #include "decoder.h" 56 #include "math.h" 57 #include "reader.h" 58 #include "streaminfo.h" 59 60 enum { 61 MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame 62 MPC_DECODER_BUFFER_LENGTH = 4 * MPC_FRAME_LENGTH /// required buffer size for decoder 63 }; 64 65 // error codes 66 #define ERROR_CODE_OK 0 67 #define ERROR_CODE_FILE -1 68 #define ERROR_CODE_SV7BETA 1 69 #define ERROR_CODE_CBR 2 70 #define ERROR_CODE_IS 3 71 #define ERROR_CODE_BLOCKSIZE 4 72 #define ERROR_CODE_INVALIDSV 5 73 74 /// Initializes a streaminfo structure. 75 /// \param si streaminfo structure to initialize 76 void mpc_streaminfo_init(mpc_streaminfo *si); 77 78 /// Reads streaminfo header from the mpc stream supplied by r. 79 /// \param si streaminfo pointer to which info will be written 80 /// \param r stream reader to supply raw data 81 /// \return error code 82 mpc_int32_t mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *r); 83 84 /// Gets length of stream si, in seconds. 85 /// \return length of stream in seconds 86 double mpc_streaminfo_get_length(mpc_streaminfo *si); 87 88 /// Returns length of stream si, in samples. 89 /// \return length of stream in samples 90 mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si); 48 typedef struct mpc_decoder_t mpc_decoder; 91 49 92 50 /// Sets up decoder library. 93 51 /// Call this first when preparing to decode an mpc stream. 94 /// \param r reader that will supply raw data to the decoder95 void mpc_decoder_setup(mpc_decoder * d, mpc_reader *r);52 /// \param p_reader reader that will supply raw data to the decoder 53 void mpc_decoder_setup(mpc_decoder *p_dec, mpc_reader *p_reader); 96 54 97 55 /// Initializes mpc decoder with the supplied stream info parameters. 98 /// Call this next after calling mpc_decoder_setup.99 56 /// \param si streaminfo structure indicating format of source stream 100 57 /// \return TRUE if decoder was initalized successfully, FALSE otherwise 101 mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si); 58 mpc_status mpc_init_decoder(mpc_decoder **p_dec, mpc_streaminfo *si); 59 60 /// Releases input mpc decoder 61 void mpc_exit_decoder(mpc_decoder *p_dec); 102 62 103 63 /// Call this next after calling mpc_decoder_setup. 104 64 /// \param si streaminfo structure indicating format of source stream 105 65 /// \param fast_seeking boolean 0 = use fast seeking if safe, 1 = force fast seeking 106 void mpc_decoder_set_seeking(mpc_decoder * d, mpc_streaminfo *si, mpc_bool_t fast_seeking);66 void mpc_decoder_set_seeking(mpc_decoder *p_dec, mpc_streaminfo *si, mpc_bool_t fast_seeking); 107 67 108 void mpc_decoder_set_streaminfo(mpc_decoder * d, mpc_streaminfo *si);68 void mpc_decoder_set_streaminfo(mpc_decoder *p_dec, mpc_streaminfo *si); 109 69 110 70 /// Sets decoder sample scaling factor. All decoded samples will be multiplied 111 71 /// by this factor. 112 72 /// \param scale_factor multiplicative scaling factor 113 void mpc_decoder_scale_output(mpc_decoder * d, double scale_factor);73 void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor); 114 74 115 75 /// Actually reads data from previously initialized stream. Call … … 122 82 /// \return > 0 to indicate the number of bytes that were actually read from the stream. 123 83 mpc_uint32_t mpc_decoder_decode( 124 mpc_decoder *d,84 mpc_decoder *p_dec, 125 85 MPC_SAMPLE_FORMAT *buffer, 126 mpc_uint32_t *vbr_update_acc,127 mpc_uint32_t *vbr_update_bits);86 mpc_uint32_t *vbr_update_acc, 87 mpc_uint32_t *vbr_update_bits); 128 88 129 89 mpc_uint32_t mpc_decoder_decode_frame( 130 mpc_decoder *d,131 mpc_uint32_t *in_buffer,132 mpc_uint32_t in_len,90 mpc_decoder *p_dec, 91 mpc_uint32_t *in_buffer, 92 mpc_uint32_t in_len, 133 93 MPC_SAMPLE_FORMAT *out_buffer); 134 94 135 95 /// Seeks to the specified sample in the source stream. 136 mpc_bool_t mpc_decoder_seek_sample(mpc_decoder * d, mpc_int64_t destsample);96 mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *p_dec, mpc_int64_t destsample); 137 97 138 98 /// Seeks to specified position in seconds in the source stream. 139 mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder * d, double seconds);99 mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *p_dec, double seconds); 140 100 141 101 #ifdef __cplusplus 142 102 } 143 #endif // __cplusplus 144 145 #endif // _mpcdec_h_ 103 #endif 104 #endif -
libmpcdec/branches/zorg/include/mpcdec/reader.h
r7 r68 32 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 /// \file reader.h 35 #ifndef _MPCDEC_READER_H_ 36 #define _MPCDEC_READER_H_ 37 #ifdef WIN32 38 #pragma once 39 #endif 34 40 35 /// \file reader.h 41 #include "mpc_types.h" 36 42 37 #ifndef _mpcdec_reader_h_ 38 #define _mpcdec_reader_h_ 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 39 47 40 48 /// \brief Stream reader interface structure. … … 43 51 /// to feed it with raw data. Implement the five member functions to provide 44 52 /// a functional reader. 45 typedef struct mpc_reader_t { 53 typedef struct mpc_reader_t mpc_reader; 54 struct mpc_reader_t { 46 55 /// Reads size bytes of data into buffer at ptr. 47 mpc_int32_t (*read)( void *t, void *ptr, mpc_int32_t size);56 mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size); 48 57 49 58 /// Seeks to byte position offset. 50 mpc_bool_t (*seek)( void *t, mpc_int32_t offset);59 mpc_bool_t (*seek)(mpc_reader *p_reader, mpc_int32_t offset); 51 60 52 61 /// Returns the current byte offset in the stream. 53 mpc_int32_t (*tell)( void *t);62 mpc_int32_t (*tell)(mpc_reader *p_reader); 54 63 55 64 /// Returns the total length of the source stream, in bytes. 56 mpc_int32_t (*get_size)( void *t);65 mpc_int32_t (*get_size)(mpc_reader *p_reader); 57 66 58 67 /// True if the stream is a seekable stream. 59 mpc_bool_t (*canseek)( void *t);68 mpc_bool_t (*canseek)(mpc_reader *p_reader); 60 69 61 70 /// Field that can be used to identify a particular instance of 62 71 /// reader or carry along data associated with that reader. 63 72 void *data; 64 65 } mpc_reader; 66 67 typedef struct mpc_reader_file_t { 68 mpc_reader reader; 69 70 FILE *file; 71 long file_size; 72 mpc_bool_t is_seekable; 73 } mpc_reader_file; 73 }; 74 74 75 75 /// Initializes reader with default stdio file reader implementation. Use 76 76 /// this if you're just reading from a plain file. 77 77 /// 78 /// \param r reader struct to initalize79 /// \param input input streamto attach to the reader80 void mpc_reader_setup_file_reader(mpc_reader_file *r, FILE *input);78 /// \param r p_reader handle to initialize 79 /// \param filename input filename to attach to the reader 80 mpc_status mpc_init_stdio_reader(mpc_reader *p_reader, char *filename); 81 81 82 #endif // _mpcdec_reader_h_ 82 /// Release reader with default stdio file reader implementation. 83 /// 84 /// \param r reader handle to release 85 void mpc_exit_stdio_reader(mpc_reader *p_reader); 86 87 #ifdef __cplusplus 88 } 89 #endif 90 #endif -
libmpcdec/branches/zorg/include/mpcdec/streaminfo.h
r37 r68 32 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 33 */ 34 /// \file streaminfo.h 35 #ifndef _MPCDEC_STREAMINFO_H_ 36 #define _MPCDEC_STREAMINFO_H_ 37 #ifdef WIN32 38 #pragma once 39 #endif 34 40 35 /// \file streaminfo.h 41 #include "mpc_types.h" 42 #include "reader.h" 36 43 37 #ifndef _mpcdec_streaminfo_h_ 38 #define _mpcdec_streaminfo_h_ 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 39 48 40 49 typedef mpc_int32_t mpc_streaminfo_off_t; … … 45 54 /// by the streaminfo_read function. 46 55 typedef struct mpc_streaminfo { 47 /// @name core mpc stream properties56 /// @name Core mpc stream properties 48 57 //@{ 49 mpc_uint32_t sample_freq; ///< sample frequency of stream 50 mpc_uint32_t channels; ///< number of channels in stream 51 mpc_streaminfo_off_t header_position; ///< byte offset of position of header in stream 52 mpc_uint32_t stream_version; ///< streamversion of stream 53 mpc_uint32_t bitrate; ///< bitrate of stream file (in bps) 54 double average_bitrate; ///< average bitrate of stream (in bits/sec) 55 mpc_uint32_t frames; ///< number of frames in stream 56 mpc_int64_t pcm_samples; 57 mpc_uint32_t max_band; ///< maximum band-index used in stream (0...31) 58 mpc_uint32_t is; ///< intensity stereo (0: off, 1: on) 59 mpc_uint32_t ms; ///< mid/side stereo (0: off, 1: on) 60 mpc_uint32_t block_size; ///< only needed for SV4...SV6 -> not supported 61 mpc_uint32_t profile; ///< quality profile of stream 62 const char* profile_name; ///< name of profile used by stream 58 mpc_uint32_t sample_freq; ///< Sample frequency of stream 59 mpc_uint32_t channels; ///< Number of channels in stream 60 mpc_streaminfo_off_t header_position; ///< Byte offset of position of header in stream 61 mpc_uint32_t stream_version; ///< Streamversion of stream 62 mpc_uint32_t bitrate; ///< Bitrate of stream file (in bps) 63 double average_bitrate; ///< Average bitrate of stream (in bits/sec) 64 mpc_uint32_t frames; ///< Number of frames in stream 65 mpc_int64_t pcm_samples; ///< Approximate number of pcm samples in stream 66 mpc_uint32_t max_band; ///< Maximum band-index used in stream (0...31) 67 mpc_uint32_t is; ///< Intensity stereo (0: off, 1: on) 68 mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) 69 mpc_uint32_t block_size; ///< Only needed for SV4...SV6 -> not supported 70 mpc_uint32_t profile; ///< Quality profile of stream 71 const char* profile_name; ///< Name of profile used by stream 72 mpc_uint32_t fast_seek; ///< True if stream supports fast-seeking 63 73 //@} 64 74 65 /// @name replaygain related fields75 /// @name Replaygain properties 66 76 //@{ 67 mpc_int16_t gain_title; ///< replaygain title value68 mpc_int16_t gain_album; ///< replaygain album value69 mpc_uint16_t peak_album; ///< peak album loudness level70 mpc_uint16_t peak_title; ///< peak title loudness level77 mpc_int16_t gain_title; ///< Replaygain title value 78 mpc_int16_t gain_album; ///< Replaygain album value 79 mpc_uint16_t peak_album; ///< Peak album loudness level 80 mpc_uint16_t peak_title; ///< Peak title loudness level 71 81 //@} 72 82 73 /// @name true gapless support data83 /// @name True gapless properties 74 84 //@{ 75 mpc_uint32_t is_true_gapless; ///< true gapless? (0: no, 1: yes)76 mpc_uint32_t last_frame_samples; ///< number of valid samples within last frame85 mpc_uint32_t is_true_gapless; ///< True gapless? (0: no, 1: yes) 86 mpc_uint32_t last_frame_samples; ///< Number of valid samples within last frame 77 87 78 mpc_uint32_t encoder_version; ///< version of encoder used79 char encoder[256]; ///< encoder name88 mpc_uint32_t encoder_version; ///< Version of encoder used 89 char encoder[256]; ///< Encoder name 80 90 81 mpc_streaminfo_off_t tag_offset; ///< offset to file tags 82 mpc_streaminfo_off_t total_file_length; ///< total length of underlying file 83 //@} 84 85 /// @name fast seeking support 86 //@{ 87 mpc_uint32_t fast_seek; ///< support fast seeking ? (0: no, 1: yes) 91 mpc_streaminfo_off_t tag_offset; ///< Ofset to file tags 92 mpc_streaminfo_off_t total_file_length; ///< Total length of underlying file 88 93 //@} 89 94 } mpc_streaminfo; 90 95 91 #endif // _mpcdec_streaminfo_h_ 96 /// Initializes a streaminfo structure. 97 /// \param si streaminfo structure to initialize 98 void mpc_streaminfo_init(mpc_streaminfo *si); 99 100 /// Reads streaminfo header from the mpc stream supplied by r. 101 /// \param si si pointer to which info will be written 102 /// \param p_reader stream reader to supply raw data 103 /// \return error code 104 mpc_status mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *p_reader); 105 106 /// Gets length of stream si, in seconds. 107 /// \return length of stream in seconds 108 double mpc_streaminfo_get_length(mpc_streaminfo *si); 109 110 /// Returns length of stream si, in samples. 111 /// \return length of stream in samples 112 mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si); 113 114 #ifdef __cplusplus 115 } 116 #endif 117 #endif
Note: See TracChangeset
for help on using the changeset viewer.