X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage.cc;h=d2842e0958eafe440dd55718a4c89d116a9e4fe9;hb=254664b5a482cb3551d0a98ececfbdd8296e6c71;hp=2355d22e5b959ab12af8c9f8bae144d781649315;hpb=fec9770dd454fdb6902180322fd3d221f2c86ed2;p=dcpomatic.git diff --git a/src/lib/image.cc b/src/lib/image.cc index 2355d22e5..d2842e095 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -90,6 +90,9 @@ Image::components () const { switch (_pixel_format) { case PIX_FMT_YUV420P: + case PIX_FMT_YUV422P9BE + case PIX_FMT_YUV422P9LE: + case PIX_FMT_YUV422P10BE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV422P: case PIX_FMT_YUV444P: @@ -509,7 +512,33 @@ SimpleImage::SimpleImage (SimpleImage const & other) allocate (); for (int i = 0; i < components(); ++i) { - memcpy (_data[i], other._data[i], _line_size[i] * lines(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 (shared_ptr other) + : Image (*other.get()) +{ + _size = other->size (); + _aligned = true; + + 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]; + } } } @@ -583,9 +612,9 @@ SimpleImage::aligned () const return _aligned; } -FilterBufferImage::FilterBufferImage (AVPixelFormat p, AVFilterBufferRef* b) - : Image (p) - , _buffer (b) +FrameImage::FrameImage (AVFrame* frame) + : Image (static_cast (frame->format)) + , _frame (frame) { _line_size = (int *) av_malloc (4 * sizeof (int)); _line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0; @@ -595,44 +624,40 @@ FilterBufferImage::FilterBufferImage (AVPixelFormat p, AVFilterBufferRef* b) } } -FilterBufferImage::~FilterBufferImage () +FrameImage::~FrameImage () { - avfilter_unref_buffer (_buffer); + av_frame_free (&_frame); av_free (_line_size); } uint8_t ** -FilterBufferImage::data () const +FrameImage::data () const { - return _buffer->data; + return _frame->data; } int * -FilterBufferImage::line_size () const +FrameImage::line_size () const { return _line_size; } int * -FilterBufferImage::stride () const +FrameImage::stride () const { - /* I've seen images where the _buffer->linesize is larger than the width - (by a small amount), suggesting that _buffer->linesize is what we call - stride. But I'm not sure. - */ - return _buffer->linesize; + /* AVFrame's `linesize' is what we call `stride' */ + return _frame->linesize; } libdcp::Size -FilterBufferImage::size () const +FrameImage::size () const { - return libdcp::Size (_buffer->video->w, _buffer->video->h); + return libdcp::Size (_frame->width, _frame->height); } bool -FilterBufferImage::aligned () const +FrameImage::aligned () const { - /* XXX? */ return true; }