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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 CHECK_NOT_NULL(in_file); | 447 CHECK_NOT_NULL(in_file); |
| 448 printf("Input file: %s\n", argv[1]); | 448 printf("Input file: %s\n", argv[1]); |
| 449 FILE* out_file = fopen(argv[2], "wb"); | 449 FILE* out_file = fopen(argv[2], "wb"); |
| 450 CHECK_NOT_NULL(out_file); | 450 CHECK_NOT_NULL(out_file); |
| 451 printf("Output file: %s\n\n", argv[2]); | 451 printf("Output file: %s\n\n", argv[2]); |
| 452 packet_size = atoi(argv[3]); | 452 packet_size = atoi(argv[3]); |
| 453 if (packet_size <= 0) { | 453 if (packet_size <= 0) { |
| 454 printf("Packet size %d must be positive", packet_size); | 454 printf("Packet size %d must be positive", packet_size); |
| 455 return -1; | 455 return -1; |
| 456 } | 456 } |
| 457 printf("Packet size: %i\n", packet_size); | 457 printf("Packet size: %d\n", packet_size); |
| 458 | 458 |
| 459 // check for stereo | 459 // check for stereo |
| 460 if (argv[4][strlen(argv[4]) - 1] == '*') { | 460 if (argv[4][strlen(argv[4]) - 1] == '*') { |
| 461 // use stereo | 461 // use stereo |
| 462 usingStereo = true; | 462 usingStereo = true; |
| 463 numChannels = 2; | 463 numChannels = 2; |
| 464 argv[4][strlen(argv[4]) - 1] = '\0'; | 464 argv[4][strlen(argv[4]) - 1] = '\0'; |
| 465 } | 465 } |
| 466 | 466 |
| 467 NetEQTest_GetCodec_and_PT(argv[4], &usedCodec, &payloadType, packet_size, &fs, | 467 NetEQTest_GetCodec_and_PT(argv[4], &usedCodec, &payloadType, packet_size, &fs, |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1565 int16_t* tempdata; | 1565 int16_t* tempdata; |
| 1566 static int first_cng = 1; | 1566 static int first_cng = 1; |
| 1567 int16_t tempLen; | 1567 int16_t tempLen; |
| 1568 | 1568 |
| 1569 *vad = 1; | 1569 *vad = 1; |
| 1570 | 1570 |
| 1571 // check VAD first | 1571 // check VAD first |
| 1572 if (useVAD) { | 1572 if (useVAD) { |
| 1573 *vad = 0; | 1573 *vad = 0; |
| 1574 | 1574 |
| 1575 int sampleRate_10 = 10 * sampleRate / 1000; | |
| 1576 int sampleRate_20 = 20 * sampleRate / 1000; | |
| 1577 int sampleRate_30 = 30 * sampleRate / 1000; | |
| 1575 for (int k = 0; k < numChannels; k++) { | 1578 for (int k = 0; k < numChannels; k++) { |
| 1576 tempLen = frameLen; | 1579 tempLen = frameLen; |
| 1577 tempdata = &indata[k * frameLen]; | 1580 tempdata = &indata[k * frameLen]; |
| 1578 int localVad = 0; | 1581 int localVad = 0; |
| 1579 /* Partition the signal and test each chunk for VAD. | 1582 /* Partition the signal and test each chunk for VAD. |
| 1580 All chunks must be VAD=0 to produce a total VAD=0. */ | 1583 All chunks must be VAD=0 to produce a total VAD=0. */ |
| 1581 while (tempLen >= 10 * sampleRate / 1000) { | 1584 while (tempLen >= sampleRate_10) { |
| 1582 if ((tempLen % 30 * sampleRate / 1000) == | 1585 if ((tempLen % sampleRate_30) == 0) { // tempLen is multiple of 30ms |
|
kwiberg-webrtc
2015/07/12 18:40:30
I don't think this means the same thing as the old
Peter Kasting
2015/07/13 02:41:24
Yes. Which suggests the test is insufficient, sin
Peter Kasting
2015/07/13 22:25:04
It looks to me as if the behavior of this code wil
kwiberg-webrtc
2015/07/15 01:10:53
OK. As long as it doesn't break the test, it can h
| |
| 1583 0) { // tempLen is multiple of 30ms | |
| 1584 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, | 1586 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, |
| 1585 30 * sampleRate / 1000); | 1587 sampleRate_30); |
| 1586 tempdata += 30 * sampleRate / 1000; | 1588 tempdata += sampleRate_30; |
| 1587 tempLen -= 30 * sampleRate / 1000; | 1589 tempLen -= sampleRate_30; |
| 1588 } else if (tempLen >= 20 * sampleRate / 1000) { // tempLen >= 20ms | 1590 } else if (tempLen >= sampleRate_20) { // tempLen >= 20ms |
| 1589 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, | 1591 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, |
| 1590 20 * sampleRate / 1000); | 1592 sampleRate_20); |
| 1591 tempdata += 20 * sampleRate / 1000; | 1593 tempdata += sampleRate_20; |
| 1592 tempLen -= 20 * sampleRate / 1000; | 1594 tempLen -= sampleRate_20; |
| 1593 } else { // use 10ms | 1595 } else { // use 10ms |
| 1594 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, | 1596 localVad |= WebRtcVad_Process(VAD_inst[k], sampleRate, tempdata, |
| 1595 10 * sampleRate / 1000); | 1597 sampleRate_10); |
| 1596 tempdata += 10 * sampleRate / 1000; | 1598 tempdata += sampleRate_10; |
| 1597 tempLen -= 10 * sampleRate / 1000; | 1599 tempLen -= sampleRate_10; |
| 1598 } | 1600 } |
| 1599 } | 1601 } |
| 1600 | 1602 |
| 1601 // aggregate all VAD decisions over all channels | 1603 // aggregate all VAD decisions over all channels |
| 1602 *vad |= localVad; | 1604 *vad |= localVad; |
| 1603 } | 1605 } |
| 1604 | 1606 |
| 1605 if (!*vad) { | 1607 if (!*vad) { |
| 1606 // all channels are silent | 1608 // all channels are silent |
| 1607 cdlen = 0; | 1609 cdlen = 0; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1832 memmove(ptrL + stride, ptrL, ptrR - ptrL); | 1834 memmove(ptrL + stride, ptrL, ptrR - ptrL); |
| 1833 | 1835 |
| 1834 // copy from temp to left pointer | 1836 // copy from temp to left pointer |
| 1835 memcpy(ptrL, temp, stride); | 1837 memcpy(ptrL, temp, stride); |
| 1836 | 1838 |
| 1837 // advance pointers | 1839 // advance pointers |
| 1838 ptrL += stride * 2; | 1840 ptrL += stride * 2; |
| 1839 ptrR += stride; | 1841 ptrR += stride; |
| 1840 } | 1842 } |
| 1841 } | 1843 } |
| OLD | NEW |