Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <stdint.h>
34 : #include "options.h"
35 : #include <math.h>
36 : #include "prot.h"
37 : #include "isar_prot.h"
38 : #include "isar_lcld_prot.h"
39 : #include "isar_rom_lcld_tables.h"
40 : #include "wmc_auto.h"
41 :
42 :
43 : /*-------------------------------------------------------------------*
44 : * Function CreatePredictionDecoder()
45 : *
46 : *
47 : *-------------------------------------------------------------------*/
48 :
49 1434 : ivas_error CreatePredictionDecoder(
50 : PredictionDecoder **psPredictionDecoder_out,
51 : const int32_t iChannels,
52 : const int32_t iNumBlocks )
53 : {
54 : int16_t n;
55 : int16_t m;
56 1434 : PredictionDecoder *psPredictionDecoder = NULL;
57 :
58 1434 : if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL )
59 : {
60 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
61 : }
62 :
63 1434 : psPredictionDecoder->iChannels = iChannels;
64 1434 : psPredictionDecoder->iNumBlocks = iNumBlocks;
65 1434 : psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks;
66 1434 : psPredictionDecoder->iSubSetId = 0;
67 :
68 : /* PLC_IMPROVEMENT */
69 1434 : if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
70 : {
71 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
72 : }
73 1434 : if ( ( psPredictionDecoder->ppiDecodingFailed = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
74 : {
75 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
76 : }
77 1434 : if ( ( psPredictionDecoder->ppiDecodingUnresolved = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
78 : {
79 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
80 : }
81 :
82 4302 : for ( n = 0; n < iChannels; n++ )
83 : {
84 : int32_t k;
85 2868 : if ( ( psPredictionDecoder->ppiDecodingUnresolved[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
86 : {
87 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
88 : }
89 2868 : if ( ( psPredictionDecoder->ppiDecodingFailed[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
90 : {
91 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
92 : }
93 2868 : if ( ( psPredictionDecoder->ppiDecodingFailedPrev[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_MAX_NUM_PRED_SUBSETS ) ) == NULL )
94 : {
95 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
96 : }
97 25812 : for ( k = 0; k < LCLD_MAX_NUM_PRED_SUBSETS; k++ )
98 : {
99 22944 : psPredictionDecoder->ppiDecodingUnresolved[n][k] = 0;
100 22944 : psPredictionDecoder->ppiDecodingFailed[n][k] = 0;
101 22944 : psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0;
102 : }
103 : }
104 :
105 1434 : if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL )
106 : {
107 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
108 : }
109 1434 : if ( ( psPredictionDecoder->ppiPredBandEnable = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
110 : {
111 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
112 : }
113 1434 : if ( ( psPredictionDecoder->ppfA1Real = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
114 : {
115 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
116 : }
117 1434 : if ( ( psPredictionDecoder->ppfA1Imag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
118 : {
119 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
120 : }
121 1434 : if ( ( psPredictionDecoder->ppiA1Mag = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
122 : {
123 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
124 : }
125 1434 : if ( ( psPredictionDecoder->ppiA1Phase = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL )
126 : {
127 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
128 : }
129 1434 : if ( ( psPredictionDecoder->ppfPredStateReal = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
130 : {
131 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
132 : }
133 1434 : if ( ( psPredictionDecoder->ppfPredStateImag = (float **) malloc( sizeof( float * ) * iChannels ) ) == NULL )
134 : {
135 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) );
136 : }
137 :
138 4302 : for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
139 : {
140 2868 : psPredictionDecoder->piPredChanEnable[n] = 0;
141 2868 : if ( ( psPredictionDecoder->ppiPredBandEnable[n] = (int32_t *) malloc( LCLD_BANDS * sizeof( int32_t ) ) ) == NULL )
142 : {
143 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
144 : }
145 174948 : for ( m = 0; m < LCLD_BANDS; m++ )
146 : {
147 172080 : psPredictionDecoder->ppiPredBandEnable[n][m] = 0;
148 : }
149 2868 : if ( ( psPredictionDecoder->ppfA1Real[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL )
150 : {
151 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
152 : }
153 2868 : if ( ( psPredictionDecoder->ppfA1Imag[n] = (float *) malloc( sizeof( float ) * LCLD_BANDS ) ) == NULL )
154 : {
155 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
156 : }
157 2868 : if ( ( psPredictionDecoder->ppiA1Mag[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL )
158 : {
159 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
160 : }
161 2868 : if ( ( psPredictionDecoder->ppiA1Phase[n] = (int32_t *) malloc( sizeof( int32_t ) * LCLD_BANDS ) ) == NULL )
162 : {
163 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) );
164 : }
165 2868 : if ( ( psPredictionDecoder->ppfPredStateReal[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL )
166 : {
167 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) );
168 : }
169 2868 : if ( ( psPredictionDecoder->ppfPredStateImag[n] = (float *) malloc( LCLD_BANDS * sizeof( float ) ) ) == NULL )
170 : {
171 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD PredictionDecoder Module \n" ) );
172 : }
173 174948 : for ( m = 0; m < LCLD_BANDS; m++ )
174 : {
175 172080 : psPredictionDecoder->ppfPredStateReal[n][m] = 0;
176 172080 : psPredictionDecoder->ppfPredStateImag[n][m] = 0;
177 : }
178 : }
179 :
180 : /* pre-define these tables? */
181 12906 : for ( n = 0; n < ( 1 << PRED_QUNAT_FILTER_MAG_BITS ); n++ )
182 : {
183 11472 : const float fInvMagScale = M_PI / ( 2.0f * (float) ( 1 << ( PRED_QUNAT_FILTER_MAG_BITS ) ) + 1.0f );
184 11472 : psPredictionDecoder->pfMagLUT[n] = sinf( fInvMagScale * (float) n );
185 : }
186 :
187 47322 : for ( n = 0; n < ( 1 << PRED_QUANT_FILTER_PHASE_BITS ); n++ )
188 : {
189 45888 : const float fInvPhaseScale = M_PI / (float) ( 1 << ( PRED_QUANT_FILTER_PHASE_BITS - 1 ) );
190 : int16_t iVal;
191 :
192 45888 : iVal = n + PRED_QUANT_FILTER_PHASE_MIN;
193 45888 : psPredictionDecoder->pfP2RRealLUT[n] = cosf( fInvPhaseScale * (float) iVal );
194 45888 : psPredictionDecoder->pfP2RImagLUT[n] = sinf( fInvPhaseScale * (float) iVal );
195 : }
196 :
197 1434 : *psPredictionDecoder_out = psPredictionDecoder;
198 :
199 1434 : return IVAS_ERR_OK;
200 : }
201 :
202 :
203 : /*-------------------------------------------------------------------*
204 : * Function DeletePredictionDecoder()
205 : *
206 : *
207 : *-------------------------------------------------------------------*/
208 :
209 1434 : void DeletePredictionDecoder(
210 : PredictionDecoder *psPredictionDecoder )
211 : {
212 : int32_t n;
213 :
214 4302 : for ( n = 0; n < psPredictionDecoder->iChannels; n++ )
215 : {
216 2868 : free( psPredictionDecoder->ppiPredBandEnable[n] );
217 2868 : free( psPredictionDecoder->ppfA1Real[n] );
218 2868 : free( psPredictionDecoder->ppfA1Imag[n] );
219 2868 : free( psPredictionDecoder->ppiA1Mag[n] );
220 2868 : free( psPredictionDecoder->ppiA1Phase[n] );
221 2868 : free( psPredictionDecoder->ppfPredStateReal[n] );
222 2868 : free( psPredictionDecoder->ppfPredStateImag[n] );
223 : /* PLC_IMPROVEMENT */
224 2868 : free( psPredictionDecoder->ppiDecodingUnresolved[n] );
225 2868 : free( psPredictionDecoder->ppiDecodingFailed[n] );
226 2868 : free( psPredictionDecoder->ppiDecodingFailedPrev[n] );
227 : }
228 1434 : free( psPredictionDecoder->piPredChanEnable );
229 1434 : free( psPredictionDecoder->ppiPredBandEnable );
230 1434 : free( psPredictionDecoder->ppfA1Real );
231 1434 : free( psPredictionDecoder->ppfA1Imag );
232 1434 : free( psPredictionDecoder->ppiA1Mag );
233 1434 : free( psPredictionDecoder->ppiA1Phase );
234 1434 : free( psPredictionDecoder->ppfPredStateReal );
235 1434 : free( psPredictionDecoder->ppfPredStateImag );
236 : /* PLC_IMPROVEMENT */
237 1434 : free( psPredictionDecoder->ppiDecodingUnresolved );
238 1434 : free( psPredictionDecoder->ppiDecodingFailed );
239 1434 : free( psPredictionDecoder->ppiDecodingFailedPrev );
240 :
241 1434 : free( psPredictionDecoder );
242 1434 : psPredictionDecoder = NULL;
243 :
244 1434 : return;
245 : }
246 :
247 :
248 : /*-------------------------------------------------------------------*
249 : * Function ReadPredictors()
250 : *
251 : *
252 : *-------------------------------------------------------------------*/
253 :
254 191422 : int16_t ReadPredictors(
255 : PredictionDecoder *psPredictionDecoder,
256 : ISAR_SPLIT_REND_BITS_HANDLE pBits )
257 : {
258 191422 : int16_t iBitsRead = 0;
259 : int32_t c;
260 : int32_t b;
261 191422 : int16_t iNumPredBandBits = 6;
262 191422 : const int16_t iSubSetBits = ( LCLD_MAX_NUM_PRED_SUBSETS > 4 ? 3 : 2 );
263 :
264 191422 : psPredictionDecoder->iNumSubSets = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits ) + 1;
265 191422 : iBitsRead += iSubSetBits;
266 :
267 191422 : if ( psPredictionDecoder->iNumSubSets > 1 )
268 : {
269 12473 : psPredictionDecoder->iSubSetId = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iSubSetBits );
270 12473 : iBitsRead += iSubSetBits;
271 12473 : iNumPredBandBits = ( psPredictionDecoder->iNumSubSets >= 4 ? 4 : 5 );
272 : }
273 : else
274 : {
275 178949 : psPredictionDecoder->iSubSetId = 0;
276 : }
277 :
278 574266 : for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
279 : {
280 382844 : psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets );
281 382844 : iBitsRead += (int16_t) psPredictionDecoder->iNumSubSets;
282 :
283 382844 : if ( get_bit( psPredictionDecoder->piPredChanEnable[c], psPredictionDecoder->iSubSetId ) )
284 : {
285 183106 : int32_t b0 = psPredictionDecoder->iSubSetId;
286 183106 : int32_t bstep = psPredictionDecoder->iNumSubSets;
287 : int32_t iNumPredBands;
288 :
289 10964011 : for ( b = b0; b < LCLD_BANDS; b += bstep )
290 : {
291 10780905 : psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
292 : }
293 183106 : iNumPredBands = ISAR_SPLIT_REND_BITStream_read_int32( pBits, iNumPredBandBits );
294 183106 : iBitsRead += iNumPredBandBits;
295 183106 : iNumPredBands = iNumPredBands * psPredictionDecoder->iNumSubSets + b0;
296 :
297 2727280 : for ( b = b0; b < iNumPredBands; b += bstep )
298 : {
299 2544174 : psPredictionDecoder->ppiPredBandEnable[c][b] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 );
300 2544174 : iBitsRead += 1;
301 :
302 2544174 : if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
303 : {
304 : int32_t iA1Mag;
305 : int32_t iA1Phase;
306 : float fA1Real;
307 : float fA1Imag;
308 1230743 : iA1Mag = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUNAT_FILTER_MAG_BITS );
309 1230743 : iBitsRead += PRED_QUNAT_FILTER_MAG_BITS;
310 1230743 : iA1Phase = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_QUANT_FILTER_PHASE_BITS );
311 1230743 : iBitsRead += PRED_QUANT_FILTER_PHASE_BITS;
312 :
313 1230743 : psPredictionDecoder->ppiA1Mag[c][b] = iA1Mag;
314 1230743 : psPredictionDecoder->ppiA1Phase[c][b] = iA1Phase + PRED_QUANT_FILTER_PHASE_MIN;
315 :
316 1230743 : fA1Real = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RRealLUT[iA1Phase];
317 1230743 : fA1Imag = psPredictionDecoder->pfMagLUT[iA1Mag] * psPredictionDecoder->pfP2RImagLUT[iA1Phase];
318 :
319 1230743 : psPredictionDecoder->ppfA1Real[c][b] = fA1Real;
320 1230743 : psPredictionDecoder->ppfA1Imag[c][b] = fA1Imag;
321 : }
322 : }
323 : }
324 : }
325 :
326 : /* disable any inactive prediction bands */
327 574266 : for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
328 : {
329 : int32_t set;
330 815582 : for ( set = 0; set < psPredictionDecoder->iNumSubSets; set++ )
331 : {
332 432738 : if ( !get_bit( psPredictionDecoder->piPredChanEnable[c], set ) )
333 : {
334 12224447 : for ( b = set; b < LCLD_BANDS; b += psPredictionDecoder->iNumSubSets )
335 : {
336 11984520 : psPredictionDecoder->ppiPredBandEnable[c][b] = 0;
337 : }
338 : }
339 : }
340 : }
341 :
342 191422 : return iBitsRead;
343 : }
344 :
345 :
346 : /*-------------------------------------------------------------------*
347 : * Function SetDecodingPassed()
348 : *
349 : *
350 : *-------------------------------------------------------------------*/
351 :
352 0 : void SetDecodingPassed(
353 : PredictionDecoder *psPredictionDecoder )
354 : {
355 : int32_t n, ch;
356 0 : for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
357 : {
358 0 : for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
359 : {
360 0 : psPredictionDecoder->ppiDecodingFailed[ch][n] = 0;
361 : }
362 : }
363 :
364 0 : return;
365 : }
366 :
367 :
368 : /*-------------------------------------------------------------------*
369 : * Function AnyDecodingUnresolved()
370 : *
371 : *
372 : *-------------------------------------------------------------------*/
373 :
374 191422 : int32_t AnyDecodingUnresolved(
375 : PredictionDecoder *psPredictionDecoder )
376 : {
377 : int32_t n, ch;
378 574266 : for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
379 : {
380 815582 : for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
381 : {
382 432738 : if ( psPredictionDecoder->ppiDecodingUnresolved[ch][n] == 1 )
383 : {
384 0 : return 1;
385 : }
386 : }
387 : }
388 191422 : return 0;
389 : }
390 :
391 :
392 : /*-------------------------------------------------------------------*
393 : * Function UpdateDecodingFailedStatus()
394 : *
395 : *
396 : *-------------------------------------------------------------------*/
397 :
398 191422 : void UpdateDecodingFailedStatus(
399 : PredictionDecoder *psPredictionDecoder )
400 : {
401 : int32_t n, ch;
402 :
403 574266 : for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
404 : {
405 815582 : for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
406 : {
407 432738 : psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n];
408 : }
409 : }
410 :
411 191422 : return;
412 : }
413 :
414 :
415 : /*-------------------------------------------------------------------*
416 : * Function UpdateDecodingUnresolved()
417 : *
418 : *
419 : *-------------------------------------------------------------------*/
420 :
421 191422 : void UpdateDecodingUnresolved(
422 : PredictionDecoder *psPredictionDecoder )
423 : {
424 : int32_t n, ch;
425 :
426 191422 : int32_t iCurrentSubSet = psPredictionDecoder->iSubSetId;
427 :
428 574266 : for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ )
429 : {
430 : /* Prediction data always available for current subset */
431 382844 : psPredictionDecoder->ppiDecodingUnresolved[ch][iCurrentSubSet] = 0;
432 :
433 815582 : for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ )
434 : {
435 432738 : int32_t iSubSetActive = get_bit( psPredictionDecoder->piPredChanEnable[ch], n );
436 432738 : if ( iSubSetActive == 0 )
437 : {
438 : /* Prediction information available inactive subsets (e.g. no Prediction) */
439 239927 : psPredictionDecoder->ppiDecodingUnresolved[ch][n] = 0;
440 : }
441 : }
442 : }
443 :
444 191422 : return;
445 : }
446 :
447 :
448 : /*-------------------------------------------------------------------*
449 : * Function ApplyInversePredictors()
450 : *
451 : *
452 : *-------------------------------------------------------------------*/
453 :
454 191422 : void ApplyInversePredictors(
455 : PredictionDecoder *psPredictionDecoder,
456 : float ***pppfReal,
457 : float ***pppfImag )
458 : {
459 : int32_t c;
460 :
461 574266 : for ( c = 0; c < psPredictionDecoder->iChannels; c++ )
462 : {
463 382844 : if ( psPredictionDecoder->piPredChanEnable[c] > 0 )
464 : {
465 : int32_t b;
466 11588536 : for ( b = 0; b < LCLD_BANDS; b++ )
467 : {
468 11398560 : if ( psPredictionDecoder->ppiPredBandEnable[c][b] == 1 )
469 : {
470 : int32_t n;
471 : float fA1Real;
472 : float fA1Imag;
473 1252867 : float fPrevReal = 0.0f;
474 1252867 : float fPrevImag = 0.0f;
475 1252867 : int32_t iSubset = b % psPredictionDecoder->iNumSubSets;
476 :
477 1252867 : if ( iSubset != psPredictionDecoder->iSubSetId )
478 : {
479 22124 : fPrevReal = psPredictionDecoder->ppfPredStateReal[c][b];
480 22124 : fPrevImag = psPredictionDecoder->ppfPredStateImag[c][b];
481 : }
482 :
483 1252867 : fA1Real = psPredictionDecoder->ppfA1Real[c][b];
484 1252867 : fA1Imag = psPredictionDecoder->ppfA1Imag[c][b];
485 20944635 : for ( n = 0; n < psPredictionDecoder->iNumBlocks; n++ )
486 : {
487 : float fReal;
488 : float fImag;
489 :
490 19691768 : fReal = pppfReal[c][n][b] - fA1Real * fPrevReal + fA1Imag * fPrevImag;
491 19691768 : fImag = pppfImag[c][n][b] - fA1Real * fPrevImag - fA1Imag * fPrevReal;
492 :
493 19691768 : pppfReal[c][n][b] = fReal;
494 19691768 : pppfImag[c][n][b] = fImag;
495 :
496 19691768 : fPrevReal = fReal;
497 19691768 : fPrevImag = fImag;
498 : }
499 1252867 : psPredictionDecoder->ppfPredStateReal[c][b] = fPrevReal;
500 1252867 : psPredictionDecoder->ppfPredStateImag[c][b] = fPrevImag;
501 : }
502 : }
503 : }
504 : }
505 :
506 191422 : return;
507 : }
|