21#define DEFAULT_RESULT_NAME "transforms.trf"
23#include <vid.stab/libvidstab.h>
47#define OFFSET(x) offsetof(StabData, x)
48#define OFFSETC(x) (offsetof(StabData, conf)+offsetof(VSMotionDetectConfig, x))
49#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
53 {
"shakiness",
"how shaky is the video and how quick is the camera?"
56 {
"stepsize",
"region around minimum is scanned with 1 pixel resolution",
OFFSETC(stepSize),
AV_OPT_TYPE_INT, {.i64 = 6}, 1, 32,
FLAGS},
59 {
"tripod",
"virtual tripod mode (if >0): motion is compared to a reference"
61#ifdef LIBVIDSTAB_FILE_FORMAT_VERSION
62 {
"fileformat",
"transforms data file format",
OFFSET(fileformat),
AV_OPT_TYPE_INT, {.i64 = BINARY_SERIALIZATION_MODE}, ASCII_SERIALIZATION_MODE, BINARY_SERIALIZATION_MODE,
FLAGS, .unit =
"file_format"},
63 {
"ascii",
"ASCII text", 0,
AV_OPT_TYPE_CONST, {.i64 = ASCII_SERIALIZATION_MODE }, 0, 0,
FLAGS, .unit =
"file_format"},
64 {
"binary",
"binary", 0,
AV_OPT_TYPE_CONST, {.i64 = BINARY_SERIALIZATION_MODE}, 0, 0,
FLAGS, .unit =
"file_format"},
75 s->class = &vidstabdetect_class;
83 VSMotionDetect *
md = &(
s->md);
90 vsMotionDetectionCleanup(
md);
98 VSMotionDetect*
md = &(
s->md);
102 const char *file_mode =
"w";
104#ifdef LIBVIDSTAB_FILE_FORMAT_VERSION
105 md->serializationMode =
s->fileformat;
106 if (
s->fileformat == BINARY_SERIALIZATION_MODE)
110 vsFrameInfoInit(&fi, inlink->
w, inlink->
h,
116 if (fi.log2ChromaW !=
desc->log2_chroma_w) {
121 if (fi.log2ChromaH !=
desc->log2_chroma_h) {
128 s->conf.modName =
"vidstabdetect";
129 if (vsMotionDetectInit(
md, &
s->conf, &fi) != VS_OK) {
134 vsMotionDetectGetConfig(&
s->conf,
md);
149 if (vsPrepareFile(
md,
s->f) != VS_OK) {
161 VSMotionDetect *
md = &(
s->md);
162 LocalMotions localmotions;
176 for (plane = 0; plane <
md->fi.planes; plane++) {
180 if (vsMotionDetection(
md, &localmotions, &
frame) != VS_OK) {
184 if (vsWriteToFile(
md,
s->f, &localmotions) != VS_OK) {
189 vs_vector_del(&localmotions);
205 .p.name =
"vidstabdetect",
207 "pass 1 of 2 for stabilization "
208 "(see vidstabtransform for pass 2)."),
210 .p.priv_class = &vidstabdetect_class,
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_vidstabdetect
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Main libavfilter public API header.
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AVERROR_EXTERNAL
Generic error in an external library.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Describe the class of an AVClass context structure.
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VSMotionDetectConfig conf
static AVFormatContext * ctx
static const AVOption vidstabdetect_options[]
#define DEFAULT_RESULT_NAME
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad avfilter_vf_vidstabdetect_inputs[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
VSPixelFormat ff_av2vs_pixfmt(AVFilterContext *ctx, enum AVPixelFormat pf)
convert AV's pixelformat to vid.stab pixelformat
enum AVPixelFormat ff_vidstab_pix_fmts[]
void ff_vs_init(void)
sets the memory allocation function and logging constants to av versions