niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 91b359e | 2012-02-28 17:26:14 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
| 11 | /****************************************************************** |
| 12 | |
| 13 | iLBC Speech Coder ANSI-C Source Code |
| 14 | |
| 15 | iLBCInterface.c |
| 16 | |
| 17 | ******************************************************************/ |
| 18 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | #include <stdlib.h> |
| 20 | |
Mirko Bonadei | 06c2aa9 | 2018-02-01 15:11:41 +0100 | [diff] [blame^] | 21 | #include "modules/audio_coding/codecs/ilbc/ilbc.h" |
| 22 | #include "modules/audio_coding/codecs/ilbc/defines.h" |
| 23 | #include "modules/audio_coding/codecs/ilbc/init_encode.h" |
| 24 | #include "modules/audio_coding/codecs/ilbc/encode.h" |
| 25 | #include "modules/audio_coding/codecs/ilbc/init_decode.h" |
| 26 | #include "modules/audio_coding/codecs/ilbc/decode.h" |
| 27 | #include "rtc_base/checks.h" |
| 28 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 29 | int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst, |
| 30 | int16_t* ILBCENC_inst_Addr, |
| 31 | int16_t* size) { |
| 32 | *iLBC_encinst=(IlbcEncoderInstance*)ILBCENC_inst_Addr; |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 33 | *size=sizeof(IlbcEncoder)/sizeof(int16_t); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | if (*iLBC_encinst!=NULL) { |
| 35 | return(0); |
| 36 | } else { |
| 37 | return(-1); |
| 38 | } |
| 39 | } |
| 40 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 41 | int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst, |
| 42 | int16_t* ILBCDEC_inst_Addr, |
| 43 | int16_t* size) { |
| 44 | *iLBC_decinst=(IlbcDecoderInstance*)ILBCDEC_inst_Addr; |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 45 | *size=sizeof(IlbcDecoder)/sizeof(int16_t); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | if (*iLBC_decinst!=NULL) { |
| 47 | return(0); |
| 48 | } else { |
| 49 | return(-1); |
| 50 | } |
| 51 | } |
| 52 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 53 | int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 54 | *iLBC_encinst=(IlbcEncoderInstance*)malloc(sizeof(IlbcEncoder)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | if (*iLBC_encinst!=NULL) { |
kma@webrtc.org | ac4d70d | 2012-10-05 00:19:01 +0000 | [diff] [blame] | 56 | WebRtcSpl_Init(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | return(0); |
| 58 | } else { |
| 59 | return(-1); |
| 60 | } |
| 61 | } |
| 62 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 63 | int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 64 | *iLBC_decinst=(IlbcDecoderInstance*)malloc(sizeof(IlbcDecoder)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | if (*iLBC_decinst!=NULL) { |
kma@webrtc.org | ac4d70d | 2012-10-05 00:19:01 +0000 | [diff] [blame] | 66 | WebRtcSpl_Init(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | return(0); |
| 68 | } else { |
| 69 | return(-1); |
| 70 | } |
| 71 | } |
| 72 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 73 | int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | free(iLBC_encinst); |
| 75 | return(0); |
| 76 | } |
| 77 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 78 | int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | free(iLBC_decinst); |
| 80 | return(0); |
| 81 | } |
| 82 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 83 | int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst, |
| 84 | int16_t mode) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | if ((mode==20)||(mode==30)) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 86 | WebRtcIlbcfix_InitEncode((IlbcEncoder*) iLBCenc_inst, mode); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | return(0); |
| 88 | } else { |
| 89 | return(-1); |
| 90 | } |
| 91 | } |
| 92 | |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 93 | int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst, |
| 94 | const int16_t* speechIn, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 95 | size_t len, |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 96 | uint8_t* encoded) { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 97 | size_t pos = 0; |
| 98 | size_t encpos = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 100 | if ((len != ((IlbcEncoder*)iLBCenc_inst)->blockl) && |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | #ifdef SPLIT_10MS |
| 102 | (len != 80) && |
| 103 | #endif |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 104 | (len != 2*((IlbcEncoder*)iLBCenc_inst)->blockl) && |
| 105 | (len != 3*((IlbcEncoder*)iLBCenc_inst)->blockl)) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | { |
| 107 | /* A maximum of 3 frames/packet is allowed */ |
| 108 | return(-1); |
| 109 | } else { |
| 110 | |
| 111 | /* call encoder */ |
| 112 | while (pos<len) { |
kwiberg@webrtc.org | cb858ba | 2014-12-08 17:11:44 +0000 | [diff] [blame] | 113 | WebRtcIlbcfix_EncodeImpl((uint16_t*)&encoded[2 * encpos], &speechIn[pos], |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 114 | (IlbcEncoder*)iLBCenc_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | #ifdef SPLIT_10MS |
| 116 | pos += 80; |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 117 | if(((IlbcEncoder*)iLBCenc_inst)->section == 0) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | #else |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 119 | pos += ((IlbcEncoder*)iLBCenc_inst)->blockl; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | #endif |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 121 | encpos += ((IlbcEncoder*)iLBCenc_inst)->no_of_words; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | } |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 123 | return (int)(encpos*2); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 127 | int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst, |
| 128 | int16_t mode) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | if ((mode==20)||(mode==30)) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 130 | WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, mode, 1); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 131 | return(0); |
| 132 | } else { |
| 133 | return(-1); |
| 134 | } |
| 135 | } |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 136 | void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 137 | WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 20, 1); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | } |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 139 | void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst) { |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 140 | WebRtcIlbcfix_InitDecode((IlbcDecoder*) iLBCdec_inst, 30, 1); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 144 | int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst, |
| 145 | const uint8_t* encoded, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 146 | size_t len, |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 147 | int16_t* decoded, |
| 148 | int16_t* speechType) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 149 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 150 | size_t i=0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | /* Allow for automatic switching between the frame sizes |
| 152 | (although you do get some discontinuity) */ |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 153 | if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 154 | (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 155 | (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 156 | /* ok, do nothing */ |
| 157 | } else { |
| 158 | /* Test if the mode has changed */ |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 159 | if (((IlbcDecoder*)iLBCdec_inst)->mode==20) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | if ((len==NO_OF_BYTES_30MS)|| |
| 161 | (len==2*NO_OF_BYTES_30MS)|| |
| 162 | (len==3*NO_OF_BYTES_30MS)) { |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 163 | WebRtcIlbcfix_InitDecode( |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 164 | ((IlbcDecoder*)iLBCdec_inst), 30, |
| 165 | ((IlbcDecoder*)iLBCdec_inst)->use_enhancer); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 166 | } else { |
| 167 | /* Unsupported frame length */ |
| 168 | return(-1); |
| 169 | } |
| 170 | } else { |
| 171 | if ((len==NO_OF_BYTES_20MS)|| |
| 172 | (len==2*NO_OF_BYTES_20MS)|| |
| 173 | (len==3*NO_OF_BYTES_20MS)) { |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 174 | WebRtcIlbcfix_InitDecode( |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 175 | ((IlbcDecoder*)iLBCdec_inst), 20, |
| 176 | ((IlbcDecoder*)iLBCdec_inst)->use_enhancer); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | } else { |
| 178 | /* Unsupported frame length */ |
| 179 | return(-1); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 184 | while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 185 | if (WebRtcIlbcfix_DecodeImpl( |
| 186 | &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
| 187 | (const uint16_t*)&encoded |
| 188 | [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
| 189 | (IlbcDecoder*)iLBCdec_inst, 1) == -1) |
| 190 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 191 | i++; |
| 192 | } |
| 193 | /* iLBC does not support VAD/CNG yet */ |
| 194 | *speechType=1; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 195 | return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 198 | int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst, |
| 199 | const uint8_t* encoded, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 200 | size_t len, |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 201 | int16_t* decoded, |
| 202 | int16_t* speechType) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 203 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 204 | size_t i=0; |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 205 | if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 206 | (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 207 | (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 208 | /* ok, do nothing */ |
| 209 | } else { |
| 210 | return(-1); |
| 211 | } |
| 212 | |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 213 | while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 214 | if (!WebRtcIlbcfix_DecodeImpl( |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 215 | &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 216 | (const uint16_t*)&encoded |
jmarusic@webrtc.org | 71b35a4 | 2015-02-17 16:02:18 +0000 | [diff] [blame] | 217 | [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 218 | (IlbcDecoder*)iLBCdec_inst, 1)) |
| 219 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 220 | i++; |
| 221 | } |
| 222 | /* iLBC does not support VAD/CNG yet */ |
| 223 | *speechType=1; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 224 | return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 227 | int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst, |
| 228 | const uint8_t* encoded, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 229 | size_t len, |
Peter Kasting | a8b335c | 2015-06-11 18:51:20 -0700 | [diff] [blame] | 230 | int16_t* decoded, |
| 231 | int16_t* speechType) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 232 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 233 | size_t i=0; |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 234 | if ((len==((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 235 | (len==2*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)|| |
| 236 | (len==3*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 237 | /* ok, do nothing */ |
| 238 | } else { |
| 239 | return(-1); |
| 240 | } |
| 241 | |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 242 | while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) { |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 243 | if (!WebRtcIlbcfix_DecodeImpl( |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 244 | &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], |
pbos@webrtc.org | e728ee0 | 2014-12-17 13:43:55 +0000 | [diff] [blame] | 245 | (const uint16_t*)&encoded |
jmarusic@webrtc.org | 71b35a4 | 2015-02-17 16:02:18 +0000 | [diff] [blame] | 246 | [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words], |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 247 | (IlbcDecoder*)iLBCdec_inst, 1)) |
| 248 | return -1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 249 | i++; |
| 250 | } |
| 251 | /* iLBC does not support VAD/CNG yet */ |
| 252 | *speechType=1; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 253 | return (int)(i*((IlbcDecoder*)iLBCdec_inst)->blockl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 256 | size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst, |
| 257 | int16_t* decoded, |
| 258 | size_t noOfLostFrames) { |
| 259 | size_t i; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 260 | uint16_t dummy; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 261 | |
| 262 | for (i=0;i<noOfLostFrames;i++) { |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 263 | // PLC decoding shouldn't fail, because there is no external input data |
| 264 | // that can be bad. |
| 265 | RTC_CHECK(WebRtcIlbcfix_DecodeImpl( |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 266 | &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy, |
kwiberg | 619a211 | 2016-08-24 02:46:44 -0700 | [diff] [blame] | 267 | (IlbcDecoder*)iLBCdec_inst, 0)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 268 | } |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 269 | return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 272 | size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst, |
| 273 | int16_t* decoded, |
| 274 | size_t noOfLostFrames) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 275 | /* Two input parameters not used, but needed for function pointers in NetEQ */ |
andrew@webrtc.org | 9562a36 | 2011-08-31 18:50:12 +0000 | [diff] [blame] | 276 | (void)(decoded = NULL); |
| 277 | (void)(noOfLostFrames = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 278 | |
pbos@webrtc.org | eb54446 | 2014-12-17 15:23:29 +0000 | [diff] [blame] | 279 | WebRtcSpl_MemSetW16(((IlbcDecoder*)iLBCdec_inst)->enh_buf, 0, ENH_BUFL); |
| 280 | ((IlbcDecoder*)iLBCdec_inst)->prev_enh_pl = 2; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | |
| 282 | return (0); |
| 283 | } |
| 284 | |
leozwang@webrtc.org | 91b359e | 2012-02-28 17:26:14 +0000 | [diff] [blame] | 285 | void WebRtcIlbcfix_version(char *version) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | { |
tina.legrand@webrtc.org | a41b4ce | 2011-08-29 08:19:30 +0000 | [diff] [blame] | 287 | strcpy((char*)version, "1.1.1"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 288 | } |