-
Notifications
You must be signed in to change notification settings - Fork 3
/
VideoProcessor.h
142 lines (112 loc) · 2.91 KB
/
VideoProcessor.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
#pragma once
#include <Windows.h>
#include <Vfw.h>
#include <string>
#include <functional>
#include "impressionistUI.h"
#include "Bitmap.h"
class Fl_Widget;
/**
* Class done with help from: https://www.codeproject.com/Articles/8739/Extracting-AVI-Frames
*/
class VideoProcessor
{
public:
/**
* Retrieves a VideoProcessor singleton instance.
* @returns a VideoProcessor singleton instance.
*/
static VideoProcessor* getInstancePtr();
/**
* Destroys the singleton instance.
*/
static void destroy();
/**
* Returns whether the file is read completely
*/
static bool isEnded();
/**
* Initialize the user interaction of opening the dialog and prepare to read the video.
*/
void openVideoFromUser();
/**
* Opens a video file in read-only mode.
* @param filename the path to read the file.
* @returns if the file was successfully opened.
*/
bool openFile(const std::string & filename);
/**
* Retrieves a stream pointer to read the opened file.
*/
bool startStream();
/**
* Returns whether the previous operation has generated an error.
* @returns if the previous operation has generated an error.
*/
bool hasError() const;
/**
* Sets the full image auto-run manipulation function that modifies the input image to a stylized output image.
* @param callbackFunction The image manipulation function.
*/
void setManipulationMethod(const std::function<void()>& callbackFunction);
/**
* Continues with the processing when one image is done.
*/
void next();
/**
* Close all opened file and stream.
*/
void close();
/**
* Information regarding the opened AVI.
*/
AVIFILEINFO aviInfo{};
/**
* AVI buffer pointer from the opened file.
*/
PAVIFILE aviReadPtr = nullptr;
/**
* AVI stream pointer within the opened file.
*/
PAVISTREAM aviReadStreamPtr = nullptr;
/**
* AVI buffer pointer from the opened file.
*/
PAVIFILE aviPtr = nullptr;
/**
* AVI stream pointer within the opened file.
*/
PAVISTREAM aviStreamPtr = nullptr;
/**
* AVI stream pointer within the opened file.
*/
PAVISTREAM aviCStreamPtr = nullptr;
bool hasSetFormat = false;
/**
* Reading position of the stream
*/
long int frameIndex = 0L;
static std::function<void()> methodAutoFill;
static std::function<void()> methodPaintly;
static Fl_Callback cbVideoAutoFill;
static Fl_Callback cbVideoPaintly;
static void cbPreparation(Fl_Widget* o);
static ImpressionistUI* uiPtr;
static ImpressionistDoc* docPtr;
static void continueWriteStream();
~VideoProcessor();
private:
explicit VideoProcessor();
static VideoProcessor* singletonPtr;
BITMAPINFOHEADER bmpInfo{};
PADDING padding{};
unsigned long byteLength = 0;
std::function<void()> perImageFunction = [&](){};
HRESULT errorCode = 0;
long int streamStartingIndex = 0;
long int totalFrames = 0;
PGETFRAME getFramePtr = nullptr;
BYTE* bitmapDibPtr = nullptr;
unsigned char* imageDataPtr = nullptr;
void saveImage();
};