2 /* -----------------------------------------------------------------------------------------------------------
3 Software License for The Fraunhofer FDK AAC Codec Library for Android
5 © Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
9 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
10 the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
11 This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
14 audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
15 independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
16 of the MPEG specifications.
18 Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
19 may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
20 individually for the purpose of encoding or decoding bit streams in products that are compliant with
21 the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
22 these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
23 software may already be covered under those patent licenses when it is used for those licensed purposes only.
25 Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
26 are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
27 applications information and documentation.
31 Redistribution and use in source and binary forms, with or without modification, are permitted without
32 payment of copyright license fees provided that you satisfy the following conditions:
34 You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
35 your modifications thereto in source code form.
37 You must retain the complete text of this software license in the documentation and/or other materials
38 provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
39 You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
40 modifications thereto to recipients of copies in binary form.
42 The name of Fraunhofer may not be used to endorse or promote products derived from this library without
43 prior written permission.
45 You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
46 software or your modifications thereto.
48 Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
49 and the date of any change. For modified versions of the FDK AAC Codec, the term
50 "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
51 "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
55 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
56 ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
57 respect to this software.
59 You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
60 by appropriate patent licenses.
64 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
65 "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
66 of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
67 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
68 including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
69 or business interruption, however caused and on any theory of liability, whether in contract, strict
70 liability, or tort (including negligence), arising in any way out of the use of this software, even if
71 advised of the possibility of such damage.
73 5. CONTACT INFORMATION
75 Fraunhofer Institute for Integrated Circuits IIS
76 Attention: Audio and Multimedia Departments - FDK AAC LL
78 91058 Erlangen, Germany
80 www.iis.fraunhofer.de/amm
81 amm-info@iis.fraunhofer.de
82 ----------------------------------------------------------------------------------------------------------- */
84 /***************************** MPEG-4 AAC Encoder **************************
86 Author(s): M. Werner, Tobias Chalupka
87 Description: Block switching
89 ******************************************************************************/
91 /****************** Includes *****************************/
93 #include "block_switch.h"
94 #include "genericStds.h"
97 #define LOWOV_WINDOW _LOWOV_WINDOW
99 /**************** internal function prototypes ***********/
101 static FIXP_DBL
FDKaacEnc_GetWindowEnergy(const FIXP_DBL in
[], const INT blSwWndIdx
);
103 static void FDKaacEnc_CalcWindowEnergy(
104 BLOCK_SWITCHING_CONTROL
*RESTRICT blockSwitchingControl
,
106 const INT_PCM
*pTimeSignal
109 /****************** Constants *****************************/
110 /* LONG START SHORT STOP LOWOV */
111 static const INT blockType2windowShape
[2][5] = { {SINE_WINDOW
, KBD_WINDOW
, WRONG_WINDOW
, SINE_WINDOW
, KBD_WINDOW
}, /* LD */
112 {KBD_WINDOW
, SINE_WINDOW
, SINE_WINDOW
, KBD_WINDOW
, WRONG_WINDOW
} }; /* LC */
114 /* IIR high pass coeffs */
116 #ifndef SINETABLE_16BIT
118 static const FIXP_DBL hiPassCoeff
[BLOCK_SWITCHING_IIR_LEN
]=
120 FL2FXCONST_DBL(-0.5095),FL2FXCONST_DBL(0.7548)
123 static const FIXP_DBL accWindowNrgFac
= FL2FXCONST_DBL(0.3f
); /* factor for accumulating filtered window energies */
124 static const FIXP_DBL oneMinusAccWindowNrgFac
= FL2FXCONST_DBL(0.7f
);
125 /* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
126 static const FIXP_DBL invAttackRatio
= FL2FXCONST_DBL(0.1f
); /* inverted lower ratio limit for attacks */
128 /* The next constants are scaled, because they are used for comparison with scaled values*/
129 /* minimum energy for attacks */
130 static const FIXP_DBL minAttackNrg
= (FL2FXCONST_DBL(1e+6f
*NORM_PCM_ENERGY
)>>BLOCK_SWITCH_ENERGY_SHIFT
); /* minimum energy for attacks */
134 static const FIXP_SGL hiPassCoeff
[BLOCK_SWITCHING_IIR_LEN
]=
136 FL2FXCONST_SGL(-0.5095),FL2FXCONST_SGL(0.7548)
139 static const FIXP_DBL accWindowNrgFac
= FL2FXCONST_DBL(0.3f
); /* factor for accumulating filtered window energies */
140 static const FIXP_SGL oneMinusAccWindowNrgFac
= FL2FXCONST_SGL(0.7f
);
141 /* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
142 static const FIXP_SGL invAttackRatio
= FL2FXCONST_SGL(0.1f
); /* inverted lower ratio limit for attacks */
143 /* minimum energy for attacks */
144 static const FIXP_DBL minAttackNrg
= (FL2FXCONST_DBL(1e+6f
*NORM_PCM_ENERGY
)>>BLOCK_SWITCH_ENERGY_SHIFT
); /* minimum energy for attacks */
148 /**************** internal function prototypes ***********/
150 /****************** Routines ****************************/
151 void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL
*blockSwitchingControl
, INT isLowDelay
)
153 FDKmemclear (blockSwitchingControl
, sizeof(BLOCK_SWITCHING_CONTROL
));
157 blockSwitchingControl
->nBlockSwitchWindows
= 4;
158 blockSwitchingControl
->allowShortFrames
= 0;
159 blockSwitchingControl
->allowLookAhead
= 0;
163 blockSwitchingControl
->nBlockSwitchWindows
= 8;
164 blockSwitchingControl
->allowShortFrames
= 1;
165 blockSwitchingControl
->allowLookAhead
= 1;
168 blockSwitchingControl
->noOfGroups
= MAX_NO_OF_GROUPS
;
170 /* Initialize startvalue for blocktype */
171 blockSwitchingControl
->lastWindowSequence
= LONG_WINDOW
;
172 blockSwitchingControl
->windowShape
= blockType2windowShape
[blockSwitchingControl
->allowShortFrames
][blockSwitchingControl
->lastWindowSequence
];
176 static const INT suggestedGroupingTable
[TRANS_FAC
][MAX_NO_OF_GROUPS
] =
178 /* Attack in Window 0 */ {1, 3, 3, 1},
179 /* Attack in Window 1 */ {1, 1, 3, 3},
180 /* Attack in Window 2 */ {2, 1, 3, 2},
181 /* Attack in Window 3 */ {3, 1, 3, 1},
182 /* Attack in Window 4 */ {3, 1, 1, 3},
183 /* Attack in Window 5 */ {3, 2, 1, 2},
184 /* Attack in Window 6 */ {3, 3, 1, 1},
185 /* Attack in Window 7 */ {3, 3, 1, 1}
188 /* change block type depending on current blocktype and whether there's an attack */
189 /* assume no look-ahead */
190 static const INT chgWndSq
[2][N_BLOCKTYPES
] =
192 /* LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW, LOWOV_WINDOW, WRONG_WINDOW */
193 /*no attack*/ {LONG_WINDOW
, STOP_WINDOW
, WRONG_WINDOW
, LONG_WINDOW
, STOP_WINDOW
, WRONG_WINDOW
},
194 /*attack */ {START_WINDOW
, LOWOV_WINDOW
, WRONG_WINDOW
, START_WINDOW
, LOWOV_WINDOW
, WRONG_WINDOW
}
197 /* change block type depending on current blocktype and whether there's an attack */
198 /* assume look-ahead */
199 static const INT chgWndSqLkAhd
[2][2][N_BLOCKTYPES
] =
201 /*attack LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW, WRONG_WINDOW */ /* last attack */
202 /*no attack*/ { {LONG_WINDOW
, SHORT_WINDOW
, STOP_WINDOW
, LONG_WINDOW
, WRONG_WINDOW
, WRONG_WINDOW
}, /* no attack */
203 /*attack */ {START_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, START_WINDOW
, WRONG_WINDOW
, WRONG_WINDOW
} }, /* no attack */
204 /*no attack*/ { {LONG_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, LONG_WINDOW
, WRONG_WINDOW
, WRONG_WINDOW
}, /* attack */
205 /*attack */ {START_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, START_WINDOW
, WRONG_WINDOW
, WRONG_WINDOW
} } /* attack */
208 int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL
*blockSwitchingControl
, const INT granuleLength
, const int isLFE
, const INT_PCM
*pTimeSignal
)
211 FIXP_DBL enM1
, enMax
;
213 UINT nBlockSwitchWindows
= blockSwitchingControl
->nBlockSwitchWindows
;
215 /* for LFE : only LONG window allowed */
219 /* only long blocks, always use sine windows (MPEG2 AAC, MPEG4 AAC) */
220 blockSwitchingControl
->lastWindowSequence
= LONG_WINDOW
;
221 blockSwitchingControl
->windowShape
= SINE_WINDOW
;
222 blockSwitchingControl
->noOfGroups
= 1;
223 blockSwitchingControl
->groupLen
[0] = 1;
228 /* Save current attack index as last attack index */
229 blockSwitchingControl
->lastattack
= blockSwitchingControl
->attack
;
230 blockSwitchingControl
->lastAttackIndex
= blockSwitchingControl
->attackIndex
;
232 /* Save current window energy as last window energy */
233 FDKmemcpy(blockSwitchingControl
->windowNrg
[0], blockSwitchingControl
->windowNrg
[1], sizeof(blockSwitchingControl
->windowNrg
[0]));
234 FDKmemcpy(blockSwitchingControl
->windowNrgF
[0], blockSwitchingControl
->windowNrgF
[1], sizeof(blockSwitchingControl
->windowNrgF
[0]));
236 if (blockSwitchingControl
->allowShortFrames
)
238 /* Calculate suggested grouping info for the last frame */
240 /* Reset grouping info */
241 FDKmemclear (blockSwitchingControl
->groupLen
, sizeof(blockSwitchingControl
->groupLen
));
243 /* Set grouping info */
244 blockSwitchingControl
->noOfGroups
= MAX_NO_OF_GROUPS
;
246 FDKmemcpy(blockSwitchingControl
->groupLen
, suggestedGroupingTable
[blockSwitchingControl
->lastAttackIndex
], sizeof(blockSwitchingControl
->groupLen
));
248 if (blockSwitchingControl
->attack
== TRUE
)
249 blockSwitchingControl
->maxWindowNrg
= FDKaacEnc_GetWindowEnergy(blockSwitchingControl
->windowNrg
[0], blockSwitchingControl
->lastAttackIndex
);
251 blockSwitchingControl
->maxWindowNrg
= FL2FXCONST_DBL(0.0);
256 /* Calculate unfiltered and filtered energies in subwindows and combine to segments */
257 FDKaacEnc_CalcWindowEnergy(blockSwitchingControl
, granuleLength
>>(nBlockSwitchWindows
==4? 2:3 ), pTimeSignal
);
259 /* now calculate if there is an attack */
262 blockSwitchingControl
->attack
= FALSE
;
264 /* look for attack */
265 enMax
= FL2FXCONST_DBL(0.0f
);
266 enM1
= blockSwitchingControl
->windowNrgF
[0][nBlockSwitchWindows
-1];
268 for (i
=0; i
<nBlockSwitchWindows
; i
++) {
269 FIXP_DBL tmp
= fMultDiv2(oneMinusAccWindowNrgFac
, blockSwitchingControl
->accWindowNrg
);
270 blockSwitchingControl
->accWindowNrg
= fMultAdd(tmp
, accWindowNrgFac
, enM1
) ;
272 if (fMult(blockSwitchingControl
->windowNrgF
[1][i
],invAttackRatio
) > blockSwitchingControl
->accWindowNrg
) {
273 blockSwitchingControl
->attack
= TRUE
;
274 blockSwitchingControl
->attackIndex
= i
;
276 enM1
= blockSwitchingControl
->windowNrgF
[1][i
];
277 enMax
= fixMax(enMax
, enM1
);
281 if (enMax
< minAttackNrg
) blockSwitchingControl
->attack
= FALSE
;
283 /* Check if attack spreads over frame border */
284 if((blockSwitchingControl
->attack
== FALSE
) && (blockSwitchingControl
->lastattack
== TRUE
)) {
285 /* if attack is in last window repeat SHORT_WINDOW */
286 if ( ((blockSwitchingControl
->windowNrgF
[0][nBlockSwitchWindows
-1]>>4) > fMult((FIXP_DBL
)(10<<(DFRACT_BITS
-1-4)), blockSwitchingControl
->windowNrgF
[1][1]))
287 && (blockSwitchingControl
->lastAttackIndex
== (INT
)nBlockSwitchWindows
-1)
290 blockSwitchingControl
->attack
= TRUE
;
291 blockSwitchingControl
->attackIndex
= 0;
296 if(blockSwitchingControl
->allowLookAhead
)
300 blockSwitchingControl
->lastWindowSequence
=
301 chgWndSqLkAhd
[blockSwitchingControl
->lastattack
][blockSwitchingControl
->attack
][blockSwitchingControl
->lastWindowSequence
];
306 blockSwitchingControl
->lastWindowSequence
=
307 chgWndSq
[blockSwitchingControl
->attack
][blockSwitchingControl
->lastWindowSequence
];
311 /* update window shape */
312 blockSwitchingControl
->windowShape
= blockType2windowShape
[blockSwitchingControl
->allowShortFrames
][blockSwitchingControl
->lastWindowSequence
];
319 static FIXP_DBL
FDKaacEnc_GetWindowEnergy(const FIXP_DBL in
[], const INT blSwWndIdx
)
321 /* For coherency, change FDKaacEnc_GetWindowEnergy() to calcluate the energy for a block switching analysis windows,
322 not for a short block. The same is done FDKaacEnc_CalcWindowEnergy(). The result of FDKaacEnc_GetWindowEnergy()
323 is used for a comparision of the max energy of left/right channel. */
325 return in
[blSwWndIdx
];
329 static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL
*RESTRICT blockSwitchingControl
, INT windowLen
, const INT_PCM
*pTimeSignal
)
334 FIXP_SGL hiPassCoeff0
= hiPassCoeff
[0];
335 FIXP_SGL hiPassCoeff1
= hiPassCoeff
[1];
337 /* sum up scalarproduct of timesignal as windowed Energies */
338 for (w
=0; w
< blockSwitchingControl
->nBlockSwitchWindows
; w
++) {
340 FIXP_DBL temp_windowNrg
= FL2FXCONST_DBL(0.0f
);
341 FIXP_DBL temp_windowNrgF
= FL2FXCONST_DBL(0.0f
);
342 FIXP_DBL temp_iirState0
= blockSwitchingControl
->iirStates
[0];
343 FIXP_DBL temp_iirState1
= blockSwitchingControl
->iirStates
[1];
345 /* windowNrg = sum(timesample^2) */
346 for(i
=0;i
<windowLen
;i
++)
349 FIXP_DBL tempUnfiltered
, tempFiltred
, t1
, t2
;
350 /* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */
351 #if SAMPLE_BITS == DFRACT_BITS
352 tempUnfiltered
= (FIXP_DBL
) *pTimeSignal
++ >> 1;
354 tempUnfiltered
= (FIXP_DBL
) *pTimeSignal
++ << (DFRACT_BITS
-SAMPLE_BITS
-1);
356 t1
= fMultDiv2(hiPassCoeff1
, tempUnfiltered
-temp_iirState0
);
357 t2
= fMultDiv2(hiPassCoeff0
, temp_iirState1
);
358 tempFiltred
= (t1
- t2
) << 1;
360 temp_iirState0
= tempUnfiltered
;
361 temp_iirState1
= tempFiltred
;
363 /* subtract 2 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT)
364 * because tempUnfiltered was already scaled with 1 (is 2 after squaring)
365 * subtract 1 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT)
366 * because of fMultDiv2 is doing a scaling by one */
367 temp_windowNrg
+= fPow2Div2(tempUnfiltered
) >> (BLOCK_SWITCH_ENERGY_SHIFT
- 1 - 2);
368 temp_windowNrgF
+= fPow2Div2(tempFiltred
) >> (BLOCK_SWITCH_ENERGY_SHIFT
- 1 - 2);
370 blockSwitchingControl
->windowNrg
[1][w
] = temp_windowNrg
;
371 blockSwitchingControl
->windowNrgF
[1][w
] = temp_windowNrgF
;
372 blockSwitchingControl
->iirStates
[0] = temp_iirState0
;
373 blockSwitchingControl
->iirStates
[1] = temp_iirState1
;
378 static const UCHAR synchronizedBlockTypeTable
[5][5] =
380 /* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW*/
381 /* LONG_WINDOW */ {LONG_WINDOW
, START_WINDOW
, SHORT_WINDOW
, STOP_WINDOW
, LOWOV_WINDOW
},
382 /* START_WINDOW */ {START_WINDOW
, START_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, LOWOV_WINDOW
},
383 /* SHORT_WINDOW */ {SHORT_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, WRONG_WINDOW
},
384 /* STOP_WINDOW */ {STOP_WINDOW
, SHORT_WINDOW
, SHORT_WINDOW
, STOP_WINDOW
, LOWOV_WINDOW
},
385 /* LOWOV_WINDOW */ {LOWOV_WINDOW
, LOWOV_WINDOW
, WRONG_WINDOW
, LOWOV_WINDOW
, LOWOV_WINDOW
},
388 int FDKaacEnc_SyncBlockSwitching (
389 BLOCK_SWITCHING_CONTROL
*blockSwitchingControlLeft
,
390 BLOCK_SWITCHING_CONTROL
*blockSwitchingControlRight
,
392 const INT commonWindow
)
394 UCHAR patchType
= LONG_WINDOW
;
396 if( nChannels
== 2 && commonWindow
== TRUE
)
398 /* could be better with a channel loop (need a handle to psy_data) */
399 /* get suggested Block Types and synchronize */
400 patchType
= synchronizedBlockTypeTable
[patchType
][blockSwitchingControlLeft
->lastWindowSequence
];
401 patchType
= synchronizedBlockTypeTable
[patchType
][blockSwitchingControlRight
->lastWindowSequence
];
403 /* sanity check (no change from low overlap window to short winow and vice versa) */
404 if (patchType
== WRONG_WINDOW
)
405 return -1; /* mixed up AAC-LC and AAC-LD */
407 /* Set synchronized Blocktype */
408 blockSwitchingControlLeft
->lastWindowSequence
= patchType
;
409 blockSwitchingControlRight
->lastWindowSequence
= patchType
;
411 /* update window shape */
412 blockSwitchingControlLeft
->windowShape
= blockType2windowShape
[blockSwitchingControlLeft
->allowShortFrames
][blockSwitchingControlLeft
->lastWindowSequence
];
413 blockSwitchingControlRight
->windowShape
= blockType2windowShape
[blockSwitchingControlLeft
->allowShortFrames
][blockSwitchingControlRight
->lastWindowSequence
];
416 if (blockSwitchingControlLeft
->allowShortFrames
)
422 if (commonWindow
== TRUE
)
424 /* Synchronize grouping info */
425 int windowSequenceLeftOld
= blockSwitchingControlLeft
->lastWindowSequence
;
426 int windowSequenceRightOld
= blockSwitchingControlRight
->lastWindowSequence
;
429 if(patchType
!= SHORT_WINDOW
) {
430 /* Set grouping info */
431 blockSwitchingControlLeft
->noOfGroups
= 1;
432 blockSwitchingControlRight
->noOfGroups
= 1;
433 blockSwitchingControlLeft
->groupLen
[0] = 1;
434 blockSwitchingControlRight
->groupLen
[0] = 1;
436 for (i
= 1; i
< MAX_NO_OF_GROUPS
; i
++)
438 blockSwitchingControlLeft
->groupLen
[i
] = 0;
439 blockSwitchingControlRight
->groupLen
[i
] = 0;
445 /* in case all two channels were detected as short-blocks before syncing, use the grouping of channel with higher maxWindowNrg */
446 if( (windowSequenceLeftOld
== SHORT_WINDOW
) &&
447 (windowSequenceRightOld
== SHORT_WINDOW
) )
449 if(blockSwitchingControlLeft
->maxWindowNrg
> blockSwitchingControlRight
->maxWindowNrg
) {
450 /* Left Channel wins */
451 blockSwitchingControlRight
->noOfGroups
= blockSwitchingControlLeft
->noOfGroups
;
452 for (i
= 0; i
< MAX_NO_OF_GROUPS
; i
++){
453 blockSwitchingControlRight
->groupLen
[i
] = blockSwitchingControlLeft
->groupLen
[i
];
457 /* Right Channel wins */
458 blockSwitchingControlLeft
->noOfGroups
= blockSwitchingControlRight
->noOfGroups
;
459 for (i
= 0; i
< MAX_NO_OF_GROUPS
; i
++){
460 blockSwitchingControlLeft
->groupLen
[i
] = blockSwitchingControlRight
->groupLen
[i
];
464 else if ( (windowSequenceLeftOld
== SHORT_WINDOW
) &&
465 (windowSequenceRightOld
!= SHORT_WINDOW
) )
467 /* else use grouping of short-block channel */
468 blockSwitchingControlRight
->noOfGroups
= blockSwitchingControlLeft
->noOfGroups
;
469 for (i
= 0; i
< MAX_NO_OF_GROUPS
; i
++){
470 blockSwitchingControlRight
->groupLen
[i
] = blockSwitchingControlLeft
->groupLen
[i
];
473 else if ( (windowSequenceRightOld
== SHORT_WINDOW
) &&
474 (windowSequenceLeftOld
!= SHORT_WINDOW
) )
476 blockSwitchingControlLeft
->noOfGroups
= blockSwitchingControlRight
->noOfGroups
;
477 for (i
= 0; i
< MAX_NO_OF_GROUPS
; i
++){
478 blockSwitchingControlLeft
->groupLen
[i
] = blockSwitchingControlRight
->groupLen
[i
];
481 /* syncing a start and stop window ... */
482 blockSwitchingControlLeft
->noOfGroups
= blockSwitchingControlRight
->noOfGroups
= 2;
483 blockSwitchingControlLeft
->groupLen
[0] = blockSwitchingControlRight
->groupLen
[0] = 4;
484 blockSwitchingControlLeft
->groupLen
[1] = blockSwitchingControlRight
->groupLen
[1] = 4;
489 /* stereo, no common window */
490 if (blockSwitchingControlLeft
->lastWindowSequence
!=SHORT_WINDOW
){
491 blockSwitchingControlLeft
->noOfGroups
= 1;
492 blockSwitchingControlLeft
->groupLen
[0] = 1;
493 for (i
= 1; i
< MAX_NO_OF_GROUPS
; i
++)
495 blockSwitchingControlLeft
->groupLen
[i
] = 0;
498 if (blockSwitchingControlRight
->lastWindowSequence
!=SHORT_WINDOW
){
499 blockSwitchingControlRight
->noOfGroups
= 1;
500 blockSwitchingControlRight
->groupLen
[0] = 1;
501 for (i
= 1; i
< MAX_NO_OF_GROUPS
; i
++)
503 blockSwitchingControlRight
->groupLen
[i
] = 0;
506 } /* common window */
509 if (blockSwitchingControlLeft
->lastWindowSequence
!=SHORT_WINDOW
){
510 blockSwitchingControlLeft
->noOfGroups
= 1;
511 blockSwitchingControlLeft
->groupLen
[0] = 1;
513 for (i
= 1; i
< MAX_NO_OF_GROUPS
; i
++)
515 blockSwitchingControlLeft
->groupLen
[i
] = 0;
519 } /* allowShortFrames */
522 /* Translate LOWOV_WINDOW block type to a meaningful window shape. */
523 if ( ! blockSwitchingControlLeft
->allowShortFrames
) {
524 if ( blockSwitchingControlLeft
->lastWindowSequence
!= LONG_WINDOW
525 && blockSwitchingControlLeft
->lastWindowSequence
!= STOP_WINDOW
)
527 blockSwitchingControlLeft
->lastWindowSequence
= LONG_WINDOW
;
528 blockSwitchingControlLeft
->windowShape
= LOL_WINDOW
;
531 if (nChannels
== 2) {
532 if ( ! blockSwitchingControlRight
->allowShortFrames
) {
533 if ( blockSwitchingControlRight
->lastWindowSequence
!= LONG_WINDOW
534 && blockSwitchingControlRight
->lastWindowSequence
!= STOP_WINDOW
)
536 blockSwitchingControlRight
->lastWindowSequence
= LONG_WINDOW
;
537 blockSwitchingControlRight
->windowShape
= LOL_WINDOW
;