]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Support JPEGs that are not 4:2:2.
[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         unsigned chroma_subsampling_x, chroma_subsampling_y;
18 };
19
20 class JPEGFrameView : public QGLWidget {
21         Q_OBJECT
22
23 public:
24         JPEGFrameView(QWidget *parent);
25
26         void setFrame(unsigned stream_idx, int64_t pts)
27         {
28                 this->stream_idx = stream_idx;
29                 this->pts = pts;
30                 update_frame();
31         }
32
33         void setDecodedFrame(std::shared_ptr<Frame> frame);
34
35 protected:
36         void initializeGL() override;
37         void resizeGL(int width, int height) override;
38         void paintGL() override;
39
40 private:
41         void update_frame();
42
43         unsigned stream_idx;
44         int64_t pts;
45
46         std::unique_ptr<movit::EffectChain> chain;
47         std::shared_ptr<Frame> current_frame;  // So that we hold on to the pixels.
48         movit::YCbCrInput *ycbcr_input;
49         movit::YCbCrFormat ycbcr_format;
50 };
51
52 #endif  // !defined(_JPEG_FRAME_VIEW_H)