Commit b07d4a0f authored by Davinder Singh's avatar Davinder Singh Committed by Michael Niedermayer

avfilter: added motion estimation and interpolation filters

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent bcd11531
......@@ -9434,6 +9434,134 @@ format=rgb24,mergeplanes=0x000102:yuv444p
@end example
@end itemize
@section mestimate
Estimate and export motion vectors using block matching algorithms.
Motion vectors are stored in frame side data to be used by other filters.
This filter accepts the following options:
@table @option
@item method
Specify the motion estimation method. Accepts one of the following values:
@table @samp
@item esa
Exhaustive search algorithm.
@item tss
Three step search algorithm.
@item tdls
Two dimensional logarithmic search algorithm.
@item ntss
New three step search algorithm.
@item fss
Four step search algorithm.
@item ds
Diamond search algorithm.
@item hexbs
Hexagon-based search algorithm.
@item epzs
Enhanced predictive zonal search algorithm.
@item umh
Uneven multi-hexagon search algorithm.
@end table
Default value is @samp{esa}.
@item mb_size
Macroblock size. Default @code{16}.
@item search_param
Search parameter. Default @code{7}.
@end table
@section minterpolate
Convert the video to specified frame rate using motion interpolation.
This filter accepts the following options:
@table @option
@item fps
Specify the output frame rate. This can be rational e.g. @code{60000/1001}. Frames are dropped if @var{fps} is lower than source fps. Default @code{60}.
@item mi_mode
Motion interpolation mode. Following values are accepted:
@table @samp
@item dup
Duplicate previous or next frame for interpolating new ones.
@item blend
Blend source frames. Interpolated frame is mean of previous and next frames.
@item mci
Motion compensated interpolation. Following options are effective when this mode is selected:
@table @samp
@item mc_mode
Motion compensation mode. Following values are accepted:
@table @samp
@item obmc
Overlapped block motion compensation.
@item aobmc
Adaptive overlapped block motion compensation. Window weighting coefficients are controlled adaptively according to the reliabilities of the neighboring motion vectors to reduce oversmoothing.
@end table
Default mode is @samp{obmc}.
@item me_mode
Motion estimation mode. Following values are accepted:
@table @samp
@item bidir
Bidirectional motion estimation. Motion vectors are estimated for each source frame in both forward and backward directions.
@item bilat
Bilateral motion estimation. Motion vectors are estimated directly for interpolated frame.
@end table
Default mode is @samp{bilat}.
@item me
The algorithm to be used for motion estimation. Following values are accepted:
@table @samp
@item esa
Exhaustive search algorithm.
@item tss
Three step search algorithm.
@item tdls
Two dimensional logarithmic search algorithm.
@item ntss
New three step search algorithm.
@item fss
Four step search algorithm.
@item ds
Diamond search algorithm.
@item hexbs
Hexagon-based search algorithm.
@item epzs
Enhanced predictive zonal search algorithm.
@item umh
Uneven multi-hexagon search algorithm.
@end table
Default algorithm is @samp{epzs}.
@item mb_size
Macroblock size. Default @code{16}.
@item search_param
Motion estimation search parameter. Default @code{32}.
@item vsmbc
Enable variable-size block motion compensation. Motion estimation is applied with smaller block sizes at object boundaries in order to make the them less blur. Default is @code{0} (disabled).
@end table
@end table
@item scd
Scene change detection method. Scene change leads motion vectors to be in random direction. Scene change detection replace interpolated frames by duplicate ones. May not be needed for other modes. Following values are accepted:
@table @samp
@item none
Disable scene change detection.
@item fdiff
Frame difference. Corresponding pixel values are compared and if it statisfies @var{scd_threshold} scene change is detected.
@end table
Default method is @samp{fdiff}.
@item scd_threshold
Scene change detection threshold. Default is @code{5.0}.
@end table
@section mpdecimate
Drop frames that do not differ greatly from the previous frame in
......
......@@ -213,7 +213,9 @@ 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 framesync.o
OBJS-$(CONFIG_MESTIMATE_FILTER) += vf_mestimate.o motion_estimation.o
OBJS-$(CONFIG_METADATA_FILTER) += f_metadata.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
OBJS-$(CONFIG_NNEDI_FILTER) += vf_nnedi.o
......
......@@ -230,7 +230,9 @@ void avfilter_register_all(void)
REGISTER_FILTER(MASKEDMERGE, maskedmerge, vf);
REGISTER_FILTER(MCDEINT, mcdeint, vf);
REGISTER_FILTER(MERGEPLANES, mergeplanes, vf);
REGISTER_FILTER(MESTIMATE, mestimate, vf);
REGISTER_FILTER(METADATA, metadata, vf);
REGISTER_FILTER(MINTERPOLATE, minterpolate, vf);
REGISTER_FILTER(MPDECIMATE, mpdecimate, vf);
REGISTER_FILTER(NEGATE, negate, vf);
REGISTER_FILTER(NNEDI, nnedi, vf);
......
This diff is collapsed.
/**
* Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>
*
* 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_MOTION_ESTIMATION_H
#define AVFILTER_MOTION_ESTIMATION_H
#include "libavutil/avutil.h"
#define AV_ME_METHOD_ESA 1
#define AV_ME_METHOD_TSS 2
#define AV_ME_METHOD_TDLS 3
#define AV_ME_METHOD_NTSS 4
#define AV_ME_METHOD_FSS 5
#define AV_ME_METHOD_DS 6
#define AV_ME_METHOD_HEXBS 7
#define AV_ME_METHOD_EPZS 8
#define AV_ME_METHOD_UMH 9
typedef struct AVMotionEstPredictor {
int mvs[10][2];
int nb;
} AVMotionEstPredictor;
typedef struct AVMotionEstContext {
uint8_t *data_cur, *data_ref;
int linesize;
int mb_size;
int search_param;
int width;
int height;
int x_min;
int x_max;
int y_min;
int y_max;
int pred_x; ///< median predictor x
int pred_y; ///< median predictor y
AVMotionEstPredictor preds[2];
uint64_t (*get_cost)(struct AVMotionEstContext *me_ctx, int x_mb, int y_mb,
int mv_x, int mv_y);
} AVMotionEstContext;
void ff_me_init_context(AVMotionEstContext *me_ctx, int mb_size, int search_param,
int width, int height, int x_min, int x_max, int y_min, int y_max);
uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int x_mv, int y_mv);
uint64_t ff_me_search_esa(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_tss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_tdls(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_ntss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_fss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_ds(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_hexbs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv);
#endif /* AVFILTER_MOTION_ESTIMATION_H */
......@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 6
#define LIBAVFILTER_VERSION_MINOR 55
#define LIBAVFILTER_VERSION_MINOR 56
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment