diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-11-12 23:45:44 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-11-12 23:45:44 +0000 |
| commit | 5161626c3c28ba528511a8b211286a5e81a0f02a (patch) | |
| tree | 2690e09169d7d0e36167c842eb8260ae7a2cfe04 /src/lib/image.cc | |
| parent | c8b0b0f61a1188b3ce8010a65e4c617a0e66eaa1 (diff) | |
Untested; extend CompactImage to return a AVPicture.
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index c8303115b..05270954d 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -379,7 +379,7 @@ AlignedImage::AlignedImage (AVPixelFormat f, Size s) CompactImage::CompactImage (AVPixelFormat f, Size s) : SimpleImage (f, s, boost::bind (round_up, _1, 1)) { - + setup_picture (); } CompactImage::CompactImage (shared_ptr<Image> im) @@ -400,6 +400,17 @@ CompactImage::CompactImage (shared_ptr<Image> im) o += im->stride()[c]; } } + + setup_picture (); +} + +void +CompactImage::setup_picture () +{ + for (int c = 0; c < components(); ++c) { + _picture.data[c] = data()[c]; + _picture.linesize[c] = line_size()[c]; + } } FilterBufferImage::FilterBufferImage (AVPixelFormat p, AVFilterBufferRef* b) @@ -439,53 +450,3 @@ FilterBufferImage::size () const return Size (_buffer->video->w, _buffer->video->h); } -/** XXX: this could be generalised to use any format, but I don't - * understand how avpicture_fill is supposed to be called with - * multi-planar images. - */ -RGBFrameImage::RGBFrameImage (Size s) - : Image (PIX_FMT_RGB24) - , _size (s) -{ - _frame = avcodec_alloc_frame (); - if (_frame == 0) { - throw EncodeError ("could not allocate frame"); - } - - _data = (uint8_t *) av_malloc (size().width * size().height * 3); - avpicture_fill ((AVPicture *) _frame, _data, PIX_FMT_RGB24, size().width, size().height); - _frame->width = size().width; - _frame->height = size().height; - _frame->format = PIX_FMT_RGB24; -} - -RGBFrameImage::~RGBFrameImage () -{ - av_free (_data); - av_free (_frame); -} - -uint8_t ** -RGBFrameImage::data () const -{ - return _frame->data; -} - -int * -RGBFrameImage::line_size () const -{ - return _frame->linesize; -} - -int * -RGBFrameImage::stride () const -{ - /* XXX? */ - return line_size (); -} - -Size -RGBFrameImage::size () const -{ - return _size; -} |
