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 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 opus_decoder_ctl(inst->decoder, OPUS_RESET_STATE); | 276 opus_decoder_ctl(inst->decoder, OPUS_RESET_STATE); |
277 inst->in_dtx_mode = 0; | 277 inst->in_dtx_mode = 0; |
278 } | 278 } |
279 | 279 |
280 /* For decoder to determine if it is to output speech or comfort noise. */ | 280 /* For decoder to determine if it is to output speech or comfort noise. */ |
281 static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) { | 281 static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) { |
282 // Audio type becomes comfort noise if |encoded_byte| is 1 and keeps | 282 // Audio type becomes comfort noise if |encoded_byte| is 1 and keeps |
283 // to be so if the following |encoded_byte| are 0 or 1. | 283 // to be so if the following |encoded_byte| are 0 or 1. |
284 if (encoded_bytes == 0 && inst->in_dtx_mode) { | 284 if (encoded_bytes == 0 && inst->in_dtx_mode) { |
285 return 2; // Comfort noise. | 285 return 2; // Comfort noise. |
286 } else if (encoded_bytes == 1) { | 286 } else if (encoded_bytes == 1 || encoded_bytes == 2) { |
| 287 // TODO(henrik.lundin): There is a slight risk that a 2-byte payload is in |
| 288 // fact a 1-byte TOC with a 1-byte payload. That will be erroneously |
| 289 // interpreted as comfort noise output, but such a payload is probably |
| 290 // faulty anyway. |
287 inst->in_dtx_mode = 1; | 291 inst->in_dtx_mode = 1; |
288 return 2; // Comfort noise. | 292 return 2; // Comfort noise. |
289 } else { | 293 } else { |
290 inst->in_dtx_mode = 0; | 294 inst->in_dtx_mode = 0; |
291 return 0; // Speech. | 295 return 0; // Speech. |
292 } | 296 } |
293 } | 297 } |
294 | 298 |
295 /* |frame_size| is set to maximum Opus frame size in the normal case, and | 299 /* |frame_size| is set to maximum Opus frame size in the normal case, and |
296 * is set to the number of samples needed for PLC in case of losses. | 300 * is set to the number of samples needed for PLC in case of losses. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 return 0; | 478 return 0; |
475 } | 479 } |
476 | 480 |
477 for (n = 0; n < channels; n++) { | 481 for (n = 0; n < channels; n++) { |
478 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 482 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
479 return 1; | 483 return 1; |
480 } | 484 } |
481 | 485 |
482 return 0; | 486 return 0; |
483 } | 487 } |
OLD | NEW |