summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-30 15:59:26 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-30 15:59:26 +0100
commit8889cf7126810fb9b754643a45dcc94ad578125f (patch)
tree682b1d0db6b3c158b5329eedddd423d46ea51ddc /src/lib
parent326bf1a5409b2520464ff5df17051d4377955495 (diff)
Update filter graph to new API.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/filter_graph.cc20
-rw-r--r--src/lib/filter_graph.h2
-rw-r--r--src/lib/image.cc32
-rw-r--r--src/lib/image.h16
4 files changed, 32 insertions, 38 deletions
diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc
index c57d26e8d..2352b3e8a 100644
--- a/src/lib/filter_graph.cc
+++ b/src/lib/filter_graph.cc
@@ -130,25 +130,23 @@ FilterGraph::FilterGraph (shared_ptr<Film> film, FFmpegDecoder* decoder, libdcp:
* set of Images.
*/
list<shared_ptr<Image> >
-FilterGraph::process (AVFrame const * frame)
+FilterGraph::process (AVFrame* frame)
{
list<shared_ptr<Image> > images;
-
- if (av_buffersrc_write_frame (_buffer_src_context, frame) < 0) {
+ if (av_buffersrc_add_frame (_buffer_src_context, frame) < 0) {
throw DecodeError (N_("could not push buffer into filter chain."));
}
- while (av_buffersink_read (_buffer_sink_context, 0)) {
- AVFilterBufferRef* filter_buffer;
- if (av_buffersink_get_buffer_ref (_buffer_sink_context, &filter_buffer, 0) < 0) {
- filter_buffer = 0;
+ while (1) {
+ AVFrame* frame = av_frame_alloc ();
+ if (av_buffersink_get_frame (_buffer_sink_context, 0) < 0) {
+ av_frame_free (&frame);
+ break;
}
- if (filter_buffer) {
- /* This takes ownership of filter_buffer */
- images.push_back (shared_ptr<Image> (new FilterBufferImage ((PixelFormat) frame->format, filter_buffer)));
- }
+ /* This takes ownership of the AVFrame */
+ images.push_back (shared_ptr<Image> (new FrameImage (frame)));
}
return images;
diff --git a/src/lib/filter_graph.h b/src/lib/filter_graph.h
index ffd6855de..249b89851 100644
--- a/src/lib/filter_graph.h
+++ b/src/lib/filter_graph.h
@@ -39,7 +39,7 @@ public:
FilterGraph (boost::shared_ptr<Film> film, FFmpegDecoder* decoder, libdcp::Size s, AVPixelFormat p);
bool can_process (libdcp::Size s, AVPixelFormat p) const;
- std::list<boost::shared_ptr<Image> > process (AVFrame const * frame);
+ std::list<boost::shared_ptr<Image> > process (AVFrame * frame);
private:
AVFilterContext* _buffer_src_context;
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 1be41fecf..2d4bc0af0 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -609,9 +609,9 @@ SimpleImage::aligned () const
return _aligned;
}
-FilterBufferImage::FilterBufferImage (AVPixelFormat p, AVFilterBufferRef* b)
- : Image (p)
- , _buffer (b)
+FrameImage::FrameImage (AVFrame* frame)
+ : Image (static_cast<AVPixelFormat> (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;
@@ -621,44 +621,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;
}
diff --git a/src/lib/image.h b/src/lib/image.h
index ad2aa79bd..00768ee02 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -98,14 +98,14 @@ private:
AVPixelFormat _pixel_format; ///< FFmpeg's way of describing the pixel format of this Image
};
-/** @class FilterBufferImage
- * @brief An Image that is held in an AVFilterBufferRef.
+/** @class FrameImage
+ * @brief An Image that is held in an AVFrame.
*/
-class FilterBufferImage : public Image
+class FrameImage : public Image
{
public:
- FilterBufferImage (AVPixelFormat, AVFilterBufferRef *);
- ~FilterBufferImage ();
+ FrameImage (AVFrame *);
+ ~FrameImage ();
uint8_t ** data () const;
int * line_size () const;
@@ -115,10 +115,10 @@ public:
private:
/* Not allowed */
- FilterBufferImage (FilterBufferImage const &);
- FilterBufferImage& operator= (FilterBufferImage const &);
+ FrameImage (FrameImage const &);
+ FrameImage& operator= (FrameImage const &);
- AVFilterBufferRef* _buffer;
+ AVFrame* _frame;
int* _line_size;
};