X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=h264encode.cpp;h=c7fdeac58d30f4d78c986e78e355ed10086cfce1;hb=6b38f75b24a40c8675c378aaed3792b4be784404;hp=d5c9e8c9e70a905cb4bef7ee53144e3c1aa91836;hpb=6afdb5d6c2a5949fcd956afbd0a2f8f2699587ed;p=nageru diff --git a/h264encode.cpp b/h264encode.cpp index d5c9e8c..c7fdeac 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -110,7 +110,7 @@ class H264EncoderImpl { public: H264EncoderImpl(QSurface *surface, int width, int height, HTTPD *httpd); ~H264EncoderImpl(); - void add_audio(int64_t pts, vector audio); // Needs to come before end_frame() of same pts. + void add_audio(int64_t pts, vector audio); bool begin_frame(GLuint *y_tex, GLuint *cbcr_tex); void end_frame(RefCountedGLsync fence, int64_t pts, const vector &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) {