-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharvidline.cpp
340 lines (302 loc) · 8.5 KB
/
arvidline.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#include "arvidline.h"
ArVidLine::ArVidLine()
{
this->clear();
}
ArVidLine::ArVidLine(const ArVidLine &in_object) : PCMLine(in_object)
{
// Copy base class fields.
PCMLine::operator =(in_object);
// Copy own fields.
// Copy pixel coordinates.
for(uint8_t bit=0;bit<BITS_PCM_DATA;bit++)
{
for(uint8_t stage=0;stage<PCM_LINE_MAX_PS_STAGES;stage++)
{
pixel_coordinates[stage][bit] = in_object.pixel_coordinates[stage][bit];
}
}
// Copy data words.
for(uint8_t index=0;index<WORD_CNT;index++)
{
words[index] = in_object.words[index];
}
}
ArVidLine& ArVidLine::operator= (const ArVidLine &in_object)
{
if(this==&in_object) return *this;
// Copy base class fields.
PCMLine::operator =(in_object);
// Copy own fields.
// Copy pixel coordinates.
for(uint8_t bit=0;bit<BITS_PCM_DATA;bit++)
{
for(uint8_t stage=0;stage<PCM_LINE_MAX_PS_STAGES;stage++)
{
pixel_coordinates[stage][bit] = in_object.pixel_coordinates[stage][bit];
}
}
// Copy data words.
for(uint8_t index=0;index<WORD_CNT;index++)
{
words[index] = in_object.words[index];
}
return *this;
}
void ArVidLine::clear()
{
// Clear base class fields.
PCMLine::clear();
// Clear own fields.
// Reset pixel coordinates.
for(uint8_t bit=0;bit<BITS_PCM_DATA;bit++)
{
for(uint8_t stage=0;stage<PCM_LINE_MAX_PS_STAGES;stage++)
{
pixel_coordinates[stage][bit] = 0;
}
}
// Reset data words.
setSilent();
}
//------------------------ Set word with source CRC.
void ArVidLine::setSourceCRC(uint16_t in_crc)
{
Q_UNUSED(in_crc)
// TODO
}
//------------------------ Zero out all data words.
void ArVidLine::setSilent()
{
for(uint8_t i=0;i<WORD_CNT;i++)
{
words[i] = 0;
}
}
//------------------------ Copy word into object.
void ArVidLine::setWord(uint8_t index, uint8_t in_word)
{
if(index<WORD_CNT)
{
words[index] = in_word&WORD_MASK;
}
}
//------------------------ Get number of data bits in the source line by the standard.
uint8_t ArVidLine::getBitsPerSourceLine()
{
return BITS_IN_LINE;
}
//------------------------ Get number of data bits between data coordinates (for PPB calculation).
uint8_t ArVidLine::getBitsBetweenDataCoordinates()
{
return BITS_PCM_DATA;
}
//------------------------ Get highest bit number for the left part of the line for pixel-shifting.
uint8_t ArVidLine::getLeftShiftZoneBit()
{
return BITS_LEFT_SHIFT;
}
//------------------------ Get lowest bit number for the right part of the line for pixel-shifting.
uint8_t ArVidLine::getRightShiftZoneBit()
{
return BITS_RIGHT_SHIFT;
}
//------------------------ Get pre-calculated coordinate of pixel in video line for requested PCM bit number and pixel-shifting stage.
//------------------------ [calcPPB()] MUST be called before any [findVideoPixel()] calls!
uint16_t ArVidLine::getVideoPixelByTable(uint8_t pcm_bit, uint8_t shift_stage)
{
return pixel_coordinates[shift_stage][pcm_bit];
}
//------------------------ Re-calculate CRCC for all words in the line.
void ArVidLine::calcCRC()
{
// TODO
}
//------------------------ Get CRC that was read from the source.
uint16_t ArVidLine::getSourceCRC()
{
// TODO
return 0;
}
//------------------------ Get the type of PCM to determine class derived from [PCMLine].
uint8_t ArVidLine::getPCMType()
{
return TYPE_ARVA;
}
int16_t ArVidLine::getSample(uint8_t index)
{
Q_UNUSED(index)
// TODO
return 0;
}
//------------------------ Is CRC valid (re-calculated CRC is the same as read one)?
bool ArVidLine::isCRCValidIgnoreForced()
{
// TODO
return false;
}
//------------------------ Is audio sample near zero value?
bool ArVidLine::isNearSilence(uint8_t index)
{
Q_UNUSED(index)
// TODO
return false;
}
//------------------------ Are audio samples in both channels near zero?
bool ArVidLine::isAlmostSilent()
{
// TODO
return false;
}
//------------------------ Are all audio words zeroed?
bool ArVidLine::isSilent()
{
// TODO
return false;
}
//------------------------ Convert PCM data to string for debug.
std::string ArVidLine::dumpWordsString()
{
std::string text_out;
uint8_t ind, bit_pos;
// Printing header.
/*if(hasStartMarker()==false)
{
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ZERO;
}
else*/
{
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
text_out += DUMP_BIT_ZERO;
text_out += DUMP_BIT_ONE;
}
// Printing 14 bit words data.
for(ind=0;ind<WORD_CNT;ind++)
{
text_out += DUMP_WBRL_OK;
bit_pos = BITS_PER_WORD;
do
{
bit_pos--;
if((words[ind]&(1<<bit_pos))==0)
{
text_out += DUMP_BIT_ZERO;
}
else
{
text_out += DUMP_BIT_ONE;
}
}
while(bit_pos>0);
text_out += DUMP_WBRR_OK;
}
return text_out;
}
//------------------------ Output full information about the line.
std::string ArVidLine::dumpContentString()
{
std::string text_out;
char c_buf[256];
if(isServiceLine()!=false)
{
if(isServNewFile()!=false)
{
sprintf(c_buf, "F[%03u] L[%03u] SERVICE LINE: next lines are from new file: %s", (unsigned int)frame_number, line_number, file_path.substr(0, 192).c_str());
text_out += c_buf;
}
else if(isServEndFile()!=false)
{
sprintf(c_buf, "F[%03u] L[%03u] SERVICE LINE: previous lines were last in the file", (unsigned int)frame_number, line_number);
text_out += c_buf;
}
else if(isServFiller()!=false)
{
sprintf(c_buf, "F[%03u] L[%03u] SERVICE LINE: line from a filler frame", (unsigned int)frame_number, line_number);
text_out += c_buf;
}
else if(isServEndField()!=false)
{
sprintf(c_buf, "F[%03u] L[%03u] SERVICE LINE: field of a frame ended", (unsigned int)frame_number, line_number);
text_out += c_buf;
}
else if(isServEndFrame()!=false)
{
sprintf(c_buf, "F[%03u] L[%03u] SERVICE LINE: frame ended", (unsigned int)frame_number, line_number);
text_out += c_buf;
}
}
else
{
sprintf(c_buf, "F[%03u] L[%03u] ", (unsigned int)frame_number, line_number);
text_out += c_buf;
if(hasBWSet()==false)
{
sprintf(c_buf, "Y[%03u?%03u] ", black_level, white_level);
text_out += c_buf;
}
else
{
sprintf(c_buf, "Y[%03u|%03u] ", black_level, white_level);
text_out += c_buf;
}
if(isDataByRefSweep()!=false)
{
sprintf(c_buf, "R>[%03u|%03u|%03u] ", ref_low, ref_level, ref_high);
}
else if(isDataBySkip()!=false)
{
sprintf(c_buf, "R=[%03u|%03u|%03u] ", ref_low, ref_level, ref_high);
}
else
{
sprintf(c_buf, "R?[%03u|%03u|%03u] ", ref_low, ref_level, ref_high);
}
text_out += c_buf;
if(isDataByCoordSweep()!=false)
{
sprintf(c_buf, "D[%03d:%04d] ", coords.data_start, coords.data_stop);
text_out += c_buf;
}
else if(coords.areValid()!=false)
{
sprintf(c_buf, "D[%03d|%04d] ", coords.data_start, coords.data_stop);
text_out += c_buf;
}
else
{
text_out += "D[N/A| N/A] ";
}
text_out += dumpWordsString();
sprintf(c_buf, " PPB[%02u.%03u] ", getPPB(), getPPBfrac());
text_out += c_buf;
sprintf(c_buf, "T[%05u]", process_time);
text_out += c_buf;
}
return text_out;
}
//------------------------ Next line in help output.
std::string ArVidLine::helpDumpNext()
{
std::string text_out;
// TODO
return text_out;
}
void ArVidLine::calcCoordinates(uint8_t in_shift)
{
for(uint8_t bit=0;bit<BITS_PCM_DATA;bit++)
{
pixel_coordinates[in_shift][bit] = PCMLine::getVideoPixeBylCalc(bit, in_shift, 0);
}
}