X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage.h;h=2d9f322310c2c3e66d5a9d4e05f9c88deffb3b51;hb=48b2c7b8ec57e72f2f27d5080e54e4b3c3fcda3d;hp=f9bda7460327e62706ef2fa3a982c0b4efe478b3;hpb=883d885dc8690519d205c8baa275385af8a39f4b;p=dcpomatic.git diff --git a/src/lib/image.h b/src/lib/image.h index f9bda7460..2d9f32231 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -31,54 +31,40 @@ extern "C" { #include #include } +#include #include "util.h" +#include "position.h" class Scaler; -class SimpleImage; -/** @class Image - * @brief Parent class for wrappers of some image, in some format, that - * can present a set of components and a size in pixels. - * - * This class also has some conversion / processing methods. - * - * The main point of this class (and its subclasses) is to abstract - * details of FFmpeg's memory management and varying data formats. - */ -class Image +class Image : public libdcp::Image { public: - Image (AVPixelFormat p) - : _pixel_format (p) - {} + Image (AVPixelFormat, libdcp::Size, bool); + Image (AVFrame *); + Image (Image const &); + Image (boost::shared_ptr, bool); + Image& operator= (Image const &); + ~Image (); - virtual ~Image () {} - - /** @return Array of pointers to arrays of the component data */ - virtual uint8_t ** data () const = 0; - - /** @return Array of sizes of the data in each line, in bytes (without any alignment padding bytes) */ - virtual int * line_size () const = 0; - - /** @return Array of strides for each line (including any alignment padding bytes) */ - virtual int * stride () const = 0; - - /** @return Size of the image, in pixels */ - virtual libdcp::Size size () const = 0; - - virtual bool aligned () const = 0; + uint8_t ** data () const; + int * line_size () const; + int * stride () const; + libdcp::Size size () const; + bool aligned () const; int components () const; + int line_factor (int) const; int lines (int) const; - boost::shared_ptr scale_and_convert_to_rgb (libdcp::Size, Scaler const *, bool) const; - boost::shared_ptr scale (libdcp::Size, Scaler const *, bool aligned) const; - boost::shared_ptr post_process (std::string, bool aligned) const; - void alpha_blend (boost::shared_ptr image, Position pos); - void copy (boost::shared_ptr image, Position pos); + boost::shared_ptr scale (libdcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; boost::shared_ptr crop (Crop c, bool aligned) const; + + boost::shared_ptr crop_scale_window (Crop c, libdcp::Size, libdcp::Size, Scaler const *, AVPixelFormat, bool aligned) const; void make_black (); + void alpha_blend (boost::shared_ptr image, Position pos); + void copy (boost::shared_ptr image, Position pos); void read_from_socket (boost::shared_ptr); void write_to_socket (boost::shared_ptr) const; @@ -87,62 +73,20 @@ public: return _pixel_format; } -protected: - virtual void swap (Image &); - float bytes_per_pixel (int) const; - - friend class pixel_formats_test; - private: - void yuv_16_black (uint16_t); - static uint16_t swap_16 (uint16_t); + friend class pixel_formats_test; - AVPixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image -}; - -/** @class SimpleImage - * @brief An Image for which memory is allocated using a `simple' av_malloc(). - */ -class SimpleImage : public Image -{ -public: - SimpleImage (AVPixelFormat, libdcp::Size, bool); - SimpleImage (AVFrame *); - SimpleImage (SimpleImage const &); - SimpleImage (boost::shared_ptr); - SimpleImage& operator= (SimpleImage const &); - ~SimpleImage (); - - uint8_t ** data () const; - int * line_size () const; - int * stride () const; - libdcp::Size size () const; - bool aligned () const; - -protected: void allocate (); - void swap (SimpleImage &); + void swap (Image &); + float bytes_per_pixel (int) const; + void yuv_16_black (uint16_t, bool); + static uint16_t swap_16 (uint16_t); -private: - libdcp::Size _size; ///< size in pixels + AVPixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image uint8_t** _data; ///< array of pointers to components int* _line_size; ///< array of sizes of the data in each line, in pixels (without any alignment padding bytes) int* _stride; ///< array of strides for each line (including any alignment padding bytes) bool _aligned; }; -class RGBPlusAlphaImage : public SimpleImage -{ -public: - RGBPlusAlphaImage (boost::shared_ptr); - ~RGBPlusAlphaImage (); - - uint8_t* alpha () const { - return _alpha; - } - -private: - uint8_t* _alpha; -}; - #endif