niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ |
| 12 | #define MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame^] | 14 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | /* |
| 17 | * Solution to support multiple instances |
| 18 | */ |
| 19 | |
| 20 | typedef struct WebRtcG722EncInst G722EncInst; |
| 21 | typedef struct WebRtcG722DecInst G722DecInst; |
| 22 | |
| 23 | /* |
| 24 | * Comfort noise constants |
| 25 | */ |
| 26 | |
| 27 | #define G722_WEBRTC_SPEECH 1 |
| 28 | #define G722_WEBRTC_CNG 2 |
| 29 | |
| 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | /**************************************************************************** |
| 36 | * WebRtcG722_CreateEncoder(...) |
| 37 | * |
| 38 | * Create memory used for G722 encoder |
| 39 | * |
| 40 | * Input: |
| 41 | * - G722enc_inst : G722 instance for encoder |
| 42 | * |
| 43 | * Return value : 0 - Ok |
| 44 | * -1 - Error |
| 45 | */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 46 | int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
| 48 | |
| 49 | /**************************************************************************** |
| 50 | * WebRtcG722_EncoderInit(...) |
| 51 | * |
| 52 | * This function initializes a G722 instance |
| 53 | * |
| 54 | * Input: |
| 55 | * - G722enc_inst : G722 instance, i.e. the user that should receive |
| 56 | * be initialized |
| 57 | * |
| 58 | * Return value : 0 - Ok |
| 59 | * -1 - Error |
| 60 | */ |
| 61 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 62 | int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
| 64 | |
| 65 | /**************************************************************************** |
| 66 | * WebRtcG722_FreeEncoder(...) |
| 67 | * |
| 68 | * Free the memory used for G722 encoder |
| 69 | * |
| 70 | * Input: |
| 71 | * - G722enc_inst : G722 instance for encoder |
| 72 | * |
| 73 | * Return value : 0 - Ok |
| 74 | * -1 - Error |
| 75 | */ |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 76 | int WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
| 78 | |
| 79 | |
| 80 | /**************************************************************************** |
| 81 | * WebRtcG722_Encode(...) |
| 82 | * |
| 83 | * This function encodes G722 encoded data. |
| 84 | * |
| 85 | * Input: |
| 86 | * - G722enc_inst : G722 instance, i.e. the user that should encode |
| 87 | * a packet |
| 88 | * - speechIn : Input speech vector |
| 89 | * - len : Samples in speechIn |
| 90 | * |
| 91 | * Output: |
| 92 | * - encoded : The encoded data vector |
| 93 | * |
Peter Kasting | 728d903 | 2015-06-11 14:31:38 -0700 | [diff] [blame] | 94 | * Return value : Length (in bytes) of coded data |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | */ |
| 96 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 97 | size_t WebRtcG722_Encode(G722EncInst* G722enc_inst, |
| 98 | const int16_t* speechIn, |
| 99 | size_t len, |
| 100 | uint8_t* encoded); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
| 102 | |
| 103 | /**************************************************************************** |
| 104 | * WebRtcG722_CreateDecoder(...) |
| 105 | * |
| 106 | * Create memory used for G722 encoder |
| 107 | * |
| 108 | * Input: |
| 109 | * - G722dec_inst : G722 instance for decoder |
| 110 | * |
| 111 | * Return value : 0 - Ok |
| 112 | * -1 - Error |
| 113 | */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 114 | int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | /**************************************************************************** |
| 117 | * WebRtcG722_DecoderInit(...) |
| 118 | * |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 119 | * This function initializes a G722 instance |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | * |
| 121 | * Input: |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 122 | * - inst : G722 instance |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | */ |
| 124 | |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 125 | void WebRtcG722_DecoderInit(G722DecInst* inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
| 127 | /**************************************************************************** |
| 128 | * WebRtcG722_FreeDecoder(...) |
| 129 | * |
| 130 | * Free the memory used for G722 decoder |
| 131 | * |
| 132 | * Input: |
| 133 | * - G722dec_inst : G722 instance for decoder |
| 134 | * |
| 135 | * Return value : 0 - Ok |
| 136 | * -1 - Error |
| 137 | */ |
| 138 | |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 139 | int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
| 141 | |
| 142 | /**************************************************************************** |
| 143 | * WebRtcG722_Decode(...) |
| 144 | * |
| 145 | * This function decodes a packet with G729 frame(s). Output speech length |
| 146 | * will be a multiple of 80 samples (80*frames/packet). |
| 147 | * |
| 148 | * Input: |
| 149 | * - G722dec_inst : G722 instance, i.e. the user that should decode |
| 150 | * a packet |
| 151 | * - encoded : Encoded G722 frame(s) |
| 152 | * - len : Bytes in encoded vector |
| 153 | * |
| 154 | * Output: |
| 155 | * - decoded : The decoded vector |
| 156 | * - speechType : 1 normal, 2 CNG (Since G722 does not have its own |
| 157 | * DTX/CNG scheme it should always return 1) |
| 158 | * |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 159 | * Return value : Samples in decoded vector |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | */ |
| 161 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 162 | size_t WebRtcG722_Decode(G722DecInst *G722dec_inst, |
| 163 | const uint8_t* encoded, |
| 164 | size_t len, |
| 165 | int16_t *decoded, |
| 166 | int16_t *speechType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 167 | |
| 168 | /**************************************************************************** |
| 169 | * WebRtcG722_Version(...) |
| 170 | * |
| 171 | * Get a string with the current version of the codec |
| 172 | */ |
| 173 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 174 | int16_t WebRtcG722_Version(char *versionStr, short len); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 175 | |
| 176 | |
| 177 | #ifdef __cplusplus |
| 178 | } |
| 179 | #endif |
| 180 | |
| 181 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 182 | #endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */ |