summaryrefslogtreecommitdiffstats
path: root/libAACenc/src/aacEnc_ram.h
blob: 1e87fc4c519d96a4c092c93c70c34e766dffa038 (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
/******************************************************************************

                     (C) Copyright Fraunhofer IIS (2005)
                               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:
   Initial authors:      M. Lohwasser, M. Gayer
   Contents/description:

******************************************************************************/
/*!
  \file
  \brief  Memory layout  $Revision: 36838 $
  \author Markus Lohwasser
*/

#ifndef AAC_ENC_RAM_H
#define AAC_ENC_RAM_H

#include "common_fix.h"

#include "aacenc.h"
#include "psy_data.h"
#include "interface.h"
#include "psy_main.h"
#include "bitenc.h"
#include "bit_cnt.h"
#include "psy_const.h"

  #define  OUTPUTBUFFER_SIZE    (8192)  /*!< Output buffer size has to be at least 6144 bits per channel (768 bytes). FDK bitbuffer implementation expects buffer of size 2^n. */


/*
  Moved AAC_ENC struct definition from aac_enc.cpp into aacEnc_ram.h to get size and respective
  static memory in aacEnc_ram.cpp.
  aac_enc.h is the outward visible header file and putting the struct into would cause necessity
  of additional visible header files outside library.
*/

/* define hBitstream size: max AAC framelength is 6144 bits/channel */
/*#define BUFFER_BITSTR_SIZE ((6400*(6)/bbWordSize)    +((bbWordSize - 1) / bbWordSize))*/

struct AAC_ENC {

  AACENC_CONFIG    *config;

  INT               ancillaryBitsPerFrame;              /* ancillary bits per frame calculated from ancillary rate */

  CHANNEL_MAPPING   channelMapping;

  QC_STATE         *qcKernel;
  QC_OUT           *qcOut[(1)];

  PSY_OUT          *psyOut[(1)];
  PSY_INTERNAL     *psyKernel;

  /* lifetime vars */

  CHANNEL_MODE encoderMode;
  INT bandwidth90dB;
  AACENC_BITRATE_MODE bitrateMode;

  INT    dontWriteAdif;      /* use: write ADIF header only before 1st frame */

  FIXP_DBL  *dynamic_RAM;


  INT maxChannels;           /* used while allocation */
  INT maxElements;
  INT maxFrames;

  AUDIO_OBJECT_TYPE aot;    /* AOT to be used while encoding.  */

} ;

#define maxSize(a,b) ( ((a)>(b)) ? (a) : (b) )

#define BIT_LOOK_UP_SIZE         ( sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)) )
#define MERGE_GAIN_LOOK_UP_SIZE  ( sizeof(INT)*MAX_SFB_LONG )



/* Dynamic RAM - Allocation */
/*
 ++++++++++++++++++++++++++++++++++++++++++++
 |   P_BUF_0   |         P_BUF_1            |
 ++++++++++++++++++++++++++++++++++++++++++++
 |  QC_OUT_CH  |         PSY_DYN            |
 ++++++++++++++++++++++++++++++++++++++++++++
 |             | BitLookUp+MergeGainLookUp  |
 ++++++++++++++++++++++++++++++++++++++++++++
 |             |  Bitstream output buffer   |
 ++++++++++++++++++++++++++++++++++++++++++++
*/

#define BUF_SIZE_0       ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(6)) )
#define BUF_SIZE_1       ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \
                                      (BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) )

#define P_BUF_0          ( 0 )
#define P_BUF_1          ( P_BUF_0 + BUF_SIZE_0 )

#define AAC_ENC_DYN_RAM_SIZE  ( BUF_SIZE_0 + BUF_SIZE_1 )


  H_ALLOC_MEM (AACdynamic_RAM, FIXP_DBL)
/*
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
END - Dynamic RAM - Allocation */

/*
  See further Memory Allocation details in aacEnc_ram.cpp
*/
  H_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC)

  H_ALLOC_MEM (Ram_aacEnc_PsyElement, PSY_ELEMENT)

  H_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL)
  H_ALLOC_MEM (Ram_aacEnc_PsyStatic, PSY_STATIC)
  H_ALLOC_MEM (Ram_aacEnc_PsyInputBuffer, INT_PCM)

  PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM);
  H_ALLOC_MEM (Ram_bsOutbuffer, UCHAR)

  H_ALLOC_MEM (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL)

  H_ALLOC_MEM (Ram_aacEnc_PsyOut, PSY_OUT)
  H_ALLOC_MEM (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT)

  H_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE)
  H_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE)

  H_ALLOC_MEM (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT)
  H_ALLOC_MEM (Ram_aacEnc_ElementBits, ELEMENT_BITS)
  H_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE)

  INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM);
  INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR* dynamic_RAM);
  QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM);

  H_ALLOC_MEM (Ram_aacEnc_QCout, QC_OUT)
  H_ALLOC_MEM (Ram_aacEnc_QCelement, QC_OUT_ELEMENT)


#endif /* #ifndef AAC_ENC_RAM_H */