Add memory buffer allocated by cuda and XYZ->RGB conversion;
[dcpomatic.git] / src / lib / fastvideo_player_video_preparer.h
1 #include "cpu_player_video_preparer.h"
2 #include "player_video_preparer.h"
3 #include <dcp/data.h>
4 #include <fastvideo_decoder_j2k.h>
5 #include <fastvideo_sdk.h>
6 #include <boost/shared_ptr.hpp>
7 #include <boost/thread.hpp>
8 #include <boost/thread/condition.hpp>
9 #include <boost/weak_ptr.hpp>
10 #include <queue>
11
12
13 class J2KImageProxy;
14
15
16 class FastvideoPlayerVideoPreparer : public PlayerVideoPreparer
17 {
18 public:
19         FastvideoPlayerVideoPreparer (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast);
20         ~FastvideoPlayerVideoPreparer ();
21
22         void request (boost::shared_ptr<PlayerVideo> pv);
23
24 private:
25         void thread ();
26         void setup (dcp::Data sample);
27         void send_to_gpu (boost::shared_ptr<PlayerVideo> pv, boost::shared_ptr<const J2KImageProxy> proxy);
28         void transform_and_extract ();
29
30         std::queue<boost::weak_ptr<PlayerVideo> > _queue;
31         boost::mutex _mutex;
32         boost::condition _work;
33
34         boost::atomic<bool> _stop_thread;
35         boost::thread _thread;
36
37         fastDecoderJ2kHandle_t _decoder;
38         fastDeviceSurfaceBufferHandle_t _buffer;
39         fastExportToHostHandle_t _adapter;
40         bool _setup_done;
41
42         std::vector<boost::weak_ptr<PlayerVideo> > _batch;
43         void* _decoded;
44         int _decoded_stride;
45
46         CPUPlayerVideoPreparer _cpu;
47
48         static const int max_batch_size = 16;
49         static const int max_stream_size = 1302083;
50 };
51