Go to the documentation of this file.
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)
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 .
name =
"vidstabdetect",
207 "pass 1 of 2 for stabilization "
208 "(see vidstabtransform for pass 2)."),
216 .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
#define FILTER_PIXFMTS_ARRAY(array)
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 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.
#define FILTER_INPUTS(array)
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
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
enum AVPixelFormat ff_vidstab_pix_fmts[]
static av_cold int init(AVFilterContext *ctx)
#define FILTER_OUTPUTS(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
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
@ AV_OPT_TYPE_INT
Underlying C type is int.
#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 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...
@ 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...
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.