-
Notifications
You must be signed in to change notification settings - Fork 2
/
renderpcm.h
159 lines (137 loc) · 5.96 KB
/
renderpcm.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
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
/**************************************************************************************************************************************************************
renderpcm.h
Copyright © 2023 Maksim Kryukov <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created: 2021-01
Renderer for visualization.
This module represents various data containers as an image for visualization purposes.
**************************************************************************************************************************************************************/
#ifndef RENDERPCM_H
#define RENDERPCM_H
#include <QColor>
#include <QElapsedTimer>
#include <QImage>
#include <QList>
#include <QObject>
#include <QTimer>
#include <QThread>
#include "frametrimset.h"
#include "pcm1datablock.h"
#include "pcm1datastitcher.h"
#include "pcm1line.h"
#include "pcm1subline.h"
#include "pcm16x0datablock.h"
#include "pcm16x0datastitcher.h"
#include "pcm16x0subline.h"
#include "stc007datablock.h"
#include "stc007datastitcher.h"
#include "stc007line.h"
#include "videoline.h"
// Colors of bits.
#define VIS_RED_TINT (qRgb(255, 190, 180)) // Video with red tint.
#define VIS_GREEN_TINT (qRgb(150, 210, 150)) // Video with green tint.
#define VIS_BLUE_TINT (qRgb(170, 180, 240)) // Video with blue tint.
#define VIS_BIT0_BLK (Qt::black) // Bit "0", PCM with valid CRC in the line.
#define VIS_BIT0_GRY (qRgb(45, 45, 45)) // Bit "0", PCM with valid CRC in the line for STC-007.
#define VIS_BIT1_GRY (qRgb(150, 150, 150)) // Bit "1", PCM with valid CRC in the line.
#define VIS_BIT0_YEL (qRgb(127, 110, 0)) // Bit "0", PCM with yellow tint.
#define VIS_BIT1_YEL (qRgb(255, 220, 0)) // Bit "1", PCM with yellow tint.
#define VIS_BIT0_GRN (qRgb(0, 95, 30)) // Bit "0", PCM with green tint.
#define VIS_BIT1_GRN (qRgb(0, 225, 70)) // Bit "1", PCM with green tint.
#define VIS_BIT0_RED (qRgb(140, 0, 0)) // Bit "0", PCM with red tint.
#define VIS_BIT1_RED (qRgb(255, 70, 43)) // Bit "1", PCM with red tint.
#define VIS_BIT0_BLU (qRgb(0, 95, 127)) // Bit "0", PCM with blue tint.
#define VIS_BIT1_BLU (qRgb(0, 191, 255)) // Bit "1", PCM with blue tint.
#define VIS_BIT0_MGN (qRgb(140, 0, 140)) // Bit "0", PCM with magenta tint.
#define VIS_BIT1_MGN (qRgb(255, 0, 255)) // Bit "1", PCM with magenta tint.
#define VIS_BIT1_MARK (qRgb(255, 255, 255)) // STC-007/PCM-F1 white marker line.
#define VIS_LIM_OK (qRgb(255, 255, 255)) // Data boundaries for data blocks.
#define VIS_LIM_MARK (qRgb(224, 170, 170)) // Data boundaries with some marker (almost silent data or data on the seam).
class RenderPCM : public QObject
{
Q_OBJECT
public:
// Minimum time between frames (ms) in live playback.
enum
{
TIME_START = 75, // Playback start (buffer-up).
TIME_NTSC = 27, // NTSC.
TIME_PAL = 31 // PAL.
};
// PPBs (Pixels Per Bit) for visualization.
enum
{
PPB_PCM1LINE = 8, // PPB for [PCM1Line].
PPB_PCM1SUBLINE = 8, // PPB for [PCM1SubLine].
PPB_PCM1BLK = 6, // PPB for [PCM1DataBlock].
PPB_PCM1600SUBLINE = 4, // PPB for [PCM16X0SubLine].
PPB_PCM1600BLK = 6, // PPB for [PCM16X0DataBlock].
PPB_STC007LINE = 5, // PPB for [STC007Line].
PPB_STC007BLK = 6 // PPB for [STC007DataBlock].
};
enum
{
PPL_PCM1BLK = 4, // Word-Pair Per Line for [PCM1DataBlock].
WPL_PCM1BLK = (PPL_PCM1BLK*2) // Words Per Line for [PCM1DataBlock].
};
enum
{
PACING_DEPTH = 30 // Depth of frame pacing buffer between render and drawer.
};
public:
explicit RenderPCM(QObject *parent = 0);
~RenderPCM();
private:
void resetFrame();
private:
QImage *img_data; // Image to render to.
QTimer *frame_period; // Frame pacing timer.
QList<QImage> pacing_buf; // Output images queue.
bool live_pb; // Is live playback enabled? (requires frame pacing)
uint8_t frame_time_lim; // Time between frames in [ms] for frame pacing.
uint8_t queue_size; // Queue length between renderer and drawer.
uint16_t fill_line_num; // Current line for filling in the image.
uint16_t provided_width; // Width of the render canvas.
uint16_t provided_heigth; // Height of the render canvas.
public slots:
void dumpThreadDebug();
void setLivePlay(bool);
void setFrameTime(uint8_t);
void setLineCount(uint8_t);
void resizeToFrame(uint16_t, uint16_t);
void startNewFrame(uint16_t, uint16_t);
void startVideoFrame();
void startPCM1Frame();
void startPCM1SubFrame();
void startPCM1600Frame();
void startSTC007NTSCFrame();
void startSTC007PALFrame();
void startPCM1DBFrame();
void startPCM1600DBFrame();
void startSTC007DBFrame();
void prepareNewFrame(uint32_t);
void finishNewFrame(uint32_t);
void renderNewLine(VideoLine);
void renderNewLineInOrder(VideoLine);
void renderNewLine(PCM1Line);
void renderNewLine(PCM1SubLine);
void renderNewLine(PCM16X0SubLine);
void renderNewLine(STC007Line);
void renderNewBlock(PCM1DataBlock);
void renderNewBlock(PCM16X0DataBlock);
void renderNewBlock(STC007DataBlock);
void displayIsReady();
private slots:
void framePacing();
signals:
void renderedFrame(QImage);
};
#endif // RENDERPCM_H