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 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 for (i = 0; i < aec->num_bands - 1; ++i) { | 1360 for (i = 0; i < aec->num_bands - 1; ++i) { |
1361 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); | 1361 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); |
1362 } | 1362 } |
1363 | 1363 |
1364 #ifdef WEBRTC_AEC_DEBUG_DUMP | 1364 #ifdef WEBRTC_AEC_DEBUG_DUMP |
1365 rtc_WavWriteSamples(aec->outLinearFile, e, PART_LEN); | 1365 rtc_WavWriteSamples(aec->outLinearFile, e, PART_LEN); |
1366 rtc_WavWriteSamples(aec->outFile, output, PART_LEN); | 1366 rtc_WavWriteSamples(aec->outFile, output, PART_LEN); |
1367 #endif | 1367 #endif |
1368 } | 1368 } |
1369 | 1369 |
1370 int WebRtcAec_CreateAec(AecCore** aecInst) { | 1370 AecCore* WebRtcAec_CreateAec() { |
1371 int i; | 1371 int i; |
1372 AecCore* aec = malloc(sizeof(AecCore)); | 1372 AecCore* aec = malloc(sizeof(AecCore)); |
1373 *aecInst = aec; | 1373 if (!aec) { |
1374 if (aec == NULL) { | 1374 return NULL; |
1375 return -1; | |
1376 } | 1375 } |
1377 | 1376 |
1378 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); | 1377 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); |
1379 if (!aec->nearFrBuf) { | 1378 if (!aec->nearFrBuf) { |
1380 WebRtcAec_FreeAec(aec); | 1379 WebRtcAec_FreeAec(aec); |
1381 aec = NULL; | 1380 return NULL; |
1382 return -1; | |
1383 } | 1381 } |
1384 | 1382 |
1385 aec->outFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); | 1383 aec->outFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); |
1386 if (!aec->outFrBuf) { | 1384 if (!aec->outFrBuf) { |
1387 WebRtcAec_FreeAec(aec); | 1385 WebRtcAec_FreeAec(aec); |
1388 aec = NULL; | 1386 return NULL; |
1389 return -1; | |
1390 } | 1387 } |
1391 | 1388 |
1392 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1389 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
1393 aec->nearFrBufH[i] = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, | 1390 aec->nearFrBufH[i] = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, |
1394 sizeof(float)); | 1391 sizeof(float)); |
1395 if (!aec->nearFrBufH[i]) { | 1392 if (!aec->nearFrBufH[i]) { |
1396 WebRtcAec_FreeAec(aec); | 1393 WebRtcAec_FreeAec(aec); |
1397 aec = NULL; | 1394 return NULL; |
1398 return -1; | |
1399 } | 1395 } |
1400 aec->outFrBufH[i] = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, | 1396 aec->outFrBufH[i] = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, |
1401 sizeof(float)); | 1397 sizeof(float)); |
1402 if (!aec->outFrBufH[i]) { | 1398 if (!aec->outFrBufH[i]) { |
1403 WebRtcAec_FreeAec(aec); | 1399 WebRtcAec_FreeAec(aec); |
1404 aec = NULL; | 1400 return NULL; |
1405 return -1; | |
1406 } | 1401 } |
1407 } | 1402 } |
1408 | 1403 |
1409 // Create far-end buffers. | 1404 // Create far-end buffers. |
1410 aec->far_buf = | 1405 aec->far_buf = |
1411 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * 2 * PART_LEN1); | 1406 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * 2 * PART_LEN1); |
1412 if (!aec->far_buf) { | 1407 if (!aec->far_buf) { |
1413 WebRtcAec_FreeAec(aec); | 1408 WebRtcAec_FreeAec(aec); |
1414 aec = NULL; | 1409 return NULL; |
1415 return -1; | |
1416 } | 1410 } |
1417 aec->far_buf_windowed = | 1411 aec->far_buf_windowed = |
1418 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * 2 * PART_LEN1); | 1412 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * 2 * PART_LEN1); |
1419 if (!aec->far_buf_windowed) { | 1413 if (!aec->far_buf_windowed) { |
1420 WebRtcAec_FreeAec(aec); | 1414 WebRtcAec_FreeAec(aec); |
1421 aec = NULL; | 1415 return NULL; |
1422 return -1; | |
1423 } | 1416 } |
1424 #ifdef WEBRTC_AEC_DEBUG_DUMP | 1417 #ifdef WEBRTC_AEC_DEBUG_DUMP |
1425 aec->instance_index = webrtc_aec_instance_count; | 1418 aec->instance_index = webrtc_aec_instance_count; |
1426 aec->far_time_buf = | 1419 aec->far_time_buf = |
1427 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN); | 1420 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN); |
1428 if (!aec->far_time_buf) { | 1421 if (!aec->far_time_buf) { |
1429 WebRtcAec_FreeAec(aec); | 1422 WebRtcAec_FreeAec(aec); |
1430 aec = NULL; | 1423 return NULL; |
1431 return -1; | |
1432 } | 1424 } |
1433 aec->farFile = aec->nearFile = aec->outFile = aec->outLinearFile = NULL; | 1425 aec->farFile = aec->nearFile = aec->outFile = aec->outLinearFile = NULL; |
1434 aec->debug_dump_count = 0; | 1426 aec->debug_dump_count = 0; |
1435 #endif | 1427 #endif |
1436 aec->delay_estimator_farend = | 1428 aec->delay_estimator_farend = |
1437 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); | 1429 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); |
1438 if (aec->delay_estimator_farend == NULL) { | 1430 if (aec->delay_estimator_farend == NULL) { |
1439 WebRtcAec_FreeAec(aec); | 1431 WebRtcAec_FreeAec(aec); |
1440 aec = NULL; | 1432 return NULL; |
1441 return -1; | |
1442 } | 1433 } |
1443 // We create the delay_estimator with the same amount of maximum lookahead as | 1434 // We create the delay_estimator with the same amount of maximum lookahead as |
1444 // the delay history size (kHistorySizeBlocks) for symmetry reasons. | 1435 // the delay history size (kHistorySizeBlocks) for symmetry reasons. |
1445 aec->delay_estimator = WebRtc_CreateDelayEstimator( | 1436 aec->delay_estimator = WebRtc_CreateDelayEstimator( |
1446 aec->delay_estimator_farend, kHistorySizeBlocks); | 1437 aec->delay_estimator_farend, kHistorySizeBlocks); |
1447 if (aec->delay_estimator == NULL) { | 1438 if (aec->delay_estimator == NULL) { |
1448 WebRtcAec_FreeAec(aec); | 1439 WebRtcAec_FreeAec(aec); |
1449 aec = NULL; | 1440 return NULL; |
1450 return -1; | |
1451 } | 1441 } |
1452 #ifdef WEBRTC_ANDROID | 1442 #ifdef WEBRTC_ANDROID |
1453 // DA-AEC assumes the system is causal from the beginning and will self adjust | 1443 // DA-AEC assumes the system is causal from the beginning and will self adjust |
1454 // the lookahead when shifting is required. | 1444 // the lookahead when shifting is required. |
1455 WebRtc_set_lookahead(aec->delay_estimator, 0); | 1445 WebRtc_set_lookahead(aec->delay_estimator, 0); |
1456 #else | 1446 #else |
1457 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); | 1447 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); |
1458 #endif | 1448 #endif |
1459 | 1449 |
1460 // Assembly optimization | 1450 // Assembly optimization |
(...skipping 17 matching lines...) Expand all Loading... |
1478 #if defined(WEBRTC_HAS_NEON) | 1468 #if defined(WEBRTC_HAS_NEON) |
1479 WebRtcAec_InitAec_neon(); | 1469 WebRtcAec_InitAec_neon(); |
1480 #elif defined(WEBRTC_DETECT_NEON) | 1470 #elif defined(WEBRTC_DETECT_NEON) |
1481 if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) { | 1471 if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) { |
1482 WebRtcAec_InitAec_neon(); | 1472 WebRtcAec_InitAec_neon(); |
1483 } | 1473 } |
1484 #endif | 1474 #endif |
1485 | 1475 |
1486 aec_rdft_init(); | 1476 aec_rdft_init(); |
1487 | 1477 |
1488 return 0; | 1478 return aec; |
1489 } | 1479 } |
1490 | 1480 |
1491 void WebRtcAec_FreeAec(AecCore* aec) { | 1481 void WebRtcAec_FreeAec(AecCore* aec) { |
1492 int i; | 1482 int i; |
1493 if (aec == NULL) { | 1483 if (aec == NULL) { |
1494 return; | 1484 return; |
1495 } | 1485 } |
1496 | 1486 |
1497 WebRtc_FreeBuffer(aec->nearFrBuf); | 1487 WebRtc_FreeBuffer(aec->nearFrBuf); |
1498 WebRtc_FreeBuffer(aec->outFrBuf); | 1488 WebRtc_FreeBuffer(aec->outFrBuf); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 1934 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
1945 return self->extended_filter_enabled; | 1935 return self->extended_filter_enabled; |
1946 } | 1936 } |
1947 | 1937 |
1948 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } | 1938 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } |
1949 | 1939 |
1950 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1940 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1951 assert(delay >= 0); | 1941 assert(delay >= 0); |
1952 self->system_delay = delay; | 1942 self->system_delay = delay; |
1953 } | 1943 } |
OLD | NEW |