Cleanup: white space.
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 0d5167c496c109ae0b7f4db56d28ee350d4134e8..6799d09b4b6b66a306774a9f511bbe6341726f12 100644 (file)
@@ -325,7 +325,7 @@ FFmpegFileEncoder::setup_video ()
        _video_codec_context->flags |= AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_GLOBAL_HEADER;
 
        if (avcodec_open2 (_video_codec_context, _video_codec, &_video_options) < 0) {
-               throw EncodeError (N_("avcodec_open"), N_("FFmpegFileEncoder::setup_video"));
+               throw EncodeError(N_("avcodec_open2"), N_("FFmpegFileEncoder::setup_video"));
        }
 
        _video_stream = avformat_new_stream (_format_context, _video_codec);
@@ -410,13 +410,8 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
        auto frame = av_frame_alloc ();
        DCPOMATIC_ASSERT (frame);
 
-       {
-               boost::mutex::scoped_lock lm (_pending_images_mutex);
-               _pending_images[image->data()[0]] = image;
-       }
-
        for (int i = 0; i < 3; ++i) {
-               auto buffer = av_buffer_create(image->data()[i], image->stride()[i] * image->size().height, &buffer_free, this, 0);
+               auto buffer = _pending_images.create_buffer(image, i);
                frame->buf[i] = av_buffer_ref (buffer);
                frame->data[i] = buffer->data;
                frame->linesize[i] = image->stride()[i];
@@ -490,20 +485,3 @@ FFmpegFileEncoder::subtitle (PlayerText, DCPTimePeriod)
 {
 
 }
-
-
-void
-FFmpegFileEncoder::buffer_free (void* opaque, uint8_t* data)
-{
-       reinterpret_cast<FFmpegFileEncoder*>(opaque)->buffer_free2(data);
-}
-
-
-void
-FFmpegFileEncoder::buffer_free2 (uint8_t* data)
-{
-       boost::mutex::scoped_lock lm (_pending_images_mutex);
-       if (_pending_images.find(data) != _pending_images.end()) {
-               _pending_images.erase (data);
-       }
-}