Tidy up test film naming.
[dcpomatic.git] / src / lib / image.h
index d10bcae9efcaf83412ec6795c1d0c90706f50013..b2b9872792a3815de37a86507203419279edb1ff 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <string>
 #include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavfilter/avfilter.h>
@@ -34,7 +35,7 @@ extern "C" {
 
 class Scaler;
 class RGBFrameImage;
-class PostProcessImage;
+class SimpleImage;
 
 /** @class Image
  *  @brief Parent class for wrappers of some image, in some format, that
@@ -48,7 +49,7 @@ class PostProcessImage;
 class Image
 {
 public:
-       Image (PixelFormat p)
+       Image (AVPixelFormat p)
                : _pixel_format (p)
        {}
        
@@ -57,26 +58,33 @@ 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;
 
        int components () const;
        int lines (int) const;
-       boost::shared_ptr<RGBFrameImage> scale_and_convert_to_rgb (Size, int, Scaler const *) const;
+       boost::shared_ptr<Image> scale_and_convert_to_rgb (Size, int, Scaler const *) const;
        boost::shared_ptr<Image> scale (Size, Scaler const *) const;
-       boost::shared_ptr<PostProcessImage> post_process (std::string) const;
+       boost::shared_ptr<Image> post_process (std::string) const;
+       void alpha_blend (boost::shared_ptr<Image> image, Position pos);
        
        void make_black ();
+
+       void read_from_socket (boost::shared_ptr<Socket>);
+       void write_to_socket (boost::shared_ptr<Socket>) 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<int (int)> 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<Image>);
 };
 
 /** @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;
@@ -137,23 +163,4 @@ private:
        uint8_t* _data;
 };
 
-/** @class PostProcessImage
- *  @brief An image that is the result of an FFmpeg post-processing run.
- */
-class PostProcessImage : public Image
-{
-public:
-       PostProcessImage (PixelFormat, Size);
-       ~PostProcessImage ();
-
-       uint8_t ** data () const;
-       int * line_size () const;
-       Size size () const;
-
-private:
-       Size _size;
-       uint8_t** _data;
-       int* _line_size;
-};
-
 #endif