|
5 | 5 | #include <assert.h> |
6 | 6 | #include <mutex> |
7 | 7 | #include <algorithm> |
| 8 | +#include <boost/filesystem.hpp> |
8 | 9 |
|
9 | 10 | #define THREAD_NUM 4 |
10 | 11 |
|
11 | 12 | using namespace std; |
| 13 | +namespace fs=boost::filesystem; |
| 14 | + |
12 | 15 | class Seed{ |
13 | 16 | public: |
14 | 17 | Seed():x(-1),y(8),dx(1),index(-1){ |
@@ -127,26 +130,42 @@ void process(string dir) |
127 | 130 |
|
128 | 131 | } |
129 | 132 |
|
130 | | -void thread_block(int argc,char ** argv,int id,int td_n){ |
131 | | - for(int i=id;i<argc-1;i=i+td_n) |
| 133 | +void thread_block(const vector<string> * qmc_collection,int id){ |
| 134 | + for(int i=id;i<qmc_collection->size();i+=THREAD_NUM) |
132 | 135 | { |
133 | | - process(std::string(argv[i+1])); |
| 136 | + process(qmc_collection->operator[](i)); |
134 | 137 | } |
135 | 138 | } |
136 | 139 |
|
137 | 140 |
|
138 | 141 | int main(int argc,char ** argv){ |
139 | 142 |
|
140 | | - if(argc<2) |
| 143 | + if(argc>1) |
141 | 144 | { |
142 | | - print_thread_s("./decoder <qmcfile1> <qmcfile2> ...",std::cout); |
| 145 | + print_thread_s("put decoder binary file in your cmq file directory, then run it.",std::cout); |
143 | 146 | return 1; |
144 | 147 | } |
145 | 148 |
|
146 | | - std::vector<std::thread> td_group; |
| 149 | + fs::path qmc_dir("."); |
| 150 | + |
| 151 | + fs::recursive_directory_iterator eod; |
| 152 | + |
| 153 | + vector<string> qmc_collection; |
| 154 | + |
| 155 | + for (fs::recursive_directory_iterator i(qmc_dir); i != eod; ++i){ |
| 156 | + fs::path fp = *i; |
| 157 | + if (fs::is_regular_file(fp)){ |
| 158 | + if(fp.string().find(".qmc3")!=string::npos|| |
| 159 | + fp.string().find(".qmc0")!=string::npos|| |
| 160 | + fp.string().find(".qmcflac")!=string::npos) |
| 161 | + qmc_collection.emplace_back(fp.string()); |
| 162 | + } |
| 163 | + }; |
| 164 | + |
| 165 | + vector<std::thread> td_group; |
147 | 166 | for(int i=1;i<THREAD_NUM;++i) |
148 | | - td_group.emplace_back(thread_block,argc,argv,i,THREAD_NUM); |
149 | | - thread_block(argc,argv,0,THREAD_NUM); |
| 167 | + td_group.emplace_back(thread_block,&qmc_collection,i); |
| 168 | + thread_block(&qmc_collection,0); |
150 | 169 | for(auto &&x: td_group) |
151 | 170 | x.join(); |
152 | 171 |
|
|
0 commit comments