| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 "webrtc/modules/audio_coding/neteq/audio_classifier.h" | 11 #include "webrtc/modules/audio_coding/neteq/audio_classifier.h" |
| 12 | 12 |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 #include <stdlib.h> | 15 #include <stdlib.h> |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 | 17 |
| 18 #include <iostream> |
| 19 #include <memory> |
| 18 #include <string> | 20 #include <string> |
| 19 #include <iostream> | |
| 20 | |
| 21 #include "webrtc/base/scoped_ptr.h" | |
| 22 | 21 |
| 23 int main(int argc, char* argv[]) { | 22 int main(int argc, char* argv[]) { |
| 24 if (argc != 5) { | 23 if (argc != 5) { |
| 25 std::cout << "Usage: " << argv[0] << | 24 std::cout << "Usage: " << argv[0] << |
| 26 " channels output_type <input file name> <output file name> " | 25 " channels output_type <input file name> <output file name> " |
| 27 << std::endl << std::endl; | 26 << std::endl << std::endl; |
| 28 std::cout << "Where channels can be 1 (mono) or 2 (interleaved stereo),"; | 27 std::cout << "Where channels can be 1 (mono) or 2 (interleaved stereo),"; |
| 29 std::cout << " outputs can be 1 (classification (boolean)) or 2"; | 28 std::cout << " outputs can be 1 (classification (boolean)) or 2"; |
| 30 std::cout << " (classification and music probability (float))," | 29 std::cout << " (classification and music probability (float))," |
| 31 << std::endl; | 30 << std::endl; |
| 32 std::cout << "and the sampling frequency is assumed to be 48 kHz." | 31 std::cout << "and the sampling frequency is assumed to be 48 kHz." |
| 33 << std::endl; | 32 << std::endl; |
| 34 return -1; | 33 return -1; |
| 35 } | 34 } |
| 36 | 35 |
| 37 const int kFrameSizeSamples = 960; | 36 const int kFrameSizeSamples = 960; |
| 38 int channels = atoi(argv[1]); | 37 int channels = atoi(argv[1]); |
| 39 if (channels < 1 || channels > 2) { | 38 if (channels < 1 || channels > 2) { |
| 40 std::cout << "Disallowed number of channels " << channels << std::endl; | 39 std::cout << "Disallowed number of channels " << channels << std::endl; |
| 41 return -1; | 40 return -1; |
| 42 } | 41 } |
| 43 | 42 |
| 44 int outputs = atoi(argv[2]); | 43 int outputs = atoi(argv[2]); |
| 45 if (outputs < 1 || outputs > 2) { | 44 if (outputs < 1 || outputs > 2) { |
| 46 std::cout << "Disallowed number of outputs " << outputs << std::endl; | 45 std::cout << "Disallowed number of outputs " << outputs << std::endl; |
| 47 return -1; | 46 return -1; |
| 48 } | 47 } |
| 49 | 48 |
| 50 const int data_size = channels * kFrameSizeSamples; | 49 const int data_size = channels * kFrameSizeSamples; |
| 51 rtc::scoped_ptr<int16_t[]> in(new int16_t[data_size]); | 50 std::unique_ptr<int16_t[]> in(new int16_t[data_size]); |
| 52 | 51 |
| 53 std::string input_filename = argv[3]; | 52 std::string input_filename = argv[3]; |
| 54 std::string output_filename = argv[4]; | 53 std::string output_filename = argv[4]; |
| 55 | 54 |
| 56 std::cout << "Input file: " << input_filename << std::endl; | 55 std::cout << "Input file: " << input_filename << std::endl; |
| 57 std::cout << "Output file: " << output_filename << std::endl; | 56 std::cout << "Output file: " << output_filename << std::endl; |
| 58 | 57 |
| 59 FILE* in_file = fopen(input_filename.c_str(), "rb"); | 58 FILE* in_file = fopen(input_filename.c_str(), "rb"); |
| 60 if (!in_file) { | 59 if (!in_file) { |
| 61 std::cout << "Cannot open input file " << input_filename << std::endl; | 60 std::cout << "Cannot open input file " << input_filename << std::endl; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 std::cout << frame_counter << " frames processed." << std::endl; | 95 std::cout << frame_counter << " frames processed." << std::endl; |
| 97 if (frame_counter > 0) { | 96 if (frame_counter > 0) { |
| 98 float music_percentage = music_counter / static_cast<float>(frame_counter); | 97 float music_percentage = music_counter / static_cast<float>(frame_counter); |
| 99 std::cout << music_percentage << " percent music." << std::endl; | 98 std::cout << music_percentage << " percent music." << std::endl; |
| 100 } | 99 } |
| 101 | 100 |
| 102 fclose(in_file); | 101 fclose(in_file); |
| 103 fclose(out_file); | 102 fclose(out_file); |
| 104 return 0; | 103 return 0; |
| 105 } | 104 } |
| OLD | NEW |