Tidy and fix logging.
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 7cc4d26a47031f3ee1160eda413968c365dc20ee..2c67bb5f927be110d0cbadea7f0d110beb0a8f4d 100644 (file)
@@ -26,7 +26,6 @@
 #include "log.h"
 #include "image.h"
 #include "cross.h"
-#include "butler.h"
 #include "compose.hpp"
 #include <iostream>
 
@@ -48,7 +47,6 @@ FFmpegFileEncoder::FFmpegFileEncoder (
        int video_frame_rate,
        int audio_frame_rate,
        int channels,
-       shared_ptr<Log> log,
        ExportFormat format,
        int x264_crf,
        boost::filesystem::path output
@@ -59,11 +57,11 @@ FFmpegFileEncoder::FFmpegFileEncoder (
        , _video_frame_size (video_frame_size)
        , _video_frame_rate (video_frame_rate)
        , _audio_frame_rate (audio_frame_rate)
-       , _log (log)
 {
+       _pixel_format = pixel_format (format);
+
        switch (format) {
        case EXPORT_FORMAT_PRORES:
-               _pixel_format = AV_PIX_FMT_YUV422P10;
                _sample_format = AV_SAMPLE_FMT_S16;
                _video_codec_name = "prores_ks";
                _audio_codec_name = "pcm_s16le";
@@ -71,7 +69,6 @@ FFmpegFileEncoder::FFmpegFileEncoder (
                av_dict_set (&_video_options, "threads", "auto", 0);
                break;
        case EXPORT_FORMAT_H264:
-               _pixel_format = AV_PIX_FMT_YUV420P;
                _sample_format = AV_SAMPLE_FMT_FLTP;
                _video_codec_name = "libx264";
                _audio_codec_name = "aac";
@@ -125,6 +122,21 @@ FFmpegFileEncoder::FFmpegFileEncoder (
        _pending_audio.reset (new AudioBuffers(channels, 0));
 }
 
+AVPixelFormat
+FFmpegFileEncoder::pixel_format (ExportFormat format)
+{
+       switch (format) {
+       case EXPORT_FORMAT_PRORES:
+               return AV_PIX_FMT_YUV422P10;
+       case EXPORT_FORMAT_H264:
+               return AV_PIX_FMT_YUV420P;
+       default:
+               DCPOMATIC_ASSERT (false);
+       }
+
+       return AV_PIX_FMT_YUV422P10;
+}
+
 void
 FFmpegFileEncoder::setup_video ()
 {