From 5f5dcf44e3c40da8c2334b9d2e62f30739d644c0 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Thu, 31 Aug 2017 19:47:37 +0200 Subject: lavfi: rename framesync2 to framesync. --- libavfilter/Makefile | 50 ++--- libavfilter/f_streamselect.c | 12 +- libavfilter/framesync.c | 415 ++++++++++++++++++++++++++++++++++++++++++ libavfilter/framesync.h | 321 ++++++++++++++++++++++++++++++++ libavfilter/framesync2.c | 415 ------------------------------------------ libavfilter/framesync2.h | 321 -------------------------------- libavfilter/maskedmerge.h | 2 +- libavfilter/vf_blend.c | 12 +- libavfilter/vf_convolve.c | 12 +- libavfilter/vf_displace.c | 16 +- libavfilter/vf_hysteresis.c | 14 +- libavfilter/vf_libvmaf.c | 12 +- libavfilter/vf_lut2.c | 14 +- libavfilter/vf_lut3d.c | 12 +- libavfilter/vf_maskedclamp.c | 16 +- libavfilter/vf_maskedmerge.c | 14 +- libavfilter/vf_mergeplanes.c | 12 +- libavfilter/vf_midequalizer.c | 14 +- libavfilter/vf_overlay.c | 12 +- libavfilter/vf_paletteuse.c | 12 +- libavfilter/vf_premultiply.c | 14 +- libavfilter/vf_psnr.c | 12 +- libavfilter/vf_remap.c | 16 +- libavfilter/vf_ssim.c | 12 +- libavfilter/vf_stack.c | 12 +- libavfilter/vf_threshold.c | 18 +- 26 files changed, 896 insertions(+), 896 deletions(-) create mode 100644 libavfilter/framesync.c create mode 100644 libavfilter/framesync.h delete mode 100644 libavfilter/framesync2.c delete mode 100644 libavfilter/framesync2.h (limited to 'libavfilter') diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 510cf5ad19..8aa974e115 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -67,7 +67,7 @@ OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o OBJS-$(CONFIG_ASIDEDATA_FILTER) += f_sidedata.o OBJS-$(CONFIG_ASPLIT_FILTER) += split.o OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o -OBJS-$(CONFIG_ASTREAMSELECT_FILTER) += f_streamselect.o framesync2.o +OBJS-$(CONFIG_ASTREAMSELECT_FILTER) += f_streamselect.o framesync.o OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o OBJS-$(CONFIG_ATRIM_FILTER) += trim.o OBJS-$(CONFIG_AZMQ_FILTER) += f_zmq.o @@ -137,7 +137,7 @@ OBJS-$(CONFIG_BENCH_FILTER) += f_bench.o OBJS-$(CONFIG_BITPLANENOISE_FILTER) += vf_bitplanenoise.o OBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o -OBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o framesync2.o +OBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o framesync.o OBJS-$(CONFIG_BOXBLUR_FILTER) += vf_boxblur.o OBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o OBJS-$(CONFIG_CHROMAKEY_FILTER) += vf_chromakey.o @@ -150,7 +150,7 @@ OBJS-$(CONFIG_COLORLEVELS_FILTER) += vf_colorlevels.o OBJS-$(CONFIG_COLORMATRIX_FILTER) += vf_colormatrix.o OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspacedsp.o OBJS-$(CONFIG_CONVOLUTION_FILTER) += vf_convolution.o -OBJS-$(CONFIG_CONVOLVE_FILTER) += vf_convolve.o framesync2.o +OBJS-$(CONFIG_CONVOLVE_FILTER) += vf_convolve.o framesync.o OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o OBJS-$(CONFIG_COREIMAGE_FILTER) += vf_coreimage.o OBJS-$(CONFIG_COVER_RECT_FILTER) += vf_cover_rect.o lavfutils.o @@ -171,7 +171,7 @@ OBJS-$(CONFIG_DESHAKE_FILTER) += vf_deshake.o OBJS-$(CONFIG_DESPILL_FILTER) += vf_despill.o OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o OBJS-$(CONFIG_DILATION_FILTER) += vf_neighbor.o -OBJS-$(CONFIG_DISPLACE_FILTER) += vf_displace.o framesync2.o +OBJS-$(CONFIG_DISPLACE_FILTER) += vf_displace.o framesync.o OBJS-$(CONFIG_DOUBLEWEAVE_FILTER) += vf_weave.o OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o OBJS-$(CONFIG_DRAWGRAPH_FILTER) += f_drawgraph.o @@ -200,19 +200,19 @@ OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o OBJS-$(CONFIG_GEQ_FILTER) += vf_geq.o OBJS-$(CONFIG_GRADFUN_FILTER) += vf_gradfun.o -OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o framesync2.o +OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o framesync.o OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o OBJS-$(CONFIG_HISTOGRAM_FILTER) += vf_histogram.o OBJS-$(CONFIG_HQDN3D_FILTER) += vf_hqdn3d.o OBJS-$(CONFIG_HQX_FILTER) += vf_hqx.o -OBJS-$(CONFIG_HSTACK_FILTER) += vf_stack.o framesync2.o +OBJS-$(CONFIG_HSTACK_FILTER) += vf_stack.o framesync.o OBJS-$(CONFIG_HUE_FILTER) += vf_hue.o OBJS-$(CONFIG_HWDOWNLOAD_FILTER) += vf_hwdownload.o OBJS-$(CONFIG_HWMAP_FILTER) += vf_hwmap.o OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER) += vf_hwupload_cuda.o OBJS-$(CONFIG_HWUPLOAD_FILTER) += vf_hwupload.o -OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync2.o +OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o OBJS-$(CONFIG_IDET_FILTER) += vf_idet.o OBJS-$(CONFIG_IL_FILTER) += vf_il.o OBJS-$(CONFIG_INFLATE_FILTER) += vf_neighbor.o @@ -220,22 +220,22 @@ OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o -OBJS-$(CONFIG_LIBVMAF_FILTER) += vf_libvmaf.o framesync2.o +OBJS-$(CONFIG_LIBVMAF_FILTER) += vf_libvmaf.o framesync.o OBJS-$(CONFIG_LIMITER_FILTER) += vf_limiter.o OBJS-$(CONFIG_LOOP_FILTER) += f_loop.o OBJS-$(CONFIG_LUMAKEY_FILTER) += vf_lumakey.o OBJS-$(CONFIG_LUT_FILTER) += vf_lut.o -OBJS-$(CONFIG_LUT2_FILTER) += vf_lut2.o framesync2.o +OBJS-$(CONFIG_LUT2_FILTER) += vf_lut2.o framesync.o OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o OBJS-$(CONFIG_LUTYUV_FILTER) += vf_lut.o -OBJS-$(CONFIG_MASKEDCLAMP_FILTER) += vf_maskedclamp.o framesync2.o -OBJS-$(CONFIG_MASKEDMERGE_FILTER) += vf_maskedmerge.o framesync2.o +OBJS-$(CONFIG_MASKEDCLAMP_FILTER) += vf_maskedclamp.o framesync.o +OBJS-$(CONFIG_MASKEDMERGE_FILTER) += vf_maskedmerge.o framesync.o OBJS-$(CONFIG_MCDEINT_FILTER) += vf_mcdeint.o -OBJS-$(CONFIG_MERGEPLANES_FILTER) += vf_mergeplanes.o framesync2.o +OBJS-$(CONFIG_MERGEPLANES_FILTER) += vf_mergeplanes.o framesync.o OBJS-$(CONFIG_MESTIMATE_FILTER) += vf_mestimate.o motion_estimation.o OBJS-$(CONFIG_METADATA_FILTER) += f_metadata.o -OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += vf_midequalizer.o framesync2.o +OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += vf_midequalizer.o framesync.o OBJS-$(CONFIG_MINTERPOLATE_FILTER) += vf_minterpolate.o motion_estimation.o OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o @@ -248,11 +248,11 @@ OBJS-$(CONFIG_OCR_FILTER) += vf_ocr.o OBJS-$(CONFIG_OCV_FILTER) += vf_libopencv.o OBJS-$(CONFIG_OPENCL) += deshake_opencl.o unsharp_opencl.o OBJS-$(CONFIG_OSCILLOSCOPE_FILTER) += vf_datascope.o -OBJS-$(CONFIG_OVERLAY_FILTER) += vf_overlay.o framesync2.o +OBJS-$(CONFIG_OVERLAY_FILTER) += vf_overlay.o framesync.o OBJS-$(CONFIG_OWDENOISE_FILTER) += vf_owdenoise.o OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o -OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o framesync2.o +OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o framesync.o OBJS-$(CONFIG_PERMS_FILTER) += f_perms.o OBJS-$(CONFIG_PERSPECTIVE_FILTER) += vf_perspective.o OBJS-$(CONFIG_PHASE_FILTER) += vf_phase.o @@ -260,17 +260,17 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o OBJS-$(CONFIG_PIXSCOPE_FILTER) += vf_datascope.o OBJS-$(CONFIG_PP_FILTER) += vf_pp.o OBJS-$(CONFIG_PP7_FILTER) += vf_pp7.o -OBJS-$(CONFIG_PREMULTIPLY_FILTER) += vf_premultiply.o framesync2.o +OBJS-$(CONFIG_PREMULTIPLY_FILTER) += vf_premultiply.o framesync.o OBJS-$(CONFIG_PREWITT_FILTER) += vf_convolution.o OBJS-$(CONFIG_PSEUDOCOLOR_FILTER) += vf_pseudocolor.o -OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o framesync2.o +OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o framesync.o OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o OBJS-$(CONFIG_QP_FILTER) += vf_qp.o OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o OBJS-$(CONFIG_READEIA608_FILTER) += vf_readeia608.o OBJS-$(CONFIG_READVITC_FILTER) += vf_readvitc.o OBJS-$(CONFIG_REALTIME_FILTER) += f_realtime.o -OBJS-$(CONFIG_REMAP_FILTER) += vf_remap.o framesync2.o +OBJS-$(CONFIG_REMAP_FILTER) += vf_remap.o framesync.o OBJS-$(CONFIG_REMOVEGRAIN_FILTER) += vf_removegrain.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o OBJS-$(CONFIG_REPEATFIELDS_FILTER) += vf_repeatfields.o @@ -304,24 +304,24 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER) += vf_smartblur.o OBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o OBJS-$(CONFIG_SPLIT_FILTER) += split.o OBJS-$(CONFIG_SPP_FILTER) += vf_spp.o -OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o framesync2.o +OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o framesync.o OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o -OBJS-$(CONFIG_STREAMSELECT_FILTER) += f_streamselect.o framesync2.o +OBJS-$(CONFIG_STREAMSELECT_FILTER) += f_streamselect.o framesync.o OBJS-$(CONFIG_SUBTITLES_FILTER) += vf_subtitles.o OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o OBJS-$(CONFIG_SWAPRECT_FILTER) += vf_swaprect.o OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o -OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync2.o +OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync.o OBJS-$(CONFIG_TELECINE_FILTER) += vf_telecine.o -OBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o framesync2.o +OBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o framesync.o OBJS-$(CONFIG_THUMBNAIL_FILTER) += vf_thumbnail.o OBJS-$(CONFIG_TILE_FILTER) += vf_tile.o OBJS-$(CONFIG_TINTERLACE_FILTER) += vf_tinterlace.o -OBJS-$(CONFIG_TLUT2_FILTER) += vf_lut2.o framesync2.o +OBJS-$(CONFIG_TLUT2_FILTER) += vf_lut2.o framesync.o OBJS-$(CONFIG_TONEMAP_FILTER) += vf_tonemap.o OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o OBJS-$(CONFIG_TRIM_FILTER) += trim.o -OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync2.o +OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync.o OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o OBJS-$(CONFIG_USPP_FILTER) += vf_uspp.o OBJS-$(CONFIG_VAGUEDENOISER_FILTER) += vf_vaguedenoiser.o @@ -330,7 +330,7 @@ OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o OBJS-$(CONFIG_VIDSTABDETECT_FILTER) += vidstabutils.o vf_vidstabdetect.o OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER) += vidstabutils.o vf_vidstabtransform.o OBJS-$(CONFIG_VIGNETTE_FILTER) += vf_vignette.o -OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync2.o +OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o OBJS-$(CONFIG_WEAVE_FILTER) += vf_weave.o diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c index 10607de9b8..923deb1a85 100644 --- a/libavfilter/f_streamselect.c +++ b/libavfilter/f_streamselect.c @@ -22,7 +22,7 @@ #include "avfilter.h" #include "audio.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -56,7 +56,7 @@ static int process_frame(FFFrameSync *fs) int i, j, ret = 0; for (i = 0; i < ctx->nb_inputs; i++) { - if ((ret = ff_framesync2_get_frame(&s->fs, i, &in[i], 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0) return ret; } @@ -87,7 +87,7 @@ static int process_frame(FFFrameSync *fs) static int activate(AVFilterContext *ctx) { StreamSelectContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static int config_output(AVFilterLink *outlink) @@ -124,7 +124,7 @@ static int config_output(AVFilterLink *outlink) if (s->fs.opaque == s) return 0; - if ((ret = ff_framesync2_init(&s->fs, ctx, ctx->nb_inputs)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, ctx->nb_inputs)) < 0) return ret; in = s->fs.in; @@ -142,7 +142,7 @@ static int config_output(AVFilterLink *outlink) if (!s->frames) return AVERROR(ENOMEM); - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int parse_definition(AVFilterContext *ctx, int nb_pads, int is_input, int is_audio) @@ -289,7 +289,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&s->last_pts); av_freep(&s->map); av_freep(&s->frames); - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static int query_formats(AVFilterContext *ctx) diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c new file mode 100644 index 0000000000..ebfbcaf090 --- /dev/null +++ b/libavfilter/framesync.c @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2013 Nicolas George + * + * This file is part of FFmpeg. + * + * 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. + * + * 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 FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avassert.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "filters.h" +#include "framesync.h" +#include "internal.h" + +#define OFFSET(member) offsetof(FFFrameSync, member) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM + +static const char *framesync_name(void *ptr) +{ + return "framesync"; +} + +static const AVOption framesync_options[] = { + { "eof_action", "Action to take when encountering EOF from secondary input ", + OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT }, + EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" }, + { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" }, + { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" }, + { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" }, + { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, + { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, + { NULL } +}; +static const AVClass framesync_class = { + .version = LIBAVUTIL_VERSION_INT, + .class_name = "framesync", + .item_name = framesync_name, + .category = AV_CLASS_CATEGORY_FILTER, + .option = framesync_options, + .parent_log_context_offset = OFFSET(parent), +}; + +enum { + STATE_BOF, + STATE_RUN, + STATE_EOF, +}; + +static int consume_from_fifos(FFFrameSync *fs); + +const AVClass *framesync_get_class(void) +{ + return &framesync_class; +} + +void ff_framesync_preinit(FFFrameSync *fs) +{ + if (fs->class) + return; + fs->class = &framesync_class; + av_opt_set_defaults(fs); +} + +int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in) +{ + /* For filters with several outputs, we will not be able to assume which + output is relevant for ff_outlink_frame_wanted() and + ff_outlink_set_status(). To be designed when needed. */ + av_assert0(parent->nb_outputs == 1); + + ff_framesync_preinit(fs); + fs->parent = parent; + fs->nb_in = nb_in; + + fs->in = av_calloc(nb_in, sizeof(*fs->in)); + if (!fs->in) + return AVERROR(ENOMEM); + return 0; +} + +static void framesync_eof(FFFrameSync *fs) +{ + fs->eof = 1; + fs->frame_ready = 0; + ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE); +} + +static void framesync_sync_level_update(FFFrameSync *fs) +{ + unsigned i, level = 0; + + for (i = 0; i < fs->nb_in; i++) + if (fs->in[i].state != STATE_EOF) + level = FFMAX(level, fs->in[i].sync); + av_assert0(level <= fs->sync_level); + if (level < fs->sync_level) + av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level); + if (level) + fs->sync_level = level; + else + framesync_eof(fs); +} + +int ff_framesync_configure(FFFrameSync *fs) +{ + unsigned i; + int64_t gcd, lcm; + + if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) { + fs->opt_repeatlast = 0; + fs->opt_eof_action = EOF_ACTION_PASS; + } + if (fs->opt_shortest || fs->opt_eof_action == EOF_ACTION_ENDALL) { + fs->opt_shortest = 1; + fs->opt_eof_action = EOF_ACTION_ENDALL; + } + if (fs->opt_shortest) { + for (i = 0; i < fs->nb_in; i++) + fs->in[i].after = EXT_STOP; + } + if (!fs->opt_repeatlast) { + for (i = 1; i < fs->nb_in; i++) { + fs->in[i].after = EXT_NULL; + fs->in[i].sync = 0; + } + } + + if (!fs->time_base.num) { + for (i = 0; i < fs->nb_in; i++) { + if (fs->in[i].sync) { + if (fs->time_base.num) { + gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den); + lcm = (fs->time_base.den / gcd) * fs->in[i].time_base.den; + if (lcm < AV_TIME_BASE / 2) { + fs->time_base.den = lcm; + fs->time_base.num = av_gcd(fs->time_base.num, + fs->in[i].time_base.num); + } else { + fs->time_base.num = 1; + fs->time_base.den = AV_TIME_BASE; + break; + } + } else { + fs->time_base = fs->in[i].time_base; + } + } + } + if (!fs->time_base.num) { + av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n"); + return AVERROR(EINVAL); + } + av_log(fs, AV_LOG_VERBOSE, "Selected %d/%d time base\n", + fs->time_base.num, fs->time_base.den); + } + + for (i = 0; i < fs->nb_in; i++) + fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE; + fs->sync_level = UINT_MAX; + framesync_sync_level_update(fs); + + return 0; +} + +static int framesync_advance(FFFrameSync *fs) +{ + unsigned i; + int64_t pts; + int ret; + + while (!(fs->frame_ready || fs->eof)) { + ret = consume_from_fifos(fs); + if (ret <= 0) + return ret; + + pts = INT64_MAX; + for (i = 0; i < fs->nb_in; i++) + if (fs->in[i].have_next && fs->in[i].pts_next < pts) + pts = fs->in[i].pts_next; + if (pts == INT64_MAX) { + framesync_eof(fs); + break; + } + for (i = 0; i < fs->nb_in; i++) { + if (fs->in[i].pts_next == pts || + (fs->in[i].before == EXT_INFINITY && + fs->in[i].state == STATE_BOF)) { + av_frame_free(&fs->in[i].frame); + fs->in[i].frame = fs->in[i].frame_next; + fs->in[i].pts = fs->in[i].pts_next; + fs->in[i].frame_next = NULL; + fs->in[i].pts_next = AV_NOPTS_VALUE; + fs->in[i].have_next = 0; + fs->in[i].state = fs->in[i].frame ? STATE_RUN : STATE_EOF; + if (fs->in[i].sync == fs->sync_level && fs->in[i].frame) + fs->frame_ready = 1; + if (fs->in[i].state == STATE_EOF && + fs->in[i].after == EXT_STOP) + framesync_eof(fs); + } + } + if (fs->frame_ready) + for (i = 0; i < fs->nb_in; i++) + if ((fs->in[i].state == STATE_BOF && + fs->in[i].before == EXT_STOP)) + fs->frame_ready = 0; + fs->pts = pts; + } + return 0; +} + +static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in, + int64_t pts) +{ + /* Possible enhancement: use the link's frame rate */ + return pts + 1; +} + +static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame) +{ + int64_t pts; + + av_assert0(!fs->in[in].have_next); + av_assert0(frame); + pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base); + frame->pts = pts; + fs->in[in].frame_next = frame; + fs->in[in].pts_next = pts; + fs->in[in].have_next = 1; +} + +static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts) +{ + av_assert0(!fs->in[in].have_next); + pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY + ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts); + fs->in[in].sync = 0; + framesync_sync_level_update(fs); + fs->in[in].frame_next = NULL; + fs->in[in].pts_next = pts; + fs->in[in].have_next = 1; +} + +int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, + unsigned get) +{ + AVFrame *frame; + unsigned need_copy = 0, i; + int64_t pts_next; + int ret; + + if (!fs->in[in].frame) { + *rframe = NULL; + return 0; + } + frame = fs->in[in].frame; + if (get) { + /* Find out if we need to copy the frame: is there another sync + stream, and do we know if its current frame will outlast this one? */ + pts_next = fs->in[in].have_next ? fs->in[in].pts_next : INT64_MAX; + for (i = 0; i < fs->nb_in && !need_copy; i++) + if (i != in && fs->in[i].sync && + (!fs->in[i].have_next || fs->in[i].pts_next < pts_next)) + need_copy = 1; + if (need_copy) { + if (!(frame = av_frame_clone(frame))) + return AVERROR(ENOMEM); + if ((ret = av_frame_make_writable(frame)) < 0) { + av_frame_free(&frame); + return ret; + } + } else { + fs->in[in].frame = NULL; + } + fs->frame_ready = 0; + } + *rframe = frame; + return 0; +} + +void ff_framesync_uninit(FFFrameSync *fs) +{ + unsigned i; + + for (i = 0; i < fs->nb_in; i++) { + av_frame_free(&fs->in[i].frame); + av_frame_free(&fs->in[i].frame_next); + } + + av_freep(&fs->in); +} + +static int consume_from_fifos(FFFrameSync *fs) +{ + AVFilterContext *ctx = fs->parent; + AVFrame *frame = NULL; + int64_t pts; + unsigned i, nb_active, nb_miss; + int ret, status; + + nb_active = nb_miss = 0; + for (i = 0; i < fs->nb_in; i++) { + if (fs->in[i].have_next || fs->in[i].state == STATE_EOF) + continue; + nb_active++; + ret = ff_inlink_consume_frame(ctx->inputs[i], &frame); + if (ret < 0) + return ret; + if (ret) { + av_assert0(frame); + framesync_inject_frame(fs, i, frame); + } else { + ret = ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts); + if (ret > 0) { + framesync_inject_status(fs, i, status, pts); + } else if (!ret) { + nb_miss++; + } + } + } + if (nb_miss) { + if (nb_miss == nb_active && !ff_outlink_frame_wanted(ctx->outputs[0])) + return FFERROR_NOT_READY; + for (i = 0; i < fs->nb_in; i++) + if (!fs->in[i].have_next && fs->in[i].state != STATE_EOF) + ff_inlink_request_frame(ctx->inputs[i]); + return 0; + } + return 1; +} + +int ff_framesync_activate(FFFrameSync *fs) +{ + int ret; + + ret = framesync_advance(fs); + if (ret < 0) + return ret; + if (fs->eof || !fs->frame_ready) + return 0; + ret = fs->on_event(fs); + if (ret < 0) + return ret; + fs->frame_ready = 0; + + return 0; +} + +int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent) +{ + int ret; + + ret = ff_framesync_init(fs, parent, 2); + if (ret < 0) + return ret; + fs->in[0].time_base = parent->inputs[0]->time_base; + fs->in[1].time_base = parent->inputs[1]->time_base; + fs->in[0].sync = 2; + fs->in[0].before = EXT_STOP; + fs->in[0].after = EXT_INFINITY; + fs->in[1].sync = 1; + fs->in[1].before = EXT_NULL; + fs->in[1].after = EXT_INFINITY; + return 0; +} + +int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) +{ + AVFilterContext *ctx = fs->parent; + AVFrame *mainpic = NULL, *secondpic = NULL; + int ret = 0; + + if ((ret = ff_framesync_get_frame(fs, 0, &mainpic, 1)) < 0 || + (ret = ff_framesync_get_frame(fs, 1, &secondpic, 0)) < 0) { + av_frame_free(&mainpic); + return ret; + } + if (ret < 0) + return ret; + av_assert0(mainpic); + mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base); + if (ctx->is_disabled) + secondpic = NULL; + *f0 = mainpic; + *f1 = secondpic; + return 0; +} + +int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) +{ + int ret; + + ret = ff_framesync_dualinput_get(fs, f0, f1); + if (ret < 0) + return ret; + ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0); + if (ret < 0) { + av_frame_free(f0); + av_frame_free(f1); + return ret; + } + return 0; +} diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h new file mode 100644 index 0000000000..9fdc4d1ae2 --- /dev/null +++ b/libavfilter/framesync.h @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2013 Nicolas George + * + * This file is part of FFmpeg. + * + * 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. + * + * 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 FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_FRAMESYNC_H +#define AVFILTER_FRAMESYNC_H + +#include "bufferqueue.h" + +enum EOFAction { + EOF_ACTION_REPEAT, + EOF_ACTION_ENDALL, + EOF_ACTION_PASS +}; + +/* + * TODO + * Export convenient options. + */ + +/** + * This API is intended as a helper for filters that have several video + * input and need to combine them somehow. If the inputs have different or + * variable frame rate, getting the input frames to match requires a rather + * complex logic and a few user-tunable options. + * + * In this API, when a set of synchronized input frames is ready to be + * procesed is called a frame event. Frame event can be generated in + * response to input frames on any or all inputs and the handling of + * situations where some stream extend beyond the beginning or the end of + * others can be configured. + * + * The basic working of this API is the following: set the on_event + * callback, then call ff_framesync_activate() from the filter's activate + * callback. + */ + +/** + * Stream extrapolation mode + * + * Describe how the frames of a stream are extrapolated before the first one + * and after EOF to keep sync with possibly longer other streams. + */ +enum FFFrameSyncExtMode { + + /** + * Completely stop all streams with this one. + */ + EXT_STOP, + + /** + * Ignore this stream and continue processing the other ones. + */ + EXT_NULL, + + /** + * Extend the frame to infinity. + */ + EXT_INFINITY, +}; + +/** + * Input stream structure + */ +typedef struct FFFrameSyncIn { + + /** + * Extrapolation mode for timestamps before the first frame + */ + enum FFFrameSyncExtMode before; + + /** + * Extrapolation mode for timestamps after the last frame + */ + enum FFFrameSyncExtMode after; + + /** + * Time base for the incoming frames + */ + AVRational time_base; + + /** + * Current frame, may be NULL before the first one or after EOF + */ + AVFrame *frame; + + /** + * Next frame, for internal use + */ + AVFrame *frame_next; + + /** + * PTS of the current frame + */ + int64_t pts; + + /** + * PTS of the next frame, for internal use + */ + int64_t pts_next; + + /** + * Boolean flagging the next frame, for internal use + */ + uint8_t have_next; + + /** + * State: before first, in stream or after EOF, for internal use + */ + uint8_t state; + + /** + * Synchronization level: frames on input at the highest sync level will + * generate output frame events. + * + * For example, if inputs #0 and #1 have sync level 2 and input #2 has + * sync level 1, then a frame on either input #0 or #1 will generate a + * frame event, but not a frame on input #2 until both inputs #0 and #1 + * have reached EOF. + * + * If sync is 0, no frame event will be generated. + */ + unsigned sync; + +} FFFrameSyncIn; + +/** + * Frame sync structure. + */ +typedef struct FFFrameSync { + const AVClass *class; + + /** + * Parent filter context. + */ + AVFilterContext *parent; + + /** + * Number of input streams + */ + unsigned nb_in; + + /** + * Time base for the output events + */ + AVRational time_base; + + /** + * Timestamp of the current event + */ + int64_t pts; + + /** + * Callback called when a frame event is ready + */ + int (*on_event)(struct FFFrameSync *fs); + + /** + * Opaque pointer, not used by the API + */ + void *opaque; + + /** + * Index of the input that requires a request + */ + unsigned in_request; + + /** + * Synchronization level: only inputs with the same sync level are sync + * sources. + */ + unsigned sync_level; + + /** + * Flag indicating that a frame event is ready + */ + uint8_t frame_ready; + + /** + * Flag indicating that output has reached EOF. + */ + uint8_t eof; + + /** + * Pointer to array of inputs. + */ + FFFrameSyncIn *in; + + int opt_repeatlast; + int opt_shortest; + int opt_eof_action; + +} FFFrameSync; + +/** + * Get the class for the framesync object. + */ +const AVClass *framesync_get_class(void); + +/** + * Pre-initialize a frame sync structure. + * + * It sets the class pointer and inits the options to their default values. + * The entire structure is expected to be already set to 0. + * This step is optional, but necessary to use the options. + */ +void ff_framesync_preinit(FFFrameSync *fs); + +/** + * Initialize a frame sync structure. + * + * The entire structure is expected to be already set to 0 or preinited. + * + * @param fs frame sync structure to initialize + * @param parent parent AVFilterContext object + * @param nb_in number of inputs + * @return >= 0 for success or a negative error code + */ +int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in); + +/** + * Configure a frame sync structure. + * + * Must be called after all options are set but before all use. + * + * @return >= 0 for success or a negative error code + */ +int ff_framesync_configure(FFFrameSync *fs); + +/** + * Free all memory currently allocated. + */ +void ff_framesync_uninit(FFFrameSync *fs); + +/** + * Get the current frame in an input. + * + * @param fs frame sync structure + * @param in index of the input + * @param rframe used to return the current frame (or NULL) + * @param get if not zero, the calling code needs to get ownership of + * the returned frame; the current frame will either be + * duplicated or removed from the framesync structure + */ +int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, + unsigned get); + +/** + * Examine the frames in the filter's input and try to produce output. + * + * This function can be the complete implementation of the activate + * method of a filter using framesync. + */ +int ff_framesync_activate(FFFrameSync *fs); + +/** + * Initialize a frame sync structure for dualinput. + * + * Compared to generic framesync, dualinput assumes the first input is the + * main one and the filtering is performed on it. The first input will be + * the only one with sync set and generic timeline support will just pass it + * unchanged when disabled. + * + * Equivalent to ff_framesync_init(fs, parent, 2) then setting the time + * base, sync and ext modes on the inputs. + */ +int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent); + +/** + * @param f0 used to return the main frame + * @param f1 used to return the second frame, or NULL if disabled + * @return >=0 for success or AVERROR code + */ +int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1); + +/** + * Same as ff_framesync_dualinput_get(), but make sure that f0 is writable. + */ +int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1); + +#define FRAMESYNC_DEFINE_CLASS(name, context, field) \ +static int name##_framesync_preinit(AVFilterContext *ctx) { \ + context *s = ctx->priv; \ + ff_framesync_preinit(&s->field); \ + return 0; \ +} \ +static const AVClass *name##_child_class_next(const AVClass *prev) { \ + return prev ? NULL : framesync_get_class(); \ +} \ +static void *name##_child_next(void *obj, void *prev) { \ + context *s = obj; \ + s->fs.class = framesync_get_class(); /* FIXME */ \ + return prev ? NULL : &s->field; \ +} \ +static const AVClass name##_class = { \ + .class_name = #name, \ + .item_name = av_default_item_name, \ + .option = name##_options, \ + .version = LIBAVUTIL_VERSION_INT, \ + .category = AV_CLASS_CATEGORY_FILTER, \ + .child_class_next = name##_child_class_next, \ + .child_next = name##_child_next, \ +} + +#endif /* AVFILTER_FRAMESYNC_H */ diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c deleted file mode 100644 index aea9937ce9..0000000000 --- a/libavfilter/framesync2.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2013 Nicolas George - * - * This file is part of FFmpeg. - * - * 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. - * - * 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 FFmpeg; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/avassert.h" -#include "libavutil/opt.h" -#include "avfilter.h" -#include "filters.h" -#include "framesync2.h" -#include "internal.h" - -#define OFFSET(member) offsetof(FFFrameSync, member) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM - -static const char *framesync_name(void *ptr) -{ - return "framesync"; -} - -static const AVOption framesync_options[] = { - { "eof_action", "Action to take when encountering EOF from secondary input ", - OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT }, - EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" }, - { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" }, - { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" }, - { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" }, - { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, - { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, - { NULL } -}; -static const AVClass framesync_class = { - .version = LIBAVUTIL_VERSION_INT, - .class_name = "framesync", - .item_name = framesync_name, - .category = AV_CLASS_CATEGORY_FILTER, - .option = framesync_options, - .parent_log_context_offset = OFFSET(parent), -}; - -enum { - STATE_BOF, - STATE_RUN, - STATE_EOF, -}; - -static int consume_from_fifos(FFFrameSync *fs); - -const AVClass *framesync2_get_class(void) -{ - return &framesync_class; -} - -void ff_framesync2_preinit(FFFrameSync *fs) -{ - if (fs->class) - return; - fs->class = &framesync_class; - av_opt_set_defaults(fs); -} - -int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in) -{ - /* For filters with several outputs, we will not be able to assume which - output is relevant for ff_outlink_frame_wanted() and - ff_outlink_set_status(). To be designed when needed. */ - av_assert0(parent->nb_outputs == 1); - - ff_framesync2_preinit(fs); - fs->parent = parent; - fs->nb_in = nb_in; - - fs->in = av_calloc(nb_in, sizeof(*fs->in)); - if (!fs->in) - return AVERROR(ENOMEM); - return 0; -} - -static void framesync_eof(FFFrameSync *fs) -{ - fs->eof = 1; - fs->frame_ready = 0; - ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE); -} - -static void framesync_sync_level_update(FFFrameSync *fs) -{ - unsigned i, level = 0; - - for (i = 0; i < fs->nb_in; i++) - if (fs->in[i].state != STATE_EOF) - level = FFMAX(level, fs->in[i].sync); - av_assert0(level <= fs->sync_level); - if (level < fs->sync_level) - av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level); - if (level) - fs->sync_level = level; - else - framesync_eof(fs); -} - -int ff_framesync2_configure(FFFrameSync *fs) -{ - unsigned i; - int64_t gcd, lcm; - - if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) { - fs->opt_repeatlast = 0; - fs->opt_eof_action = EOF_ACTION_PASS; - } - if (fs->opt_shortest || fs->opt_eof_action == EOF_ACTION_ENDALL) { - fs->opt_shortest = 1; - fs->opt_eof_action = EOF_ACTION_ENDALL; - } - if (fs->opt_shortest) { - for (i = 0; i < fs->nb_in; i++) - fs->in[i].after = EXT_STOP; - } - if (!fs->opt_repeatlast) { - for (i = 1; i < fs->nb_in; i++) { - fs->in[i].after = EXT_NULL; - fs->in[i].sync = 0; - } - } - - if (!fs->time_base.num) { - for (i = 0; i < fs->nb_in; i++) { - if (fs->in[i].sync) { - if (fs->time_base.num) { - gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den); - lcm = (fs->time_base.den / gcd) * fs->in[i].time_base.den; - if (lcm < AV_TIME_BASE / 2) { - fs->time_base.den = lcm; - fs->time_base.num = av_gcd(fs->time_base.num, - fs->in[i].time_base.num); - } else { - fs->time_base.num = 1; - fs->time_base.den = AV_TIME_BASE; - break; - } - } else { - fs->time_base = fs->in[i].time_base; - } - } - } - if (!fs->time_base.num) { - av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n"); - return AVERROR(EINVAL); - } - av_log(fs, AV_LOG_VERBOSE, "Selected %d/%d time base\n", - fs->time_base.num, fs->time_base.den); - } - - for (i = 0; i < fs->nb_in; i++) - fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE; - fs->sync_level = UINT_MAX; - framesync_sync_level_update(fs); - - return 0; -} - -static int framesync_advance(FFFrameSync *fs) -{ - unsigned i; - int64_t pts; - int ret; - - while (!(fs->frame_ready || fs->eof)) { - ret = consume_from_fifos(fs); - if (ret <= 0) - return ret; - - pts = INT64_MAX; - for (i = 0; i < fs->nb_in; i++) - if (fs->in[i].have_next && fs->in[i].pts_next < pts) - pts = fs->in[i].pts_next; - if (pts == INT64_MAX) { - framesync_eof(fs); - break; - } - for (i = 0; i < fs->nb_in; i++) { - if (fs->in[i].pts_next == pts || - (fs->in[i].before == EXT_INFINITY && - fs->in[i].state == STATE_BOF)) { - av_frame_free(&fs->in[i].frame); - fs->in[i].frame = fs->in[i].frame_next; - fs->in[i].pts = fs->in[i].pts_next; - fs->in[i].frame_next = NULL; - fs->in[i].pts_next = AV_NOPTS_VALUE; - fs->in[i].have_next = 0; - fs->in[i].state = fs->in[i].frame ? STATE_RUN : STATE_EOF; - if (fs->in[i].sync == fs->sync_level && fs->in[i].frame) - fs->frame_ready = 1; - if (fs->in[i].state == STATE_EOF && - fs->in[i].after == EXT_STOP) - framesync_eof(fs); - } - } - if (fs->frame_ready) - for (i = 0; i < fs->nb_in; i++) - if ((fs->in[i].state == STATE_BOF && - fs->in[i].before == EXT_STOP)) - fs->frame_ready = 0; - fs->pts = pts; - } - return 0; -} - -static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in, - int64_t pts) -{ - /* Possible enhancement: use the link's frame rate */ - return pts + 1; -} - -static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame) -{ - int64_t pts; - - av_assert0(!fs->in[in].have_next); - av_assert0(frame); - pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base); - frame->pts = pts; - fs->in[in].frame_next = frame; - fs->in[in].pts_next = pts; - fs->in[in].have_next = 1; -} - -static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts) -{ - av_assert0(!fs->in[in].have_next); - pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY - ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts); - fs->in[in].sync = 0; - framesync_sync_level_update(fs); - fs->in[in].frame_next = NULL; - fs->in[in].pts_next = pts; - fs->in[in].have_next = 1; -} - -int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, - unsigned get) -{ - AVFrame *frame; - unsigned need_copy = 0, i; - int64_t pts_next; - int ret; - - if (!fs->in[in].frame) { - *rframe = NULL; - return 0; - } - frame = fs->in[in].frame; - if (get) { - /* Find out if we need to copy the frame: is there another sync - stream, and do we know if its current frame will outlast this one? */ - pts_next = fs->in[in].have_next ? fs->in[in].pts_next : INT64_MAX; - for (i = 0; i < fs->nb_in && !need_copy; i++) - if (i != in && fs->in[i].sync && - (!fs->in[i].have_next || fs->in[i].pts_next < pts_next)) - need_copy = 1; - if (need_copy) { - if (!(frame = av_frame_clone(frame))) - return AVERROR(ENOMEM); - if ((ret = av_frame_make_writable(frame)) < 0) { - av_frame_free(&frame); - return ret; - } - } else { - fs->in[in].frame = NULL; - } - fs->frame_ready = 0; - } - *rframe = frame; - return 0; -} - -void ff_framesync2_uninit(FFFrameSync *fs) -{ - unsigned i; - - for (i = 0; i < fs->nb_in; i++) { - av_frame_free(&fs->in[i].frame); - av_frame_free(&fs->in[i].frame_next); - } - - av_freep(&fs->in); -} - -static int consume_from_fifos(FFFrameSync *fs) -{ - AVFilterContext *ctx = fs->parent; - AVFrame *frame = NULL; - int64_t pts; - unsigned i, nb_active, nb_miss; - int ret, status; - - nb_active = nb_miss = 0; - for (i = 0; i < fs->nb_in; i++) { - if (fs->in[i].have_next || fs->in[i].state == STATE_EOF) - continue; - nb_active++; - ret = ff_inlink_consume_frame(ctx->inputs[i], &frame); - if (ret < 0) - return ret; - if (ret) { - av_assert0(frame); - framesync_inject_frame(fs, i, frame); - } else { - ret = ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts); - if (ret > 0) { - framesync_inject_status(fs, i, status, pts); - } else if (!ret) { - nb_miss++; - } - } - } - if (nb_miss) { - if (nb_miss == nb_active && !ff_outlink_frame_wanted(ctx->outputs[0])) - return FFERROR_NOT_READY; - for (i = 0; i < fs->nb_in; i++) - if (!fs->in[i].have_next && fs->in[i].state != STATE_EOF) - ff_inlink_request_frame(ctx->inputs[i]); - return 0; - } - return 1; -} - -int ff_framesync2_activate(FFFrameSync *fs) -{ - int ret; - - ret = framesync_advance(fs); - if (ret < 0) - return ret; - if (fs->eof || !fs->frame_ready) - return 0; - ret = fs->on_event(fs); - if (ret < 0) - return ret; - fs->frame_ready = 0; - - return 0; -} - -int ff_framesync2_init_dualinput(FFFrameSync *fs, AVFilterContext *parent) -{ - int ret; - - ret = ff_framesync2_init(fs, parent, 2); - if (ret < 0) - return ret; - fs->in[0].time_base = parent->inputs[0]->time_base; - fs->in[1].time_base = parent->inputs[1]->time_base; - fs->in[0].sync = 2; - fs->in[0].before = EXT_STOP; - fs->in[0].after = EXT_INFINITY; - fs->in[1].sync = 1; - fs->in[1].before = EXT_NULL; - fs->in[1].after = EXT_INFINITY; - return 0; -} - -int ff_framesync2_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) -{ - AVFilterContext *ctx = fs->parent; - AVFrame *mainpic = NULL, *secondpic = NULL; - int ret = 0; - - if ((ret = ff_framesync2_get_frame(fs, 0, &mainpic, 1)) < 0 || - (ret = ff_framesync2_get_frame(fs, 1, &secondpic, 0)) < 0) { - av_frame_free(&mainpic); - return ret; - } - if (ret < 0) - return ret; - av_assert0(mainpic); - mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base); - if (ctx->is_disabled) - secondpic = NULL; - *f0 = mainpic; - *f1 = secondpic; - return 0; -} - -int ff_framesync2_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) -{ - int ret; - - ret = ff_framesync2_dualinput_get(fs, f0, f1); - if (ret < 0) - return ret; - ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0); - if (ret < 0) { - av_frame_free(f0); - av_frame_free(f1); - return ret; - } - return 0; -} diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h deleted file mode 100644 index 63a0eabbeb..0000000000 --- a/libavfilter/framesync2.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright (c) 2013 Nicolas George - * - * This file is part of FFmpeg. - * - * 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. - * - * 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 FFmpeg; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFILTER_FRAMESYNC2_H -#define AVFILTER_FRAMESYNC2_H - -#include "bufferqueue.h" - -enum EOFAction { - EOF_ACTION_REPEAT, - EOF_ACTION_ENDALL, - EOF_ACTION_PASS -}; - -/* - * TODO - * Export convenient options. - */ - -/** - * This API is intended as a helper for filters that have several video - * input and need to combine them somehow. If the inputs have different or - * variable frame rate, getting the input frames to match requires a rather - * complex logic and a few user-tunable options. - * - * In this API, when a set of synchronized input frames is ready to be - * procesed is called a frame event. Frame event can be generated in - * response to input frames on any or all inputs and the handling of - * situations where some stream extend beyond the beginning or the end of - * others can be configured. - * - * The basic working of this API is the following: set the on_event - * callback, then call ff_framesync2_activate() from the filter's activate - * callback. - */ - -/** - * Stream extrapolation mode - * - * Describe how the frames of a stream are extrapolated before the first one - * and after EOF to keep sync with possibly longer other streams. - */ -enum FFFrameSyncExtMode { - - /** - * Completely stop all streams with this one. - */ - EXT_STOP, - - /** - * Ignore this stream and continue processing the other ones. - */ - EXT_NULL, - - /** - * Extend the frame to infinity. - */ - EXT_INFINITY, -}; - -/** - * Input stream structure - */ -typedef struct FFFrameSyncIn { - - /** - * Extrapolation mode for timestamps before the first frame - */ - enum FFFrameSyncExtMode before; - - /** - * Extrapolation mode for timestamps after the last frame - */ - enum FFFrameSyncExtMode after; - - /** - * Time base for the incoming frames - */ - AVRational time_base; - - /** - * Current frame, may be NULL before the first one or after EOF - */ - AVFrame *frame; - - /** - * Next frame, for internal use - */ - AVFrame *frame_next; - - /** - * PTS of the current frame - */ - int64_t pts; - - /** - * PTS of the next frame, for internal use - */ - int64_t pts_next; - - /** - * Boolean flagging the next frame, for internal use - */ - uint8_t have_next; - - /** - * State: before first, in stream or after EOF, for internal use - */ - uint8_t state; - - /** - * Synchronization level: frames on input at the highest sync level will - * generate output frame events. - * - * For example, if inputs #0 and #1 have sync level 2 and input #2 has - * sync level 1, then a frame on either input #0 or #1 will generate a - * frame event, but not a frame on input #2 until both inputs #0 and #1 - * have reached EOF. - * - * If sync is 0, no frame event will be generated. - */ - unsigned sync; - -} FFFrameSyncIn; - -/** - * Frame sync structure. - */ -typedef struct FFFrameSync { - const AVClass *class; - - /** - * Parent filter context. - */ - AVFilterContext *parent; - - /** - * Number of input streams - */ - unsigned nb_in; - - /** - * Time base for the output events - */ - AVRational time_base; - - /** - * Timestamp of the current event - */ - int64_t pts; - - /** - * Callback called when a frame event is ready - */ - int (*on_event)(struct FFFrameSync *fs); - - /** - * Opaque pointer, not used by the API - */ - void *opaque; - - /** - * Index of the input that requires a request - */ - unsigned in_request; - - /** - * Synchronization level: only inputs with the same sync level are sync - * sources. - */ - unsigned sync_level; - - /** - * Flag indicating that a frame event is ready - */ - uint8_t frame_ready; - - /** - * Flag indicating that output has reached EOF. - */ - uint8_t eof; - - /** - * Pointer to array of inputs. - */ - FFFrameSyncIn *in; - - int opt_repeatlast; - int opt_shortest; - int opt_eof_action; - -} FFFrameSync; - -/** - * Get the class for the framesync2 object. - */ -const AVClass *framesync2_get_class(void); - -/** - * Pre-initialize a frame sync structure. - * - * It sets the class pointer and inits the options to their default values. - * The entire structure is expected to be already set to 0. - * This step is optional, but necessary to use the options. - */ -void ff_framesync2_preinit(FFFrameSync *fs); - -/** - * Initialize a frame sync structure. - * - * The entire structure is expected to be already set to 0 or preinited. - * - * @param fs frame sync structure to initialize - * @param parent parent AVFilterContext object - * @param nb_in number of inputs - * @return >= 0 for success or a negative error code - */ -int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in); - -/** - * Configure a frame sync structure. - * - * Must be called after all options are set but before all use. - * - * @return >= 0 for success or a negative error code - */ -int ff_framesync2_configure(FFFrameSync *fs); - -/** - * Free all memory currently allocated. - */ -void ff_framesync2_uninit(FFFrameSync *fs); - -/** - * Get the current frame in an input. - * - * @param fs frame sync structure - * @param in index of the input - * @param rframe used to return the current frame (or NULL) - * @param get if not zero, the calling code needs to get ownership of - * the returned frame; the current frame will either be - * duplicated or removed from the framesync structure - */ -int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, - unsigned get); - -/** - * Examine the frames in the filter's input and try to produce output. - * - * This function can be the complete implementation of the activate - * method of a filter using framesync2. - */ -int ff_framesync2_activate(FFFrameSync *fs); - -/** - * Initialize a frame sync structure for dualinput. - * - * Compared to generic framesync, dualinput assumes the first input is the - * main one and the filtering is performed on it. The first input will be - * the only one with sync set and generic timeline support will just pass it - * unchanged when disabled. - * - * Equivalent to ff_framesync2_init(fs, parent, 2) then setting the time - * base, sync and ext modes on the inputs. - */ -int ff_framesync2_init_dualinput(FFFrameSync *fs, AVFilterContext *parent); - -/** - * @param f0 used to return the main frame - * @param f1 used to return the second frame, or NULL if disabled - * @return >=0 for success or AVERROR code - */ -int ff_framesync2_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1); - -/** - * Same as ff_framesync2_dualinput_get(), but make sure that f0 is writable. - */ -int ff_framesync2_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1); - -#define FRAMESYNC_DEFINE_CLASS(name, context, field) \ -static int name##_framesync_preinit(AVFilterContext *ctx) { \ - context *s = ctx->priv; \ - ff_framesync2_preinit(&s->field); \ - return 0; \ -} \ -static const AVClass *name##_child_class_next(const AVClass *prev) { \ - return prev ? NULL : framesync2_get_class(); \ -} \ -static void *name##_child_next(void *obj, void *prev) { \ - context *s = obj; \ - s->fs.class = framesync2_get_class(); /* FIXME */ \ - return prev ? NULL : &s->field; \ -} \ -static const AVClass name##_class = { \ - .class_name = #name, \ - .item_name = av_default_item_name, \ - .option = name##_options, \ - .version = LIBAVUTIL_VERSION_INT, \ - .category = AV_CLASS_CATEGORY_FILTER, \ - .child_class_next = name##_child_class_next, \ - .child_next = name##_child_next, \ -} - -#endif /* AVFILTER_FRAMESYNC2_H */ diff --git a/libavfilter/maskedmerge.h b/libavfilter/maskedmerge.h index 3d670f6d5d..8e2b1cf676 100644 --- a/libavfilter/maskedmerge.h +++ b/libavfilter/maskedmerge.h @@ -22,7 +22,7 @@ #define AVFILTER_MASKEDMERGE_H #include "avfilter.h" -#include "framesync2.h" +#include "framesync.h" typedef struct MaskedMergeContext { const AVClass *class; diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 4939b10150..054c0d55d0 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -25,7 +25,7 @@ #include "avfilter.h" #include "bufferqueue.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" #include "blend.h" @@ -411,7 +411,7 @@ static int blend_frame_for_dualinput(FFFrameSync *fs) AVFrame *top_buf, *bottom_buf, *dst_buf; int ret; - ret = ff_framesync2_dualinput_get(fs, &top_buf, &bottom_buf); + ret = ff_framesync_dualinput_get(fs, &top_buf, &bottom_buf); if (ret < 0) return ret; if (!bottom_buf) @@ -454,7 +454,7 @@ static av_cold void uninit(AVFilterContext *ctx) BlendContext *s = ctx->priv; int i; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_frame_free(&s->prev_frame); for (i = 0; i < FF_ARRAY_ELEMS(s->params); i++) @@ -554,7 +554,7 @@ static int config_output(AVFilterLink *outlink) s->nb_planes = av_pix_fmt_count_planes(toplink->format); if (!s->tblend) - if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0) + if ((ret = ff_framesync_init_dualinput(&s->fs, ctx)) < 0) return ret; for (plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) { @@ -581,7 +581,7 @@ static int config_output(AVFilterLink *outlink) } } - return s->tblend ? 0 : ff_framesync2_configure(&s->fs); + return s->tblend ? 0 : ff_framesync_configure(&s->fs); } #if CONFIG_BLEND_FILTER @@ -589,7 +589,7 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { BlendContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static const AVFilterPad blend_inputs[] = { diff --git a/libavfilter/vf_convolve.c b/libavfilter/vf_convolve.c index 63f3809598..e00a44d63d 100644 --- a/libavfilter/vf_convolve.c +++ b/libavfilter/vf_convolve.c @@ -25,7 +25,7 @@ #include "avfilter.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -262,7 +262,7 @@ static int do_convolve(FFFrameSync *fs) AVFrame *mainpic = NULL, *impulsepic = NULL; int ret, y, x, plane; - ret = ff_framesync2_dualinput_get(fs, &mainpic, &impulsepic); + ret = ff_framesync_dualinput_get(fs, &mainpic, &impulsepic); if (ret < 0) return ret; if (!impulsepic) @@ -336,7 +336,7 @@ static int config_output(AVFilterLink *outlink) int ret, i; s->fs.on_event = do_convolve; - ret = ff_framesync2_init_dualinput(&s->fs, ctx); + ret = ff_framesync_init_dualinput(&s->fs, ctx); if (ret < 0) return ret; outlink->w = mainlink->w; @@ -345,7 +345,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio; outlink->frame_rate = mainlink->frame_rate; - if ((ret = ff_framesync2_configure(&s->fs)) < 0) + if ((ret = ff_framesync_configure(&s->fs)) < 0) return ret; for (i = 0; i < s->nb_planes; i++) { @@ -361,7 +361,7 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { ConvolveContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -378,7 +378,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_fft_end(s->ifft[i]); } - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad convolve_inputs[] = { diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c index 9f16ad441f..768af6def4 100644 --- a/libavfilter/vf_displace.c +++ b/libavfilter/vf_displace.c @@ -23,7 +23,7 @@ #include "libavutil/opt.h" #include "avfilter.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -248,9 +248,9 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *in, *xpic, *ypic; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &in, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &xpic, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 2, &ypic, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &in, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &xpic, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 2, &ypic, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -336,7 +336,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = srclink->sample_aspect_ratio; outlink->frame_rate = srclink->frame_rate; - ret = ff_framesync2_init(&s->fs, ctx, 3); + ret = ff_framesync_init(&s->fs, ctx, 3); if (ret < 0) return ret; @@ -356,20 +356,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { DisplaceContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { DisplaceContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad displace_inputs[] = { diff --git a/libavfilter/vf_hysteresis.c b/libavfilter/vf_hysteresis.c index 8ee827d8af..a788e1b9ee 100644 --- a/libavfilter/vf_hysteresis.c +++ b/libavfilter/vf_hysteresis.c @@ -26,7 +26,7 @@ #include "formats.h" #include "internal.h" #include "video.h" -#include "framesync2.h" +#include "framesync.h" #define OFFSET(x) offsetof(HysteresisContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM @@ -94,8 +94,8 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *base, *alt; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &base, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &alt, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &alt, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -324,7 +324,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = base->sample_aspect_ratio; outlink->frame_rate = base->frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, 2)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0) return ret; in = s->fs.in; @@ -339,20 +339,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { HysteresisContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { HysteresisContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_freep(&s->map); av_freep(&s->xy); } diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 405820f182..2c3a9f3349 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -32,7 +32,7 @@ #include "avfilter.h" #include "drawutils.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -177,7 +177,7 @@ static int do_vmaf(FFFrameSync *fs) AVFrame *main, *ref; int ret; - ret = ff_framesync2_dualinput_get(fs, &main, &ref); + ret = ff_framesync_dualinput_get(fs, &main, &ref); if (ret < 0) return ret; if (!ref) @@ -266,7 +266,7 @@ static int config_output(AVFilterLink *outlink) AVFilterLink *mainlink = ctx->inputs[0]; int ret; - ret = ff_framesync2_init_dualinput(&s->fs, ctx); + ret = ff_framesync_init_dualinput(&s->fs, ctx); if (ret < 0) return ret; outlink->w = mainlink->w; @@ -274,7 +274,7 @@ static int config_output(AVFilterLink *outlink) outlink->time_base = mainlink->time_base; outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio; outlink->frame_rate = mainlink->frame_rate; - if ((ret = ff_framesync2_configure(&s->fs)) < 0) + if ((ret = ff_framesync_configure(&s->fs)) < 0) return ret; return 0; @@ -283,14 +283,14 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { LIBVMAFContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { LIBVMAFContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); pthread_mutex_lock(&s->lock); s->eof = 1; diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c index ba599c3d14..585d121ca3 100644 --- a/libavfilter/vf_lut2.c +++ b/libavfilter/vf_lut2.c @@ -28,7 +28,7 @@ #include "formats.h" #include "internal.h" #include "video.h" -#include "framesync2.h" +#include "framesync.h" static const char *const var_names[] = { "w", ///< width of the input video @@ -85,7 +85,7 @@ static av_cold void uninit(AVFilterContext *ctx) LUT2Context *s = ctx->priv; int i; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_frame_free(&s->prev_frame); for (i = 0; i < 4; i++) { @@ -216,8 +216,8 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *srcx = NULL, *srcy = NULL; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &srcx, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &srcy, 0)) < 0) return ret; if (ctx->is_disabled || !srcy) { @@ -327,7 +327,7 @@ static int lut2_config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = srcx->sample_aspect_ratio; outlink->frame_rate = srcx->frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, 2)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0) return ret; in = s->fs.in; @@ -345,13 +345,13 @@ static int lut2_config_output(AVFilterLink *outlink) if ((ret = config_output(outlink)) < 0) return ret; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { LUT2Context *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static const AVFilterPad inputs[] = { diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index 5ba91f7e47..39cd73f0de 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -32,7 +32,7 @@ #include "avfilter.h" #include "drawutils.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -681,13 +681,13 @@ static int config_output(AVFilterLink *outlink) LUT3DContext *lut3d = ctx->priv; int ret; - ret = ff_framesync2_init_dualinput(&lut3d->fs, ctx); + ret = ff_framesync_init_dualinput(&lut3d->fs, ctx); if (ret < 0) return ret; outlink->w = ctx->inputs[0]->w; outlink->h = ctx->inputs[0]->h; outlink->time_base = ctx->inputs[0]->time_base; - if ((ret = ff_framesync2_configure(&lut3d->fs)) < 0) + if ((ret = ff_framesync_configure(&lut3d->fs)) < 0) return ret; return 0; } @@ -695,7 +695,7 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { LUT3DContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static int config_clut(AVFilterLink *inlink) @@ -755,7 +755,7 @@ static int update_apply_clut(FFFrameSync *fs) AVFrame *main, *second, *out; int ret; - ret = ff_framesync2_dualinput_get(fs, &main, &second); + ret = ff_framesync_dualinput_get(fs, &main, &second); if (ret < 0) return ret; if (!second) @@ -775,7 +775,7 @@ static av_cold int haldclut_init(AVFilterContext *ctx) static av_cold void haldclut_uninit(AVFilterContext *ctx) { LUT3DContext *lut3d = ctx->priv; - ff_framesync2_uninit(&lut3d->fs); + ff_framesync_uninit(&lut3d->fs); } static const AVOption haldclut_options[] = { diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c index 81ba05147c..67a979f8c0 100644 --- a/libavfilter/vf_maskedclamp.c +++ b/libavfilter/vf_maskedclamp.c @@ -25,7 +25,7 @@ #include "formats.h" #include "internal.h" #include "video.h" -#include "framesync2.h" +#include "framesync.h" #define OFFSET(x) offsetof(MaskedClampContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM @@ -93,9 +93,9 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *base, *dark, *bright; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &base, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &dark, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 2, &bright, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &dark, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 2, &bright, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -265,7 +265,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = base->sample_aspect_ratio; outlink->frame_rate = base->frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, 3)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 3)) < 0) return ret; in = s->fs.in; @@ -284,20 +284,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { MaskedClampContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { MaskedClampContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad maskedclamp_inputs[] = { diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c index cd11c959f6..d31b92659e 100644 --- a/libavfilter/vf_maskedmerge.c +++ b/libavfilter/vf_maskedmerge.c @@ -71,9 +71,9 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *base, *overlay, *mask; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &base, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &overlay, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 2, &mask, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &overlay, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 2, &mask, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -232,7 +232,7 @@ static int config_output(AVFilterLink *outlink) if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, outlink->w)) < 0) return ret; - if ((ret = ff_framesync2_init(&s->fs, ctx, 3)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 3)) < 0) return ret; in = s->fs.in; @@ -251,20 +251,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { MaskedMergeContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { MaskedMergeContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad maskedmerge_inputs[] = { diff --git a/libavfilter/vf_mergeplanes.c b/libavfilter/vf_mergeplanes.c index b8ccee0802..4b4f91be5d 100644 --- a/libavfilter/vf_mergeplanes.c +++ b/libavfilter/vf_mergeplanes.c @@ -25,7 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "internal.h" -#include "framesync2.h" +#include "framesync.h" typedef struct InputParam { int depth[4]; @@ -143,7 +143,7 @@ static int process_frame(FFFrameSync *fs) int i, ret; for (i = 0; i < s->nb_inputs; i++) { - if ((ret = ff_framesync2_get_frame(&s->fs, i, &in[i], 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0) return ret; } @@ -172,7 +172,7 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int i, ret; - if ((ret = ff_framesync2_init(&s->fs, ctx, s->nb_inputs)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, s->nb_inputs)) < 0) return ret; in = s->fs.in; @@ -265,7 +265,7 @@ static int config_output(AVFilterLink *outlink) } } - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); fail: return AVERROR(EINVAL); } @@ -273,7 +273,7 @@ fail: static int activate(AVFilterContext *ctx) { MergePlanesContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -281,7 +281,7 @@ static av_cold void uninit(AVFilterContext *ctx) MergePlanesContext *s = ctx->priv; int i; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); for (i = 0; i < ctx->nb_inputs; i++) av_freep(&ctx->input_pads[i].name); diff --git a/libavfilter/vf_midequalizer.c b/libavfilter/vf_midequalizer.c index 8101741bdc..c03814a24f 100644 --- a/libavfilter/vf_midequalizer.c +++ b/libavfilter/vf_midequalizer.c @@ -25,7 +25,7 @@ #include "formats.h" #include "internal.h" #include "video.h" -#include "framesync2.h" +#include "framesync.h" typedef struct MidEqualizerContext { const AVClass *class; @@ -89,8 +89,8 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *in0, *in1; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &in0, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &in1, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &in0, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &in1, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -311,7 +311,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = in0->sample_aspect_ratio; outlink->frame_rate = in0->frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, 2)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0) return ret; in = s->fs.in; @@ -326,20 +326,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { MidEqualizerContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { MidEqualizerContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_freep(&s->histogram[0]); av_freep(&s->histogram[1]); av_freep(&s->cchange); diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 619a5a6354..5bf3d66cf1 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -37,7 +37,7 @@ #include "libavutil/timestamp.h" #include "internal.h" #include "drawutils.h" -#include "framesync2.h" +#include "framesync.h" #include "video.h" static const char *const var_names[] = { @@ -130,7 +130,7 @@ static av_cold void uninit(AVFilterContext *ctx) { OverlayContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_expr_free(s->x_pexpr); s->x_pexpr = NULL; av_expr_free(s->y_pexpr); s->y_pexpr = NULL; } @@ -377,14 +377,14 @@ static int config_output(AVFilterLink *outlink) OverlayContext *s = ctx->priv; int ret; - if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0) + if ((ret = ff_framesync_init_dualinput(&s->fs, ctx)) < 0) return ret; outlink->w = ctx->inputs[MAIN]->w; outlink->h = ctx->inputs[MAIN]->h; outlink->time_base = ctx->inputs[MAIN]->time_base; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } // divide by 255 and round to nearest @@ -765,7 +765,7 @@ static int do_blend(FFFrameSync *fs) AVFilterLink *inlink = ctx->inputs[0]; int ret; - ret = ff_framesync2_dualinput_get_writable(fs, &mainpic, &second); + ret = ff_framesync_dualinput_get_writable(fs, &mainpic, &second); if (ret < 0) return ret; if (!second) @@ -808,7 +808,7 @@ static av_cold int init(AVFilterContext *ctx) static int activate(AVFilterContext *ctx) { OverlayContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } #define OFFSET(x) offsetof(OverlayContext, x) diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index 3d16c2dd84..ffd37bf1da 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -29,7 +29,7 @@ #include "libavutil/qsort.h" #include "avfilter.h" #include "filters.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" enum dithering_mode { @@ -904,7 +904,7 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; PaletteUseContext *s = ctx->priv; - ret = ff_framesync2_init_dualinput(&s->fs, ctx); + ret = ff_framesync_init_dualinput(&s->fs, ctx); if (ret < 0) return ret; s->fs.opt_repeatlast = 1; // only 1 frame in the palette @@ -915,7 +915,7 @@ static int config_output(AVFilterLink *outlink) outlink->h = ctx->inputs[0]->h; outlink->time_base = ctx->inputs[0]->time_base; - if ((ret = ff_framesync2_configure(&s->fs)) < 0) + if ((ret = ff_framesync_configure(&s->fs)) < 0) return ret; return 0; } @@ -971,7 +971,7 @@ static int load_apply_palette(FFFrameSync *fs) int ret; // writable for error diffusal dithering - ret = ff_framesync2_dualinput_get_writable(fs, &main, &second); + ret = ff_framesync_dualinput_get_writable(fs, &main, &second); if (ret < 0) return ret; if (!main || !second) { @@ -1052,7 +1052,7 @@ static av_cold int init(AVFilterContext *ctx) static int activate(AVFilterContext *ctx) { PaletteUseContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -1060,7 +1060,7 @@ static av_cold void uninit(AVFilterContext *ctx) int i; PaletteUseContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); for (i = 0; i < CACHE_SIZE; i++) av_freep(&s->cache[i].entries); av_frame_free(&s->last_in); diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c index 148a9e55cb..5120adc476 100644 --- a/libavfilter/vf_premultiply.c +++ b/libavfilter/vf_premultiply.c @@ -24,7 +24,7 @@ #include "avfilter.h" #include "filters.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -503,8 +503,8 @@ static int process_frame(FFFrameSync *fs) AVFrame *out = NULL, *base, *alpha; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &base, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &alpha, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &alpha, 0)) < 0) return ret; if ((ret = filter_frame(ctx, &out, base, alpha)) < 0) @@ -578,7 +578,7 @@ static int config_output(AVFilterLink *outlink) if (s->inplace) return 0; - if ((ret = ff_framesync2_init(&s->fs, ctx, 2)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0) return ret; in = s->fs.in; @@ -593,7 +593,7 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) @@ -623,7 +623,7 @@ static int activate(AVFilterContext *ctx) return 0; } } else { - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } } @@ -668,7 +668,7 @@ static av_cold void uninit(AVFilterContext *ctx) PreMultiplyContext *s = ctx->priv; if (!s->inplace) - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad premultiply_outputs[] = { diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c index a8eb315445..adf16444ff 100644 --- a/libavfilter/vf_psnr.c +++ b/libavfilter/vf_psnr.c @@ -31,7 +31,7 @@ #include "avfilter.h" #include "drawutils.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "psnr.h" #include "video.h" @@ -151,7 +151,7 @@ static int do_psnr(FFFrameSync *fs) int ret, j, c; AVDictionary **metadata; - ret = ff_framesync2_dualinput_get(fs, &main, &ref); + ret = ff_framesync_dualinput_get(fs, &main, &ref); if (ret < 0) return ret; if (!ref) @@ -339,7 +339,7 @@ static int config_output(AVFilterLink *outlink) AVFilterLink *mainlink = ctx->inputs[0]; int ret; - ret = ff_framesync2_init_dualinput(&s->fs, ctx); + ret = ff_framesync_init_dualinput(&s->fs, ctx); if (ret < 0) return ret; outlink->w = mainlink->w; @@ -347,7 +347,7 @@ static int config_output(AVFilterLink *outlink) outlink->time_base = mainlink->time_base; outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio; outlink->frame_rate = mainlink->frame_rate; - if ((ret = ff_framesync2_configure(&s->fs)) < 0) + if ((ret = ff_framesync_configure(&s->fs)) < 0) return ret; return 0; @@ -356,7 +356,7 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { PSNRContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -380,7 +380,7 @@ static av_cold void uninit(AVFilterContext *ctx) get_psnr(s->min_mse, 1, s->average_max)); } - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); if (s->stats_file && s->stats_file != stdout) fclose(s->stats_file); diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c index a62ec4c183..d24284703b 100644 --- a/libavfilter/vf_remap.c +++ b/libavfilter/vf_remap.c @@ -41,7 +41,7 @@ #include "libavutil/opt.h" #include "avfilter.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -286,9 +286,9 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *in, *xpic, *ypic; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &in, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &xpic, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 2, &ypic, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &in, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &xpic, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 2, &ypic, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -333,7 +333,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = srclink->sample_aspect_ratio; outlink->frame_rate = srclink->frame_rate; - ret = ff_framesync2_init(&s->fs, ctx, 3); + ret = ff_framesync_init(&s->fs, ctx, 3); if (ret < 0) return ret; @@ -353,13 +353,13 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { RemapContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } @@ -367,7 +367,7 @@ static av_cold void uninit(AVFilterContext *ctx) { RemapContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad remap_inputs[] = { diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c index 5f5bed7a0e..40f09ad5aa 100644 --- a/libavfilter/vf_ssim.c +++ b/libavfilter/vf_ssim.c @@ -40,7 +40,7 @@ #include "avfilter.h" #include "drawutils.h" #include "formats.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "ssim.h" #include "video.h" @@ -291,7 +291,7 @@ static int do_ssim(FFFrameSync *fs) float c[4], ssimv = 0.0; int ret, i; - ret = ff_framesync2_dualinput_get(fs, &main, &ref); + ret = ff_framesync_dualinput_get(fs, &main, &ref); if (ret < 0) return ret; if (!ref) @@ -431,7 +431,7 @@ static int config_output(AVFilterLink *outlink) AVFilterLink *mainlink = ctx->inputs[0]; int ret; - ret = ff_framesync2_init_dualinput(&s->fs, ctx); + ret = ff_framesync_init_dualinput(&s->fs, ctx); if (ret < 0) return ret; outlink->w = mainlink->w; @@ -440,7 +440,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio; outlink->frame_rate = mainlink->frame_rate; - if ((ret = ff_framesync2_configure(&s->fs)) < 0) + if ((ret = ff_framesync_configure(&s->fs)) < 0) return ret; return 0; @@ -449,7 +449,7 @@ static int config_output(AVFilterLink *outlink) static int activate(AVFilterContext *ctx) { SSIMContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -469,7 +469,7 @@ static av_cold void uninit(AVFilterContext *ctx) s->ssim_total / s->nb_frames, ssim_db(s->ssim_total, s->nb_frames)); } - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); if (s->stats_file && s->stats_file != stdout) fclose(s->stats_file); diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c index fa8a02257e..2467302159 100644 --- a/libavfilter/vf_stack.c +++ b/libavfilter/vf_stack.c @@ -26,7 +26,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" -#include "framesync2.h" +#include "framesync.h" #include "video.h" typedef struct StackContext { @@ -97,7 +97,7 @@ static int process_frame(FFFrameSync *fs) int i, p, ret, offset[4] = { 0 }; for (i = 0; i < s->nb_inputs; i++) { - if ((ret = ff_framesync2_get_frame(&s->fs, i, &in[i], 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0) return ret; } @@ -180,7 +180,7 @@ static int config_output(AVFilterLink *outlink) outlink->time_base = time_base; outlink->frame_rate = frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, s->nb_inputs)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, s->nb_inputs)) < 0) return ret; in = s->fs.in; @@ -196,7 +196,7 @@ static int config_output(AVFilterLink *outlink) in[i].after = s->shortest ? EXT_STOP : EXT_INFINITY; } - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) @@ -204,7 +204,7 @@ static av_cold void uninit(AVFilterContext *ctx) StackContext *s = ctx->priv; int i; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); av_freep(&s->frames); for (i = 0; i < ctx->nb_inputs; i++) @@ -214,7 +214,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int activate(AVFilterContext *ctx) { StackContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } #define OFFSET(x) offsetof(StackContext, x) diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c index 4e31ab4c0f..88f6ef28d7 100644 --- a/libavfilter/vf_threshold.c +++ b/libavfilter/vf_threshold.c @@ -28,7 +28,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" -#include "framesync2.h" +#include "framesync.h" #include "internal.h" #include "video.h" @@ -96,10 +96,10 @@ static int process_frame(FFFrameSync *fs) AVFrame *out, *in, *threshold, *min, *max; int ret; - if ((ret = ff_framesync2_get_frame(&s->fs, 0, &in, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 1, &threshold, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 2, &min, 0)) < 0 || - (ret = ff_framesync2_get_frame(&s->fs, 3, &max, 0)) < 0) + if ((ret = ff_framesync_get_frame(&s->fs, 0, &in, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 1, &threshold, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 2, &min, 0)) < 0 || + (ret = ff_framesync_get_frame(&s->fs, 3, &max, 0)) < 0) return ret; if (ctx->is_disabled) { @@ -256,7 +256,7 @@ static int config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = base->sample_aspect_ratio; outlink->frame_rate = base->frame_rate; - if ((ret = ff_framesync2_init(&s->fs, ctx, 4)) < 0) + if ((ret = ff_framesync_init(&s->fs, ctx, 4)) < 0) return ret; in = s->fs.in; @@ -279,20 +279,20 @@ static int config_output(AVFilterLink *outlink) s->fs.opaque = s; s->fs.on_event = process_frame; - return ff_framesync2_configure(&s->fs); + return ff_framesync_configure(&s->fs); } static int activate(AVFilterContext *ctx) { ThresholdContext *s = ctx->priv; - return ff_framesync2_activate(&s->fs); + return ff_framesync_activate(&s->fs); } static av_cold void uninit(AVFilterContext *ctx) { ThresholdContext *s = ctx->priv; - ff_framesync2_uninit(&s->fs); + ff_framesync_uninit(&s->fs); } static const AVFilterPad inputs[] = { -- cgit v1.2.3