-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimages_panel.cpp
68 lines (57 loc) · 1.84 KB
/
images_panel.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
#include <QTimer>
#include "images_panel.h"
#include "mylog.h"
ImagesPanel::ImagesPanel(QWidget *parent)
: QWidget{parent}
{
const char* file = "D:/docs/movie/.unknown/6798973.mp4";
// file = "Z:/coding/github/steins_gate_cut.mkv";
dec_obj_ = new DecoderThread;
dec_obj_->Init(file);
dec_obj_->moveToThread(&dec_thread_);
dec_thread_.start();
connect(&dec_thread_, &QThread::finished, dec_obj_, &QObject::deleteLater);
connect(this, &ImagesPanel::signal_require_frames,
dec_obj_, &DecoderThread::on_require_frames);
connect(dec_obj_, &DecoderThread::signal_frame_decoded,
this, &ImagesPanel::on_frame_decoded);
connect(this, &ImagesPanel::signal_frame_consumed,
dec_obj_, &DecoderThread::on_frame_consumed);
timer_ = new QTimer(this);
connect(timer_, &QTimer::timeout, dec_obj_, &DecoderThread::on_timer);
connect(timer_, &QTimer::timeout, this, &ImagesPanel::on_timer);
timer_->start(300);
}
void ImagesPanel::InitGLWidgets()
{
if (!layout_)
layout_ = new QGridLayout;
// uint32_t glw_idx = 0;
for (uint32_t row = 0; row < layout_row_; ++row) {
for (uint32_t col = 0; col < layout_col_; ++col) {
GLWidget *glw = new GLWidget;
glwidgets_.push_back(glw);
layout_->addWidget(glw, row, col);
}
}
setLayout(layout_);
}
void ImagesPanel::PutLayout()
{
}
void ImagesPanel::on_frame_decoded(uint32_t frame_id, AVFrame* avframe)
{
LOG << "fid: " << frame_id
<< " key:" << avframe->key_frame
<< " pts:" << avframe->pkt_pos
<< " " << avframe->width << "*" << avframe->height
<< " " << avframe;
frames_map.emplace(frame_id, avframe);
uint32_t glw_idx = frame_id % glwidgets_.size();
glwidgets_[glw_idx]->repaint(avframe);
emit signal_frame_consumed(avframe);
}
void ImagesPanel::on_timer()
{
emit signal_require_frames(layout_row_ * layout_col_);
}