Coverage Report

Created: 2025-07-01 06:21

/src/aac/libSACenc/src/sacenc_framewindowing.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -----------------------------------------------------------------------------
2
Software License for The Fraunhofer FDK AAC Codec Library for Android
3
4
© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
5
Forschung e.V. All rights reserved.
6
7
 1.    INTRODUCTION
8
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
9
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
10
scheme for digital audio. This FDK AAC Codec software is intended to be used on
11
a wide variety of Android devices.
12
13
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
14
general perceptual audio codecs. AAC-ELD is considered the best-performing
15
full-bandwidth communications codec by independent studies and is widely
16
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
17
specifications.
18
19
Patent licenses for necessary patent claims for the FDK AAC Codec (including
20
those of Fraunhofer) may be obtained through Via Licensing
21
(www.vialicensing.com) or through the respective patent owners individually for
22
the purpose of encoding or decoding bit streams in products that are compliant
23
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
24
Android devices already license these patent claims through Via Licensing or
25
directly from the patent owners, and therefore FDK AAC Codec software may
26
already be covered under those patent licenses when it is used for those
27
licensed purposes only.
28
29
Commercially-licensed AAC software libraries, including floating-point versions
30
with enhanced sound quality, are also available from Fraunhofer. Users are
31
encouraged to check the Fraunhofer website for additional applications
32
information and documentation.
33
34
2.    COPYRIGHT LICENSE
35
36
Redistribution and use in source and binary forms, with or without modification,
37
are permitted without payment of copyright license fees provided that you
38
satisfy the following conditions:
39
40
You must retain the complete text of this software license in redistributions of
41
the FDK AAC Codec or your modifications thereto in source code form.
42
43
You must retain the complete text of this software license in the documentation
44
and/or other materials provided with redistributions of the FDK AAC Codec or
45
your modifications thereto in binary form. You must make available free of
46
charge copies of the complete source code of the FDK AAC Codec and your
47
modifications thereto to recipients of copies in binary form.
48
49
The name of Fraunhofer may not be used to endorse or promote products derived
50
from this library without prior written permission.
51
52
You may not charge copyright license fees for anyone to use, copy or distribute
53
the FDK AAC Codec software or your modifications thereto.
54
55
Your modified versions of the FDK AAC Codec must carry prominent notices stating
56
that you changed the software and the date of any change. For modified versions
57
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
58
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
59
AAC Codec Library for Android."
60
61
3.    NO PATENT LICENSE
62
63
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
64
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
65
Fraunhofer provides no warranty of patent non-infringement with respect to this
66
software.
67
68
You may use this FDK AAC Codec software or modifications thereto only for
69
purposes that are authorized by appropriate patent licenses.
70
71
4.    DISCLAIMER
72
73
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
74
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
75
including but not limited to the implied warranties of merchantability and
76
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
77
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
78
or consequential damages, including but not limited to procurement of substitute
79
goods or services; loss of use, data, or profits, or business interruption,
80
however caused and on any theory of liability, whether in contract, strict
81
liability, or tort (including negligence), arising in any way out of the use of
82
this software, even if advised of the possibility of such damage.
83
84
5.    CONTACT INFORMATION
85
86
Fraunhofer Institute for Integrated Circuits IIS
87
Attention: Audio and Multimedia Departments - FDK AAC LL
88
Am Wolfsmantel 33
89
91058 Erlangen, Germany
90
91
www.iis.fraunhofer.de/amm
92
amm-info@iis.fraunhofer.de
93
----------------------------------------------------------------------------- */
94
95
/*********************** MPEG surround encoder library *************************
96
97
   Author(s):   Max Neuendorf
98
99
   Description: Encoder Library Interface
100
                Get windows for framing
101
102
*******************************************************************************/
103
104
/**************************************************************************/ /**
105
   \file
106
   Description of file contents
107
 ******************************************************************************/
108
109
/* Includes ******************************************************************/
110
#include "sacenc_framewindowing.h"
111
#include "sacenc_vectorfunctions.h"
112
113
/* Defines *******************************************************************/
114
115
/* Data Types ****************************************************************/
116
typedef struct T_FRAMEWINDOW {
117
  INT nTimeSlotsMax;
118
  INT bFrameKeep;
119
  INT startSlope;
120
  INT stopSlope;
121
  INT startRect;
122
  INT stopRect;
123
124
  INT taperAnaLen;
125
  INT taperSynLen;
126
  FIXP_WIN pTaperAna__FDK[MAX_TIME_SLOTS];
127
  FIXP_WIN pTaperSyn__FDK[MAX_TIME_SLOTS];
128
129
} FRAMEWINDOW;
130
131
typedef enum {
132
  FIX_INVALID = -1,
133
  FIX_RECT_SMOOTH = 0,
134
  FIX_SMOOTH_RECT = 1,
135
  FIX_LARGE_SMOOTH = 2,
136
  FIX_RECT_TRIANG = 3
137
138
} FIX_TYPE;
139
140
typedef enum {
141
  VAR_INVALID = -1,
142
  VAR_HOLD = 0,
143
  VAR_ISOLATE = 1
144
145
} VAR_TYPE;
146
147
/* Constants *****************************************************************/
148
149
/* Function / Class Declarations *********************************************/
150
151
/* Function / Class Definition ***********************************************/
152
0
static void calcTaperWin(FIXP_WIN *pTaperWin, INT timeSlots) {
153
0
  FIXP_DBL x;
154
0
  int i, scale;
155
156
0
  for (i = 0; i < timeSlots; i++) {
157
0
    x = fDivNormHighPrec((FIXP_DBL)i, (FIXP_DBL)timeSlots, &scale);
158
159
0
    if (scale < 0) {
160
0
      pTaperWin[i] = FX_DBL2FX_WIN(x >> (-scale));
161
0
    } else {
162
0
      pTaperWin[i] = FX_DBL2FX_WIN(x << (scale));
163
0
    }
164
0
  }
165
0
  pTaperWin[timeSlots] = FX_DBL2FX_WIN((FIXP_DBL)MAXVAL_DBL);
166
0
}
167
168
FDK_SACENC_ERROR fdk_sacenc_frameWindow_Create(
169
0
    HANDLE_FRAMEWINDOW *phFrameWindow) {
170
0
  FDK_SACENC_ERROR error = SACENC_OK;
171
172
0
  if (NULL == phFrameWindow) {
173
0
    error = SACENC_INVALID_HANDLE;
174
0
  } else {
175
    /* Memory Allocation */
176
0
    FDK_ALLOCATE_MEMORY_1D(*phFrameWindow, 1, FRAMEWINDOW);
177
0
  }
178
0
  return error;
179
180
0
bail:
181
0
  fdk_sacenc_frameWindow_Destroy(phFrameWindow);
182
0
  return ((SACENC_OK == error) ? SACENC_MEMORY_ERROR : error);
183
0
}
184
185
FDK_SACENC_ERROR fdk_sacenc_frameWindow_Init(
186
    HANDLE_FRAMEWINDOW hFrameWindow,
187
0
    const FRAMEWINDOW_CONFIG *const pFrameWindowConfig) {
188
0
  FDK_SACENC_ERROR error = SACENC_OK;
189
190
0
  if ((hFrameWindow == NULL) || (pFrameWindowConfig == NULL)) {
191
0
    error = SACENC_INVALID_HANDLE;
192
0
  } else if (pFrameWindowConfig->nTimeSlotsMax < 0) {
193
0
    error = SACENC_INIT_ERROR;
194
0
  } else {
195
0
    int ts;
196
0
    hFrameWindow->bFrameKeep = pFrameWindowConfig->bFrameKeep;
197
0
    hFrameWindow->nTimeSlotsMax = pFrameWindowConfig->nTimeSlotsMax;
198
199
0
    FIXP_WIN winMaxVal = FX_DBL2FX_WIN((FIXP_DBL)MAXVAL_DBL);
200
0
    int timeSlots = pFrameWindowConfig->nTimeSlotsMax;
201
0
    {
202
0
      hFrameWindow->startSlope = 0;
203
0
      hFrameWindow->stopSlope = ((3 * timeSlots) >> 1) - 1;
204
0
      hFrameWindow->startRect = timeSlots >> 1;
205
0
      hFrameWindow->stopRect = timeSlots;
206
0
      calcTaperWin(hFrameWindow->pTaperSyn__FDK, timeSlots >> 1);
207
0
      hFrameWindow->taperSynLen = timeSlots >> 1;
208
0
    }
209
210
    /* Calculate Taper for non-rect. ana. windows */
211
0
    hFrameWindow->taperAnaLen =
212
0
        hFrameWindow->startRect - hFrameWindow->startSlope;
213
0
    for (ts = 0; ts < hFrameWindow->taperAnaLen; ts++) {
214
0
      { hFrameWindow->pTaperAna__FDK[ts] = winMaxVal; }
215
0
    }
216
0
  }
217
218
0
  return error;
219
0
}
220
221
FDK_SACENC_ERROR fdk_sacenc_frameWindow_Destroy(
222
0
    HANDLE_FRAMEWINDOW *phFrameWindow) {
223
0
  FDK_SACENC_ERROR error = SACENC_OK;
224
225
0
  if ((NULL != phFrameWindow) && (NULL != *phFrameWindow)) {
226
0
    FDKfree(*phFrameWindow);
227
0
    *phFrameWindow = NULL;
228
0
  }
229
0
  return error;
230
0
}
231
232
0
static FDK_SACENC_ERROR FrameWinList_Reset(FRAMEWIN_LIST *const pFrameWinList) {
233
0
  FDK_SACENC_ERROR error = SACENC_OK;
234
235
0
  if (NULL == pFrameWinList) {
236
0
    error = SACENC_INVALID_HANDLE;
237
0
  } else {
238
0
    int k = 0;
239
0
    for (k = 0; k < MAX_NUM_PARAMS; k++) {
240
0
      pFrameWinList->dat[k].slot = -1;
241
0
      pFrameWinList->dat[k].hold = FW_INTP;
242
0
    }
243
0
    pFrameWinList->n = 0;
244
0
  }
245
0
  return error;
246
0
}
247
248
static FDK_SACENC_ERROR FrameWindowList_Add(FRAMEWIN_LIST *const pFrameWinList,
249
                                            const INT slot,
250
0
                                            const FW_SLOTTYPE hold) {
251
0
  FDK_SACENC_ERROR error = SACENC_OK;
252
253
0
  if (NULL == pFrameWinList) {
254
0
    error = SACENC_INVALID_HANDLE;
255
0
  } else {
256
0
    if (pFrameWinList->n >= MAX_NUM_PARAMS) { /* Place left in List ?*/
257
0
      error = SACENC_PARAM_ERROR;
258
0
    } else if (pFrameWinList->n > 0 &&
259
0
               pFrameWinList->dat[pFrameWinList->n - 1].slot - slot > 0) {
260
0
      error = SACENC_PARAM_ERROR;
261
0
    } else {
262
0
      pFrameWinList->dat[pFrameWinList->n].slot = slot;
263
0
      pFrameWinList->dat[pFrameWinList->n].hold = hold;
264
0
      pFrameWinList->n++;
265
0
    }
266
0
  }
267
0
  return error;
268
0
}
269
270
static FDK_SACENC_ERROR FrameWindowList_Remove(
271
0
    FRAMEWIN_LIST *const pFrameWinList, const INT idx) {
272
0
  FDK_SACENC_ERROR error = SACENC_OK;
273
274
0
  if (NULL == pFrameWinList) {
275
0
    error = SACENC_INVALID_HANDLE;
276
0
  } else {
277
0
    int k = 0;
278
0
    if (idx < 0 || idx >= MAX_NUM_PARAMS) {
279
0
      error = SACENC_PARAM_ERROR;
280
0
    } else if (pFrameWinList->n > 0) {
281
0
      if (idx == MAX_NUM_PARAMS - 1) {
282
0
        pFrameWinList->dat[idx].slot = -1;
283
0
        pFrameWinList->dat[idx].hold = FW_INTP;
284
0
      } else {
285
0
        for (k = idx; k < MAX_NUM_PARAMS - 1; k++) {
286
0
          pFrameWinList->dat[k] = pFrameWinList->dat[k + 1];
287
0
        }
288
0
      }
289
0
      pFrameWinList->n--;
290
0
    }
291
0
  }
292
0
  return error;
293
0
}
294
295
static FDK_SACENC_ERROR FrameWindowList_Limit(
296
    FRAMEWIN_LIST *const pFrameWinList, const INT ll /*lower limit*/,
297
    const INT ul /*upper limit*/
298
0
) {
299
0
  FDK_SACENC_ERROR error = SACENC_OK;
300
301
0
  if (NULL == pFrameWinList) {
302
0
    error = SACENC_INVALID_HANDLE;
303
0
  } else {
304
0
    int k = 0;
305
0
    for (k = 0; k < pFrameWinList->n; k++) {
306
0
      if (pFrameWinList->dat[k].slot < ll || pFrameWinList->dat[k].slot > ul) {
307
0
        FrameWindowList_Remove(pFrameWinList, k);
308
0
        --k;
309
0
      }
310
0
    }
311
0
  }
312
0
  return error;
313
0
}
314
315
FDK_SACENC_ERROR fdk_sacenc_frameWindow_GetWindow(
316
    HANDLE_FRAMEWINDOW hFrameWindow, INT tr_pos[MAX_NUM_PARAMS],
317
    const INT timeSlots, FRAMINGINFO *const pFramingInfo,
318
    FIXP_WIN *pWindowAna__FDK[MAX_NUM_PARAMS],
319
0
    FRAMEWIN_LIST *const pFrameWinList, const INT avoid_keep) {
320
0
  FDK_SACENC_ERROR error = SACENC_OK;
321
322
0
  if ((hFrameWindow == NULL) || (tr_pos == NULL) || (pFramingInfo == NULL) ||
323
0
      (pFrameWinList == NULL) || (pWindowAna__FDK == NULL)) {
324
0
    error = SACENC_INVALID_HANDLE;
325
0
  } else {
326
0
    const VAR_TYPE varType = VAR_HOLD;
327
0
    const int tranL = 4;
328
0
    int winCnt = 0;
329
0
    int w, ps;
330
331
0
    int startSlope = hFrameWindow->startSlope;
332
0
    int stopSlope = hFrameWindow->stopSlope;
333
0
    int startRect = hFrameWindow->startRect;
334
0
    int stopRect = hFrameWindow->stopRect;
335
0
    int taperAnaLen = hFrameWindow->taperAnaLen;
336
337
0
    FIXP_WIN winMaxVal = FX_DBL2FX_WIN((FIXP_DBL)MAXVAL_DBL);
338
0
    FIXP_WIN applyRightWindowGain__FDK[MAX_NUM_PARAMS];
339
0
    FIXP_WIN *pTaperAna__FDK = hFrameWindow->pTaperAna__FDK;
340
341
    /* sanity check */
342
0
    for (ps = 0; ps < MAX_NUM_PARAMS; ps++) {
343
0
      if (pWindowAna__FDK[ps] == NULL) {
344
0
        error = SACENC_INVALID_HANDLE;
345
0
        goto bail;
346
0
      }
347
0
    }
348
349
0
    if ((timeSlots > hFrameWindow->nTimeSlotsMax) || (timeSlots < 0)) {
350
0
      error = SACENC_INVALID_CONFIG;
351
0
      goto bail;
352
0
    }
353
354
    /* Reset */
355
0
    if (SACENC_OK != (error = FrameWinList_Reset(pFrameWinList))) goto bail;
356
357
0
    FDKmemclear(applyRightWindowGain__FDK, sizeof(applyRightWindowGain__FDK));
358
359
0
    if (tr_pos[0] > -1) { /* Transients in first (left) half? */
360
0
      int p_l = tr_pos[0];
361
0
      winCnt = 0;
362
363
      /* Create Parameter Positions */
364
0
      switch (varType) {
365
0
        case VAR_HOLD:
366
0
          if (SACENC_OK !=
367
0
              (error = FrameWindowList_Add(pFrameWinList, p_l - 1, FW_HOLD)))
368
0
            goto bail;
369
0
          if (SACENC_OK !=
370
0
              (error = FrameWindowList_Add(pFrameWinList, p_l, FW_INTP)))
371
0
            goto bail;
372
0
          break;
373
0
        case VAR_ISOLATE:
374
0
          if (SACENC_OK !=
375
0
              (error = FrameWindowList_Add(pFrameWinList, p_l - 1, FW_HOLD)))
376
0
            goto bail;
377
0
          if (SACENC_OK !=
378
0
              (error = FrameWindowList_Add(pFrameWinList, p_l, FW_INTP)))
379
0
            goto bail;
380
0
          if (SACENC_OK != (error = FrameWindowList_Add(pFrameWinList,
381
0
                                                        p_l + tranL, FW_HOLD)))
382
0
            goto bail;
383
0
          if (SACENC_OK != (error = FrameWindowList_Add(
384
0
                                pFrameWinList, p_l + tranL + 1, FW_INTP)))
385
0
            goto bail;
386
0
          break;
387
0
        default:
388
0
          error = SACENC_INVALID_CONFIG;
389
0
          break;
390
0
      }
391
392
      /* Outside of frame? => Kick Out */
393
0
      if (SACENC_OK !=
394
0
          (error = FrameWindowList_Limit(pFrameWinList, 0, timeSlots - 1)))
395
0
        goto bail;
396
397
      /* Add timeSlots as temporary border for window creation */
398
0
      if (SACENC_OK !=
399
0
          (error = FrameWindowList_Add(pFrameWinList, timeSlots - 1, FW_HOLD)))
400
0
        goto bail;
401
402
      /* Create Windows */
403
0
      for (ps = 0; ps < pFrameWinList->n - 1; ps++) {
404
0
        if (FW_HOLD != pFrameWinList->dat[ps].hold) {
405
0
          int const start = pFrameWinList->dat[ps].slot;
406
0
          int const stop = pFrameWinList->dat[ps + 1].slot;
407
408
          /* Analysis Window */
409
0
          FDKmemset_flex(pWindowAna__FDK[winCnt], FX_DBL2FX_WIN((FIXP_DBL)0),
410
0
                         start);
411
0
          FDKmemset_flex(&pWindowAna__FDK[winCnt][start], winMaxVal,
412
0
                         stop - start + 1);
413
0
          FDKmemset_flex(&pWindowAna__FDK[winCnt][stop + 1],
414
0
                         FX_DBL2FX_WIN((FIXP_DBL)0), timeSlots - stop - 1);
415
416
0
          applyRightWindowGain__FDK[winCnt] =
417
0
              pWindowAna__FDK[winCnt][timeSlots - 1];
418
0
          winCnt++;
419
0
        }
420
0
      } /* ps */
421
422
      /* Pop temporary frame border */
423
0
      if (SACENC_OK !=
424
0
          (error = FrameWindowList_Remove(pFrameWinList, pFrameWinList->n - 1)))
425
0
        goto bail;
426
0
    } else { /* No transient in left half of ana. window */
427
0
      winCnt = 0;
428
429
      /* Add paramter set at end of frame */
430
0
      if (SACENC_OK !=
431
0
          (error = FrameWindowList_Add(pFrameWinList, timeSlots - 1, FW_INTP)))
432
0
        goto bail;
433
      /* Analysis Window */
434
0
      FDKmemset_flex(pWindowAna__FDK[winCnt], FX_DBL2FX_WIN((FIXP_DBL)0),
435
0
                     startSlope);
436
0
      FDKmemcpy_flex(&pWindowAna__FDK[winCnt][startSlope], 1, pTaperAna__FDK, 1,
437
0
                     taperAnaLen);
438
0
      FDKmemset_flex(&pWindowAna__FDK[winCnt][startRect], winMaxVal,
439
0
                     timeSlots - startRect);
440
441
0
      applyRightWindowGain__FDK[winCnt] = winMaxVal;
442
0
      winCnt++;
443
0
    } /* if (tr_pos[0] > -1) */
444
445
0
    for (w = 0; w < winCnt; w++) {
446
0
      if (applyRightWindowGain__FDK[w] > (FIXP_WIN)0) {
447
0
        if (tr_pos[1] > -1) { /* Transients in second (right) half? */
448
0
          int p_r = tr_pos[1];
449
450
          /* Analysis Window */
451
0
          FDKmemset_flex(&pWindowAna__FDK[w][timeSlots], winMaxVal,
452
0
                         p_r - timeSlots);
453
0
          FDKmemset_flex(&pWindowAna__FDK[w][p_r], FX_DBL2FX_WIN((FIXP_DBL)0),
454
0
                         2 * timeSlots - p_r);
455
456
0
        } else { /* No transient in right half of ana. window */
457
          /* Analysis Window */
458
0
          FDKmemset_flex(&pWindowAna__FDK[w][timeSlots], winMaxVal,
459
0
                         stopRect - timeSlots + 1);
460
0
          FDKmemcpy_flex(&pWindowAna__FDK[w][stopRect], 1,
461
0
                         &pTaperAna__FDK[taperAnaLen - 1], -1, taperAnaLen);
462
0
          FDKmemset_flex(&pWindowAna__FDK[w][stopSlope + 1],
463
0
                         FX_DBL2FX_WIN((FIXP_DBL)0),
464
0
                         2 * timeSlots - stopSlope - 1);
465
466
0
        } /* if (tr_pos[1] > -1) */
467
468
        /* Weight */
469
0
        if (applyRightWindowGain__FDK[w] < winMaxVal) {
470
0
          int ts;
471
0
          for (ts = 0; ts < timeSlots; ts++) {
472
0
            pWindowAna__FDK[w][timeSlots + ts] =
473
0
                FX_DBL2FX_WIN(fMult(pWindowAna__FDK[w][timeSlots + ts],
474
0
                                    applyRightWindowGain__FDK[w]));
475
0
          }
476
0
        }
477
0
      } /* if (applyRightWindowGain[w] > 0.0f) */
478
0
      else {
479
        /* All Zero */
480
0
        FDKmemset_flex(&pWindowAna__FDK[w][timeSlots],
481
0
                       FX_DBL2FX_WIN((FIXP_DBL)0), timeSlots);
482
0
      }
483
0
    } /* loop over windows */
484
485
0
    if (hFrameWindow->bFrameKeep == 1) {
486
0
      FDKmemcpy_flex(&pWindowAna__FDK[0][2 * timeSlots], 1,
487
0
                     &pWindowAna__FDK[0][timeSlots], 1, timeSlots);
488
0
      FDKmemcpy_flex(&pWindowAna__FDK[0][timeSlots], 1, pWindowAna__FDK[0], 1,
489
0
                     timeSlots);
490
491
0
      if (avoid_keep != 0) {
492
0
        FDKmemset_flex(pWindowAna__FDK[0], FX_DBL2FX_WIN((FIXP_DBL)0),
493
0
                       timeSlots);
494
0
      } else {
495
0
        FDKmemset_flex(pWindowAna__FDK[0], winMaxVal, timeSlots);
496
0
      }
497
0
    } /* if (hFrameWindow->bFrameKeep==1) */
498
499
    /* Feed Info to Bitstream Formatter */
500
0
    pFramingInfo->numParamSets = pFrameWinList->n;
501
0
    pFramingInfo->bsFramingType = 1; /* variable framing */
502
0
    for (ps = 0; ps < pFramingInfo->numParamSets; ps++) {
503
0
      pFramingInfo->bsParamSlots[ps] = pFrameWinList->dat[ps].slot;
504
0
    }
505
506
    /* if there is just one param set at last slot,
507
       use fixed framing to save some bits */
508
0
    if ((pFramingInfo->numParamSets == 1) &&
509
0
        (pFramingInfo->bsParamSlots[0] == timeSlots - 1)) {
510
0
      pFramingInfo->bsFramingType = 0;
511
0
    }
512
513
0
  } /* valid handle */
514
515
0
bail:
516
517
0
  return error;
518
0
}
519
520
FDK_SACENC_ERROR fdk_sacenc_analysisWindowing(
521
    const INT nTimeSlots, const INT startTimeSlot,
522
    FIXP_WIN *pFrameWindowAna__FDK, const FIXP_DPK *const *const ppDataIn__FDK,
523
    FIXP_DPK *const *const ppDataOut__FDK, const INT nHybridBands,
524
0
    const INT dim) {
525
0
  FDK_SACENC_ERROR error = SACENC_OK;
526
527
0
  if ((pFrameWindowAna__FDK == NULL) || (ppDataIn__FDK == NULL) ||
528
0
      (ppDataOut__FDK == NULL)) {
529
0
    error = SACENC_INVALID_HANDLE;
530
0
  } else {
531
0
    int i, ts;
532
0
    FIXP_WIN maxVal = FX_DBL2FX_WIN((FIXP_DBL)MAXVAL_DBL);
533
534
0
    if (dim == FW_CHANGE_DIM) {
535
0
      for (ts = startTimeSlot; ts < nTimeSlots; ts++) {
536
0
        FIXP_WIN win = pFrameWindowAna__FDK[ts];
537
0
        if (win == maxVal) {
538
0
          for (i = 0; i < nHybridBands; i++) {
539
0
            ppDataOut__FDK[i][ts].v.re = ppDataIn__FDK[ts][i].v.re;
540
0
            ppDataOut__FDK[i][ts].v.im = ppDataIn__FDK[ts][i].v.im;
541
0
          }
542
0
        } else {
543
0
          for (i = 0; i < nHybridBands; i++) {
544
0
            ppDataOut__FDK[i][ts].v.re = fMult(win, ppDataIn__FDK[ts][i].v.re);
545
0
            ppDataOut__FDK[i][ts].v.im = fMult(win, ppDataIn__FDK[ts][i].v.im);
546
0
          }
547
0
        }
548
0
      } /* ts */
549
0
    } else {
550
0
      for (ts = startTimeSlot; ts < nTimeSlots; ts++) {
551
0
        FIXP_WIN win = pFrameWindowAna__FDK[ts];
552
0
        if (win == maxVal) {
553
0
          for (i = 0; i < nHybridBands; i++) {
554
0
            ppDataOut__FDK[ts][i].v.re = ppDataIn__FDK[ts][i].v.re;
555
0
            ppDataOut__FDK[ts][i].v.im = ppDataIn__FDK[ts][i].v.im;
556
0
          }
557
0
        } else {
558
0
          for (i = 0; i < nHybridBands; i++) {
559
0
            ppDataOut__FDK[ts][i].v.re = fMult(win, ppDataIn__FDK[ts][i].v.re);
560
0
            ppDataOut__FDK[ts][i].v.im = fMult(win, ppDataIn__FDK[ts][i].v.im);
561
0
          }
562
0
        }
563
0
      } /* ts */
564
0
    }
565
0
  }
566
567
0
  return error;
568
0
}