Rename PRORES -> PRORES_HQ
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 705557f799b3b76f434eb182fe116b4a32b03e85..17f6f55cb01413ddebdda3b52df944ce95f8c092 100644 (file)
@@ -127,14 +127,15 @@ public:
                return false;
        }
 
-       void write (int size, int channel_offset, int channels, float** data, int64_t sample_offset)
+       void write (int size, int channel_offset, int channels, float* const* data, int64_t sample_offset)
        {
                DCPOMATIC_ASSERT (size);
 
                auto frame = av_frame_alloc ();
                DCPOMATIC_ASSERT (frame);
 
-               int const buffer_size = av_samples_get_buffer_size (0, channels, size, _codec_context->sample_fmt, 0);
+               int line_size;
+               int const buffer_size = av_samples_get_buffer_size (&line_size, channels, size, _codec_context->sample_fmt, 0);
                DCPOMATIC_ASSERT (buffer_size >= 0);
 
                auto samples = av_malloc (buffer_size);
@@ -169,10 +170,8 @@ public:
                }
                case AV_SAMPLE_FMT_FLTP:
                {
-                       float* q = reinterpret_cast<float*> (samples);
                        for (int i = 0; i < channels; ++i) {
-                               memcpy (q, data[i + channel_offset], sizeof(float) * size);
-                               q += size;
+                               memcpy (reinterpret_cast<float*>(static_cast<uint8_t*>(samples) + i * line_size), data[i + channel_offset], sizeof(float) * size);
                        }
                        break;
                }
@@ -229,7 +228,7 @@ FFmpegFileEncoder::FFmpegFileEncoder (
        _pixel_format = pixel_format (format);
 
        switch (format) {
-       case ExportFormat::PRORES:
+       case ExportFormat::PRORES_HQ:
                _sample_format = AV_SAMPLE_FMT_S16;
                _video_codec_name = "prores_ks";
                _audio_codec_name = "pcm_s16le";
@@ -242,12 +241,6 @@ FFmpegFileEncoder::FFmpegFileEncoder (
                _audio_codec_name = "aac";
                av_dict_set_int (&_video_options, "crf", x264_crf, 0);
                break;
-       case ExportFormat::H264_PCM:
-               _sample_format = AV_SAMPLE_FMT_S32;
-               _video_codec_name = "libx264";
-               _audio_codec_name = "pcm_s24le";
-               av_dict_set_int (&_video_options, "crf", x264_crf, 0);
-               break;
        default:
                DCPOMATIC_ASSERT (false);
        }
@@ -272,7 +265,7 @@ FFmpegFileEncoder::FFmpegFileEncoder (
                throw EncodeError (N_("avformat_write_header"), N_("FFmpegFileEncoder::FFmpegFileEncoder"), r);
        }
 
-       _pending_audio.reset (new AudioBuffers(channels, 0));
+       _pending_audio = make_shared<AudioBuffers>(channels, 0);
 }
 
 
@@ -288,10 +281,9 @@ AVPixelFormat
 FFmpegFileEncoder::pixel_format (ExportFormat format)
 {
        switch (format) {
-       case ExportFormat::PRORES:
+       case ExportFormat::PRORES_HQ:
                return AV_PIX_FMT_YUV422P10;
        case ExportFormat::H264_AAC:
-       case ExportFormat::H264_PCM:
                return AV_PIX_FMT_YUV420P;
        default:
                DCPOMATIC_ASSERT (false);
@@ -400,7 +392,7 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
 {
        /* All our output formats are video range at the moment */
        auto image = video->image (
-               bind (&PlayerVideo::force, _1, _pixel_format),
+               bind (&PlayerVideo::force, _pixel_format),
                VideoRange::VIDEO,
                false
                );