Move things round a bit.
[dcpomatic.git] / src / lib / options.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file src/options.h
21  *  @brief Options for a transcoding operation.
22  */
23
24 #include <string>
25 #include <iomanip>
26 #include <sstream>
27 #include "util.h"
28
29 /** @class Options
30  *  @brief Options for a transcoding operation.
31  *
32  *  These are settings which may be different, in different circumstances, for
33  *  the same film; ie they are options for a particular transcode operation.
34  */
35 class Options
36 {
37 public:
38
39         Options (std::string f, std::string e, std::string m)
40                 : padding (0)
41                 , apply_crop (true)
42                 , num_frames (0)
43                 , decode_video (true)
44                 , decode_video_frequency (0)
45                 , decode_audio (true)
46                 , _frame_out_path (f)
47                 , _frame_out_extension (e)
48                 , _multichannel_audio_out_path (m)
49         {}
50
51         /** @return The path to write video frames to */
52         std::string frame_out_path () const {
53                 return _frame_out_path;
54         }
55
56         /** @param f Frame index.
57          *  @param t true to return a temporary file path, otherwise a permanent one.
58          *  @return The path to write this video frame to.
59          */
60         std::string frame_out_path (int f, bool t) const {
61                 std::stringstream s;
62                 s << _frame_out_path << "/";
63                 s.width (8);
64                 s << std::setfill('0') << f << _frame_out_extension;
65
66                 if (t) {
67                         s << ".tmp";
68                 }
69
70                 return s.str ();
71         }
72
73         /** @return Path to write multichannel audio data to */
74         std::string multichannel_audio_out_path () const {
75                 return _multichannel_audio_out_path;
76         }
77
78         /** @param c Audio channel index.
79          *  @param t true to return a temporary file path, otherwise a permanent one.
80          *  @return The path to write this audio file to.
81          */
82         std::string multichannel_audio_out_path (int c, bool t) const {
83                 std::stringstream s;
84                 s << _multichannel_audio_out_path << "/" << (c + 1) << ".wav";
85                 if (t) {
86                         s << ".tmp";
87                 }
88
89                 return s.str ();
90         }
91
92         Size out_size;              ///< size of output images
93         float ratio;                ///< ratio of the wanted output image (not considering padding)
94         int padding;                ///< number of pixels of padding (in terms of the output size) each side of the image
95         bool apply_crop;            ///< true to apply cropping
96         int num_frames;             ///< number of video frames to run for, or 0 for all
97         int black_after;            ///< first frame for which to output a black frame, rather than the actual video content, or 0 for none
98         bool decode_video;          ///< true to decode video, otherwise false
99         int decode_video_frequency; ///< skip frames so that this many are decoded in all (or 0) (for generating thumbnails)
100         bool decode_audio;          ///< true to decode audio, otherwise false
101
102 private:
103         /** Path of the directory to write video frames to */
104         std::string _frame_out_path;
105         /** Extension to use for video frame files (including the leading .) */
106         std::string _frame_out_extension;
107         /** Path of the directory to write audio files to */
108         std::string _multichannel_audio_out_path;
109 };