summaryrefslogtreecommitdiff
path: root/cras/src/plc/cras_plc.h
blob: ccde8bbe57b65e0330fecfb0c65d23e851a6887d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <stdint.h>

#include "cras_audio_codec.h"

/* PLC library provides helper functions to mask the effects of lost or
 * disrupted packets. It currentyl only supports the mSBC codec.
 *
 * This struct contains informations needed for applying the PLC algorithm.
 */
struct cras_msbc_plc;

/* Creates a plc component for mSBC codec, which is used for wideband speech
 * mode of HFP
 */
struct cras_msbc_plc *cras_msbc_plc_create();

/* Destroys a mSBC PLC.
 * Args:
 *    plc - The PLC to destroy.
 */
void cras_msbc_plc_destroy(struct cras_msbc_plc *plc);

/* Conceals the packet loss by writing the substitution samples to the ouput
 * buffer provided by the caller. The samples will be generated based on the
 * informations recorded in the PLC struct passed in.
 * Args:
 *    plc - The PLC you use.
 *    codec - The mSBC codec.
 *    output - Pointer to the output buffer.
 * Returns:
 *    The number of bytes written to the output buffer.
 */
int cras_msbc_plc_handle_bad_frames(struct cras_msbc_plc *plc,
				    struct cras_audio_codec *codec,
				    uint8_t *output);

/* Updates informations needed and potentially processes the input samples to
 * help it to reconverge after a frame loss.
 *
 * The memory space input and output pointers point to can be overlapping.
 * Args:
 *   plc - The PLC you use.
 *   input - Pointer to the true input.
 *   output - Pointer to the output buffer.
 * Returns:
 *    The number of bytes written to the output buffer.
 */
int cras_msbc_plc_handle_good_frames(struct cras_msbc_plc *plc,
				     const uint8_t *input, uint8_t *output);