1*4e074f72SMilanka Ringwald /* 2*4e074f72SMilanka Ringwald * Copyright (C) 2016 BlueKitchen GmbH 3*4e074f72SMilanka Ringwald * 4*4e074f72SMilanka Ringwald * Redistribution and use in source and binary forms, with or without 5*4e074f72SMilanka Ringwald * modification, are permitted provided that the following conditions 6*4e074f72SMilanka Ringwald * are met: 7*4e074f72SMilanka Ringwald * 8*4e074f72SMilanka Ringwald * 1. Redistributions of source code must retain the above copyright 9*4e074f72SMilanka Ringwald * notice, this list of conditions and the following disclaimer. 10*4e074f72SMilanka Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*4e074f72SMilanka Ringwald * notice, this list of conditions and the following disclaimer in the 12*4e074f72SMilanka Ringwald * documentation and/or other materials provided with the distribution. 13*4e074f72SMilanka Ringwald * 3. Neither the name of the copyright holders nor the names of 14*4e074f72SMilanka Ringwald * contributors may be used to endorse or promote products derived 15*4e074f72SMilanka Ringwald * from this software without specific prior written permission. 16*4e074f72SMilanka Ringwald * 4. Any redistribution, use, or modification is done solely for 17*4e074f72SMilanka Ringwald * personal benefit and not for any commercial purpose or for 18*4e074f72SMilanka Ringwald * monetary gain. 19*4e074f72SMilanka Ringwald * 20*4e074f72SMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*4e074f72SMilanka Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*4e074f72SMilanka Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*4e074f72SMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24*4e074f72SMilanka Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*4e074f72SMilanka Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*4e074f72SMilanka Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*4e074f72SMilanka Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*4e074f72SMilanka Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*4e074f72SMilanka Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*4e074f72SMilanka Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*4e074f72SMilanka Ringwald * SUCH DAMAGE. 32*4e074f72SMilanka Ringwald * 33*4e074f72SMilanka Ringwald * Please inquire about commercial licensing options at 34*4e074f72SMilanka Ringwald * [email protected] 35*4e074f72SMilanka Ringwald * 36*4e074f72SMilanka Ringwald */ 37*4e074f72SMilanka Ringwald 38*4e074f72SMilanka Ringwald /* 39*4e074f72SMilanka Ringwald * sbc_plc.h 40*4e074f72SMilanka Ringwald * 41*4e074f72SMilanka Ringwald */ 42*4e074f72SMilanka Ringwald 43*4e074f72SMilanka Ringwald #ifndef __SBC_PLC_H 44*4e074f72SMilanka Ringwald #define __SBC_PLC_H 45*4e074f72SMilanka Ringwald 46*4e074f72SMilanka Ringwald #include <stdint.h> 47*4e074f72SMilanka Ringwald 48*4e074f72SMilanka Ringwald #if defined __cplusplus 49*4e074f72SMilanka Ringwald extern "C" { 50*4e074f72SMilanka Ringwald #endif 51*4e074f72SMilanka Ringwald 52*4e074f72SMilanka Ringwald #define FS 120 /* Frame Size */ 53*4e074f72SMilanka Ringwald #define N 256 /* 16ms - Window Length for pattern matching */ 54*4e074f72SMilanka Ringwald #define M 64 /* 4ms - Template for matching */ 55*4e074f72SMilanka Ringwald #define LHIST (N+FS-1) /* Length of history buffer required */ 56*4e074f72SMilanka Ringwald #define SBCRT 36 /* SBC Reconvergence Time (samples) */ 57*4e074f72SMilanka Ringwald #define OLAL 16 /* OverLap-Add Length (samples) */ 58*4e074f72SMilanka Ringwald 59*4e074f72SMilanka Ringwald /* PLC State Information */ 60*4e074f72SMilanka Ringwald typedef struct sbc_plc_state { 61*4e074f72SMilanka Ringwald int16_t hist[LHIST+FS+SBCRT+OLAL]; 62*4e074f72SMilanka Ringwald int16_t bestlag; 63*4e074f72SMilanka Ringwald int nbf; 64*4e074f72SMilanka Ringwald } sbc_plc_state_t; 65*4e074f72SMilanka Ringwald 66*4e074f72SMilanka Ringwald #if defined __cplusplus 67*4e074f72SMilanka Ringwald } 68*4e074f72SMilanka Ringwald #endif 69*4e074f72SMilanka Ringwald 70*4e074f72SMilanka Ringwald void sbc_plc_init(sbc_plc_state_t *plc_state); 71*4e074f72SMilanka Ringwald void sbc_plc_bad_frame(sbc_plc_state_t *plc_state, int16_t *ZIRbuf, int16_t *out); 72*4e074f72SMilanka Ringwald void sbc_plc_good_frame(sbc_plc_state_t *plc_state, int16_t *in, int16_t *out); 73*4e074f72SMilanka Ringwald uint8_t * sbc_plc_zero_signal_frame(void); 74*4e074f72SMilanka Ringwald 75*4e074f72SMilanka Ringwald #endif // __SBC_PLC_H