2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 /** @file src/film_state.h
21 * @brief The state of a Film. This is separate from Film so that
22 * state can easily be copied and kept around for reference
23 * by long-running jobs. This avoids the jobs getting confused
24 * by the user changing Film settings during their run.
27 #ifndef DVDOMATIC_FILM_STATE_H
28 #define DVDOMATIC_FILM_STATE_H
31 #include <libavcodec/avcodec.h>
32 #include <libswscale/swscale.h>
36 #include "trim_action.h"
43 * @brief The state of a Film.
45 * This is separate from Film so that state can easily be copied and
46 * kept around for reference by long-running jobs. This avoids the
47 * jobs getting confused by the user changing Film settings during
55 : dcp_content_type (0)
56 , frames_per_second (0)
58 , scaler (Scaler::from_id ("bicubic"))
60 , dcp_trim_action (CUT)
65 , with_subtitles (false)
68 , audio_sample_rate (0)
69 , audio_sample_format (AV_SAMPLE_FMT_NONE)
70 , has_subtitles (false)
73 std::string file (std::string f) const;
74 std::string dir (std::string d) const;
76 std::string content_path () const;
77 ContentType content_type () const;
79 bool content_is_dvd () const;
81 std::string thumb_file (int) const;
82 std::string thumb_base (int) const;
83 int thumb_frame (int) const;
85 int bytes_per_sample () const;
86 int target_sample_rate () const;
88 void write_metadata (std::ofstream &) const;
89 void read_metadata (std::string, std::string);
91 Size cropped_size (Size) const;
93 int dcp_length () const;
95 /** Complete path to directory containing the film metadata;
98 std::string directory;
99 /** Name for DVD-o-matic */
101 /** File or directory containing content; may be relative to our directory
102 * or an absolute path.
105 /** The type of content that this Film represents (feature, trailer etc.) */
106 DCPContentType const * dcp_content_type;
107 /** Frames per second of the source */
108 float frames_per_second;
109 /** The format to present this Film in (flat, scope, etc.) */
110 Format const * format;
112 /** Video filters that should be used when generating DCPs */
113 std::vector<Filter const *> filters;
114 /** Scaler algorithm to use */
115 Scaler const * scaler;
116 /** Number of frames to put in the DCP, or 0 for all */
119 TrimAction dcp_trim_action;
121 /** true to create an A/B comparison DCP, where the left half of the image
122 is the video without any filters or post-processing, and the right half
123 has the specified filters and post-processing.
126 /** Gain to apply to audio in dB */
128 /** Delay to apply to audio (positive moves audio later) in milliseconds */
130 /** Duration to make still-sourced films (in seconds) */
134 /* Data which is cached to speed things up */
136 /** Vector of frame indices for each of our `thumbnails' */
137 std::vector<int> thumbs;
138 /** Size, in pixels, of the source (ignoring cropping) */
140 /** Length of the source in frames */
142 /** Number of audio channels */
144 /** Sample rate of the source audio, in Hz */
145 int audio_sample_rate;
146 /** Format of the audio samples */
147 AVSampleFormat audio_sample_format;
148 /** MD5 digest of our content file */
149 std::string content_digest;
150 /** true if the source has subtitles */
154 std::string thumb_file_for_frame (int) const;
155 std::string thumb_base_for_frame (int) const;