]> git.sesse.net Git - nageru/blobdiff - h264encode.cpp
Mark API entry points in theme.lua clearly as such.
[nageru] / h264encode.cpp
index d5c9e8c9e70a905cb4bef7ee53144e3c1aa91836..78e34474b80e07a397c41dbaf3a0cf70d1807a3d 100644 (file)
@@ -110,7 +110,7 @@ class H264EncoderImpl {
 public:
        H264EncoderImpl(QSurface *surface, int width, int height, HTTPD *httpd);
        ~H264EncoderImpl();
-       void add_audio(int64_t pts, vector<float> audio);  // Needs to come before end_frame() of same pts.
+       void add_audio(int64_t pts, vector<float> audio);
        bool begin_frame(GLuint *y_tex, GLuint *cbcr_tex);
        void end_frame(RefCountedGLsync fence, int64_t pts, const vector<RefCountedFrame> &input_frames);
        void shutdown();
@@ -293,7 +293,11 @@ bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits)
         bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val);
     } else {
         size_in_bits -= bit_left;
-        bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits);
+        if (bit_left >= 32) {
+            bs->buffer[pos] = (val >> size_in_bits);
+        } else {
+            bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits);
+        }
         bs->buffer[pos] = va_swap32(bs->buffer[pos]);
 
         if (pos + 1 == bs->max_size_in_dword) {
@@ -1440,7 +1444,7 @@ void H264EncoderImpl::save_codeddata(storage_task task)
 
     string data;
 
-    const int64_t global_delay = (ip_period - 1) * (TIMEBASE / MAX_FPS);  // So we never get negative dts.
+    const int64_t global_delay = int64_t(ip_period - 1) * (TIMEBASE / MAX_FPS);  // So we never get negative dts.
 
     va_status = vaMapBuffer(va_dpy, gl_surfaces[task.display_order % SURFACE_NUM].coded_buf, (void **)(&buf_list));
     CHECK_VASTATUS(va_status, "vaMapBuffer");