X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_output.h;h=44eb86dea9860e6480c4552aeaf352a5990bf979;hb=d3e48df512d9476d3849227067792a3537bb094e;hp=d5e743aa2e801cc91d1156f082c2fe15e34a17ef;hpb=9aabf53d2ee424e66e3d51039a7a8ecce25f3516;p=nageru diff --git a/decklink_output.h b/decklink_output.h index d5e743a..44eb86d 100644 --- a/decklink_output.h +++ b/decklink_output.h @@ -2,6 +2,7 @@ #define _DECKLINK_OUTPUT_H 1 #include +#include #include #include #include @@ -18,6 +19,7 @@ #include "context.h" #include "print_latency.h" +#include "quittable_sleeper.h" #include "ref_counted_frame.h" #include "ref_counted_gl_sync.h" @@ -36,11 +38,11 @@ class DeckLinkOutput : public IDeckLinkVideoOutputCallback { public: DeckLinkOutput(movit::ResourcePool *resource_pool, QSurface *surface, unsigned width, unsigned height, unsigned card_index); - void set_device(IDeckLink *output); + bool set_device(IDeckLink *output); void start_output(uint32_t mode, int64_t base_pts); // Mode comes from get_available_video_modes(). void end_output(); - void send_frame(GLuint y_tex, GLuint cbcr_tex, const std::vector &input_frames, int64_t pts, int64_t duration); + void send_frame(GLuint y_tex, GLuint cbcr_tex, movit::YCbCrLumaCoefficients ycbcr_coefficients, const std::vector &input_frames, int64_t pts, int64_t duration); void send_audio(int64_t pts, const std::vector &samples); // NOTE: The returned timestamp is undefined for preroll. @@ -59,6 +61,9 @@ public: // If the given mode is supported, return it. If not, pick some “best” valid mode. uint32_t pick_video_mode(uint32_t mode) const; + // Desired Y'CbCr coefficients for the current mode. Undefined before start_output(). + movit::YCbCrLumaCoefficients preferred_ycbcr_coefficients() const; + // IUnknown. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) override; ULONG STDMETHODCALLTYPE AddRef() override; @@ -98,7 +103,7 @@ private: movit::ResourcePool *resource_pool; // These members are persistently allocated, and reused when the frame object is. - GLuint uyvy_tex; // Owned by . + GLuint uyvy_tex; // Owned by . Can also hold v210 data. GLuint pbo; uint8_t *uyvy_ptr; // Persistent mapping into the PBO. @@ -123,7 +128,7 @@ private: std::map video_modes; std::thread present_thread; - std::atomic should_quit{false}; + QuittableSleeper should_quit; std::mutex frame_queue_mutex; std::queue> pending_video_frames; // Under . @@ -132,6 +137,8 @@ private: std::condition_variable frame_queues_changed; bool playback_initiated = false, playback_started = false; int64_t base_pts, frame_duration; + BMDDisplayModeFlags current_mode_flags = 0; + bool last_frame_had_mode_mismatch = false; movit::ResourcePool *resource_pool; IDeckLinkOutput *output = nullptr;