autodetection: convert path to native separators before displaying it.
[Rockbox.git] / apps / codecs / libmusepack / musepack.h
blob9bdebf8b0457ff7aa51f8db26df6932cb79e1a29
1 /*
2 Copyright (c) 2005, The Musepack Development Team
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
17 * Neither the name of the The Musepack Development Team nor the
18 names of its contributors may be used to endorse or promote
19 products derived from this software without specific prior
20 written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /// \file mpcdec.h
36 /// Top level include file for libmpcdec.
38 #ifndef _mpcdec_h_
39 #define _mpcdec_h_
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 //#include <stdlib.h>
46 #include <string.h>
48 #include "../codec.h"
49 #include "config_types.h"
50 #include "decoder.h"
51 #include "math.h"
52 #include "reader.h"
53 #include "streaminfo.h"
55 #ifndef IBSS_ATTR_MPC_SAMPLE_BUF
56 #define IBSS_ATTR_MPC_SAMPLE_BUF IBSS_ATTR
57 #endif
59 #ifndef IBSS_ATTR_MPC_LARGE_IRAM
60 #if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250)
61 /* PP5022/24 and MCF5250 have 128KB of IRAM */
62 #define IBSS_ATTR_MPC_LARGE_IRAM IBSS_ATTR
63 #else
64 /* other PP's and MCF5249 have 96KB of IRAM */
65 #define IBSS_ATTR_MPC_LARGE_IRAM
66 #endif
67 #endif
69 #ifndef ICODE_ATTR_MPC_LARGE_IRAM
70 #if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024)
71 /* PP5022/24 have 128KB of IRAM and have better performance with ICODE_ATTR */
72 #define ICODE_ATTR_MPC_LARGE_IRAM ICODE_ATTR
73 #else
74 /* all other targets either haven't enough IRAM or performance suffers */
75 #define ICODE_ATTR_MPC_LARGE_IRAM
76 #endif
77 #endif
79 #ifdef ROCKBOX_LITTLE_ENDIAN
80 #define MPC_LITTLE_ENDIAN
81 #endif
83 enum {
84 MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame
85 MPC_DECODER_BUFFER_LENGTH = 2 * MPC_FRAME_LENGTH /// required buffer size for decoder
88 // error codes
89 #define ERROR_CODE_OK 0
90 #define ERROR_CODE_FILE -1
91 #define ERROR_CODE_SV7BETA 1
92 #define ERROR_CODE_CBR 2
93 #define ERROR_CODE_IS 3
94 #define ERROR_CODE_BLOCKSIZE 4
95 #define ERROR_CODE_INVALIDSV 5
97 /// Initializes a streaminfo structure.
98 /// \param si streaminfo structure to initialize
99 void mpc_streaminfo_init(mpc_streaminfo *si);
101 /// Reads streaminfo header from the mpc stream supplied by r.
102 /// \param si streaminfo pointer to which info will be written
103 /// \param r stream reader to supply raw data
104 /// \return error code
105 mpc_int32_t mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *r);
107 /// Gets length of stream si, in seconds.
108 /// \return length of stream in seconds
109 double mpc_streaminfo_get_length(mpc_streaminfo *si);
111 /// Returns length of stream si, in samples.
112 /// \return length of stream in samples
113 mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si);
115 /// Sets up decoder library.
116 /// Call this first when preparing to decode an mpc stream.
117 /// \param r reader that will supply raw data to the decoder
118 void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r);
120 /// Initializes mpc decoder with the supplied stream info parameters.
121 /// Call this next after calling mpc_decoder_setup.
122 /// \param si streaminfo structure indicating format of source stream
123 /// \return TRUE if decoder was initalized successfully, FALSE otherwise
124 mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si);
126 /// Sets decoder sample scaling factor. All decoded samples will be multiplied
127 /// by this factor.
128 /// \param scale_factor multiplicative scaling factor
129 void mpc_decoder_scale_output(mpc_decoder *d, double scale_factor);
131 /// Actually reads data from previously initialized stream. Call
132 /// this iteratively to decode the mpc stream.
133 /// \param buffer destination buffer for decoded samples
134 /// \param vbr_update_acc \todo document me
135 /// \param vbr_update_bits \todo document me
136 /// \return -1 if an error is encountered
137 /// \return 0 if the stream has been completely decoded successfully and there are no more samples
138 /// \return > 0 to indicate the number of bytes that were actually read from the stream.
139 mpc_uint32_t mpc_decoder_decode(
140 mpc_decoder *d,
141 MPC_SAMPLE_FORMAT *buffer,
142 mpc_uint32_t *vbr_update_acc,
143 mpc_uint32_t *vbr_update_bits);
145 mpc_uint32_t mpc_decoder_decode_frame(
146 mpc_decoder *d,
147 mpc_uint32_t *in_buffer,
148 mpc_uint32_t in_len,
149 MPC_SAMPLE_FORMAT *out_buffer);
151 /// Seeks to the specified sample in the source stream.
152 mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
154 /// Seeks to specified position in seconds in the source stream.
155 mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds);
157 /// Cleans up the decoder (seektable)
158 void mpc_decoder_destroy(mpc_decoder *d);
160 #ifdef __cplusplus
162 #endif // __cplusplus
164 #endif // _mpcdec_h_