]> git.sesse.net Git - nageru/blobdiff - x264_encoder.cpp
Don't bother making AVPackets if x264 has no data for us.
[nageru] / x264_encoder.cpp
index 9874519362aadf8a3059eb77f2e797243d230459..6006e0e6843b0c32204411c4681d89edef754e25 100644 (file)
@@ -1,14 +1,20 @@
+#include "x264_encoder.h"
+
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <x264.h>
+#include <cstdint>
 
 #include "defs.h"
 #include "flags.h"
 #include "mux.h"
 #include "timebase.h"
-#include "x264_encoder.h"
 #include "x264_speed_control.h"
 
 extern "C" {
+#include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 }
 
@@ -188,6 +194,7 @@ void X264Encoder::encoder_thread_func()
                // No exit; it's not fatal.
        }
        init_x264();
+       x264_init_done = true;
 
        bool frames_left;
 
@@ -271,6 +278,8 @@ void X264Encoder::encode_frame(X264Encoder::QueuedFrame qf)
                speed_control->after_frame();
        }
 
+       if (num_nal == 0) return;
+
        // We really need one AVPacket for the entire frame, it seems,
        // so combine it all.
        size_t num_bytes = buffered_sei.size();