]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Convert Y'CbCr using Movit instead of in software with Qt. Saves a fair amount of...
[nageru] / jpeg_frame_view.h
1 #ifndef _JPEG_FRAME_VIEW_H
2 #define _JPEG_FRAME_VIEW_H 1
3
4 #include <epoxy/gl.h>
5 #include <QGLWidget>
6
7 #include <stdint.h>
8
9 #include <movit/effect_chain.h>
10 #include <movit/ycbcr_input.h>
11
12 #include <memory>
13
14 struct Frame {
15         std::unique_ptr<uint8_t[]> y, cb, cr;
16         unsigned width, height;
17 };
18
19 class JPEGFrameView : public QGLWidget {
20         Q_OBJECT
21
22 public:
23         JPEGFrameView(QWidget *parent);
24
25         void setFrame(unsigned stream_idx, int64_t pts)
26         {
27                 this->stream_idx = stream_idx;
28                 this->pts = pts;
29                 update_frame();
30         }
31
32         void setDecodedFrame(std::shared_ptr<Frame> frame);
33
34 protected:
35         void initializeGL() override;
36         void resizeGL(int width, int height) override;
37         void paintGL() override;
38
39 private:
40         void update_frame();
41
42         unsigned stream_idx;
43         int64_t pts;
44
45         std::unique_ptr<movit::EffectChain> chain;
46         std::shared_ptr<Frame> current_frame;  // So that we hold on to the pixels.
47         movit::YCbCrInput *ycbcr_input;
48 };
49
50 #endif  // !defined(_JPEG_FRAME_VIEW_H)