Ignore:
Timestamp:
10/06/06 17:14:05 (18 years ago)
Author:
zorg
Message:

Separated public interface from private headers
Use opaque objects whenever possible
Some (useless?) cosmetics on libmpcdec
Remove sv5-6 outdated support
Added libwavformat for upcoming mpcdec
New layout
Work in progress...

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  
    3232  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333*/
    34 
    3534/// \file mpcdec.h
    3635/// Top level include file for libmpcdec.
     36#ifndef _MPCDEC_H_
     37#define _MPCDEC_H_
     38#ifdef WIN32
     39#pragma once
     40#endif
    3741
    38 #ifndef _mpcdec_h_
    39 #define _mpcdec_h_
     42#include "streaminfo.h"
    4043
    4144#ifdef __cplusplus
     
    4346#endif
    4447
    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);
     48typedef struct mpc_decoder_t mpc_decoder;
    9149
    9250/// Sets up decoder library.
    9351/// Call this first when preparing to decode an mpc stream.
    94 /// \param r reader that will supply raw data to the decoder
    95 void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r);
     52/// \param p_reader reader that will supply raw data to the decoder
     53void mpc_decoder_setup(mpc_decoder *p_dec, mpc_reader *p_reader);
    9654
    9755/// Initializes mpc decoder with the supplied stream info parameters.
    98 /// Call this next after calling mpc_decoder_setup.
    9956/// \param si streaminfo structure indicating format of source stream
    10057/// \return TRUE if decoder was initalized successfully, FALSE otherwise   
    101 mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si);
     58mpc_status mpc_init_decoder(mpc_decoder **p_dec, mpc_streaminfo *si);
     59
     60/// Releases input mpc decoder
     61void mpc_exit_decoder(mpc_decoder *p_dec);
    10262
    10363/// Call this next after calling mpc_decoder_setup.
    10464/// \param si streaminfo structure indicating format of source stream
    10565/// \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);
     66void mpc_decoder_set_seeking(mpc_decoder *p_dec, mpc_streaminfo *si, mpc_bool_t fast_seeking);
    10767
    108 void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si);
     68void mpc_decoder_set_streaminfo(mpc_decoder *p_dec, mpc_streaminfo *si);
    10969
    11070/// Sets decoder sample scaling factor.  All decoded samples will be multiplied
    11171/// by this factor.
    11272/// \param scale_factor multiplicative scaling factor
    113 void mpc_decoder_scale_output(mpc_decoder *d, double scale_factor);
     73void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor);
    11474
    11575/// Actually reads data from previously initialized stream.  Call
     
    12282/// \return > 0 to indicate the number of bytes that were actually read from the stream.
    12383mpc_uint32_t mpc_decoder_decode(
    124     mpc_decoder *d,
     84    mpc_decoder       *p_dec,
    12585    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);
    12888
    12989mpc_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,
    13393    MPC_SAMPLE_FORMAT *out_buffer);
    13494
    13595/// Seeks to the specified sample in the source stream.
    136 mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
     96mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *p_dec, mpc_int64_t destsample);
    13797
    13898/// Seeks to specified position in seconds in the source stream.
    139 mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds);
     99mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *p_dec, double seconds);
    140100
    141101#ifdef __cplusplus
    142102}
    143 #endif // __cplusplus
    144 
    145 #endif // _mpcdec_h_
     103#endif
     104#endif
  • libmpcdec/branches/zorg/include/mpcdec/reader.h

    r7 r68  
    3232  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333*/
     34/// \file reader.h
     35#ifndef _MPCDEC_READER_H_
     36#define _MPCDEC_READER_H_
     37#ifdef WIN32
     38#pragma once
     39#endif
    3440
    35 /// \file reader.h
     41#include "mpc_types.h"
    3642
    37 #ifndef _mpcdec_reader_h_
    38 #define _mpcdec_reader_h_
     43#ifdef __cplusplus
     44extern "C" {
     45#endif
     46
    3947
    4048/// \brief Stream reader interface structure.
     
    4351/// to feed it with raw data.  Implement the five member functions to provide
    4452/// a functional reader.
    45 typedef struct mpc_reader_t {
     53typedef struct mpc_reader_t mpc_reader;
     54struct mpc_reader_t {
    4655    /// 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);
    4857
    4958    /// 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);
    5160
    5261    /// Returns the current byte offset in the stream.
    53         mpc_int32_t (*tell)(void *t);
     62        mpc_int32_t (*tell)(mpc_reader *p_reader);
    5463
    5564    /// 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);
    5766
    5867    /// True if the stream is a seekable stream.
    59         mpc_bool_t (*canseek)(void *t);
     68        mpc_bool_t (*canseek)(mpc_reader *p_reader);
    6069
    6170    /// Field that can be used to identify a particular instance of
    6271    /// reader or carry along data associated with that reader.
    6372    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};
    7474
    7575/// Initializes reader with default stdio file reader implementation.  Use
    7676/// this if you're just reading from a plain file.
    7777///
    78 /// \param r reader struct to initalize
    79 /// \param input input stream to attach to the reader
    80 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
     80mpc_status mpc_init_stdio_reader(mpc_reader *p_reader, char *filename);
    8181
    82 #endif // _mpcdec_reader_h_
     82/// Release reader with default stdio file reader implementation.
     83///
     84/// \param r reader handle to release
     85void 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  
    3232  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333*/
     34/// \file streaminfo.h
     35#ifndef _MPCDEC_STREAMINFO_H_
     36#define _MPCDEC_STREAMINFO_H_
     37#ifdef WIN32
     38#pragma once
     39#endif
    3440
    35 /// \file streaminfo.h
     41#include "mpc_types.h"
     42#include "reader.h"
    3643
    37 #ifndef _mpcdec_streaminfo_h_
    38 #define _mpcdec_streaminfo_h_
     44#ifdef __cplusplus
     45extern "C" {
     46#endif
     47
    3948
    4049typedef mpc_int32_t mpc_streaminfo_off_t;
     
    4554/// by the streaminfo_read function.
    4655typedef struct mpc_streaminfo {
    47     /// @name core mpc stream properties
     56    /// @name Core mpc stream properties
    4857    //@{
    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
    6373    //@}
    6474
    65     /// @name replaygain related fields
     75    /// @name Replaygain properties
    6676    //@{
    67     mpc_int16_t         gain_title;          ///< replaygain title value
    68     mpc_int16_t         gain_album;          ///< replaygain album value
    69     mpc_uint16_t        peak_album;          ///< peak album loudness level
    70     mpc_uint16_t        peak_title;          ///< peak title loudness level
     77    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
    7181    //@}
    7282
    73     /// @name true gapless support data
     83    /// @name True gapless properties
    7484    //@{
    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 frame
     85    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
    7787
    78     mpc_uint32_t        encoder_version;     ///< version of encoder used
    79     char                encoder[256];        ///< encoder name
     88    mpc_uint32_t         encoder_version;    ///< Version of encoder used
     89    char                 encoder[256];       ///< Encoder name
    8090
    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
    8893    //@}
    8994} mpc_streaminfo;
    9095
    91 #endif // _mpcdec_streaminfo_h_
     96/// Initializes a streaminfo structure.
     97/// \param si streaminfo structure to initialize
     98void 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
     104mpc_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
     108double mpc_streaminfo_get_length(mpc_streaminfo *si);
     109
     110/// Returns length of stream si, in samples.
     111/// \return length of stream in samples
     112mpc_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.