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 |
11 | 11 |
12 #include <math.h> | 12 #include <math.h> |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 | 15 |
16 #include <algorithm> | 16 #include <algorithm> |
17 | 17 |
18 #include "gflags/gflags.h" | 18 #include "gflags/gflags.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/modules/audio_processing/agc/agc.h" | 20 #include "webrtc/modules/audio_processing/agc/agc.h" |
| 21 #include "webrtc/modules/audio_processing/agc/agc_audio_proc.h" |
| 22 #include "webrtc/modules/audio_processing/agc/common.h" |
21 #include "webrtc/modules/audio_processing/agc/histogram.h" | 23 #include "webrtc/modules/audio_processing/agc/histogram.h" |
| 24 #include "webrtc/modules/audio_processing/agc/pitch_based_vad.h" |
| 25 #include "webrtc/modules/audio_processing/agc/standalone_vad.h" |
22 #include "webrtc/modules/audio_processing/agc/utility.h" | 26 #include "webrtc/modules/audio_processing/agc/utility.h" |
23 #include "webrtc/modules/audio_processing/vad/vad_audio_proc.h" | |
24 #include "webrtc/modules/audio_processing/vad/common.h" | |
25 #include "webrtc/modules/audio_processing/vad/pitch_based_vad.h" | |
26 #include "webrtc/modules/audio_processing/vad/standalone_vad.h" | |
27 #include "webrtc/modules/interface/module_common_types.h" | 27 #include "webrtc/modules/interface/module_common_types.h" |
28 | 28 |
29 static const int kAgcAnalWindowSamples = 100; | 29 static const int kAgcAnalWindowSamples = 100; |
30 static const double kDefaultActivityThreshold = 0.3; | 30 static const double kDefaultActivityThreshold = 0.3; |
31 | 31 |
32 DEFINE_bool(standalone_vad, true, "enable stand-alone VAD"); | 32 DEFINE_bool(standalone_vad, true, "enable stand-alone VAD"); |
33 DEFINE_string(true_vad, "", "name of a file containing true VAD in 'int'" | 33 DEFINE_string(true_vad, "", "name of a file containing true VAD in 'int'" |
34 " format"); | 34 " format"); |
35 DEFINE_string(video_vad, "", "name of a file containing video VAD (activity" | 35 DEFINE_string(video_vad, "", "name of a file containing video VAD (activity" |
36 " probabilities) in double format. One activity per 10ms is" | 36 " probabilities) in double format. One activity per 10ms is" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 frame->data_[n] = (rand() & 0xF) - 8; | 68 frame->data_[n] = (rand() & 0xF) - 8; |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 class AgcStat { | 72 class AgcStat { |
73 public: | 73 public: |
74 AgcStat() | 74 AgcStat() |
75 : video_index_(0), | 75 : video_index_(0), |
76 activity_threshold_(kDefaultActivityThreshold), | 76 activity_threshold_(kDefaultActivityThreshold), |
77 audio_content_(Histogram::Create(kAgcAnalWindowSamples)), | 77 audio_content_(Histogram::Create(kAgcAnalWindowSamples)), |
78 audio_processing_(new VadAudioProc()), | 78 audio_processing_(new AgcAudioProc()), |
79 vad_(new PitchBasedVad()), | 79 vad_(new PitchBasedVad()), |
80 standalone_vad_(StandaloneVad::Create()), | 80 standalone_vad_(StandaloneVad::Create()), |
81 audio_content_fid_(NULL) { | 81 audio_content_fid_(NULL) { |
82 for (int n = 0; n < kMaxNumFrames; n++) | 82 for (int n = 0; n < kMaxNumFrames; n++) |
83 video_vad_[n] = 0.5; | 83 video_vad_[n] = 0.5; |
84 } | 84 } |
85 | 85 |
86 ~AgcStat() { | 86 ~AgcStat() { |
87 if (audio_content_fid_ != NULL) { | 87 if (audio_content_fid_ != NULL) { |
88 fclose(audio_content_fid_); | 88 fclose(audio_content_fid_); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 void SetActivityThreshold(double activity_threshold) { | 149 void SetActivityThreshold(double activity_threshold) { |
150 activity_threshold_ = activity_threshold; | 150 activity_threshold_ = activity_threshold; |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 int video_index_; | 154 int video_index_; |
155 double activity_threshold_; | 155 double activity_threshold_; |
156 double video_vad_[kMaxNumFrames]; | 156 double video_vad_[kMaxNumFrames]; |
157 rtc::scoped_ptr<Histogram> audio_content_; | 157 rtc::scoped_ptr<Histogram> audio_content_; |
158 rtc::scoped_ptr<VadAudioProc> audio_processing_; | 158 rtc::scoped_ptr<AgcAudioProc> audio_processing_; |
159 rtc::scoped_ptr<PitchBasedVad> vad_; | 159 rtc::scoped_ptr<PitchBasedVad> vad_; |
160 rtc::scoped_ptr<StandaloneVad> standalone_vad_; | 160 rtc::scoped_ptr<StandaloneVad> standalone_vad_; |
161 | 161 |
162 FILE* audio_content_fid_; | 162 FILE* audio_content_fid_; |
163 }; | 163 }; |
164 | 164 |
165 | 165 |
166 void void_main(int argc, char* argv[]) { | 166 void void_main(int argc, char* argv[]) { |
167 webrtc::AgcStat agc_stat; | 167 webrtc::AgcStat agc_stat; |
168 | 168 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 " one probability per frame.\n" | 375 " one probability per frame.\n" |
376 "\nUsage:\n\n" | 376 "\nUsage:\n\n" |
377 "activity_metric input_pcm [options]\n" | 377 "activity_metric input_pcm [options]\n" |
378 "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " | 378 "where 'input_pcm' is the input audio sampled at 16 kHz in 16 bits " |
379 "format.\n\n"; | 379 "format.\n\n"; |
380 google::SetUsageMessage(kUsage); | 380 google::SetUsageMessage(kUsage); |
381 google::ParseCommandLineFlags(&argc, &argv, true); | 381 google::ParseCommandLineFlags(&argc, &argv, true); |
382 webrtc::void_main(argc, argv); | 382 webrtc::void_main(argc, argv); |
383 return 0; | 383 return 0; |
384 } | 384 } |
OLD | NEW |