#include <string>
#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavfilter/avfilter.h>
class Image
{
public:
- Image (PixelFormat p)
+ Image (AVPixelFormat p)
: _pixel_format (p)
{}
/** @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;
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
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:
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
uint8_t ** data () const;
int * line_size () const;
+ int * stride () const;
Size size () const;
AVFrame * frame () const {
return _frame;