summaryrefslogtreecommitdiff
path: root/src/lib/image.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-03 10:01:36 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-03 10:01:36 +0100
commit3fc3aad8735903ced3dae65f764eb33e3f5b3f11 (patch)
treebe6e5dd91a8c8b07e50a93f835ccff2706907441 /src/lib/image.cc
parentfdd63a4c9925f0339089dce3a52f0d6ed0d97880 (diff)
Try to fix the filter / AVFrame ownership.
Diffstat (limited to 'src/lib/image.cc')
-rw-r--r--src/lib/image.cc77
1 files changed, 21 insertions, 56 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 1768be924..b166dfac6 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -469,10 +469,9 @@ SimpleImage::allocate ()
SimpleImage::SimpleImage (SimpleImage const & other)
: Image (other)
+ , _size (other._size)
+ , _aligned (other._aligned)
{
- _size = other._size;
- _aligned = other._aligned;
-
allocate ();
for (int i = 0; i < components(); ++i) {
@@ -486,6 +485,25 @@ SimpleImage::SimpleImage (SimpleImage const & other)
}
}
+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)
: Image (*other.get())
{
@@ -576,59 +594,6 @@ SimpleImage::aligned () const
return _aligned;
}
-FrameImage::FrameImage (AVFrame* frame, bool own)
- : Image (static_cast<AVPixelFormat> (frame->format))
- , _frame (frame)
- , _own (own)
-{
- _line_size = (int *) av_malloc (4 * sizeof (int));
- _line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0;
-
- for (int i = 0; i < components(); ++i) {
- _line_size[i] = size().width * bytes_per_pixel(i);
- }
-}
-
-FrameImage::~FrameImage ()
-{
- if (_own) {
- av_frame_free (&_frame);
- }
-
- av_free (_line_size);
-}
-
-uint8_t **
-FrameImage::data () const
-{
- return _frame->data;
-}
-
-int *
-FrameImage::line_size () const
-{
- return _line_size;
-}
-
-int *
-FrameImage::stride () const
-{
- /* AVFrame's `linesize' is what we call `stride' */
- return _frame->linesize;
-}
-
-libdcp::Size
-FrameImage::size () const
-{
- return libdcp::Size (_frame->width, _frame->height);
-}
-
-bool
-FrameImage::aligned () const
-{
- return true;
-}
-
RGBPlusAlphaImage::RGBPlusAlphaImage (shared_ptr<const Image> im)
: SimpleImage (im->pixel_format(), im->size(), false)
{