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