+ uint8_t* p = _data[i];
+ uint8_t* q = other._data[i];
+ for (int j = 0; j < lines(i); ++j) {
+ memcpy (p, q, _line_size[i]);
+ p += stride()[i];
+ q += other.stride()[i];
+ }
+ }
+}
+
+SimpleImage::SimpleImage (AVFrame* frame)
+ : Image (static_cast<AVPixelFormat> (frame->format))
+ , _size (frame->width, frame->height)
+ , _aligned (true)
+{
+ allocate ();
+
+ for (int i = 0; i < components(); ++i) {
+ uint8_t* p = _data[i];
+ uint8_t* q = frame->data[i];
+ for (int j = 0; j < lines(i); ++j) {
+ memcpy (p, q, _line_size[i]);
+ p += stride()[i];
+ /* AVFrame's linesize is what we call `stride' */
+ q += frame->linesize[i];
+ }
+ }
+}
+
+SimpleImage::SimpleImage (shared_ptr<const Image> other, bool aligned)
+ : Image (*other.get())
+ , _size (other->size())
+ , _aligned (aligned)
+{
+ allocate ();
+
+ for (int i = 0; i < components(); ++i) {
+ assert(line_size()[i] == other->line_size()[i]);
+ uint8_t* p = _data[i];
+ uint8_t* q = other->data()[i];
+ for (int j = 0; j < lines(i); ++j) {
+ memcpy (p, q, line_size()[i]);
+ p += stride()[i];
+ q += other->stride()[i];
+ }
+ }
+}
+
+SimpleImage&
+SimpleImage::operator= (SimpleImage const & other)
+{
+ if (this == &other) {
+ return *this;
+ }
+
+ SimpleImage tmp (other);
+ swap (tmp);
+ return *this;
+}
+
+void
+SimpleImage::swap (SimpleImage & other)
+{
+ Image::swap (other);
+
+ std::swap (_size, other._size);
+
+ for (int i = 0; i < 4; ++i) {
+ std::swap (_data[i], other._data[i]);
+ std::swap (_line_size[i], other._line_size[i]);
+ std::swap (_stride[i], other._stride[i]);