X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmjpeg_encoder.cpp;h=07deae02289a3c321a6a4c58c036a8c96109ccb8;hb=271ddbb0c7e84560e73e89b1a125576477f95380;hp=3587d78dcf3fa51a61a92af89ec362b3297b2d3e;hpb=eeda8995329601f9f4e35047358400833eeae68e;p=nageru diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 3587d78..07deae0 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -177,6 +177,11 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display) running = true; } +MJPEGEncoder::~MJPEGEncoder() +{ + av_free(avctx->pb->buffer); +} + void MJPEGEncoder::stop() { if (!running) { @@ -268,7 +273,7 @@ void MJPEGEncoder::encoder_thread_func() unique_lock lock(mu); for (;;) { any_frames_to_be_encoded.wait(lock, [this] { return !frames_to_be_encoded.empty() || should_quit; }); - if (should_quit) return; + if (should_quit) break; QueuedFrame qf = move(frames_to_be_encoded.front()); frames_to_be_encoded.pop(); @@ -288,6 +293,11 @@ void MJPEGEncoder::encoder_thread_func() exit(1); } } + + free(tmp_y); + free(tmp_cbcr); + free(tmp_cb); + free(tmp_cr); } class VABufferDestroyer { @@ -389,6 +399,10 @@ void MJPEGEncoder::init_jpeg_422(unsigned width, unsigned height, VectorDestinat cinfo->comp_info[2].v_samp_factor = 1; cinfo->CCIR601_sampling = true; // Seems to be mostly ignored by libjpeg, though. jpeg_start_compress(cinfo, true); + + // This comment marker is private to FFmpeg. It signals limited Y'CbCr range + // (and nothing else). + jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)"CS=ITU601", strlen("CS=ITU601")); } vector MJPEGEncoder::get_jpeg_header(unsigned width, unsigned height, jpeg_compress_struct *cinfo)