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

Side by Side Diff: webrtc/modules/audio_processing/transient/click_annotate.cc

Issue 1698843003: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/transient/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: compile fix Created 4 years, 10 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <cfloat> 11 #include <cfloat>
12 #include <cstdio> 12 #include <cstdio>
13 #include <cstdlib> 13 #include <cstdlib>
14 #include <memory>
14 #include <vector> 15 #include <vector>
15 16
16 #include "webrtc/modules/audio_processing/transient/transient_detector.h" 17 #include "webrtc/modules/audio_processing/transient/transient_detector.h"
17 #include "webrtc/modules/audio_processing/transient/file_utils.h" 18 #include "webrtc/modules/audio_processing/transient/file_utils.h"
18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/system_wrappers/include/file_wrapper.h" 19 #include "webrtc/system_wrappers/include/file_wrapper.h"
20 20
21 using rtc::scoped_ptr;
22 using webrtc::FileWrapper; 21 using webrtc::FileWrapper;
23 using webrtc::TransientDetector; 22 using webrtc::TransientDetector;
24 23
25 // Application to generate a RTP timing file. 24 // Application to generate a RTP timing file.
26 // Opens the PCM file and divides the signal in frames. 25 // Opens the PCM file and divides the signal in frames.
27 // Creates a send times array, one for each step. 26 // Creates a send times array, one for each step.
28 // Each block that contains a transient, has an infinite send time. 27 // Each block that contains a transient, has an infinite send time.
29 // The resultant array is written to a DAT file 28 // The resultant array is written to a DAT file
30 // Returns -1 on error or |lost_packets| otherwise. 29 // Returns -1 on error or |lost_packets| otherwise.
31 int main(int argc, char* argv[]) { 30 int main(int argc, char* argv[]) {
32 if (argc != 5) { 31 if (argc != 5) {
33 printf("\n%s - Application to generate a RTP timing file.\n\n", argv[0]); 32 printf("\n%s - Application to generate a RTP timing file.\n\n", argv[0]);
34 printf("%s PCMfile DATfile chunkSize sampleRate\n\n", argv[0]); 33 printf("%s PCMfile DATfile chunkSize sampleRate\n\n", argv[0]);
35 printf("Opens the PCMfile with sampleRate in Hertz.\n"); 34 printf("Opens the PCMfile with sampleRate in Hertz.\n");
36 printf("Creates a send times array, one for each chunkSize "); 35 printf("Creates a send times array, one for each chunkSize ");
37 printf("milliseconds step.\n"); 36 printf("milliseconds step.\n");
38 printf("Each block that contains a transient, has an infinite send time. "); 37 printf("Each block that contains a transient, has an infinite send time. ");
39 printf("The resultant array is written to a DATfile.\n\n"); 38 printf("The resultant array is written to a DATfile.\n\n");
40 return 0; 39 return 0;
41 } 40 }
42 41
43 scoped_ptr<FileWrapper> pcm_file(FileWrapper::Create()); 42 std::unique_ptr<FileWrapper> pcm_file(FileWrapper::Create());
44 pcm_file->OpenFile(argv[1], true, false, false); 43 pcm_file->OpenFile(argv[1], true, false, false);
45 if (!pcm_file->Open()) { 44 if (!pcm_file->Open()) {
46 printf("\nThe %s could not be opened.\n\n", argv[1]); 45 printf("\nThe %s could not be opened.\n\n", argv[1]);
47 return -1; 46 return -1;
48 } 47 }
49 48
50 scoped_ptr<FileWrapper> dat_file(FileWrapper::Create()); 49 std::unique_ptr<FileWrapper> dat_file(FileWrapper::Create());
51 dat_file->OpenFile(argv[2], false, false, false); 50 dat_file->OpenFile(argv[2], false, false, false);
52 if (!dat_file->Open()) { 51 if (!dat_file->Open()) {
53 printf("\nThe %s could not be opened.\n\n", argv[2]); 52 printf("\nThe %s could not be opened.\n\n", argv[2]);
54 return -1; 53 return -1;
55 } 54 }
56 55
57 int chunk_size_ms = atoi(argv[3]); 56 int chunk_size_ms = atoi(argv[3]);
58 if (chunk_size_ms <= 0) { 57 if (chunk_size_ms <= 0) {
59 printf("\nThe chunkSize must be a positive integer\n\n"); 58 printf("\nThe chunkSize must be a positive integer\n\n");
60 return -1; 59 return -1;
61 } 60 }
62 61
63 int sample_rate_hz = atoi(argv[4]); 62 int sample_rate_hz = atoi(argv[4]);
64 if (sample_rate_hz <= 0) { 63 if (sample_rate_hz <= 0) {
65 printf("\nThe sampleRate must be a positive integer\n\n"); 64 printf("\nThe sampleRate must be a positive integer\n\n");
66 return -1; 65 return -1;
67 } 66 }
68 67
69 TransientDetector detector(sample_rate_hz); 68 TransientDetector detector(sample_rate_hz);
70 int lost_packets = 0; 69 int lost_packets = 0;
71 size_t audio_buffer_length = chunk_size_ms * sample_rate_hz / 1000; 70 size_t audio_buffer_length = chunk_size_ms * sample_rate_hz / 1000;
72 scoped_ptr<float[]> audio_buffer(new float[audio_buffer_length]); 71 std::unique_ptr<float[]> audio_buffer(new float[audio_buffer_length]);
73 std::vector<float> send_times; 72 std::vector<float> send_times;
74 73
75 // Read first buffer from the PCM test file. 74 // Read first buffer from the PCM test file.
76 size_t file_samples_read = ReadInt16FromFileToFloatBuffer( 75 size_t file_samples_read = ReadInt16FromFileToFloatBuffer(
77 pcm_file.get(), 76 pcm_file.get(),
78 audio_buffer_length, 77 audio_buffer_length,
79 audio_buffer.get()); 78 audio_buffer.get());
80 for (int time = 0; file_samples_read > 0; time += chunk_size_ms) { 79 for (int time = 0; file_samples_read > 0; time += chunk_size_ms) {
81 // Pad the rest of the buffer with zeros. 80 // Pad the rest of the buffer with zeros.
82 for (size_t i = file_samples_read; i < audio_buffer_length; ++i) { 81 for (size_t i = file_samples_read; i < audio_buffer_length; ++i) {
(...skipping 22 matching lines...) Expand all
105 if (floats_written == 0) { 104 if (floats_written == 0) {
106 printf("\nThe send times could not be written to DAT file\n\n"); 105 printf("\nThe send times could not be written to DAT file\n\n");
107 return -1; 106 return -1;
108 } 107 }
109 108
110 pcm_file->CloseFile(); 109 pcm_file->CloseFile();
111 dat_file->CloseFile(); 110 dat_file->CloseFile();
112 111
113 return lost_packets; 112 return lost_packets;
114 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698