Missed update to private test repo version.
[dcpomatic.git] / src / lib / subtitle_analysis.h
1 /*
2     Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "rect.h"
23 #include <boost/filesystem.hpp>
24
25
26 /** @class SubtitleAnalysis
27  *  @brief Class to store the results of a SubtitleAnalysisJob.
28  */
29 class SubtitleAnalysis
30 {
31 public:
32         explicit SubtitleAnalysis (boost::filesystem::path path);
33
34         SubtitleAnalysis (
35                         boost::optional<dcpomatic::Rect<double>> bounding_box,
36                         double analysis_x_offset_,
37                         double analysis_y_offset_
38                         )
39                 : _bounding_box (bounding_box)
40                 , _analysis_x_offset (analysis_x_offset_)
41                 , _analysis_y_offset (analysis_y_offset_)
42         {}
43
44         SubtitleAnalysis (SubtitleAnalysis const&) = delete;
45         SubtitleAnalysis& operator= (SubtitleAnalysis const&) = delete;
46
47         void write (boost::filesystem::path path) const;
48
49         boost::optional<dcpomatic::Rect<double>> bounding_box () const {
50                 return _bounding_box;
51         }
52
53         double analysis_x_offset () const {
54                 return _analysis_x_offset;
55         }
56
57         double analysis_y_offset () const {
58                 return _analysis_y_offset;
59         }
60
61 private:
62         /** Smallest box which surrounds all subtitles in our content,
63          *  expressed as a proportion of screen size (i.e. 0 is left hand side/top,
64          *  1 is right hand side/bottom), or empty if no subtitles were found.
65          */
66         boost::optional<dcpomatic::Rect<double>> _bounding_box;
67         double _analysis_x_offset;
68         double _analysis_y_offset;
69
70         static int const _current_state_version;
71 };