Chromium Code Reviews| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 if (decoded_samples < 0) { | 352 if (decoded_samples < 0) { |
| 353 return -1; | 353 return -1; |
| 354 } | 354 } |
| 355 | 355 |
| 356 return decoded_samples; | 356 return decoded_samples; |
| 357 } | 357 } |
| 358 | 358 |
| 359 int WebRtcOpus_DurationEst(OpusDecInst* inst, | 359 int WebRtcOpus_DurationEst(OpusDecInst* inst, |
| 360 const uint8_t* payload, | 360 const uint8_t* payload, |
| 361 size_t payload_length_bytes) { | 361 size_t payload_length_bytes) { |
| 362 if (payload_length_bytes == 0) { | |
| 363 // WebRtcOpus_Decode calls PLC when payload length is zero. So we returns | |
|
hlundin-webrtc
2015/09/15 13:05:09
we returns -> we return
| |
| 364 // PLC duration correspondingly. | |
| 365 return WebRtcOpus_PlcDuration(inst); | |
| 366 } | |
| 367 | |
| 362 int frames, samples; | 368 int frames, samples; |
| 363 frames = opus_packet_get_nb_frames(payload, (opus_int32)payload_length_bytes); | 369 frames = opus_packet_get_nb_frames(payload, (opus_int32)payload_length_bytes); |
| 364 if (frames < 0) { | 370 if (frames < 0) { |
| 365 /* Invalid payload data. */ | 371 /* Invalid payload data. */ |
| 366 return 0; | 372 return 0; |
| 367 } | 373 } |
| 368 samples = frames * opus_packet_get_samples_per_frame(payload, 48000); | 374 samples = frames * opus_packet_get_samples_per_frame(payload, 48000); |
| 369 if (samples < 120 || samples > 5760) { | 375 if (samples < 120 || samples > 5760) { |
| 370 /* Invalid payload duration. */ | 376 /* Invalid payload duration. */ |
| 371 return 0; | 377 return 0; |
| 372 } | 378 } |
| 373 return samples; | 379 return samples; |
| 374 } | 380 } |
| 375 | 381 |
| 382 int WebRtcOpus_PlcDuration(OpusDecInst* inst) { | |
| 383 /* The number of samples we ask for is |number_of_lost_frames| times | |
| 384 * |prev_decoded_samples_|. Limit the number of samples to maximum | |
| 385 * |kWebRtcOpusMaxFrameSizePerChannel|. */ | |
| 386 int plc_samples; | |
|
hlundin-webrtc
2015/09/15 13:05:09
Merge lines 386 and 387, and make it const.
minyue-webrtc
2015/09/16 08:05:31
Done.
| |
| 387 plc_samples = inst->prev_decoded_samples; | |
| 388 plc_samples = (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel) ? | |
| 389 plc_samples : kWebRtcOpusMaxFrameSizePerChannel; | |
| 390 return plc_samples; | |
|
hlundin-webrtc
2015/09/15 13:05:09
return (plc_samples <= kWebRtcOpusMaxFrameSizePerC
minyue-webrtc
2015/09/16 08:05:31
Done.
| |
| 391 } | |
| 392 | |
| 393 | |
|
hlundin-webrtc
2015/09/15 13:05:09
Remove one extra line.
minyue-webrtc
2015/09/16 08:05:31
Done.
| |
| 376 int WebRtcOpus_FecDurationEst(const uint8_t* payload, | 394 int WebRtcOpus_FecDurationEst(const uint8_t* payload, |
| 377 size_t payload_length_bytes) { | 395 size_t payload_length_bytes) { |
| 378 int samples; | 396 int samples; |
| 379 if (WebRtcOpus_PacketHasFec(payload, payload_length_bytes) != 1) { | 397 if (WebRtcOpus_PacketHasFec(payload, payload_length_bytes) != 1) { |
| 380 return 0; | 398 return 0; |
| 381 } | 399 } |
| 382 | 400 |
| 383 samples = opus_packet_get_samples_per_frame(payload, 48000); | 401 samples = opus_packet_get_samples_per_frame(payload, 48000); |
| 384 if (samples < 480 || samples > 5760) { | 402 if (samples < 480 || samples > 5760) { |
| 385 /* Invalid payload duration. */ | 403 /* Invalid payload duration. */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 return 0; | 455 return 0; |
| 438 } | 456 } |
| 439 | 457 |
| 440 for (n = 0; n < channels; n++) { | 458 for (n = 0; n < channels; n++) { |
| 441 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 459 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
| 442 return 1; | 460 return 1; |
| 443 } | 461 } |
| 444 | 462 |
| 445 return 0; | 463 return 0; |
| 446 } | 464 } |
| OLD | NEW |