1
0
Fork 0
forked from len0rd/rockbox

Major change to musepack decoder: Import v1.3.0 (r458 from svn.musepack.net) to rockbox. Several adaptions in the musepack decoder were made to get the library work and perform fast under rockbox on several targets. With this change mpc sv8 is supported, including seek, replay gain and metadata support. The decoding speed is a 1-4% lower than the last implementation. Reason for this is main restructuring in the bitstream demuxer.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25056 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2010-03-07 19:34:44 +00:00
parent ce92b8bf34
commit b3d9578c27
36 changed files with 3204 additions and 2807 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2005, The Musepack Development Team
Copyright (c) 2005-2009, The Musepack Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -31,43 +31,77 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// \file internal.h
/// Definitions and structures used only internally by the libmpcdec.
#ifndef _MPCDEC_INTERNAL_H_
#define _MPCDEC_INTERNAL_H_
#ifdef WIN32
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _mpcdec_internal_h
#define _mpcdec_internal_h
#include "mpcdec.h"
/* rockbox: not used, rockbox's swap32 is used now.
/// Big/little endian 32 bit byte swapping routine.
static mpc_inline
mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8)
| ((val & 0x0000FF00) << 8) | ((val & 0x000000FF) << 24));
}
*/
typedef struct mpc_block_t {
char key[2]; // block key
mpc_uint64_t size; // block size minus the block header size
} mpc_block;
#define MAX_FRAME_SIZE 4352
#define DEMUX_BUFFER_SIZE (65536 - MAX_FRAME_SIZE) // need some space as sand box
struct mpc_demux_t {
mpc_reader * r;
mpc_decoder * d;
mpc_streaminfo si;
// buffer
mpc_uint8_t *buffer;
mpc_size_t bytes_total;
mpc_bits_reader bits_reader;
mpc_int32_t block_bits; /// bits remaining in current audio block
mpc_uint_t block_frames; /// frames remaining in current audio block
// seeking
mpc_seek_t * seek_table;
mpc_uint_t seek_pwr; /// distance between 2 frames in seek_table = 2^seek_pwr
mpc_uint32_t seek_table_size; /// used size in seek_table
// chapters
mpc_seek_t chap_pos; /// supposed position of the first chapter block
mpc_int_t chap_nb; /// number of chapters (-1 if unknown, 0 if no chapter)
mpc_chap_info * chap; /// chapters position and tag
enum {
MPC_DECODER_SYNTH_DELAY = 481
};
/// Big/little endian 32 bit byte swapping routine.
/* Use our Rockbox (maybe) optimised swap routine instead */
#define mpc_swap32(x) swap32(x)
#if 0
static __inline
mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) |
((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24));
/**
* checks if a block key is valid
* @param key the two caracters key to check
* @return MPC_STATUS_INVALIDSV if the key is invalid, MPC_STATUS_OK else
*/
static mpc_inline mpc_status mpc_check_key(char * key)
{
if (key[0] < 65 || key[0] > 90 || key[1] < 65 || key[1] > 90)
return MPC_STATUS_INVALIDSV;
return MPC_STATUS_OK;
}
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
/// Searches for a ID3v2-tag and reads the length (in bytes) of it.
/// \param reader supplying raw stream data
/// \return size of tag, in bytes
/// \return -1 on errors of any kind
mpc_int32_t JumpID3v2(mpc_reader* fp);
/// helper functions used by multiple files
mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c
void mpc_decoder_initialisiere_quantisierungstabellen(mpc_decoder *d, double scale_factor);
void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData);
#endif // _mpcdec_internal_h
void mpc_decoder_init_quant(mpc_decoder *d, double scale_factor);
void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData, mpc_int_t channels);
#ifdef __cplusplus
}
#endif
#endif