Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: webrtc/modules/audio_coding/codecs/g711/test/testG711.cc

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 /* 11 /*
12 * testG711.cpp : Defines the entry point for the console application. 12 * testG711.cpp : Defines the entry point for the console application.
13 */ 13 */
14 14
15 #include <stdio.h> 15 #include <stdio.h>
16 #include <stdlib.h> 16 #include <stdlib.h>
17 #include <string.h> 17 #include <string.h>
18 18
19 /* include API */ 19 /* include API */
20 #include "g711_interface.h" 20 #include "g711_interface.h"
21 21
22 /* Runtime statistics */ 22 /* Runtime statistics */
23 #include <time.h> 23 #include <time.h>
24 #define CLOCKS_PER_SEC_G711 1000 24 #define CLOCKS_PER_SEC_G711 1000
25 25
26 /* function for reading audio data from PCM file */ 26 /* function for reading audio data from PCM file */
27 int readframe(int16_t* data, FILE* inp, int length) { 27 bool readframe(int16_t* data, FILE* inp, int length) {
28 28 short rlen = (short) fread(data, sizeof(int16_t), length, inp);
29 short k, rlen, status = 0; 29 if (rlen >= length)
30 30 return false;
31 rlen = (short) fread(data, sizeof(int16_t), length, inp); 31 memset(data + rlen, 0, (length - rlen) * sizeof(int16_t));
32 if (rlen < length) { 32 return true;
kwiberg-webrtc 2015/06/10 11:58:32 Umm... this return true if it failed and false if
33 for (k = rlen; k < length; k++)
34 data[k] = 0;
35 status = 1;
36 }
37
38 return status;
39 } 33 }
40 34
41 int main(int argc, char* argv[]) { 35 int main(int argc, char* argv[]) {
42 char inname[80], outname[40], bitname[40]; 36 char inname[80], outname[40], bitname[40];
43 FILE* inp; 37 FILE* inp;
44 FILE* outp; 38 FILE* outp;
45 FILE* bitp = NULL; 39 FILE* bitp = NULL;
46 int framecnt, endfile; 40 int framecnt;
41 bool endfile;
kwiberg-webrtc 2015/06/10 11:58:32 Consider moving declarations to first use while yo
47 42
48 int16_t framelength = 80; 43 int16_t framelength = 80;
49 44
50 int err; 45 int err;
51 46
52 /* Runtime statistics */ 47 /* Runtime statistics */
53 double starttime; 48 double starttime;
54 double runtime; 49 double runtime;
55 double length_file; 50 double length_file;
56 51
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 106 }
112 printf("\nInput: %s\nOutput: %s\n", inname, outname); 107 printf("\nInput: %s\nOutput: %s\n", inname, outname);
113 if (argc == 6) { 108 if (argc == 6) {
114 printf("\nBitfile: %s\n", bitname); 109 printf("\nBitfile: %s\n", bitname);
115 } 110 }
116 111
117 starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */ 112 starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */
118 113
119 /* Initialize encoder and decoder */ 114 /* Initialize encoder and decoder */
120 framecnt = 0; 115 framecnt = 0;
121 endfile = 0; 116 endfile = false;
122 while (endfile == 0) { 117 while (!endfile) {
123 framecnt++; 118 framecnt++;
124 /* Read speech block */ 119 /* Read speech block */
125 endfile = readframe(shortdata, inp, framelength); 120 endfile = readframe(shortdata, inp, framelength);
126 121
127 /* G.711 encoding */ 122 /* G.711 encoding */
128 if (!strcmp(law, "A")) { 123 if (!strcmp(law, "A")) {
129 /* A-law encoding */ 124 /* A-law encoding */
130 stream_len = WebRtcG711_EncodeA(shortdata, framelength, streamdata); 125 stream_len = WebRtcG711_EncodeA(shortdata, framelength, streamdata);
131 if (argc == 6) { 126 if (argc == 6) {
132 /* Write bits to file */ 127 /* Write bits to file */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", 165 printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n",
171 runtime, 166 runtime,
172 (100 * runtime / length_file)); 167 (100 * runtime / length_file));
173 printf("---------------------END----------------------\n"); 168 printf("---------------------END----------------------\n");
174 169
175 fclose(inp); 170 fclose(inp);
176 fclose(outp); 171 fclose(outp);
177 172
178 return 0; 173 return 0;
179 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698