2 Copyright (c) 2005-2009, The Musepack Development Team
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
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
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 /// Definitions and structures used only internally by the libmpcdec.
36 #ifndef _MPCDEC_INTERNAL_H_
37 #define _MPCDEC_INTERNAL_H_
47 /* rockbox: not used, rockbox's swap32 is used now.
48 /// Big/little endian 32 bit byte swapping routine.
50 mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
51 return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8)
52 | ((val & 0x0000FF00) << 8) | ((val & 0x000000FF) << 24));
55 typedef struct mpc_block_t
{
56 char key
[2]; // block key
57 mpc_uint64_t size
; // block size minus the block header size
60 #define MAX_FRAME_SIZE 4352
61 #define DEMUX_BUFFER_SIZE (65536 - MAX_FRAME_SIZE) // need some space as sand box
70 mpc_size_t bytes_total
;
71 mpc_bits_reader bits_reader
;
72 mpc_int32_t block_bits
; /// bits remaining in current audio block
73 mpc_uint_t block_frames
; /// frames remaining in current audio block
76 mpc_seek_t
* seek_table
;
77 mpc_uint_t seek_pwr
; /// distance between 2 frames in seek_table = 2^seek_pwr
78 mpc_uint32_t seek_table_size
; /// used size in seek_table
81 mpc_seek_t chap_pos
; /// supposed position of the first chapter block
82 mpc_int_t chap_nb
; /// number of chapters (-1 if unknown, 0 if no chapter)
83 mpc_chap_info
* chap
; /// chapters position and tag
88 * checks if a block key is valid
89 * @param key the two caracters key to check
90 * @return MPC_STATUS_INVALIDSV if the key is invalid, MPC_STATUS_OK else
92 static mpc_inline mpc_status
mpc_check_key(char * key
)
94 if (key
[0] < 65 || key
[0] > 90 || key
[1] < 65 || key
[1] > 90)
95 return MPC_STATUS_INVALIDSV
;
99 /// helper functions used by multiple files
100 mpc_uint32_t
mpc_random_int(mpc_decoder
*d
); // in synth_filter.c
101 void mpc_decoder_init_quant(mpc_decoder
*d
, double scale_factor
);
102 void mpc_decoder_synthese_filter_float(mpc_decoder
*d
, MPC_SAMPLE_FORMAT
* OutData
, mpc_int_t channels
);
103 unsigned long mpc_crc32(unsigned char *buf
, int len
);
106 mpc_status
streaminfo_read_header_sv8(mpc_streaminfo
* si
,
107 const mpc_bits_reader
* r_in
,
108 mpc_size_t block_size
);
109 mpc_status
streaminfo_read_header_sv7(mpc_streaminfo
* si
, mpc_bits_reader
* r_in
);
110 void streaminfo_encoder_info(mpc_streaminfo
* si
, const mpc_bits_reader
* r_in
);
111 void streaminfo_gain(mpc_streaminfo
* si
, const mpc_bits_reader
* r_in
);
114 void mpc_decoder_reset_scf(mpc_decoder
* d
, int value
);