summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_file_encoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-11-06 23:19:00 +0100
committerCarl Hetherington <cth@carlh.net>2022-11-06 23:19:04 +0100
commitc42ce0e5b188d6fe0b022f1aec4fdcb04c4835f1 (patch)
tree0af522285bfacf0eb464a17b4bfecebc8a04e3d5 /src/lib/ffmpeg_file_encoder.cc
parent8a9b2db6f7a51d6bb1fb4bf6f37db33599cfd0fc (diff)
Strictly I think we should be putting each component of an image into _pending_images.
We probably get away with only keeping component 0 but I think that could perhaps lead to use-after-free as the Image for components 1 and 2 could go away a bit before it should.
Diffstat (limited to 'src/lib/ffmpeg_file_encoder.cc')
-rw-r--r--src/lib/ffmpeg_file_encoder.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc
index 6f33700a2..791edb9bc 100644
--- a/src/lib/ffmpeg_file_encoder.cc
+++ b/src/lib/ffmpeg_file_encoder.cc
@@ -410,18 +410,18 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
auto frame = av_frame_alloc ();
DCPOMATIC_ASSERT (frame);
- {
- boost::mutex::scoped_lock lm (_pending_images_mutex);
- auto key = image->data()[0];
- auto iter = _pending_images.find(key);
- if (iter != _pending_images.end()) {
- iter->second.second++;
- } else {
- _pending_images[key] = { image, 1 };
+ for (int i = 0; i < 3; ++i) {
+ {
+ boost::mutex::scoped_lock lm (_pending_images_mutex);
+ auto key = image->data()[i];
+ auto iter = _pending_images.find(key);
+ if (iter != _pending_images.end()) {
+ iter->second.second++;
+ } else {
+ _pending_images[key] = { image, 1 };
+ }
}
- }
- 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);
frame->buf[i] = av_buffer_ref (buffer);
frame->data[i] = buffer->data;