summaryrefslogtreecommitdiff
path: root/apps/codecs/libmusepack/decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libmusepack/decoder.h')
-rw-r--r--apps/codecs/libmusepack/decoder.h120
1 files changed, 42 insertions, 78 deletions
diff --git a/apps/codecs/libmusepack/decoder.h b/apps/codecs/libmusepack/decoder.h
index 9031bf29e7..b3d24cf4ea 100644
--- a/apps/codecs/libmusepack/decoder.h
+++ b/apps/codecs/libmusepack/decoder.h
@@ -1,5 +1,5 @@
1/* 1/*
2 Copyright (c) 2005, The Musepack Development Team 2 Copyright (c) 2005-2009, The Musepack Development Team
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
@@ -31,107 +31,71 @@
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*/ 33*/
34
35/// \file decoder.h 34/// \file decoder.h
35#ifndef _MPCDEC_DECODER_H_
36#define _MPCDEC_DECODER_H_
37#ifdef WIN32
38#pragma once
39#endif
36 40
37#ifndef _mpcdec_decoder_h_
38#define _mpcdec_decoder_h_
39
40#include "huffman.h"
41#include "math.h"
42#include "musepack.h"
43#include "reader.h" 41#include "reader.h"
44#include "streaminfo.h"
45 42
46// define this to enable/disable support for streamversion SV4-6 43#ifdef __cplusplus
47//#define MPC_SUPPORT_SV456 44extern "C" {
45#endif
48 46
49// SCF_HACK is used to avoid possible distortion after seeking with mpc files 47#define SEEKING_TABLE_SIZE 256u
50// background: scf's are coded differential in time domain. if you seek to the 48// set it to SLOW_SEEKING_WINDOW to not use fast seeking
51// desired postion it might happen that the baseline is missed and the resulting 49#define FAST_SEEKING_WINDOW 32
52// scf is much too high (hissing noise). this hack uses the lowest scaling until 50// set it to FAST_SEEKING_WINDOW to only use fast seeking
53// a non-differential scf could be decoded after seek. through this hack subbands 51#define SLOW_SEEKING_WINDOW 0x80000000
54// are faded out until there was at least a single non-differential scf found.
55#define SCF_HACK
56 52
57enum { 53enum {
58 MPC_V_MEM = 2304, 54 MPC_V_MEM = 2304,
59 MPC_DECODER_MEMSIZE = 16384, // overall buffer size (words) 55 MPC_DECODER_MEMSIZE = 16384, // overall buffer size
60 MPC_SEEK_BUFFER_SIZE = 8192, // seek buffer size (words)
61}; 56};
62 57
63typedef struct { 58struct mpc_decoder_t {
64 mpc_int16_t L [36];
65 mpc_int16_t R [36];
66} QuantTyp;
67
68typedef struct mpc_decoder_t {
69 mpc_reader *r;
70
71 /// @name internal state variables 59 /// @name internal state variables
72 //@{ 60 //@{
61 mpc_uint32_t stream_version; ///< Streamversion of stream
62 mpc_int32_t max_band; ///< Maximum band-index used in stream (0...31)
63 mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on)
64 mpc_uint32_t channels; ///< Number of channels in stream
73 65
74 mpc_uint32_t next; 66 mpc_uint64_t samples; ///< Number of samples in stream
75 mpc_uint32_t dword; /// currently decoded 32bit-word
76 mpc_uint32_t pos; /// bit-position within dword
77 mpc_uint32_t *Speicher; /// read-buffer
78 mpc_uint32_t Zaehler; /// actual index within read-buffer
79 mpc_uint32_t Ring;
80
81 mpc_uint32_t samples_to_skip;
82 mpc_uint32_t last_block_samples;
83 mpc_uint32_t FwdJumpInfo;
84 mpc_uint32_t ActDecodePos;
85
86
87 mpc_uint32_t DecodedFrames;
88 mpc_uint32_t OverallFrames;
89 mpc_int32_t SampleRate; // Sample frequency
90
91 mpc_uint32_t StreamVersion; // version of bitstream
92 mpc_int32_t Max_Band;
93 mpc_uint32_t MPCHeaderPos; // AB: needed to support ID3v2
94 67
95 mpc_uint32_t FrameWasValid; 68 mpc_uint64_t decoded_samples; ///< Number of samples decoded from file begining
96 mpc_uint32_t MS_used; // MS-coding used ? 69 mpc_uint32_t samples_to_skip; ///< Number samples to skip (used for seeking)
97 mpc_uint32_t TrueGaplessPresent; 70 mpc_int32_t last_max_band; ///< number of bands used in the last frame
98
99 mpc_uint32_t WordsRead; // counts amount of decoded dwords
100 71
101 // randomizer state variables 72 // randomizer state variables
102 mpc_uint32_t __r1; 73 mpc_uint32_t __r1;
103 mpc_uint32_t __r2; 74 mpc_uint32_t __r2;
104 75
105 mpc_int8_t SCF_Index_L [32] [3]; 76 mpc_int32_t SCF_Index_L [32] [3];
106 mpc_int8_t SCF_Index_R [32] [3]; // holds scalefactor-indices 77 mpc_int32_t SCF_Index_R [32] [3]; // holds scalefactor-indices
107 QuantTyp Q [32]; // holds quantized samples 78 mpc_quantizer Q [32]; // holds quantized samples
108 mpc_int8_t Res_L [32]; 79 mpc_int32_t Res_L [32];
109 mpc_int8_t Res_R [32]; // holds the chosen quantizer for each subband 80 mpc_int32_t Res_R [32]; // holds the chosen quantizer for each subband
110#ifdef MPC_SUPPORT_SV456
111 mpc_bool_t DSCF_Flag_L [32]; 81 mpc_bool_t DSCF_Flag_L [32];
112 mpc_bool_t DSCF_Flag_R [32]; // differential SCF used? 82 mpc_bool_t DSCF_Flag_R [32]; // differential SCF used?
113#endif 83 mpc_int32_t SCFI_L [32];
114 mpc_int8_t SCFI_L [32]; 84 mpc_int32_t SCFI_R [32]; // describes order of transmitted SCF
115 mpc_int8_t SCFI_R [32]; // describes order of transmitted SCF
116 mpc_bool_t MS_Flag[32]; // MS used? 85 mpc_bool_t MS_Flag[32]; // MS used?
117
118 mpc_uint32_t SeekTableCounter; // used to sum up skip info, if SeekTable_Step != 1
119 mpc_uint32_t MaxDecodedFrames; // Maximum frames decoded (indicates usable seek table entries)
120 mpc_uint32_t* SeekTable; // seek table itself
121 mpc_uint8_t SeekTable_Step; // 1<<SeekTable_Step = frames per table index
122 mpc_uint32_t SeekTable_Mask; // used to avoid modulo-operation in seek
123
124#ifdef MPC_FIXED_POINT 86#ifdef MPC_FIXED_POINT
125 mpc_uint8_t SCF_shift[256]; 87 mpc_uint8_t SCF_shift[256];
126#endif 88#endif
127 89
128 MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960]; 90 MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960];
129 MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960]; 91 MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960];
130 MPC_SAMPLE_FORMAT (*Y_L)[32]; 92 MPC_SAMPLE_FORMAT *Y_L;
131 MPC_SAMPLE_FORMAT (*Y_R)[32]; 93 MPC_SAMPLE_FORMAT *Y_R;
132 MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention) 94 MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention)
133 //@} 95 //@}
96};
134 97
135} mpc_decoder; 98#ifdef __cplusplus
136 99}
137#endif // _mpc_decoder_h 100#endif
101#endif