summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libmusepack/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libmusepack/internal.h')
-rw-r--r--lib/rbcodec/codecs/libmusepack/internal.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libmusepack/internal.h b/lib/rbcodec/codecs/libmusepack/internal.h
new file mode 100644
index 0000000000..897e6a7b17
--- /dev/null
+++ b/lib/rbcodec/codecs/libmusepack/internal.h
@@ -0,0 +1,123 @@
1/*
2 Copyright (c) 2005-2009, The Musepack Development Team
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
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.
16
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.
21
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.
33*/
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
42extern "C" {
43#endif
44
45#include "mpcdec.h"
46
47/* rockbox: not used, rockbox's swap32 is used now.
48/// Big/little endian 32 bit byte swapping routine.
49static mpc_inline
50mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
51 return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8)
52 | ((val & 0x0000FF00) << 8) | ((val & 0x000000FF) << 24));
53}
54*/
55typedef 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;
59
60#define MAX_FRAME_SIZE 4352
61#define DEMUX_BUFFER_SIZE (32768 - MAX_FRAME_SIZE) // need some space as sand box
62
63struct mpc_demux_t {
64 mpc_reader * r;
65 mpc_decoder * d;
66 mpc_streaminfo si;
67
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
74
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
79
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
85*/
86};
87
88/**
89 * checks if a block key is valid
90 * @param key the two caracters key to check
91 * @return MPC_STATUS_FAIL if the key is invalid, MPC_STATUS_OK else
92 */
93static mpc_inline mpc_status mpc_check_key(char * key)
94{
95 if (key[0] < 65 || key[0] > 90 || key[1] < 65 || key[1] > 90)
96 return MPC_STATUS_FAIL;
97 return MPC_STATUS_OK;
98}
99
100/// helper functions used by multiple files
101mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c
102void mpc_decoder_init_quant(mpc_decoder *d, MPC_SAMPLE_FORMAT factor); // in requant.c
103void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData, mpc_int_t channels);
104unsigned long mpc_crc32(unsigned char *buf, int len);
105
106// streaminfo.c
107mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si,
108 const mpc_bits_reader * r_in,
109 mpc_size_t block_size);
110mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in);
111void streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in);
112void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in);
113
114// mpc_decoder.c
115void mpc_decoder_reset_scf(mpc_decoder * d, int value);
116
117#define MPC_IS_FAILURE(X) ((int)(X) < (int)MPC_STATUS_OK)
118#define MPC_AUTO_FAIL(X) { mpc_status s = (X); if (MPC_IS_FAILURE(s)) return s; }
119
120#ifdef __cplusplus
121}
122#endif
123#endif