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.
21 * @brief A set of classes to describe video images.
24 #ifndef DCPOMATIC_IMAGE_H
25 #define DCPOMATIC_IMAGE_H
28 #include "position_image.h"
31 #include <libavutil/pixfmt.h>
33 #include <dcp/colour_conversion.h>
34 #include <boost/shared_ptr.hpp>
42 Image (AVPixelFormat, dcp::Size, bool);
44 Image (Image const &);
45 Image (boost::shared_ptr<const Image>, bool);
46 Image& operator= (Image const &);
49 uint8_t * const * data () const;
50 int const * line_size () const;
51 int const * stride () const;
52 dcp::Size size () const;
53 bool aligned () const;
56 int components () const;
57 int line_factor (int) const;
58 dcp::Size sample_size (int) const;
60 boost::shared_ptr<Image> scale (dcp::Size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat, bool aligned) const;
61 boost::shared_ptr<Image> crop_scale_window (Crop c, dcp::Size, dcp::Size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat, bool aligned) const;
64 void make_transparent ();
65 void alpha_blend (boost::shared_ptr<const Image> image, Position<int> pos);
66 void copy (boost::shared_ptr<const Image> image, Position<int> pos);
69 void read_from_socket (boost::shared_ptr<Socket>);
70 void write_to_socket (boost::shared_ptr<Socket>) const;
72 AVPixelFormat pixel_format () const {
77 friend struct pixel_formats_test;
81 float bytes_per_pixel (int) const;
82 void yuv_16_black (uint16_t, bool);
83 static uint16_t swap_16 (uint16_t);
86 AVPixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image
87 uint8_t** _data; ///< array of pointers to components
88 int* _line_size; ///< array of sizes of the data in each line, in pixels (without any alignment padding bytes)
89 int* _stride; ///< array of strides for each line (including any alignment padding bytes)
93 extern PositionImage merge (std::list<PositionImage> images);
94 extern bool operator== (Image const & a, Image const & b);