]> git.sesse.net Git - nageru/blobdiff - h264encode.cpp
Run IWYU (plus lots of manual fiddling).
[nageru] / h264encode.cpp
index 33057a890359e4abd98e3bd2341b527f6be55cb8..db0ba93588fc72f9061e491c694910bc0f4f3180 100644 (file)
@@ -1,28 +1,34 @@
 //#include "sysdeps.h"
+#include "h264encode.h"
+
+#include <EGL/eglplatform.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <assert.h>
+#include <epoxy/egl.h>
+#include <libavcodec/avcodec.h>
+#include <libavformat/avio.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/rational.h>
+#include <libdrm/drm_fourcc.h>
+#include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <assert.h>
-#include <pthread.h>
-#include <errno.h>
-#include <math.h>
+#include <string.h>
 #include <va/va.h>
-#include <va/va_x11.h>
-#include <va/va_enc_h264.h>
 #include <va/va_drmcommon.h>
-#include <libdrm/drm_fourcc.h>
-#include <thread>
+#include <va/va_enc_h264.h>
+#include <va/va_x11.h>
+#include <condition_variable>
 #include <mutex>
 #include <queue>
-#include <condition_variable>
-#include "h264encode.h"
+#include <string>
+#include <thread>
+
+#include "context.h"
+
+class QOpenGLContext;
+class QSurface;
 
 #define CHECK_VASTATUS(va_status, func)                                 \
     if (va_status != VA_STATUS_SUCCESS) {                               \
@@ -1740,10 +1746,9 @@ H264Encoder::H264Encoder(QSurface *surface, int width, int height, const char *o
                fprintf(stderr, "%s: avformat_new_stream() failed\n", output_filename);
                exit(1);
        }
-       avstream->time_base = AVRational{1, frame_rate};  // TODO
+       avstream->time_base = AVRational{1, frame_rate};
        avstream->codec->width = width;
        avstream->codec->height = height;
-       //avstream->codec->time_base = AVRational{1, 60};  // TODO
        avstream->codec->time_base = AVRational{1, frame_rate};
        avstream->codec->ticks_per_frame = 1;  // or 2?
 
@@ -1875,7 +1880,7 @@ bool H264Encoder::begin_frame(GLuint *y_tex, GLuint *cbcr_tex)
        return true;
 }
 
-void H264Encoder::end_frame(GLsync fence, const std::vector<FrameAllocator::Frame> &input_frames_to_release)
+void H264Encoder::end_frame(RefCountedGLsync fence, const std::vector<FrameAllocator::Frame> &input_frames_to_release)
 {
        {
                unique_lock<mutex> lock(frame_queue_mutex);
@@ -1905,8 +1910,7 @@ void H264Encoder::copy_thread_func()
                }
 
                // Wait for the GPU to be done with the frame.
-               glClientWaitSync(frame.fence, 0, 0);
-               glDeleteSync(frame.fence);
+               glClientWaitSync(frame.fence.get(), 0, 0);
 
                // Release back any input frames we needed to render this frame.
                // (Actually, those that were needed one output frame ago.)