Build fixes for Boost >= 1.73
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index d7a56f01eb95ccb311bd15c1e883c525e9e08ac5..2c5faa461e75b5120ca390e81cf25e3c4ccacdb8 100644 (file)
@@ -38,6 +38,9 @@ using std::pair;
 using boost::shared_ptr;
 using boost::bind;
 using boost::weak_ptr;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 
 int FFmpegFileEncoder::_video_stream_index = 0;
 int FFmpegFileEncoder::_audio_stream_index = 1;
@@ -244,7 +247,11 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
        AVFrame* frame = av_frame_alloc ();
        DCPOMATIC_ASSERT (frame);
 
-       _pending_images[image->data()[0]] = image;
+       {
+               boost::mutex::scoped_lock lm (_pending_images_mutex);
+               _pending_images[image->data()[0]] = image;
+       }
+
        for (int i = 0; i < 3; ++i) {
                AVBufferRef* buffer = av_buffer_create(image->data()[i], image->stride()[i] * image->size().height, &buffer_free, this, 0);
                frame->buf[i] = av_buffer_ref (buffer);
@@ -256,7 +263,8 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
        frame->width = image->size().width;
        frame->height = image->size().height;
        frame->format = _pixel_format;
-       frame->pts = time.seconds() / av_q2d (_video_stream->time_base);
+       DCPOMATIC_ASSERT (_video_stream->time_base.num == 1);
+       frame->pts = time.get() * _video_stream->time_base.den / DCPTime::HZ;
 
        AVPacket packet;
        av_init_packet (&packet);
@@ -378,7 +386,7 @@ FFmpegFileEncoder::buffer_free (void* opaque, uint8_t* data)
 void
 FFmpegFileEncoder::buffer_free2 (uint8_t* data)
 {
-       /* XXX: does this need a lock to prevent cross-thread access to _pending_images? */
+       boost::mutex::scoped_lock lm (_pending_images_mutex);
        if (_pending_images.find(data) != _pending_images.end()) {
                _pending_images.erase (data);
        }