* @param frame to decode; caller manages memory.
*/
void
-Decoder::process_video (AVFrame* frame)
+Decoder::process_video (AVFrame const * frame)
{
shared_ptr<FilterGraph> graph;
virtual PixelFormat pixel_format () const = 0;
- void process_video (AVFrame *);
+ void process_video (AVFrame const *);
void process_audio (boost::shared_ptr<AudioBuffers>);
void process_subtitle (boost::shared_ptr<TimedSubtitle>);
void repeat_last_video ();
}
list<shared_ptr<Image> >
-FilterGraph::process (AVFrame* frame)
+FilterGraph::process (AVFrame const * frame)
{
list<shared_ptr<Image> > images;
FilterGraph (boost::shared_ptr<Film> film, Decoder* decoder, bool crop, Size s, AVPixelFormat p);
bool can_process (Size s, AVPixelFormat p) const;
- std::list<boost::shared_ptr<Image> > process (AVFrame* frame);
+ std::list<boost::shared_ptr<Image> > process (AVFrame const * frame);
private:
AVFilterContext* _buffer_src_context;
CompactImage::CompactImage (AVPixelFormat f, Size s)
: SimpleImage (f, s, boost::bind (round_up, _1, 1))
{
-
+ setup_picture ();
}
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)
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;
-}
public:
CompactImage (AVPixelFormat, Size);
CompactImage (boost::shared_ptr<Image>);
-};
-
-/** @class RGBFrameImage
- * @brief An RGB image that is held within an AVFrame.
- */
-class RGBFrameImage : public Image
-{
-public:
- RGBFrameImage (Size);
- ~RGBFrameImage ();
- uint8_t ** data () const;
- int * line_size () const;
- int * stride () const;
- Size size () const;
- AVFrame * frame () const {
- return _frame;
+ AVPicture const * picture () const {
+ return &_picture;
}
private:
- Size _size;
- AVFrame* _frame;
- uint8_t* _data;
+ void setup_picture ();
+
+ AVPicture _picture;
};
#endif
}
Size size = native_size ();
- RGBFrameImage image (size);
+ CompactImage image (PIX_FMT_RGB24, size);
uint8_t* p = image.data()[0];
for (int y = 0; y < size.height; ++y) {
}
- process_video (image.frame ());
+ process_video ((AVFrame const *) image.picture());
_done = true;
return false;
throw DecodeError ("could not read TIFF data");
}
- RGBFrameImage image (Size (width, height));
+ CompactImage image (PIX_FMT_RGB24, Size (width, height));
uint8_t* p = image.data()[0];
for (uint32_t y = 0; y < height; ++y) {
_TIFFfree (raster);
TIFFClose (t);
- process_video (image.frame ());
+ process_video ((AVFrame const *) image.picture ());
++_iter;
return false;