*/
+/** @file src/lib/filter_graph.cc
+ * @brief A graph of FFmpeg filters.
+ */
+
extern "C" {
#include <libavfilter/avfiltergraph.h>
#include <libavfilter/buffersrc.h>
#endif
#include <libavformat/avio.h>
}
-#include "film.h"
#include "decoder.h"
#include "filter_graph.h"
#include "ffmpeg_compatibility.h"
#include "filter.h"
#include "exceptions.h"
#include "image.h"
+#include "film.h"
+#include "ffmpeg_decoder.h"
using std::stringstream;
using std::string;
using std::list;
using boost::shared_ptr;
-FilterGraph::FilterGraph (shared_ptr<Film> film, Decoder* decoder, bool crop, Size s, AVPixelFormat p)
+/** Construct a FilterGraph for the settings in a film.
+ * @param film Film.
+ * @param decoder Decoder that we are using.
+ * @param crop true to apply crop, otherwise false.
+ * @param s Size of the images to process.
+ * @param p Pixel format of the images to process.
+ */
+FilterGraph::FilterGraph (shared_ptr<Film> film, FFmpegDecoder* decoder, bool crop, Size s, AVPixelFormat p)
: _buffer_src_context (0)
, _buffer_sink_context (0)
, _size (s)
, _pixel_format (p)
{
- stringstream fs;
- Size size_after_crop;
-
- if (crop) {
- size_after_crop = film->cropped_size (decoder->native_size ());
- fs << crop_string (Position (film->crop().left, film->crop().top), size_after_crop);
- } else {
- size_after_crop = decoder->native_size ();
- fs << crop_string (Position (0, 0), size_after_crop);
- }
-
string filters = Filter::ffmpeg_strings (film->filters()).first;
if (!filters.empty ()) {
filters += ",";
}
- filters += fs.str ();
+ if (crop) {
+ filters += crop_string (Position (film->crop().left, film->crop().top), film->cropped_size (decoder->native_size()));
+ } else {
+ filters += crop_string (Position (0, 0), decoder->native_size());
+ }
avfilter_register_all ();
/* XXX: leaking `inputs' / `outputs' ? */
}
+/** Take an AVFrame and process it using our configured filters, returning a
+ * set of Images.
+ */
list<shared_ptr<Image> >
-FilterGraph::process (AVFrame* frame)
+FilterGraph::process (AVFrame const * frame)
{
list<shared_ptr<Image> > images;
return images;
}
+/** @param s Image size.
+ * @param p Pixel format.
+ * @return true if this chain can process images with `s' and `p', otherwise false.
+ */
bool
FilterGraph::can_process (Size s, AVPixelFormat p) const
{