1 #ifndef _JPEG_FRAME_VIEW_H
2 #define _JPEG_FRAME_VIEW_H 1
9 #include <movit/effect_chain.h>
10 #include <movit/flat_input.h>
11 #include <movit/ycbcr_input.h>
21 std::unique_ptr<uint8_t[]> y, cb, cr;
22 unsigned width, height;
23 unsigned chroma_subsampling_x, chroma_subsampling_y;
24 unsigned pitch_y, pitch_chroma;
26 enum CacheMissBehavior {
27 DECODE_IF_NOT_IN_CACHE,
28 RETURN_NULLPTR_IF_NOT_IN_CACHE
31 std::string filename_for_frame(unsigned stream_idx, int64_t pts);
32 std::shared_ptr<Frame> decode_jpeg(const std::string &filename);
33 std::shared_ptr<Frame> decode_jpeg_with_cache(JPEGID id, CacheMissBehavior cache_miss_behavior, bool *did_decode);
35 class JPEGFrameView : public QGLWidget {
39 JPEGFrameView(QWidget *parent);
41 void setFrame(unsigned stream_idx, int64_t pts, bool interpolated);
42 static void insert_interpolated_frame(unsigned stream_idx, int64_t pts, std::shared_ptr<Frame> frame);
44 void mousePressEvent(QMouseEvent *event) override;
46 unsigned get_stream_idx() const { return current_stream_idx; }
48 void setDecodedFrame(std::shared_ptr<Frame> frame);
49 void set_overlay(const std::string &text); // Blank for none.
55 void initializeGL() override;
56 void resizeGL(int width, int height) override;
57 void paintGL() override;
60 // The stream index of the latest frame we displayed.
61 unsigned current_stream_idx;
63 std::unique_ptr<movit::EffectChain> chain;
64 std::shared_ptr<Frame> current_frame; // So that we hold on to the pixels.
65 movit::YCbCrInput *ycbcr_input;
66 movit::YCbCrFormat ycbcr_format;
68 static constexpr int overlay_width = 16, overlay_height = 16;
69 std::unique_ptr<QImage> overlay_image; // If nullptr, no overlay.
70 std::unique_ptr<movit::EffectChain> overlay_chain; // Just to get the overlay on screen in the easiest way possible.
71 movit::FlatInput *overlay_input;
72 bool overlay_input_needs_refresh = false;
75 #endif // !defined(_JPEG_FRAME_VIEW_H)