summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_file_encoder.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-10-24 20:37:02 +0200
committerCarl Hetherington <cth@carlh.net>2022-10-25 16:08:34 +0200
commite55b2b3a7eb05b3cc69411b133aeec9772420c83 (patch)
tree633c6295351e6feed73b98add6d24be3f17d49d0 /src/lib/ffmpeg_file_encoder.h
parent811cd49873641f612a1df12b5b9d7d26bc289759 (diff)
Hopefully fix crash when the same frame is encoded twice.
Previously if some frame X was passed to the encoder twice I think this would happen: X1 written; X stored to _pending_images X2 written; _pending_images remains the same X1 encode finishes; X is discarded from _pending_images Data for X2 is read by the encoder but was just freed I think this might have resulted in intermittent crashes, which were fairly common in the 2.17.x branch with the test ffmpeg_encoder_prores_regression_1 But I didn't conclusively prove it.
Diffstat (limited to 'src/lib/ffmpeg_file_encoder.h')
-rw-r--r--src/lib/ffmpeg_file_encoder.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/ffmpeg_file_encoder.h b/src/lib/ffmpeg_file_encoder.h
index 5bf501370..f0b3eac8c 100644
--- a/src/lib/ffmpeg_file_encoder.h
+++ b/src/lib/ffmpeg_file_encoder.h
@@ -106,9 +106,10 @@ private:
std::shared_ptr<AudioBuffers> _pending_audio;
/** Store of shared_ptr<Image> to keep them alive whilst raw pointers into
- their data have been passed to FFmpeg.
+ their data have been passed to FFmpeg. The second part of the pair is
+ a count of how many copies of the same key must be kept.
*/
- std::map<uint8_t*, std::shared_ptr<const Image>> _pending_images;
+ std::map<uint8_t*, std::pair<std::shared_ptr<const Image>, int>> _pending_images;
boost::mutex _pending_images_mutex;
static int _video_stream_index;