OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" | 11 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" |
12 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" | 12 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" |
13 | 13 |
14 #include <assert.h> | |
hlundin-webrtc
2015/08/26 13:07:23
Why? You're not adding any asserts and I couldn't
kwiberg-webrtc
2015/08/26 18:54:37
No. There was probably some intermediate state whe
| |
14 #include <stdlib.h> | 15 #include <stdlib.h> |
15 #include <string.h> | 16 #include <string.h> |
16 | 17 |
17 enum { | 18 enum { |
18 /* Maximum supported frame size in WebRTC is 60 ms. */ | 19 /* Maximum supported frame size in WebRTC is 60 ms. */ |
19 kWebRtcOpusMaxEncodeFrameSizeMs = 60, | 20 kWebRtcOpusMaxEncodeFrameSizeMs = 60, |
20 | 21 |
21 /* The format allows up to 120 ms frames. Since we don't control the other | 22 /* The format allows up to 120 ms frames. Since we don't control the other |
22 * side, we must allow for packets of that size. NetEq is currently limited | 23 * side, we must allow for packets of that size. NetEq is currently limited |
23 * to 60 ms on the receive side. */ | 24 * to 60 ms on the receive side. */ |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 return 0; | 244 return 0; |
244 } else { | 245 } else { |
245 return -1; | 246 return -1; |
246 } | 247 } |
247 } | 248 } |
248 | 249 |
249 int WebRtcOpus_DecoderChannels(OpusDecInst* inst) { | 250 int WebRtcOpus_DecoderChannels(OpusDecInst* inst) { |
250 return inst->channels; | 251 return inst->channels; |
251 } | 252 } |
252 | 253 |
253 int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst) { | 254 void WebRtcOpus_DecoderInit(OpusDecInst* inst) { |
254 int error = opus_decoder_ctl(inst->decoder, OPUS_RESET_STATE); | 255 opus_decoder_ctl(inst->decoder, OPUS_RESET_STATE); |
255 if (error == OPUS_OK) { | 256 inst->in_dtx_mode = 0; |
256 inst->in_dtx_mode = 0; | |
257 return 0; | |
258 } | |
259 return -1; | |
260 } | 257 } |
261 | 258 |
262 /* For decoder to determine if it is to output speech or comfort noise. */ | 259 /* For decoder to determine if it is to output speech or comfort noise. */ |
263 static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) { | 260 static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) { |
264 // Audio type becomes comfort noise if |encoded_byte| is 1 and keeps | 261 // Audio type becomes comfort noise if |encoded_byte| is 1 and keeps |
265 // to be so if the following |encoded_byte| are 0 or 1. | 262 // to be so if the following |encoded_byte| are 0 or 1. |
266 if (encoded_bytes == 0 && inst->in_dtx_mode) { | 263 if (encoded_bytes == 0 && inst->in_dtx_mode) { |
267 return 2; // Comfort noise. | 264 return 2; // Comfort noise. |
268 } else if (encoded_bytes == 1) { | 265 } else if (encoded_bytes == 1) { |
269 inst->in_dtx_mode = 1; | 266 inst->in_dtx_mode = 1; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 return 0; | 438 return 0; |
442 } | 439 } |
443 | 440 |
444 for (n = 0; n < channels; n++) { | 441 for (n = 0; n < channels; n++) { |
445 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 442 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
446 return 1; | 443 return 1; |
447 } | 444 } |
448 | 445 |
449 return 0; | 446 return 0; |
450 } | 447 } |
OLD | NEW |