aboutsummaryrefslogtreecommitdiffstats
path: root/libSBRenc/src/sbr_ram.h
blob: 23eca20f32d2348ff1caa8ad451b7e33b5799ad9 (plain)
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
/****************************************************************************

                     (C) Copyright Fraunhofer IIS (2004)
                               All Rights Reserved

    Please be advised that this software and/or program delivery is
    Confidential Information of Fraunhofer and subject to and covered by the

    Fraunhofer IIS Software Evaluation Agreement
    between Google Inc. and  Fraunhofer
    effective and in full force since March 1, 2012.

    You may use this software and/or program only under the terms and
    conditions described in the above mentioned Fraunhofer IIS Software
    Evaluation Agreement. Any other and/or further use requires a separate agreement.


   This software and/or program is protected by copyright law and international
   treaties. Any reproduction or distribution of this software and/or program,
   or any portion of it, may result in severe civil and criminal penalties, and
   will be prosecuted to the maximum extent possible under law.

 $Id$

*******************************************************************************/
/*!
\file
\brief Memory layout
$Revision: 36847 $
*/
#ifndef __SBR_RAM_H
#define __SBR_RAM_H

#include "sbr_def.h"
#include "env_est.h"
#include "sbr_encoder.h"
#include "sbr.h"



#include "ps_main.h"
#include "ps_encode.h"


#define ENV_TRANSIENTS_BYTE  ( (sizeof(FIXP_DBL)*(MAX_NUM_CHANNELS*3*QMF_MAX_TIME_SLOTS)) )

#define ENV_R_BUFF_BYTE      ( (sizeof(FIXP_DBL)*((QMF_MAX_TIME_SLOTS) * QMF_CHANNELS)) )
#define ENV_I_BUFF_BYTE      ( (sizeof(FIXP_DBL)*((QMF_MAX_TIME_SLOTS) * QMF_CHANNELS)) )

#define Y_BUF_CH_BYTE        ( (sizeof(FIXP_DBL)*QMF_MAX_TIME_SLOTS * QMF_CHANNELS) )

#define ENV_R_BUF_PS_BYTE    ( (sizeof(FIXP_DBL)*QMF_MAX_TIME_SLOTS * QMF_CHANNELS / 2) )
#define ENV_I_BUF_PS_BYTE    ( (sizeof(FIXP_DBL)*QMF_MAX_TIME_SLOTS * QMF_CHANNELS / 2) )

#define TON_BUF_CH_BYTE      ( (sizeof(FIXP_DBL)*(MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS)) )

#define Y_2_BUF_BYTE         ( Y_BUF_CH_BYTE>>1 )


/* Workbuffer RAM - Allocation */
/*
 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 |        OFFSET_NRG      |        OFFSET_QMF       |
 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  --------------------------------------------------
 |         0.5 *          |                         |
 | sbr_envYBuffer_size    |     sbr_envRBuffer      |
 |                        |     sbr_envIBuffer      |
  --------------------------------------------------

*/
  #define BUF_NRG_SIZE   ( (MAX_NUM_CHANNELS * Y_2_BUF_BYTE) )

  #define OFFSET_NRG         ( 0 )
  #define OFFSET_QMF         ( OFFSET_NRG + BUF_NRG_SIZE )

  /* if common dynamic memory used in AAC-core and SBR, find out maximal size of
     SCR buffer (see XX in figure above) */
  /* Only PS required holding 2 channel QMF data. AAC_WK_BUF_SIZE_0 must fit into this buffer. */
  #define BUF_QMF_SIZE  ( 2*(ENV_R_BUFF_BYTE + ENV_I_BUFF_BYTE) )

  /* Size of the shareable memory region than can be reused */
  #define SBR_ENC_DYN_RAM_SIZE  ( BUF_NRG_SIZE + BUF_QMF_SIZE )

/*
 *****************************************************************************************************
 */

  H_ALLOC_MEM(Ram_SbrDynamic_RAM, FIXP_DBL)

  H_ALLOC_MEM(Ram_SbrEncoder, SBR_ENCODER)
  H_ALLOC_MEM(Ram_SbrChannel, SBR_CHANNEL)
  H_ALLOC_MEM(Ram_SbrElement, SBR_ELEMENT)

  H_ALLOC_MEM(Ram_Sbr_quotaMatrix, FIXP_DBL)
  H_ALLOC_MEM(Ram_Sbr_signMatrix, INT)

  H_ALLOC_MEM(Ram_Sbr_QmfStatesAnalysis, FIXP_QAS)

  H_ALLOC_MEM(Ram_Sbr_freqBandTableLO, UCHAR)
  H_ALLOC_MEM(Ram_Sbr_freqBandTableHI, UCHAR)
  H_ALLOC_MEM(Ram_Sbr_v_k_master, UCHAR)

  H_ALLOC_MEM(Ram_Sbr_detectionVectors, UCHAR)
  H_ALLOC_MEM(Ram_Sbr_prevEnvelopeCompensation, UCHAR)
  H_ALLOC_MEM(Ram_Sbr_guideScfb, UCHAR)
  H_ALLOC_MEM(Ram_Sbr_guideVectorDetected, UCHAR)

  /* Dynamic Memory Allocation */

  H_ALLOC_MEM(Ram_Sbr_envYBuffer, FIXP_DBL)
  FIXP_DBL* GetRam_Sbr_envYBuffer (int n, UCHAR* dynamic_RAM);
  FIXP_DBL* GetRam_Sbr_envRBuffer (int n, UCHAR* dynamic_RAM);
  FIXP_DBL* GetRam_Sbr_envIBuffer (int n, UCHAR* dynamic_RAM);

  H_ALLOC_MEM(Ram_Sbr_guideVectorDiff, FIXP_DBL)
  H_ALLOC_MEM(Ram_Sbr_guideVectorOrig, FIXP_DBL)


  H_ALLOC_MEM(Ram_PsEnvRBuffer, FIXP_QMF)
  H_ALLOC_MEM(Ram_PsEnvIBuffer, FIXP_QMF)

  H_ALLOC_MEM(Ram_PsQmfStatesSynthesis, FIXP_DBL)
  H_ALLOC_MEM(Ram_PsQmfNewSamples, FIXP_DBL)

  H_ALLOC_MEM(Ram_PsEncConf, PSENC_CONFIG)
  H_ALLOC_MEM(Ram_PsEncode, PS_ENCODE)
  H_ALLOC_MEM(Ram_PsData, PS_DATA)

#define HYBRID_READ_OFFSET       ( 10 )
#define HYBRID_WRITE_OFFSET      ( ((32)>>1)-6 )

#define HYBRID_DATA_READ_OFFSET  ( 0 )
#define QMF_READ_OFFSET          ( 0 )

  H_ALLOC_MEM(Ram_PsRqmf, FIXP_DBL)
  H_ALLOC_MEM(Ram_PsIqmf, FIXP_DBL)
  FIXP_DBL* FDKsbrEnc_SliceRam_PsRqmf (FIXP_DBL* rQmfData, UCHAR* dynamic_RAM, int n, int i, int qmfSlots);
  FIXP_DBL* FDKsbrEnc_SliceRam_PsIqmf (FIXP_DBL* iQmfData, UCHAR* dynamic_RAM, int n, int i, int qmfSlots);

  H_ALLOC_MEM(Ram_PsQmfData, PS_QMF_DATA)
  H_ALLOC_MEM(Ram_PsChData, PS_CHANNEL_DATA)

  H_ALLOC_MEM(Ram_ParamStereo, PARAMETRIC_STEREO)
  H_ALLOC_MEM(Ram_PsOut, PS_OUT)

  /*  HYBRID  */
  H_ALLOC_MEM(Ram_PsHybFFT, FIXP_DBL)

  H_ALLOC_MEM(Ram_HybData, PS_HYBRID_DATA)
  H_ALLOC_MEM(Ram_PsRhyb, FIXP_DBL)
  H_ALLOC_MEM(Ram_PsIhyb, FIXP_DBL)

  H_ALLOC_MEM(Ram_PsHybConfig, PS_HYBRID_CONFIG)
  H_ALLOC_MEM(Ram_PsHybrid, PS_HYBRID)

  FIXP_DBL* psMqmfBufferRealInit (INT ch, INT i);
  FIXP_DBL* psMqmfBufferImagInit (INT ch, INT i);


  /* working buffer */
  H_ALLOC_MEM(Ram_PsHybWkReal, FIXP_DBL)
  H_ALLOC_MEM(Ram_PsHybWkImag, FIXP_DBL)

  H_ALLOC_MEM(Ram_PsMtmpReal, FIXP_DBL)
  H_ALLOC_MEM(Ram_PsMtmpImag, FIXP_DBL)



#endif