Tidy up equality options slightly.
[libdcp.git] / src / picture_asset.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/picture_asset.h
21  *  @brief An asset made up of JPEG2000 files
22  */
23
24 #include <openjpeg.h>
25 #include "asset.h"
26
27 namespace libdcp
28 {
29
30 /** @brief An asset made up of JPEG2000 files */
31 class PictureAsset : public Asset
32 {
33 public:
34         /** Construct a PictureAsset, generating the MXF from the JPEG2000 files.
35          *  This may take some time; progress is indicated by emission of the Progress signal.
36          *  @param files Pathnames of JPEG2000 files, in frame order.
37          *  @param directory Directory in which to create MXF file.
38          *  @param mxf_name Name of MXF file to create.
39          *  @param progress Signal to inform of progress.
40          *  @param fps Frames per second.
41          *  @param length Length in frames.
42          *  @param width Width of images in pixels.
43          *  @param height Height of images in pixels.
44          */
45         PictureAsset (
46                 std::vector<std::string> const & files,
47                 std::string directory,
48                 std::string mxf_name,
49                 sigc::signal1<void, float>* progress,
50                 int fps,
51                 int length,
52                 int width,
53                 int height
54                 );
55
56         /** Construct a PictureAsset, generating the MXF from the JPEG2000 files.
57          *  This may take some time; progress is indicated by emission of the Progress signal.
58          *  @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
59          *  @param directory Directory in which to create MXF file.
60          *  @param mxf_name Name of MXF file to create.
61          *  @param progress Signal to inform of progress.
62          *  @param fps Frames per second.
63          *  @param length Length in frames.
64          *  @param width Width of images in pixels.
65          *  @param height Height of images in pixels.
66          */
67         PictureAsset (
68                 sigc::slot<std::string, int> get_path,
69                 std::string directory,
70                 std::string mxf_name,
71                 sigc::signal1<void, float>* progress,
72                 int fps,
73                 int length,
74                 int width,
75                 int height
76                 );
77
78         PictureAsset (std::string directory, std::string mxf_name, int fps, int length, int width, int height);
79         
80         /** Write details of this asset to a CPL stream.
81          *  @param s Stream.
82          */
83         void write_to_cpl (std::ostream& s) const;
84
85         std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
86         
87 private:
88         std::string path_from_list (int f, std::vector<std::string> const & files) const;
89         void construct (sigc::slot<std::string, int>);
90         opj_image_t* decompress_j2k (uint8_t* data, int64_t size) const;
91         
92         /** picture width in pixels */
93         int _width;
94         /** picture height in pixels */
95         int _height;
96 };
97
98 }