Go to the documentation of this file.
21 #define DEFAULT_RESULT_NAME "transforms.trf"
23 #include <vid.stab/libvidstab.h>
48 #define OFFSET(x) offsetof(StabData, x)
49 #define OFFSETC(x) (offsetof(StabData, conf)+offsetof(VSMotionDetectConfig, x))
50 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
54 {
"shakiness",
"how shaky is the video and how quick is the camera?"
57 {
"stepsize",
"region around minimum is scanned with 1 pixel resolution",
OFFSETC(stepSize),
AV_OPT_TYPE_INT, {.i64 = 6}, 1, 32,
FLAGS},
60 {
"tripod",
"virtual tripod mode (if >0): motion is compared to a reference"
62 #ifdef LIBVIDSTAB_FILE_FORMAT_VERSION
63 {
"fileformat",
"transforms data file format",
OFFSET(fileformat),
AV_OPT_TYPE_INT, {.i64 = BINARY_SERIALIZATION_MODE}, ASCII_SERIALIZATION_MODE, BINARY_SERIALIZATION_MODE,
FLAGS,
"file_format"},
64 {
"ascii",
"ASCII text", 0,
AV_OPT_TYPE_CONST, {.i64 = ASCII_SERIALIZATION_MODE }, 0, 0,
FLAGS,
"file_format"},
65 {
"binary",
"binary", 0,
AV_OPT_TYPE_CONST, {.i64 = BINARY_SERIALIZATION_MODE}, 0, 0,
FLAGS,
"file_format"},
76 s->class = &vidstabdetect_class;
84 VSMotionDetect *
md = &(
s->md);
91 vsMotionDetectionCleanup(
md);
99 VSMotionDetect*
md = &(
s->md);
103 const char *file_mode =
"w";
105 #ifdef LIBVIDSTAB_FILE_FORMAT_VERSION
106 md->serializationMode =
s->fileformat;
107 if (
s->fileformat == BINARY_SERIALIZATION_MODE)
117 if (fi.log2ChromaW !=
desc->log2_chroma_w) {
122 if (fi.log2ChromaH !=
desc->log2_chroma_h) {
129 s->conf.modName =
"vidstabdetect";
130 if (vsMotionDetectInit(
md, &
s->conf, &fi) != VS_OK) {
135 vsMotionDetectGetConfig(&
s->conf,
md);
150 if (vsPrepareFile(
md,
s->f) != VS_OK) {
162 VSMotionDetect *
md = &(
s->md);
163 LocalMotions localmotions;
177 for (plane = 0; plane <
md->fi.planes; plane++) {
181 if (vsMotionDetection(
md, &localmotions, &
frame) != VS_OK) {
185 if (vsWriteToFile(
md,
s->f, &localmotions) != VS_OK) {
190 vs_vector_del(&localmotions);
206 .
name =
"vidstabdetect",
208 "pass 1 of 2 for stabilization "
209 "(see vidstabtransform for pass 2)."),
217 .priv_class = &vidstabdetect_class,
const AVFilter ff_vf_vidstabdetect
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
#define DEFAULT_RESULT_NAME
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define AV_LOG_VERBOSE
Detailed information.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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[]
static av_cold int init(AVFilterContext *ctx)
#define FILTER_INPUTS(array)
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
static const AVFilterPad avfilter_vf_vidstabdetect_inputs[]
VSMotionDetectConfig conf
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
#define AVERROR_EXTERNAL
Generic error in an external library.
static int config_input(AVFilterLink *inlink)
static const AVOption vidstabdetect_options[]
#define AV_LOG_INFO
Standard information.
static av_cold void uninit(AVFilterContext *ctx)
const char * name
Pad name.
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
AVFILTER_DEFINE_CLASS(vidstabdetect)
void ff_vs_init(void)
sets the memory allocation function and logging constants to av versions
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...