-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrameBuilder.h
106 lines (97 loc) · 3.42 KB
/
FrameBuilder.h
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
#ifndef __FRAMEBUILDER_H__
#define __FRAMEBUILDER_H__
#include "Logger.h"
#include "SyncDetector.h"
#include <list>
class FrameBuilder
{
public:
// Structures
struct ColorBurstWaveInfo
{
double startPos;
double endPos;
double peakLevel;
bool isPositive;
bool isPredicted;
};
struct LineInfo
{
SyncDetector::SyncInfo leadingSyncInfo;
SyncDetector::SyncInfo followingSyncInfo;
double backPorchStartPos;
double frontPorchEndPos;
double averageSyncLevel;
double averageBlankingLevel;
//##TODO##
bool halfLine;
double ireLevel0;
double ireLevel100;
bool colorBurstValid;
double colorBurstSyncCorrection;
std::vector<ColorBurstWaveInfo> colorBurstWaves;
};
struct FieldInfo
{
std::vector<SyncDetector::SyncInfo> syncEvents;
int lineCount;
size_t endSampleNo;
SyncDetector::SyncInfo followingSyncEvent;
std::vector<LineInfo> lines;
};
struct FrameInfo
{
std::vector<FieldInfo> fields;
};
public:
// Constructors
FrameBuilder(const Logger& log);
// Frame detection methods
template<class SampleType>
std::list<FieldInfo> DetectFields(const std::vector<SampleType>& sampleData, const std::list<SyncDetector::SyncInfo>& syncEvents) const;
std::vector<FrameInfo> DetectFrames(const std::list<FieldInfo>& fields) const;
template<class SampleType>
void DetectLines(const std::vector<SampleType>& sampleData, FieldInfo& fieldInfo) const;
template<class SampleType>
void DetectLines(const std::vector<SampleType>& sampleData, std::vector<FrameInfo>& frames, unsigned int threadCount = 0) const;
private:
// Trigger detection methods
template<class SampleType>
double FindSyncRisingEdgeSamplePos(const std::vector<SampleType>& inputData, const SyncDetector::SyncInfo& syncInfo) const;
template<class SampleType>
double FindSyncFallingEdgeSamplePos(const std::vector<SampleType>& inputData, const SyncDetector::SyncInfo& syncInfo) const;
template<class SampleType>
double FindSyncRisingEdgeEndSamplePos(const std::vector<SampleType>& inputData, const SyncDetector::SyncInfo& syncInfo, double risingEdgePos) const;
// Colour burst methods
template<class SampleType>
void DetectColorBurst(const std::vector<SampleType>& backPorchData, SampleType zeroLevel, SampleType burstAmplitude, std::vector<ColorBurstWaveInfo>& burstWaves) const;
bool ValidateColorBurst(unsigned int minimumWaveCount, const std::vector<ColorBurstWaveInfo>& burstWaves) const;
template<class SampleType>
bool RepairColorBurst(const std::vector<SampleType>& backPorchData, SampleType zeroLevel, SampleType burstAmplitude, std::vector<ColorBurstWaveInfo>& burstWaves) const;
bool PerformColorBurstLineSyncCorrection(FieldInfo& fieldInfo) const;
//##FIX##
public:
// IRE conversion methods
template<class SampleType>
float SampleToIRE(SampleType sampleValue, float ireLevel0, float ireLevel100) const;
template<class SampleType>
SampleType IREToSample(float ire, float ireLevel0, float ireLevel100) const;
private:
const Logger& _log;
//##DEBUG##
public:
bool combineInterlacedFields;
bool interlaceHalfLineInFirstField;
double syncAmplitudeMinTolerance;
double slopeDetectionTolerance;
double slopeValueFlatTolerance;
double syncLengthToBackPorchMinRatio;
double blankingUpsampleRatio;
double colorBurstIREDetectionThreshold;
unsigned int colorBurstMinimumHalfOscillationCount;
double colorBurstLineSyncTolerance;
bool useColorBurstForLineSyncCorrection;
double colorBurstRepairWaveLengthTolerance;
};
#include "FrameBuilder.inl"
#endif