]> git.sesse.net Git - nageru/blobdiff - h264encode.h
Refcount the input frames directly instead of trying to free them after-the-fact...
[nageru] / h264encode.h
index f355116781cadde6f06c25d5a7c2b8a35b17870d..9525d802c8875a8908e30dfa319b246087ac825c 100644 (file)
 extern "C" {
 #include <libavformat/avformat.h>
 }
-#include <epoxy/egl.h>
+#include <epoxy/gl.h>
 #include <atomic>
+#include <condition_variable>
 #include <map>
 #include <memory>
 #include <mutex>
+#include <queue>
 #include <thread>
-#include <thread>
-#include <thread>
-#include <thread>
-#include <condition_variable>
+#include <vector>
 
-#include "pbo_frame_allocator.h"
+#include "bmusb.h"
 #include "context.h"
+#include "pbo_frame_allocator.h"
+#include "ref_counted_frame.h"
+#include "ref_counted_gl_sync.h"
+
+class QSurface;
 
 #define SURFACE_NUM 16 /* 16 surfaces for source YUV */
 
@@ -63,7 +67,7 @@ public:
        void 
 #endif
        bool begin_frame(GLuint *y_tex, GLuint *cbcr_tex);
-       void end_frame(GLsync fence);
+       void end_frame(RefCountedGLsync fence, const std::vector<RefCountedFrame> &input_frames);
 
 private:
        struct storage_task {
@@ -92,10 +96,12 @@ private:
        //int frame_width, frame_height;
        //int ;
        int current_storage_frame;
-#if 0
-       std::map<int, std::pair<FrameAllocator::Frame, GLsync>> pending_frames;
-#endif
-       std::map<int, GLsync> pending_frames;
+
+       struct PendingFrame {
+               RefCountedGLsync fence;
+               std::vector<RefCountedFrame> input_frames;
+       };
+       std::map<int, PendingFrame> pending_frames;
        QSurface *surface;
 
        AVFormatContext *avctx;