Housekeeping. Comment musepack code seqments unused in rockbox.
[kugel-rb.git] / apps / codecs / libmusepack / internal.h
blob760f50b02d2337cd588b711e879a5714154140ac
1 /*
2 Copyright (c) 2005-2009, 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.
34 /// \file internal.h
35 /// Definitions and structures used only internally by the libmpcdec.
36 #ifndef _MPCDEC_INTERNAL_H_
37 #define _MPCDEC_INTERNAL_H_
38 #ifdef WIN32
39 #pragma once
40 #endif
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 #include "mpcdec.h"
47 /* rockbox: not used, rockbox's swap32 is used now.
48 /// Big/little endian 32 bit byte swapping routine.
49 static mpc_inline
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
58 } mpc_block;
60 #define MAX_FRAME_SIZE 4352
61 #define DEMUX_BUFFER_SIZE (65536 - MAX_FRAME_SIZE) // need some space as sand box
63 struct mpc_demux_t {
64 mpc_reader * r;
65 mpc_decoder * d;
66 mpc_streaminfo si;
68 // buffer
69 mpc_uint8_t *buffer;
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
75 // seeking
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
80 // chapters
81 /* rockbox: not used
82 mpc_seek_t chap_pos; /// supposed position of the first chapter block
83 mpc_int_t chap_nb; /// number of chapters (-1 if unknown, 0 if no chapter)
84 mpc_chap_info * chap; /// chapters position and tag
88 /**
89 * checks if a block key is valid
90 * @param key the two caracters key to check
91 * @return MPC_STATUS_INVALIDSV if the key is invalid, MPC_STATUS_OK else
93 static mpc_inline mpc_status mpc_check_key(char * key)
95 if (key[0] < 65 || key[0] > 90 || key[1] < 65 || key[1] > 90)
96 return MPC_STATUS_INVALIDSV;
97 return MPC_STATUS_OK;
100 /// helper functions used by multiple files
101 mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c
102 void mpc_decoder_init_quant(mpc_decoder *d, double scale_factor);
103 void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData, mpc_int_t channels);
104 unsigned long mpc_crc32(unsigned char *buf, int len);
106 // streaminfo.c
107 mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si,
108 const mpc_bits_reader * r_in,
109 mpc_size_t block_size);
110 mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in);
111 void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in);
112 void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in);
114 // mpc_decoder.c
115 void mpc_decoder_reset_scf(mpc_decoder * d, int value);
117 #ifdef __cplusplus
119 #endif
120 #endif