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