/*
* Copyright (c) 2013 Vittorio Giovara
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
static int query_formats(AVFilterContext *ctx)
{
// this will ensure that formats are the same on all pads
- ff_set_common_formats(ctx, ff_make_format_list(formats_supported));
- return 0;
+ AVFilterFormats *fmts_list = ff_make_format_list(formats_supported);
+ if (!fmts_list)
+ return AVERROR(ENOMEM);
+ return ff_set_common_formats(ctx, fmts_list);
}
static av_cold void framepack_uninit(AVFilterContext *ctx)
for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
if (plane == 1 || plane == 2) {
- length = -(-(out->width / 2) >> s->pix_desc->log2_chroma_w);
- lines = -(-(out->height) >> s->pix_desc->log2_chroma_h);
+ length = FF_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
+ lines = FF_CEIL_RSHIFT(out->height, s->pix_desc->log2_chroma_h);
}
for (i = 0; i < lines; i++) {
int j;
}
}
+static int try_push_frame(AVFilterContext *ctx);
+
static int filter_frame_left(AVFilterLink *inlink, AVFrame *frame)
{
FramepackContext *s = inlink->dst->priv;
s->input_views[LEFT] = frame;
- return 0;
+ return try_push_frame(inlink->dst);
}
static int filter_frame_right(AVFilterLink *inlink, AVFrame *frame)
{
FramepackContext *s = inlink->dst->priv;
s->input_views[RIGHT] = frame;
- return 0;
+ return try_push_frame(inlink->dst);
}
static int request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
FramepackContext *s = ctx->priv;
- AVStereo3D *stereo;
int ret, i;
/* get a frame on the either input, stop as soon as a video ends */
return ret;
}
}
+ return 0;
+}
+static int try_push_frame(AVFilterContext *ctx)
+{
+ FramepackContext *s = ctx->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVStereo3D *stereo;
+ int ret, i;
+
+ if (!(s->input_views[0] && s->input_views[1]))
+ return 0;
if (s->format == AV_STEREO3D_FRAMESEQUENCE) {
if (s->double_pts == AV_NOPTS_VALUE)
s->double_pts = s->input_views[LEFT]->pts;
#define OFFSET(x) offsetof(FramepackContext, x)
#define V AV_OPT_FLAG_VIDEO_PARAM
-static const AVOption options[] = {
+static const AVOption framepack_options[] = {
{ "format", "Frame pack output format", OFFSET(format), AV_OPT_TYPE_INT,
{ .i64 = AV_STEREO3D_SIDEBYSIDE }, 0, INT_MAX, .flags = V, .unit = "format" },
{ "sbs", "Views are packed next to each other", 0, AV_OPT_TYPE_CONST,
{ NULL },
};
-static const AVClass framepack_class = {
- .class_name = "framepack",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
+AVFILTER_DEFINE_CLASS(framepack);
static const AVFilterPad framepack_inputs[] = {
{