14e074f72SMilanka Ringwald /* 24e074f72SMilanka Ringwald * Copyright (C) 2016 BlueKitchen GmbH 34e074f72SMilanka Ringwald * 44e074f72SMilanka Ringwald * Redistribution and use in source and binary forms, with or without 54e074f72SMilanka Ringwald * modification, are permitted provided that the following conditions 64e074f72SMilanka Ringwald * are met: 74e074f72SMilanka Ringwald * 84e074f72SMilanka Ringwald * 1. Redistributions of source code must retain the above copyright 94e074f72SMilanka Ringwald * notice, this list of conditions and the following disclaimer. 104e074f72SMilanka Ringwald * 2. Redistributions in binary form must reproduce the above copyright 114e074f72SMilanka Ringwald * notice, this list of conditions and the following disclaimer in the 124e074f72SMilanka Ringwald * documentation and/or other materials provided with the distribution. 134e074f72SMilanka Ringwald * 3. Neither the name of the copyright holders nor the names of 144e074f72SMilanka Ringwald * contributors may be used to endorse or promote products derived 154e074f72SMilanka Ringwald * from this software without specific prior written permission. 164e074f72SMilanka Ringwald * 4. Any redistribution, use, or modification is done solely for 174e074f72SMilanka Ringwald * personal benefit and not for any commercial purpose or for 184e074f72SMilanka Ringwald * monetary gain. 194e074f72SMilanka Ringwald * 204e074f72SMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 214e074f72SMilanka Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 224e074f72SMilanka Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 234e074f72SMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 244e074f72SMilanka Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 254e074f72SMilanka Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 264e074f72SMilanka Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 274e074f72SMilanka Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 284e074f72SMilanka Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 294e074f72SMilanka Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 304e074f72SMilanka Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314e074f72SMilanka Ringwald * SUCH DAMAGE. 324e074f72SMilanka Ringwald * 334e074f72SMilanka Ringwald * Please inquire about commercial licensing options at 344e074f72SMilanka Ringwald * [email protected] 354e074f72SMilanka Ringwald * 364e074f72SMilanka Ringwald */ 374e074f72SMilanka Ringwald 384e074f72SMilanka Ringwald /* 39*e7a41128SMilanka Ringwald * btstack_sbc_plc.h 404e074f72SMilanka Ringwald * 414e074f72SMilanka Ringwald */ 424e074f72SMilanka Ringwald 43*e7a41128SMilanka Ringwald #ifndef __BTSTACK_SBC_PLC_H 44*e7a41128SMilanka Ringwald #define __BTSTACK_SBC_PLC_H 454e074f72SMilanka Ringwald 464e074f72SMilanka Ringwald #include <stdint.h> 474e074f72SMilanka Ringwald 484e074f72SMilanka Ringwald #if defined __cplusplus 494e074f72SMilanka Ringwald extern "C" { 504e074f72SMilanka Ringwald #endif 514e074f72SMilanka Ringwald 524e074f72SMilanka Ringwald #define FS 120 /* Frame Size */ 534e074f72SMilanka Ringwald #define N 256 /* 16ms - Window Length for pattern matching */ 544e074f72SMilanka Ringwald #define M 64 /* 4ms - Template for matching */ 554e074f72SMilanka Ringwald #define LHIST (N+FS-1) /* Length of history buffer required */ 564e074f72SMilanka Ringwald #define SBCRT 36 /* SBC Reconvergence Time (samples) */ 574e074f72SMilanka Ringwald #define OLAL 16 /* OverLap-Add Length (samples) */ 584e074f72SMilanka Ringwald 594e074f72SMilanka Ringwald /* PLC State Information */ 604e074f72SMilanka Ringwald typedef struct sbc_plc_state { 614e074f72SMilanka Ringwald int16_t hist[LHIST+FS+SBCRT+OLAL]; 624e074f72SMilanka Ringwald int16_t bestlag; 634e074f72SMilanka Ringwald int nbf; 64*e7a41128SMilanka Ringwald } btstack_sbc_plc_state_t; 65*e7a41128SMilanka Ringwald 66*e7a41128SMilanka Ringwald void btstack_sbc_plc_init(btstack_sbc_plc_state_t *plc_state); 67*e7a41128SMilanka Ringwald void btstack_sbc_plc_bad_frame(btstack_sbc_plc_state_t *plc_state, int16_t *ZIRbuf, int16_t *out); 68*e7a41128SMilanka Ringwald void btstack_sbc_plc_good_frame(btstack_sbc_plc_state_t *plc_state, int16_t *in, int16_t *out); 69*e7a41128SMilanka Ringwald uint8_t * btstack_sbc_plc_zero_signal_frame(void); 704e074f72SMilanka Ringwald 714e074f72SMilanka Ringwald #if defined __cplusplus 724e074f72SMilanka Ringwald } 734e074f72SMilanka Ringwald #endif 744e074f72SMilanka Ringwald 75*e7a41128SMilanka Ringwald #endif // __BTSTACK_SBC_PLC_H