forked from pixop/video-compare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_compare.h
58 lines (54 loc) · 1.67 KB
/
video_compare.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
#pragma once
#include <memory>
#include <stdexcept>
#include <string>
#include <thread>
#include <vector>
#include "demuxer.h"
#include "display.h"
#include "format_converter.h"
#include "queue.h"
#include "timer.h"
#include "video_decoder.h"
#include "video_filterer.h"
extern "C" {
#include <libavcodec/avcodec.h>
}
class VideoCompare {
public:
VideoCompare(Display::Mode display_mode,
bool high_dpi_allowed,
std::tuple<int, int> window_size,
double time_shift_ms,
const std::string& left_file_name,
const std::string& left_video_filters,
const std::string& right_file_name,
const std::string& right_video_filters);
void operator()();
private:
void thread_demultiplex_left();
void thread_demultiplex_right();
void demultiplex(int video_idx);
void thread_decode_video_left();
void thread_decode_video_right();
bool process_packet(int video_idx, AVPacket* packet, AVFrame* frame_decoded);
void decode_video(int video_idx);
void video();
double time_shift_ms_;
std::unique_ptr<Demuxer> demuxer_[2];
std::unique_ptr<VideoDecoder> video_decoder_[2];
std::unique_ptr<VideoFilterer> video_filterer_[2];
size_t max_width_;
size_t max_height_;
double shortest_duration_;
std::unique_ptr<FormatConverter> format_converter_[2];
std::unique_ptr<Display> display_;
std::unique_ptr<Timer> timer_;
std::unique_ptr<PacketQueue> packet_queue_[2];
std::unique_ptr<FrameQueue> frame_queue_[2];
std::vector<std::thread> stages_;
static const size_t QUEUE_SIZE;
std::exception_ptr exception_{};
volatile bool seeking_{false};
volatile bool readyToSeek_[2][2];
};