X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage.h;h=b2b9872792a3815de37a86507203419279edb1ff;hb=44b57d623dec97a3f9955082f0b8a7a8d27b7518;hp=970750719794fefad5280cb2996ece40c55b912e;hpb=27fac0b4c6d42cb3b47bc1240d50ce11923fb66a;p=dcpomatic.git diff --git a/src/lib/image.h b/src/lib/image.h index 970750719..b2b987279 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -26,6 +26,7 @@ #include #include +#include extern "C" { #include #include @@ -48,7 +49,7 @@ class SimpleImage; class Image { public: - Image (PixelFormat p) + Image (AVPixelFormat p) : _pixel_format (p) {} @@ -57,9 +58,12 @@ public: /** @return Array of pointers to arrays of the component data */ virtual uint8_t ** data () const = 0; - /** @return Array of sizes of each line, in pixels */ + /** @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 Size size () const = 0; @@ -68,15 +72,19 @@ public: boost::shared_ptr scale_and_convert_to_rgb (Size, int, Scaler const *) const; boost::shared_ptr scale (Size, Scaler const *) const; boost::shared_ptr post_process (std::string) const; + void alpha_blend (boost::shared_ptr image, Position pos); void make_black (); + + void read_from_socket (boost::shared_ptr); + void write_to_socket (boost::shared_ptr) const; - PixelFormat pixel_format () const { + AVPixelFormat pixel_format () const { return _pixel_format; } private: - PixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image + AVPixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image }; /** @class FilterBufferImage @@ -85,11 +93,12 @@ private: class FilterBufferImage : public Image { public: - FilterBufferImage (PixelFormat, AVFilterBufferRef *); + FilterBufferImage (AVPixelFormat, AVFilterBufferRef *); ~FilterBufferImage (); uint8_t ** data () const; int * line_size () const; + int * stride () const; Size size () const; private: @@ -102,17 +111,33 @@ private: class SimpleImage : public Image { public: - SimpleImage (PixelFormat, Size); + SimpleImage (AVPixelFormat, Size, boost::function rounder); ~SimpleImage (); uint8_t ** data () const; int * line_size () const; + int * stride () const; Size size () const; private: + Size _size; ///< size in pixels uint8_t** _data; ///< array of pointers to components - int* _line_size; ///< array of widths of each line, in bytes + 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) +}; + +class AlignedImage : public SimpleImage +{ +public: + AlignedImage (AVPixelFormat, Size); +}; + +class CompactImage : public SimpleImage +{ +public: + CompactImage (AVPixelFormat, Size); + CompactImage (boost::shared_ptr); }; /** @class RGBFrameImage @@ -126,6 +151,7 @@ public: uint8_t ** data () const; int * line_size () const; + int * stride () const; Size size () const; AVFrame * frame () const { return _frame;