-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.h
174 lines (145 loc) · 9.38 KB
/
types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/***********************************************************************
MPEG-4 Audio RM Module
Lossless coding of 1-bit oversampled audio - DST (Direct Stream Transfer)
This software was originally developed by:
* Aad Rijnberg
Philips Digital Systems Laboratories Eindhoven
* Fons Bruekers
Philips Research Laboratories Eindhoven
* Eric Knapen
Philips Digital Systems Laboratories Eindhoven
And edited by:
* Richard Theelen
Philips Digital Systems Laboratories Eindhoven
* Maxim Anisiutkin
ICT Group
in the course of development of the MPEG-4 Audio standard ISO-14496-1, 2 and 3.
This software module is an implementation of a part of one or more MPEG-4 Audio
tools as specified by the MPEG-4 Audio standard. ISO/IEC gives users of the
MPEG-4 Audio standards free licence to this software module or modifications
thereof for use in hardware or software products claiming conformance to the
MPEG-4 Audio standards. Those intending to use this software module in hardware
or software products are advised that this use may infringe existing patents.
The original developers of this software of this module and their company,
the subsequent editors and their companies, and ISO/EIC have no liability for
use of this software module or modifications thereof in an implementation.
Copyright is not released for non MPEG-4 Audio conforming products. The
original developer retains full right to use this code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party from
using the code for non MPEG-4 Audio conforming products. This copyright notice
must be included in all copies of derivative works.
Copyright © 2004.
Source file: types.h (Type definitions)
Required libraries: <none>
Authors:
RT: Richard Theelen, PDSL-labs Eindhoven <[email protected]>
MA: Maxim Anisiutkin, ICT Group <[email protected]>
Changes:
08-Mar-2004 RT Initial version
26-Jun-2011 MA Most of the arrays are made static to boost performance
************************************************************************/
#ifndef __TYPES_H_INCLUDED
#define __TYPES_H_INCLUDED
/*============================================================================*/
/* INCLUDES */
/*============================================================================*/
#include <stdint.h>
#include "conststr.h"
/*============================================================================*/
/* TYPE DEFINITIONS */
/*============================================================================*/
enum TTable {FILTER, PTABLE};
typedef struct
{
int Resolution; /* Resolution for segments */
int SegmentLen[MAX_CHANNELS][MAXNROF_SEGS]; /* SegmentLen[ChNr][SegmentNr] */
int NrOfSegments[MAX_CHANNELS]; /* NrOfSegments[ChNr] */
int Table4Segment[MAX_CHANNELS][MAXNROF_SEGS]; /* Table4Segment[ChNr][SegmentNr] */
} Segment;
typedef struct
{
int FrameNr; /* Nr of frame that is currently processed */
int NrOfChannels; /* Number of channels in the recording */
int NrOfFilters; /* Number of filters used for this frame */
int NrOfPtables; /* Number of Ptables used for this frame */
int Fsample44; /* Sample frequency 64, 128, 256 */
int PredOrder[2 * MAX_CHANNELS]; /* Prediction order used for this frame */
int PtableLen[2 * MAX_CHANNELS]; /* Nr of Ptable entries used for this frame */
int16_t **ICoefA; /* Integer coefs for actual coding */
int DSTCoded; /* 1=DST coded is put in DST stream, */
/* 0=DSD is put in DST stream */
long CalcNrOfBytes; /* Contains number of bytes of the complete */
long CalcNrOfBits; /* Contains number of bits of the complete */
/* channel stream after arithmetic encoding */
/* (also containing bytestuff-, */
/* ICoefA-bits, etc.) */
int HalfProb[MAX_CHANNELS]; /* Defines per channel which probability is */
/* applied for the first PredOrder[] bits of */
/* a frame (0 = use Ptable entry, 1 = 128) */
int NrOfHalfBits[MAX_CHANNELS]; /* Defines per channel how many bits at the */
/* start of each frame are optionally coded */
/* with p=0.5 */
Segment FSeg; /* Contains segmentation data for filters */
char Filter4Bit[MAX_CHANNELS][MAX_DSDBITS_INFRAME]; /* Filter4Bit[ChNr][BitNr] */
Segment PSeg; /* Contains segmentation data for Ptables */
char Ptable4Bit[MAX_CHANNELS][MAX_DSDBITS_INFRAME]; /* Ptable4Bit[ChNr][BitNr] */
int PSameSegAsF; /* 1 if segmentation is equal for F and P */
int PSameMapAsF; /* 1 if mapping is equal for F and P */
int FSameSegAllCh; /* 1 if all channels have same Filtersegm. */
int FSameMapAllCh; /* 1 if all channels have same Filtermap */
int PSameSegAllCh; /* 1 if all channels have same Ptablesegm. */
int PSameMapAllCh; /* 1 if all channels have same Ptablemap */
int SegAndMapBits; /* Number of bits in the stream for Seg&Map */
int MaxNrOfFilters; /* Max. nr. of filters allowed per frame */
int MaxNrOfPtables; /* Max. nr. of Ptables allowed per frame */
long MaxFrameLen; /* Max frame length of this file */
long ByteStreamLen; /* MaxFrameLen * NrOfChannels */
long BitStreamLen; /* ByteStreamLen * RESOL */
long NrOfBitsPerCh; /* MaxFrameLen * RESOL */
} FrameHeader;
typedef struct
{
int *CPredOrder; /* Code_PredOrder[Method] */
int **CPredCoef; /* Code_PredCoef[Method][CoefNr] */
int *Coded; /* DST encode coefs/entries of Fir/PtabNr */
int *BestMethod; /* BestMethod[Fir/PtabNr] */
int **m; /* m[Fir/PtabNr][Method] */
int **Data; /* Fir/PtabData[Fir/PtabNr][Index] */
int *DataLen; /* Fir/PtabDataLength[Fir/PtabNr] */
int StreamBits; /* nr of bits all filters use in the stream */
int TableType; /* FILTER or PTABLE: indicates contents */
} CodedTable;
typedef struct
{
uint8_t DSTdata[MAX_CHANNELS * MAX_DSDBYTES_INFRAME];
int32_t TotalBytes;
int32_t ByteCounter;
int BitPosition;
uint8_t DataByte;
} StrData;
typedef struct
{
unsigned int Init;
unsigned int C;
unsigned int A;
int cbptr;
} ACData;
typedef struct
{
FrameHeader FrameHdr; /* Contains frame based header information */
CodedTable StrFilter; /* Contains FIR-coef. compression data */
CodedTable StrPtable; /* Contains Ptable-entry compression data */
/* input stream. */
int **P_one; /* Probability table for arithmetic coder */
uint8_t *AData; /* Contains the arithmetic coded bit stream */
/* of a complete frame */
int ADataLen; /* Number of code bits contained in AData[] */
StrData S; /* DST data stream */
int SSE2;
} ebunch;
#endif /* __TYPES_H_INCLUDED */