block_switch.h revision 956c553ab0ce72f8074ad0fda2ffd66a0305700c
1/*
2 ** Copyright 2003-2010, VisualOn, Inc.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 **     http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16/*******************************************************************************
17	File:		block_switch.h
18
19	Content:	Block switching structure and functions
20
21*******************************************************************************/
22
23#ifndef _BLOCK_SWITCH_H
24#define _BLOCK_SWITCH_H
25
26#include "typedef.h"
27
28
29/****************** Defines ******************************/
30#define BLOCK_SWITCHING_IIR_LEN 2                                           /* Length of HighPass-FIR-Filter for Attack-Detection */
31#define BLOCK_SWITCH_WINDOWS TRANS_FAC                                      /* number of windows for energy calculation */
32#define BLOCK_SWITCH_WINDOW_LEN FRAME_LEN_SHORT                             /* minimal granularity of energy calculation */
33
34
35
36/****************** Structures ***************************/
37typedef struct{
38  Word32 invAttackRatio;
39  Word16 windowSequence;
40  Word16 nextwindowSequence;
41  Flag attack;
42  Flag lastattack;
43  Word16 attackIndex;
44  Word16 lastAttackIndex;
45  Word16 noOfGroups;
46  Word16 groupLen[TRANS_FAC];
47  Word32 windowNrg[2][BLOCK_SWITCH_WINDOWS];     /* time signal energy in Subwindows (last and current) */
48  Word32 windowNrgF[2][BLOCK_SWITCH_WINDOWS];    /* filtered time signal energy in segments (last and current) */
49  Word32 iirStates[BLOCK_SWITCHING_IIR_LEN];     /* filter delay-line */
50  Word32 maxWindowNrg;                           /* max energy in subwindows */
51  Word32 accWindowNrg;                           /* recursively accumulated windowNrgF */
52}BLOCK_SWITCHING_CONTROL;
53
54
55
56
57
58Word16 InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
59                          const Word32 bitRate, const Word16 nChannels);
60
61Word16 BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
62                      Word16 *timeSignal,
63					  Word32  sampleRate,
64                      Word16 chIncrement);
65
66Word16 SyncBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
67                          BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight,
68                          const Word16 noOfChannels);
69
70
71
72#endif  /* #ifndef _BLOCK_SWITCH_H */
73