Hopefully fix crash when the same frame is encoded twice.
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.h
index 9f3d88551266b26a184f03fa37f2d4f34e690e36..f0b3eac8c1fa1f610f3bdbe6108a3190edba6578 100644 (file)
 #define DCPOMATIC_FFMPEG_FILE_ENCODER_H
 
 
+#include "audio_mapping.h"
+#include "dcpomatic_time.h"
 #include "encoder.h"
 #include "event_history.h"
-#include "audio_mapping.h"
 #include "log.h"
-#include "warnings.h"
 #include <dcp/key.h>
-DCPOMATIC_DISABLE_WARNINGS
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 }
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 
 class ExportAudioStream;
 
 
+enum class ExportFormat
+{
+       PRORES_4444,
+       PRORES_HQ,
+       H264_AAC,
+       SUBTITLES_DCP
+};
+
+
 class FFmpegFileEncoder
 {
 public:
@@ -96,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;