BOOST_FOREACH.
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 511730185716ddba8368b828f76228f775d5eeba..0eea003a92dda1f4a282af05988ca24811c03b93 100644 (file)
@@ -35,9 +35,9 @@ using std::string;
 using std::runtime_error;
 using std::cout;
 using std::pair;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::bind;
-using boost::weak_ptr;
+using std::weak_ptr;
 using boost::optional;
 using namespace dcpomatic;
 #if BOOST_VERSION >= 106100
@@ -80,6 +80,7 @@ public:
                }
 
                _stream->id = stream_index;
+               _stream->disposition |= AV_DISPOSITION_DEFAULT;
 DCPOMATIC_DISABLE_WARNINGS
                _stream->codec = _codec_context;
 DCPOMATIC_ENABLE_WARNINGS
@@ -217,10 +218,6 @@ FFmpegFileEncoder::FFmpegFileEncoder (
        bool audio_stream_per_channel,
        int x264_crf,
        boost::filesystem::path output
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-       , optional<dcp::Key> key
-       , optional<string> id
-#endif
        )
        : _audio_stream_per_channel (audio_stream_per_channel)
        , _video_options (0)
@@ -257,11 +254,7 @@ FFmpegFileEncoder::FFmpegFileEncoder (
                DCPOMATIC_ASSERT (false);
        }
 
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-       int r = avformat_alloc_output_context2 (&_format_context, av_guess_format("mov", 0, 0), 0, 0);
-#else
        int r = avformat_alloc_output_context2 (&_format_context, 0, 0, _output.string().c_str());
-#endif
        if (!_format_context) {
                throw runtime_error (String::compose("could not allocate FFmpeg format context (%1)", r));
        }
@@ -276,21 +269,6 @@ FFmpegFileEncoder::FFmpegFileEncoder (
 
        AVDictionary* options = 0;
 
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-       if (key) {
-               av_dict_set (&options, "encryption_key", key->hex().c_str(), 0);
-               /* XXX: is this OK? */
-               av_dict_set (&options, "encryption_kid", "00000000000000000000000000000000", 0);
-               av_dict_set (&options, "encryption_scheme", "cenc-aes-ctr", 0);
-       }
-
-       if (id) {
-               if (av_dict_set(&_format_context->metadata, SWAROOP_ID_TAG, id->c_str(), 0) < 0) {
-                       throw runtime_error ("Could not write ID to output");
-               }
-       }
-#endif
-
        if (avformat_write_header (_format_context, &options) < 0) {
                throw runtime_error ("could not write header to FFmpeg output file");
        }
@@ -407,7 +385,7 @@ DCPOMATIC_ENABLE_WARNINGS
                av_packet_unref (&packet);
 
                flushed_audio = true;
-               BOOST_FOREACH (shared_ptr<ExportAudioStream> i, _audio_streams) {
+               for (auto i: _audio_streams) {
                        if (!i->flush()) {
                                flushed_audio = false;
                        }
@@ -420,8 +398,10 @@ DCPOMATIC_ENABLE_WARNINGS
 void
 FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
 {
+       /* All our output formats are video range at the moment */
        shared_ptr<Image> image = video->image (
                bind (&PlayerVideo::force, _1, _pixel_format),
+               VIDEO_RANGE_VIDEO,
                true,
                false
                );
@@ -493,7 +473,7 @@ FFmpegFileEncoder::audio_frame (int size)
 {
        if (_audio_stream_per_channel) {
                int offset = 0;
-               BOOST_FOREACH (shared_ptr<ExportAudioStream> i, _audio_streams) {
+               for (auto i: _audio_streams) {
                        i->write (size, offset, 1, _pending_audio->data(), _audio_frames);
                        ++offset;
                }