]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Start hacking in support for interpolated frames in the main application.
[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         unsigned pitch_y, pitch_chroma;
19 };
20
21 std::string filename_for_frame(unsigned stream_idx, int64_t pts);
22 std::shared_ptr<Frame> decode_jpeg(const std::string &filename);
23
24 class JPEGFrameView : public QGLWidget {
25         Q_OBJECT
26
27 public:
28         JPEGFrameView(QWidget *parent);
29
30         void setFrame(unsigned stream_idx, int64_t pts)
31         {
32                 this->stream_idx = stream_idx;
33                 this->pts = pts;
34                 update_frame();
35         }
36
37         unsigned get_stream_idx() const { return stream_idx; }
38
39         void setDecodedFrame(std::shared_ptr<Frame> frame);
40
41 protected:
42         void initializeGL() override;
43         void resizeGL(int width, int height) override;
44         void paintGL() override;
45
46 private:
47         void update_frame();
48
49         unsigned stream_idx;
50         int64_t pts;
51
52         std::unique_ptr<movit::EffectChain> chain;
53         std::shared_ptr<Frame> current_frame;  // So that we hold on to the pixels.
54         movit::YCbCrInput *ycbcr_input;
55         movit::YCbCrFormat ycbcr_format;
56 };
57
58 #endif  // !defined(_JPEG_FRAME_VIEW_H)