2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-06-01 17:46:21 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* kenny.c - Main function for the iSAC coder */
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include "windows.h"
|
2016-01-30 14:40:44 -08:00
|
|
|
#ifndef CLOCKS_PER_SEC
|
2015-06-03 12:32:41 -07:00
|
|
|
#define CLOCKS_PER_SEC 1000
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
2016-01-30 14:40:44 -08:00
|
|
|
#endif
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
/* include API */
|
2018-02-01 14:12:55 +01:00
|
|
|
#include "modules/audio_coding/codecs/isac/main/include/isac.h"
|
|
|
|
|
#include "modules/audio_coding/codecs/isac/main/util/utility.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/format_macros.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* max number of samples per frame (= 60 ms frame) */
|
2015-06-03 12:32:41 -07:00
|
|
|
#define MAX_FRAMESAMPLES_SWB 1920
|
2011-07-07 08:21:25 +00:00
|
|
|
/* number of samples per 10ms frame */
|
2015-06-03 12:32:41 -07:00
|
|
|
#define FRAMESAMPLES_SWB_10ms 320
|
|
|
|
|
#define FRAMESAMPLES_WB_10ms 160
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* sampling frequency (Hz) */
|
2015-06-03 12:32:41 -07:00
|
|
|
#define FS_SWB 32000
|
|
|
|
|
#define FS_WB 16000
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
unsigned long framecnt = 0;
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
//--- File IO ----
|
|
|
|
|
FILE* inp;
|
|
|
|
|
FILE* outp;
|
|
|
|
|
char inname[500];
|
|
|
|
|
char outname[500];
|
|
|
|
|
|
|
|
|
|
/* Runtime statistics */
|
|
|
|
|
double rate;
|
|
|
|
|
double rateRCU;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t totalbits = 0;
|
2015-06-03 12:32:41 -07:00
|
|
|
unsigned long totalBitsRCU = 0;
|
|
|
|
|
unsigned long totalsmpls = 0;
|
|
|
|
|
|
|
|
|
|
int32_t bottleneck = 39;
|
Reland "Upconvert various types to int.", isac portion.
This reverts portions of commit cb180976dd0e9672cde4523d87b5f4857478b5e9, which
reverted commit 83ad33a8aed1fb00e422b6abd33c3e8942821c24. Specifically, the
files in webrtc/modules/audio_coding/codecs/isac/ are relanded.
The original commit message is below:
Upconvert various types to int.
Per comments from HL/kwiberg on https://webrtc-codereview.appspot.com/42569004 , when there is existing usage of mixed types (int16_t, int, etc.), we'd prefer to standardize on larger types like int and phase out use of int16_t.
Specifically, "Using int16 just because we're sure all reasonable values will fit in 16 bits isn't usually meaningful in C."
This converts some existing uses of int16_t (and, in a few cases, other types such as uint16_t) to int (or, in a few places, int32_t). Other locations will be converted to size_t in a separate change.
BUG=none
TBR=kwiberg
Review URL: https://codereview.webrtc.org/1179093002
Cr-Commit-Position: refs/heads/master@{#9422}
2015-06-11 18:19:24 -07:00
|
|
|
int frameSize = 30; /* ms */
|
2015-06-03 12:32:41 -07:00
|
|
|
int16_t codingMode = 1;
|
|
|
|
|
int16_t shortdata[FRAMESAMPLES_SWB_10ms];
|
|
|
|
|
int16_t decoded[MAX_FRAMESAMPLES_SWB];
|
|
|
|
|
int16_t speechType[1];
|
|
|
|
|
int16_t payloadLimit;
|
|
|
|
|
int32_t rateLimit;
|
|
|
|
|
ISACStruct* ISAC_main_inst;
|
|
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t stream_len = 0;
|
Reland "Upconvert various types to int.", isac portion.
This reverts portions of commit cb180976dd0e9672cde4523d87b5f4857478b5e9, which
reverted commit 83ad33a8aed1fb00e422b6abd33c3e8942821c24. Specifically, the
files in webrtc/modules/audio_coding/codecs/isac/ are relanded.
The original commit message is below:
Upconvert various types to int.
Per comments from HL/kwiberg on https://webrtc-codereview.appspot.com/42569004 , when there is existing usage of mixed types (int16_t, int, etc.), we'd prefer to standardize on larger types like int and phase out use of int16_t.
Specifically, "Using int16 just because we're sure all reasonable values will fit in 16 bits isn't usually meaningful in C."
This converts some existing uses of int16_t (and, in a few cases, other types such as uint16_t) to int (or, in a few places, int32_t). Other locations will be converted to size_t in a separate change.
BUG=none
TBR=kwiberg
Review URL: https://codereview.webrtc.org/1179093002
Cr-Commit-Position: refs/heads/master@{#9422}
2015-06-11 18:19:24 -07:00
|
|
|
int declen = 0;
|
2015-06-03 12:32:41 -07:00
|
|
|
int16_t err;
|
Reland "Upconvert various types to int.", isac portion.
This reverts portions of commit cb180976dd0e9672cde4523d87b5f4857478b5e9, which
reverted commit 83ad33a8aed1fb00e422b6abd33c3e8942821c24. Specifically, the
files in webrtc/modules/audio_coding/codecs/isac/ are relanded.
The original commit message is below:
Upconvert various types to int.
Per comments from HL/kwiberg on https://webrtc-codereview.appspot.com/42569004 , when there is existing usage of mixed types (int16_t, int, etc.), we'd prefer to standardize on larger types like int and phase out use of int16_t.
Specifically, "Using int16 just because we're sure all reasonable values will fit in 16 bits isn't usually meaningful in C."
This converts some existing uses of int16_t (and, in a few cases, other types such as uint16_t) to int (or, in a few places, int32_t). Other locations will be converted to size_t in a separate change.
BUG=none
TBR=kwiberg
Review URL: https://codereview.webrtc.org/1179093002
Cr-Commit-Position: refs/heads/master@{#9422}
2015-06-11 18:19:24 -07:00
|
|
|
int cur_framesmpls;
|
2015-06-03 12:32:41 -07:00
|
|
|
int endfile;
|
2011-09-23 15:45:48 +00:00
|
|
|
#ifdef WIN32
|
2015-06-03 12:32:41 -07:00
|
|
|
double length_file;
|
|
|
|
|
double runtime;
|
|
|
|
|
char outDrive[10];
|
|
|
|
|
char outPath[500];
|
|
|
|
|
char outPrefix[500];
|
|
|
|
|
char outSuffix[500];
|
|
|
|
|
char bitrateFileName[500];
|
|
|
|
|
FILE* bitrateFile;
|
|
|
|
|
double starttime;
|
|
|
|
|
double rateLB = 0;
|
|
|
|
|
double rateUB = 0;
|
2011-09-23 15:45:48 +00:00
|
|
|
#endif
|
2015-06-03 12:32:41 -07:00
|
|
|
FILE* histFile;
|
|
|
|
|
FILE* averageFile;
|
|
|
|
|
int sampFreqKHz;
|
|
|
|
|
int samplesIn10Ms;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t maxStreamLen = 0;
|
2015-06-03 12:32:41 -07:00
|
|
|
char histFileName[500];
|
|
|
|
|
char averageFileName[500];
|
|
|
|
|
unsigned int hist[600];
|
Match existing type usage better.
This makes a variety of small changes to synchronize bits of code using different types, remove useless code or casts, and add explicit casts in some places previously doing implicit ones. For example:
* Change a few type declarations to better match how the majority of code uses those objects.
* Eliminate "< 0" check for unsigned values.
* Replace "(float)sin(x)", where |x| is also a float, with "sinf(x)", and similar.
* Add casts to uint32_t in many places timestamps were used and the existing code stored signed values into the unsigned objects.
* Remove downcasts when the results would be passed to a larger type, e.g. calling "foo((int16_t)x)" with an int |x| when foo() takes an int instead of an int16_t.
* Similarly, add casts when passing a larger type to a function taking a smaller one.
* Add casts to int16_t when doing something like "int16_t = int16_t + int16_t" as the "+" operation would implicitly upconvert to int, and similar.
* Use "false" instead of "0" for setting a bool.
* Shift a few temp types when doing a multi-stage calculation involving typecasts, so as to put the most logical/semantically correct type possible into the temps. For example, when doing "int foo = int + int; size_t bar = (size_t)foo + size_t;", we might change |foo| to a size_t and move the cast if it makes more sense for |foo| to be represented as a size_t.
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=andrew, asapersson, henrika
Review URL: https://codereview.webrtc.org/1168753002
Cr-Commit-Position: refs/heads/master@{#9419}
2015-06-11 12:55:50 -07:00
|
|
|
double tmpSumStreamLen = 0;
|
2015-06-03 12:32:41 -07:00
|
|
|
unsigned int packetCntr = 0;
|
|
|
|
|
unsigned int lostPacketCntr = 0;
|
|
|
|
|
uint8_t payload[1200];
|
|
|
|
|
uint8_t payloadRCU[1200];
|
|
|
|
|
uint16_t packetLossPercent = 0;
|
|
|
|
|
int16_t rcuStreamLen = 0;
|
|
|
|
|
int onlyEncode;
|
|
|
|
|
int onlyDecode;
|
|
|
|
|
|
|
|
|
|
BottleNeckModel packetData;
|
|
|
|
|
packetData.arrival_time = 0;
|
|
|
|
|
packetData.sample_count = 0;
|
|
|
|
|
packetData.rtp_number = 0;
|
|
|
|
|
memset(hist, 0, sizeof(hist));
|
|
|
|
|
|
|
|
|
|
/* handling wrong input arguments in the command line */
|
|
|
|
|
if (argc < 5) {
|
|
|
|
|
printf("\n\nWrong number of arguments or flag values.\n\n");
|
|
|
|
|
|
|
|
|
|
printf("Usage:\n\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("%s infile outfile -bn bottleneck [options]\n\n", argv[0]);
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("with:\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("-I.............. indicates encoding in instantaneous mode.\n");
|
|
|
|
|
printf("-bn bottleneck.. the value of the bottleneck in bit/sec, e.g.\n");
|
|
|
|
|
printf(" 39742, in instantaneous (channel-independent)\n");
|
|
|
|
|
printf(" mode.\n\n");
|
|
|
|
|
printf("infile.......... Normal speech input file\n\n");
|
|
|
|
|
printf("outfile......... Speech output file\n\n");
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("OPTIONS\n");
|
|
|
|
|
printf("-------\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("-fs sampFreq.... sampling frequency of codec 16 or 32 (default)\n");
|
|
|
|
|
printf(" kHz.\n");
|
|
|
|
|
printf("-plim payloadLim payload limit in bytes, default is the maximum\n");
|
|
|
|
|
printf(" possible.\n");
|
|
|
|
|
printf("-rlim rateLim... rate limit in bits/sec, default is the maximum\n");
|
|
|
|
|
printf(" possible.\n");
|
|
|
|
|
printf("-h file......... record histogram and *append* to 'file'.\n");
|
|
|
|
|
printf("-ave file....... record average rate of 3 sec intervales and\n");
|
|
|
|
|
printf(" *append* to 'file'.\n");
|
|
|
|
|
printf("-ploss.......... packet-loss percentage.\n");
|
|
|
|
|
printf("-enc............ do only encoding and store the bit-stream\n");
|
|
|
|
|
printf("-dec............ the input file is a bit-stream, decode it.\n\n");
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("Example usage:\n\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("%s speechIn.pcm speechOut.pcm -B 40000 -fs 32\n\n", argv[0]);
|
2012-01-27 13:44:26 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get Bottleneck value */
|
|
|
|
|
bottleneck = readParamInt(argc, argv, "-bn", 50000);
|
|
|
|
|
fprintf(stderr, "\nfixed bottleneck rate of %d bits/s\n\n", bottleneck);
|
|
|
|
|
|
|
|
|
|
/* Get Input and Output files */
|
|
|
|
|
sscanf(argv[1], "%s", inname);
|
|
|
|
|
sscanf(argv[2], "%s", outname);
|
|
|
|
|
codingMode = readSwitch(argc, argv, "-I");
|
|
|
|
|
sampFreqKHz = (int16_t)readParamInt(argc, argv, "-fs", 32);
|
|
|
|
|
if (readParamString(argc, argv, "-h", histFileName, 500) > 0) {
|
|
|
|
|
histFile = fopen(histFileName, "a");
|
|
|
|
|
if (histFile == NULL) {
|
|
|
|
|
printf("cannot open hist file %s", histFileName);
|
|
|
|
|
exit(0);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
} else {
|
|
|
|
|
// NO recording of hitstogram
|
|
|
|
|
histFile = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
packetLossPercent = readParamInt(argc, argv, "-ploss", 0);
|
|
|
|
|
|
|
|
|
|
if (readParamString(argc, argv, "-ave", averageFileName, 500) > 0) {
|
|
|
|
|
averageFile = fopen(averageFileName, "a");
|
|
|
|
|
if (averageFile == NULL) {
|
|
|
|
|
printf("cannot open file to write rate %s", averageFileName);
|
|
|
|
|
exit(0);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
} else {
|
|
|
|
|
averageFile = NULL;
|
|
|
|
|
}
|
2012-01-27 13:44:26 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
onlyEncode = readSwitch(argc, argv, "-enc");
|
|
|
|
|
onlyDecode = readSwitch(argc, argv, "-dec");
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
switch (sampFreqKHz) {
|
|
|
|
|
case 16: {
|
|
|
|
|
samplesIn10Ms = 160;
|
|
|
|
|
break;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
case 32: {
|
|
|
|
|
samplesIn10Ms = 320;
|
|
|
|
|
break;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
default:
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("A sampling frequency of %d kHz is not supported, valid values are"
|
|
|
|
|
" 8 and 16.\n", sampFreqKHz);
|
2015-06-03 12:32:41 -07:00
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
payloadLimit = (int16_t)readParamInt(argc, argv, "-plim", 400);
|
|
|
|
|
rateLimit = readParamInt(argc, argv, "-rlim", 106800);
|
|
|
|
|
|
|
|
|
|
if ((inp = fopen(inname, "rb")) == NULL) {
|
|
|
|
|
printf(" iSAC: Cannot read file %s.\n", inname);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
if ((outp = fopen(outname, "wb")) == NULL) {
|
|
|
|
|
printf(" iSAC: Cannot write file %s.\n", outname);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-01-27 13:44:26 +00:00
|
|
|
#ifdef WIN32
|
2015-06-03 12:32:41 -07:00
|
|
|
_splitpath(outname, outDrive, outPath, outPrefix, outSuffix);
|
|
|
|
|
_makepath(bitrateFileName, outDrive, outPath, "bitrate", ".txt");
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
bitrateFile = fopen(bitrateFileName, "a");
|
2016-01-30 14:40:44 -08:00
|
|
|
fprintf(bitrateFile, "%% %s \n", inname);
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("\n");
|
|
|
|
|
printf("Input.................... %s\n", inname);
|
|
|
|
|
printf("Output................... %s\n", outname);
|
|
|
|
|
printf("Encoding Mode............ %s\n",
|
|
|
|
|
(codingMode == 1) ? "Channel-Independent" : "Channel-Adaptive");
|
|
|
|
|
printf("Bottleneck............... %d bits/sec\n", bottleneck);
|
|
|
|
|
printf("Packet-loss Percentage... %d\n", packetLossPercent);
|
|
|
|
|
printf("\n");
|
2012-01-27 13:44:26 +00:00
|
|
|
|
|
|
|
|
#ifdef WIN32
|
2015-06-03 12:32:41 -07:00
|
|
|
starttime = clock() / (double)CLOCKS_PER_SEC; /* Runtime statistics */
|
2012-01-27 13:44:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
/* Initialize the ISAC and BN structs */
|
|
|
|
|
err = WebRtcIsac_Create(&ISAC_main_inst);
|
|
|
|
|
|
|
|
|
|
WebRtcIsac_SetEncSampRate(ISAC_main_inst, sampFreqKHz * 1000);
|
|
|
|
|
WebRtcIsac_SetDecSampRate(ISAC_main_inst, sampFreqKHz >= 32 ? 32000 : 16000);
|
|
|
|
|
/* Error check */
|
|
|
|
|
if (err < 0) {
|
|
|
|
|
fprintf(stderr, "\n\n Error in create.\n\n");
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
framecnt = 0;
|
|
|
|
|
endfile = 0;
|
|
|
|
|
|
|
|
|
|
/* Initialize encoder and decoder */
|
|
|
|
|
if (WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0) {
|
|
|
|
|
printf("cannot initialize encoder\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2015-08-27 15:22:11 +02:00
|
|
|
WebRtcIsac_DecoderInit(ISAC_main_inst);
|
2015-06-03 12:32:41 -07:00
|
|
|
|
|
|
|
|
if (codingMode == 1) {
|
|
|
|
|
if (WebRtcIsac_Control(ISAC_main_inst, bottleneck, frameSize) < 0) {
|
|
|
|
|
printf("cannot set bottleneck\n");
|
|
|
|
|
return -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
} else {
|
|
|
|
|
if (WebRtcIsac_ControlBwe(ISAC_main_inst, 15000, 30, 1) < 0) {
|
|
|
|
|
printf("cannot configure BWE\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-27 13:44:26 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
if (WebRtcIsac_SetMaxPayloadSize(ISAC_main_inst, payloadLimit) < 0) {
|
|
|
|
|
printf("cannot set maximum payload size %d.\n", payloadLimit);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2012-01-27 13:44:26 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
if (rateLimit < 106800) {
|
|
|
|
|
if (WebRtcIsac_SetMaxRate(ISAC_main_inst, rateLimit) < 0) {
|
|
|
|
|
printf("cannot set the maximum rate %d.\n", rateLimit);
|
|
|
|
|
return -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (endfile == 0) {
|
|
|
|
|
fprintf(stderr, " \rframe = %7li", framecnt);
|
|
|
|
|
|
|
|
|
|
//============== Readind from the file and encoding =================
|
|
|
|
|
cur_framesmpls = 0;
|
|
|
|
|
stream_len = 0;
|
|
|
|
|
|
|
|
|
|
if (onlyDecode) {
|
|
|
|
|
uint8_t auxUW8;
|
|
|
|
|
if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
stream_len = auxUW8 << 8;
|
2015-06-03 12:32:41 -07:00
|
|
|
if (fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
stream_len |= auxUW8;
|
|
|
|
|
if (fread(payload, 1, stream_len, inp) < stream_len) {
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("last payload is corrupted\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
while (stream_len == 0) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int stream_len_int;
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
// Read 10 ms speech block
|
|
|
|
|
endfile = readframe(shortdata, inp, samplesIn10Ms);
|
|
|
|
|
if (endfile) {
|
|
|
|
|
break;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
cur_framesmpls += samplesIn10Ms;
|
|
|
|
|
|
|
|
|
|
//-------- iSAC encoding ---------
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
stream_len_int = WebRtcIsac_Encode(ISAC_main_inst, shortdata, payload);
|
2015-06-03 12:32:41 -07:00
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
if (stream_len_int < 0) {
|
2015-06-03 12:32:41 -07:00
|
|
|
// exit if returned with error
|
|
|
|
|
// errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
|
|
|
|
|
fprintf(stderr, "\nError in encoder\n");
|
|
|
|
|
getc(stdin);
|
|
|
|
|
exit(EXIT_FAILURE);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
stream_len = (size_t)stream_len_int;
|
2015-06-03 12:32:41 -07:00
|
|
|
}
|
|
|
|
|
//===================================================================
|
|
|
|
|
if (endfile) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rcuStreamLen = WebRtcIsac_GetRedPayload(ISAC_main_inst, payloadRCU);
|
2015-07-22 15:17:22 -07:00
|
|
|
if (rcuStreamLen < 0) {
|
|
|
|
|
fprintf(stderr, "\nError getting RED payload\n");
|
|
|
|
|
getc(stdin);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
|
|
|
|
|
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData,
|
|
|
|
|
sampFreqKHz * 1000, sampFreqKHz * 1000);
|
|
|
|
|
if (WebRtcIsac_UpdateBwEstimate(
|
|
|
|
|
ISAC_main_inst, payload, stream_len, packetData.rtp_number,
|
|
|
|
|
packetData.sample_count, packetData.arrival_time) < 0) {
|
|
|
|
|
printf(" BWE Error at client\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
if (endfile) {
|
|
|
|
|
break;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
maxStreamLen = (stream_len > maxStreamLen) ? stream_len : maxStreamLen;
|
|
|
|
|
packetCntr++;
|
|
|
|
|
|
|
|
|
|
hist[stream_len]++;
|
|
|
|
|
if (averageFile != NULL) {
|
|
|
|
|
tmpSumStreamLen += stream_len;
|
|
|
|
|
if (packetCntr == 100) {
|
|
|
|
|
// kbps
|
|
|
|
|
fprintf(averageFile, "%8.3f ",
|
Match existing type usage better.
This makes a variety of small changes to synchronize bits of code using different types, remove useless code or casts, and add explicit casts in some places previously doing implicit ones. For example:
* Change a few type declarations to better match how the majority of code uses those objects.
* Eliminate "< 0" check for unsigned values.
* Replace "(float)sin(x)", where |x| is also a float, with "sinf(x)", and similar.
* Add casts to uint32_t in many places timestamps were used and the existing code stored signed values into the unsigned objects.
* Remove downcasts when the results would be passed to a larger type, e.g. calling "foo((int16_t)x)" with an int |x| when foo() takes an int instead of an int16_t.
* Similarly, add casts when passing a larger type to a function taking a smaller one.
* Add casts to int16_t when doing something like "int16_t = int16_t + int16_t" as the "+" operation would implicitly upconvert to int, and similar.
* Use "false" instead of "0" for setting a bool.
* Shift a few temp types when doing a multi-stage calculation involving typecasts, so as to put the most logical/semantically correct type possible into the temps. For example, when doing "int foo = int + int; size_t bar = (size_t)foo + size_t;", we might change |foo| to a size_t and move the cast if it makes more sense for |foo| to be represented as a size_t.
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=andrew, asapersson, henrika
Review URL: https://codereview.webrtc.org/1168753002
Cr-Commit-Position: refs/heads/master@{#9419}
2015-06-11 12:55:50 -07:00
|
|
|
tmpSumStreamLen * 8.0 / (30.0 * packetCntr));
|
2015-06-03 12:32:41 -07:00
|
|
|
packetCntr = 0;
|
|
|
|
|
tmpSumStreamLen = 0;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
if (onlyEncode) {
|
|
|
|
|
uint8_t auxUW8;
|
|
|
|
|
auxUW8 = (uint8_t)(((stream_len & 0x7F00) >> 8) & 0xFF);
|
|
|
|
|
if (fwrite(&auxUW8, sizeof(uint8_t), 1, outp) != 1) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
auxUW8 = (uint8_t)(stream_len & 0xFF);
|
|
|
|
|
if (fwrite(&auxUW8, sizeof(uint8_t), 1, outp) != 1) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
if (fwrite(payload, 1, stream_len, outp) != stream_len) {
|
2015-06-03 12:32:41 -07:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//======================= iSAC decoding ===========================
|
|
|
|
|
|
|
|
|
|
if ((rand() % 100) < packetLossPercent) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, payloadRCU,
|
|
|
|
|
(size_t)rcuStreamLen, decoded,
|
|
|
|
|
speechType);
|
2015-06-03 12:32:41 -07:00
|
|
|
lostPacketCntr++;
|
|
|
|
|
} else {
|
|
|
|
|
declen = WebRtcIsac_Decode(ISAC_main_inst, payload, stream_len, decoded,
|
|
|
|
|
speechType);
|
|
|
|
|
}
|
|
|
|
|
if (declen <= 0) {
|
|
|
|
|
// errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
|
|
|
|
|
fprintf(stderr, "\nError in decoder.\n");
|
|
|
|
|
getc(stdin);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
// Write decoded speech frame to file
|
|
|
|
|
if (fwrite(decoded, sizeof(int16_t), declen, outp) != (size_t)declen) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
cur_framesmpls = declen;
|
|
|
|
|
}
|
|
|
|
|
// Update Statistics
|
|
|
|
|
framecnt++;
|
|
|
|
|
totalsmpls += cur_framesmpls;
|
|
|
|
|
if (stream_len > 0) {
|
|
|
|
|
totalbits += 8 * stream_len;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
if (rcuStreamLen > 0) {
|
|
|
|
|
totalBitsRCU += 8 * rcuStreamLen;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls;
|
|
|
|
|
rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("\n\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("Sampling Rate............... %d kHz\n", sampFreqKHz);
|
|
|
|
|
printf("Payload Limit............... %d bytes \n", payloadLimit);
|
|
|
|
|
printf("Rate Limit.................. %d bits/sec \n", rateLimit);
|
2012-01-27 13:44:26 +00:00
|
|
|
|
|
|
|
|
#ifdef WIN32
|
2018-06-04 09:23:46 +02:00
|
|
|
fprintf(bitrateFile, "%d %10lu %d %6.3f %6.3f %6.3f\n",
|
2015-06-03 12:32:41 -07:00
|
|
|
sampFreqKHz, framecnt, bottleneck, rateLB, rateUB, rate);
|
|
|
|
|
fclose(bitrateFile);
|
|
|
|
|
#endif // WIN32
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("Measured bit-rate........... %0.3f kbps\n", rate);
|
|
|
|
|
printf("Measured RCU bit-ratre...... %0.3f kbps\n", rateRCU);
|
2019-08-02 09:36:47 +02:00
|
|
|
printf("Maximum bit-rate/payloadsize %0.3f / %" RTC_PRIuS "\n",
|
2015-06-03 12:32:41 -07:00
|
|
|
maxStreamLen * 8 / 0.03, maxStreamLen);
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("Measured packet-loss........ %0.1f%% \n",
|
2015-06-03 12:32:41 -07:00
|
|
|
100.0f * (float)lostPacketCntr / (float)packetCntr);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
/* Runtime statistics */
|
2011-07-07 08:21:25 +00:00
|
|
|
#ifdef WIN32
|
2015-06-03 12:32:41 -07:00
|
|
|
runtime = (double)(clock() / (double)CLOCKS_PER_SEC - starttime);
|
|
|
|
|
length_file = ((double)framecnt * (double)declen / (sampFreqKHz * 1000));
|
2015-06-09 17:26:40 -07:00
|
|
|
printf("Length of speech file....... %.1f s\n", length_file);
|
|
|
|
|
printf("Time to run iSAC............ %.2f s (%.2f %% of realtime)\n\n",
|
|
|
|
|
runtime, (100 * runtime / length_file));
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
2015-06-03 12:32:41 -07:00
|
|
|
printf("\n\n_______________________________________________\n");
|
|
|
|
|
|
|
|
|
|
if (histFile != NULL) {
|
|
|
|
|
int n;
|
|
|
|
|
for (n = 0; n < 600; n++) {
|
|
|
|
|
fprintf(histFile, "%6d ", hist[n]);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
fprintf(histFile, "\n");
|
|
|
|
|
fclose(histFile);
|
|
|
|
|
}
|
|
|
|
|
if (averageFile != NULL) {
|
|
|
|
|
if (packetCntr > 0) {
|
|
|
|
|
fprintf(averageFile, "%8.3f ",
|
Match existing type usage better.
This makes a variety of small changes to synchronize bits of code using different types, remove useless code or casts, and add explicit casts in some places previously doing implicit ones. For example:
* Change a few type declarations to better match how the majority of code uses those objects.
* Eliminate "< 0" check for unsigned values.
* Replace "(float)sin(x)", where |x| is also a float, with "sinf(x)", and similar.
* Add casts to uint32_t in many places timestamps were used and the existing code stored signed values into the unsigned objects.
* Remove downcasts when the results would be passed to a larger type, e.g. calling "foo((int16_t)x)" with an int |x| when foo() takes an int instead of an int16_t.
* Similarly, add casts when passing a larger type to a function taking a smaller one.
* Add casts to int16_t when doing something like "int16_t = int16_t + int16_t" as the "+" operation would implicitly upconvert to int, and similar.
* Use "false" instead of "0" for setting a bool.
* Shift a few temp types when doing a multi-stage calculation involving typecasts, so as to put the most logical/semantically correct type possible into the temps. For example, when doing "int foo = int + int; size_t bar = (size_t)foo + size_t;", we might change |foo| to a size_t and move the cast if it makes more sense for |foo| to be represented as a size_t.
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=andrew, asapersson, henrika
Review URL: https://codereview.webrtc.org/1168753002
Cr-Commit-Position: refs/heads/master@{#9419}
2015-06-11 12:55:50 -07:00
|
|
|
tmpSumStreamLen * 8.0 / (30.0 * packetCntr));
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-06-03 12:32:41 -07:00
|
|
|
fprintf(averageFile, "\n");
|
|
|
|
|
fclose(averageFile);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
fclose(inp);
|
|
|
|
|
fclose(outp);
|
2012-01-27 13:44:26 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
WebRtcIsac_Free(ISAC_main_inst);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-03 12:32:41 -07:00
|
|
|
exit(0);
|
2012-01-27 13:44:26 +00:00
|
|
|
}
|