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>
16 #include "jpeg_frame.h"
23 enum CacheMissBehavior {
24 DECODE_IF_NOT_IN_CACHE,
25 RETURN_NULLPTR_IF_NOT_IN_CACHE
28 std::string filename_for_frame(unsigned stream_idx, int64_t pts);
29 std::shared_ptr<Frame> decode_jpeg(const std::string &filename);
30 std::shared_ptr<Frame> decode_jpeg_with_cache(JPEGID id, CacheMissBehavior cache_miss_behavior, bool *did_decode);
32 class JPEGFrameView : public QGLWidget {
36 JPEGFrameView(QWidget *parent);
38 void setFrame(unsigned stream_idx, int64_t pts, bool interpolated);
39 static void insert_interpolated_frame(unsigned stream_idx, int64_t pts, std::shared_ptr<Frame> frame);
41 void mousePressEvent(QMouseEvent *event) override;
43 unsigned get_stream_idx() const { return current_stream_idx; }
45 void setDecodedFrame(std::shared_ptr<Frame> frame);
46 void set_overlay(const std::string &text); // Blank for none.
48 static void shutdown();
54 void initializeGL() override;
55 void resizeGL(int width, int height) override;
56 void paintGL() override;
59 // The stream index of the latest frame we displayed.
60 unsigned current_stream_idx = 0;
62 std::unique_ptr<movit::EffectChain> planar_chain;
63 std::shared_ptr<Frame> current_frame; // So that we hold on to the pixels.
64 movit::YCbCrInput *ycbcr_planar_input;
65 movit::YCbCrFormat ycbcr_format;
67 std::unique_ptr<movit::EffectChain> semiplanar_chain;
68 movit::YCbCrInput *ycbcr_semiplanar_input;
70 static constexpr int overlay_base_width = 16, overlay_base_height = 16;
71 int overlay_width = overlay_base_width, overlay_height = overlay_base_height;
72 std::unique_ptr<QImage> overlay_image; // If nullptr, no overlay.
73 std::unique_ptr<movit::EffectChain> overlay_chain; // Just to get the overlay on screen in the easiest way possible.
74 movit::FlatInput *overlay_input;
75 bool overlay_input_needs_refresh = false;
77 int gl_width, gl_height;
79 static std::thread jpeg_decoder_thread;
82 #endif // !defined(_JPEG_FRAME_VIEW_H)