2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <libavfilter/avfiltergraph.h>
23 #include "exceptions.h"
27 #if LIBAVFILTER_VERSION_MAJOR == 2 && LIBAVFILTER_VERSION_MINOR == 15
30 enum PixelFormat pix_fmt;
34 avsink_init (AVFilterContext* ctx, const char* args, void* opaque)
36 AVSinkContext* priv = (AVSinkContext *) ctx->priv;
38 return AVERROR (EINVAL);
41 *priv = *(AVSinkContext *) opaque;
46 null_end_frame (AVFilterLink *)
52 avsink_query_formats (AVFilterContext* ctx)
54 AVSinkContext* priv = (AVSinkContext *) ctx->priv;
55 enum PixelFormat pix_fmts[] = {
60 avfilter_set_common_formats (ctx, avfilter_make_format_list ((int *) pix_fmts));
69 #if LIBAVFILTER_VERSION_MAJOR == 2 && LIBAVFILTER_VERSION_MINOR == 15
70 /* XXX does this leak stuff? */
71 AVFilter* buffer_sink = new AVFilter;
72 buffer_sink->name = av_strdup (N_("avsink"));
73 buffer_sink->priv_size = sizeof (AVSinkContext);
74 buffer_sink->init = avsink_init;
75 buffer_sink->query_formats = avsink_query_formats;
76 buffer_sink->inputs = new AVFilterPad[2];
77 AVFilterPad* i0 = const_cast<AVFilterPad*> (&buffer_sink->inputs[0]);
78 i0->name = N_("default");
79 i0->type = AVMEDIA_TYPE_VIDEO;
80 i0->min_perms = AV_PERM_READ;
83 i0->get_video_buffer = 0;
84 i0->get_audio_buffer = 0;
85 i0->end_frame = null_end_frame;
87 i0->filter_samples = 0;
89 i0->request_frame = 0;
91 const_cast<AVFilterPad*> (&buffer_sink->inputs[1])->name = 0;
92 buffer_sink->outputs = new AVFilterPad[1];
93 const_cast<AVFilterPad*> (&buffer_sink->outputs[0])->name = 0;
96 AVFilter* buffer_sink = avfilter_get_by_name(N_("buffersink"));
97 if (buffer_sink == 0) {
98 throw DecodeError (N_("Could not create buffer sink filter"));
105 #if LIBAVFILTER_VERSION_MAJOR == 2 && LIBAVFILTER_VERSION_MINOR == 15
107 avfilter_inout_alloc ()
109 return (AVFilterInOut *) av_malloc (sizeof (AVFilterInOut));
113 #ifndef HAVE_AV_FRAME_GET_BEST_EFFORT_TIMESTAMP
114 int64_t av_frame_get_best_effort_timestamp (AVFrame const * f)
116 return f->best_effort_timestamp;