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