xref: /btstack/3rd-party/lc3-google/src/bwdet.h (revision 4930cef6e21e6da2d7571b9259c7f0fb8bed3d01)
19a19cd78SMatthias Ringwald /******************************************************************************
29a19cd78SMatthias Ringwald  *
3*4930cef6SMatthias Ringwald  *  Copyright 2022 Google LLC
49a19cd78SMatthias Ringwald  *
59a19cd78SMatthias Ringwald  *  Licensed under the Apache License, Version 2.0 (the "License");
69a19cd78SMatthias Ringwald  *  you may not use this file except in compliance with the License.
79a19cd78SMatthias Ringwald  *  You may obtain a copy of the License at:
89a19cd78SMatthias Ringwald  *
99a19cd78SMatthias Ringwald  *  http://www.apache.org/licenses/LICENSE-2.0
109a19cd78SMatthias Ringwald  *
119a19cd78SMatthias Ringwald  *  Unless required by applicable law or agreed to in writing, software
129a19cd78SMatthias Ringwald  *  distributed under the License is distributed on an "AS IS" BASIS,
139a19cd78SMatthias Ringwald  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149a19cd78SMatthias Ringwald  *  See the License for the specific language governing permissions and
159a19cd78SMatthias Ringwald  *  limitations under the License.
169a19cd78SMatthias Ringwald  *
179a19cd78SMatthias Ringwald  ******************************************************************************/
189a19cd78SMatthias Ringwald 
199a19cd78SMatthias Ringwald /**
209a19cd78SMatthias Ringwald  * LC3 - Bandwidth detector
219a19cd78SMatthias Ringwald  *
229a19cd78SMatthias Ringwald  * Reference : Low Complexity Communication Codec (LC3)
239a19cd78SMatthias Ringwald  *             Bluetooth Specification v1.0
249a19cd78SMatthias Ringwald  */
259a19cd78SMatthias Ringwald 
269a19cd78SMatthias Ringwald #ifndef __LC3_BWDET_H
279a19cd78SMatthias Ringwald #define __LC3_BWDET_H
289a19cd78SMatthias Ringwald 
299a19cd78SMatthias Ringwald #include "common.h"
309a19cd78SMatthias Ringwald #include "bits.h"
319a19cd78SMatthias Ringwald 
329a19cd78SMatthias Ringwald 
339a19cd78SMatthias Ringwald /**
349a19cd78SMatthias Ringwald  * Bandwidth detector (cf. 3.3.5)
359a19cd78SMatthias Ringwald  * dt, sr          Duration and samplerate of the frame
369a19cd78SMatthias Ringwald  * e               Energy estimation per bands
379a19cd78SMatthias Ringwald  * return          Return detected bandwitdth
389a19cd78SMatthias Ringwald  */
399a19cd78SMatthias Ringwald enum lc3_bandwidth lc3_bwdet_run(
409a19cd78SMatthias Ringwald     enum lc3_dt dt, enum lc3_srate sr, const float *e);
419a19cd78SMatthias Ringwald 
429a19cd78SMatthias Ringwald /**
439a19cd78SMatthias Ringwald  * Return number of bits coding the bandwidth value
449a19cd78SMatthias Ringwald  * sr              Samplerate of the frame
459a19cd78SMatthias Ringwald  * return          Number of bits coding the bandwidth value
469a19cd78SMatthias Ringwald  */
479a19cd78SMatthias Ringwald int lc3_bwdet_get_nbits(enum lc3_srate sr);
489a19cd78SMatthias Ringwald 
499a19cd78SMatthias Ringwald /**
509a19cd78SMatthias Ringwald  * Put bandwidth indication
519a19cd78SMatthias Ringwald  * bits            Bitstream context
529a19cd78SMatthias Ringwald  * sr              Samplerate of the frame
539a19cd78SMatthias Ringwald  * bw              Bandwidth detected
549a19cd78SMatthias Ringwald  */
559a19cd78SMatthias Ringwald void lc3_bwdet_put_bw(lc3_bits_t *bits,
569a19cd78SMatthias Ringwald     enum lc3_srate sr, enum lc3_bandwidth bw);
579a19cd78SMatthias Ringwald 
589a19cd78SMatthias Ringwald /**
599a19cd78SMatthias Ringwald  * Get bandwidth indication
609a19cd78SMatthias Ringwald  * bits            Bitstream context
619a19cd78SMatthias Ringwald  * sr              Samplerate of the frame
629a19cd78SMatthias Ringwald  * bw              Return bandwidth indication
639a19cd78SMatthias Ringwald  * return          0: Ok  -1: Invalid bandwidth indication
649a19cd78SMatthias Ringwald  */
659a19cd78SMatthias Ringwald int lc3_bwdet_get_bw(lc3_bits_t *bits,
669a19cd78SMatthias Ringwald     enum lc3_srate sr, enum lc3_bandwidth *bw);
679a19cd78SMatthias Ringwald 
689a19cd78SMatthias Ringwald 
699a19cd78SMatthias Ringwald #endif /* __LC3_BWDET_H */
70