Orbiter 2022
Combinatorial Objects
prepare_frames.cpp
Go to the documentation of this file.
1/*
2 * prepare_frames.cpp
3 *
4 * Created on: Jul 10, 2020
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13#include <sstream>
14
15using namespace std;
16
17
18
19namespace orbiter {
20namespace layer1_foundations {
21namespace orbiter_kernel_system {
22
23
25{
26 nb_inputs = 0;
27 //int input_first[1000];
28 //int input_len[1000];
29 //const char *input_mask[1000];
30 f_o = FALSE;
31 //output_mask;
34 f_step = FALSE;
35 step = 0;
36
37}
38
40{
41
42}
43
44int prepare_frames::parse_arguments(int argc, std::string *argv, int verbose_level)
45{
46 int f_v = (verbose_level >= 1);
47 int i;
49
50 if (f_v) {
51 cout << "prepare_frames::parse_arguments" << endl;
52 }
53 for (i = 0; i < argc; i++) {
54 if (ST.stringcmp(argv[i], "-i") == 0) {
55 input_first[nb_inputs] = ST.strtoi(argv[++i]);
56 input_len[nb_inputs] = ST.strtoi(argv[++i]);
57 input_mask[nb_inputs].assign(argv[++i]);
58 if (f_v) {
59 cout << "-i " << input_first[nb_inputs] << " " << input_len[nb_inputs] << " " << input_mask[nb_inputs] << endl;
60 }
61 nb_inputs++;
62 }
63 else if (ST.stringcmp(argv[i], "-step") == 0) {
64 f_step = TRUE;
65 step = ST.strtoi(argv[++i]);
66 if (f_v) {
67 cout << "-step " << step << endl;
68 }
69 }
70 else if (ST.stringcmp(argv[i], "-o") == 0) {
71 f_o = TRUE;
72 output_mask.assign(argv[++i]);
73 if (f_v) {
74 cout << "-o " << output_mask << endl;
75 }
76 }
77 else if (ST.stringcmp(argv[i], "-output_starts_at") == 0) {
79 output_starts_at = ST.strtoi(argv[++i]);
80 if (f_v) {
81 cout << "-output_starts_at " << output_starts_at << endl;
82 }
83 }
84 else if (ST.stringcmp(argv[i], "-end") == 0) {
85 if (f_v) {
86 cout << "-end" << endl;
87 }
88 break;
89 }
90 else {
91 cout << "prepare_frames::parse_arguments "
92 "unrecognized option " << argv[i] << endl;
93 }
94 }
95 return i + 1;
96}
97
99{
100 int i;
101
102 if (f_step) {
103 cout << "-step " << step << endl;
104 }
105 if (f_o) {
106 cout << "-o " << output_mask << endl;
107 }
108 if (f_output_starts_at) {
109 cout << "-output_starts_at " << output_starts_at << endl;
110 }
111 for (i = 0; i < nb_inputs; i++) {
112 print_item(i);
113 }
114}
115
117{
118 cout << "-i " << input_first[i] << " " << input_len[i] << " " << input_mask[i] << endl;
119}
120
121
122void prepare_frames::do_the_work(int verbose_level)
123{
124 int f_v = (verbose_level >= 1);
125 int nb_frames;
126 int i, j, h, u;
127 char input_fname[1000];
128 char output_fname[1000];
129 char cmd[3000];
130
131 if (f_v) {
132 cout << "prepare_frames::do_the_work" << endl;
133 }
134 nb_frames = 0;
135 for (i = 0; i < nb_inputs; i++) {
136 nb_frames += input_len[i];
137 }
138
139 cout << "nb_frames = " << nb_frames << endl;
141 for (i = 0; i < nb_inputs; i++) {
142 cout << "input " << i << " / " << nb_inputs << endl;
143 for (u = 0; u < input_len[i]; u++) {
144 j = input_first[i] + u;
145 cout << "input " << i << " / " << nb_inputs << " frame " << j << " / " << input_len[i] << endl;
146
147 if (f_step) {
148 j *= step;
149 }
150 sprintf(input_fname, input_mask[i].c_str(), (int) j);
151 sprintf(output_fname, output_mask.c_str(), (int) h);
152 sprintf(cmd, "cp %s %s", input_fname, output_fname);
153 system(cmd);
154 h++;
155 }
156 }
157 cout << "nb_frames = " << nb_frames << " copied" << endl;
158#if 0
159 if (h != nb_frames) {
160 cout << "h != nb_frames" << endl;
161 exit(1);
162 }
163#endif
164 cout << "copied " << h - output_starts_at << " files, we are done" << endl;
165 if (f_v) {
166 cout << "prepare_frames::do_the_work done" << endl;
167 }
168}
169
170}}}
171
172
functions related to strings and character arrays
int parse_arguments(int argc, std::string *argv, int verbose_level)
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
the orbiter library for the classification of combinatorial objects