|
|
@@ -29,7 +29,9 @@
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * @defgroup lavfi Libavfilter - graph-based frame editing library
|
|
|
+ * @defgroup lavfi libavfilter
|
|
|
+ * Graph-based frame editing library.
|
|
|
+ *
|
|
|
* @{
|
|
|
*/
|
|
|
|
|
|
@@ -37,6 +39,7 @@
|
|
|
|
|
|
#include "libavutil/attributes.h"
|
|
|
#include "libavutil/avutil.h"
|
|
|
+#include "libavutil/buffer.h"
|
|
|
#include "libavutil/dict.h"
|
|
|
#include "libavutil/frame.h"
|
|
|
#include "libavutil/log.h"
|
|
|
@@ -66,335 +69,6 @@ typedef struct AVFilterLink AVFilterLink;
|
|
|
typedef struct AVFilterPad AVFilterPad;
|
|
|
typedef struct AVFilterFormats AVFilterFormats;
|
|
|
|
|
|
-#if FF_API_AVFILTERBUFFER
|
|
|
-/**
|
|
|
- * A reference-counted buffer data type used by the filter system. Filters
|
|
|
- * should not store pointers to this structure directly, but instead use the
|
|
|
- * AVFilterBufferRef structure below.
|
|
|
- */
|
|
|
-typedef struct AVFilterBuffer {
|
|
|
- uint8_t *data[8]; ///< buffer data for each plane/channel
|
|
|
-
|
|
|
- /**
|
|
|
- * pointers to the data planes/channels.
|
|
|
- *
|
|
|
- * For video, this should simply point to data[].
|
|
|
- *
|
|
|
- * For planar audio, each channel has a separate data pointer, and
|
|
|
- * linesize[0] contains the size of each channel buffer.
|
|
|
- * For packed audio, there is just one data pointer, and linesize[0]
|
|
|
- * contains the total size of the buffer for all channels.
|
|
|
- *
|
|
|
- * Note: Both data and extended_data will always be set, but for planar
|
|
|
- * audio with more channels that can fit in data, extended_data must be used
|
|
|
- * in order to access all channels.
|
|
|
- */
|
|
|
- uint8_t **extended_data;
|
|
|
- int linesize[8]; ///< number of bytes per line
|
|
|
-
|
|
|
- /** private data to be used by a custom free function */
|
|
|
- void *priv;
|
|
|
- /**
|
|
|
- * A pointer to the function to deallocate this buffer if the default
|
|
|
- * function is not sufficient. This could, for example, add the memory
|
|
|
- * back into a memory pool to be reused later without the overhead of
|
|
|
- * reallocating it from scratch.
|
|
|
- */
|
|
|
- void (*free)(struct AVFilterBuffer *buf);
|
|
|
-
|
|
|
- int format; ///< media format
|
|
|
- int w, h; ///< width and height of the allocated buffer
|
|
|
- unsigned refcount; ///< number of references to this buffer
|
|
|
-} AVFilterBuffer;
|
|
|
-
|
|
|
-#define AV_PERM_READ 0x01 ///< can read from the buffer
|
|
|
-#define AV_PERM_WRITE 0x02 ///< can write to the buffer
|
|
|
-#define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
|
|
|
-#define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
|
|
|
-#define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
|
|
|
-#define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
|
|
|
-#define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned
|
|
|
-
|
|
|
-#define AVFILTER_ALIGN 16 //not part of ABI
|
|
|
-
|
|
|
-/**
|
|
|
- * Audio specific properties in a reference to an AVFilterBuffer. Since
|
|
|
- * AVFilterBufferRef is common to different media formats, audio specific
|
|
|
- * per reference properties must be separated out.
|
|
|
- */
|
|
|
-typedef struct AVFilterBufferRefAudioProps {
|
|
|
- uint64_t channel_layout; ///< channel layout of audio buffer
|
|
|
- int nb_samples; ///< number of audio samples per channel
|
|
|
- int sample_rate; ///< audio buffer sample rate
|
|
|
- int channels; ///< number of channels (do not access directly)
|
|
|
-} AVFilterBufferRefAudioProps;
|
|
|
-
|
|
|
-/**
|
|
|
- * Video specific properties in a reference to an AVFilterBuffer. Since
|
|
|
- * AVFilterBufferRef is common to different media formats, video specific
|
|
|
- * per reference properties must be separated out.
|
|
|
- */
|
|
|
-typedef struct AVFilterBufferRefVideoProps {
|
|
|
- int w; ///< image width
|
|
|
- int h; ///< image height
|
|
|
- AVRational sample_aspect_ratio; ///< sample aspect ratio
|
|
|
- int interlaced; ///< is frame interlaced
|
|
|
- int top_field_first; ///< field order
|
|
|
- enum AVPictureType pict_type; ///< picture type of the frame
|
|
|
- int key_frame; ///< 1 -> keyframe, 0-> not
|
|
|
- int qp_table_linesize; ///< qp_table stride
|
|
|
- int qp_table_size; ///< qp_table size
|
|
|
- int8_t *qp_table; ///< array of Quantization Parameters
|
|
|
-} AVFilterBufferRefVideoProps;
|
|
|
-
|
|
|
-/**
|
|
|
- * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
|
|
|
- * a buffer to, for example, crop image without any memcpy, the buffer origin
|
|
|
- * and dimensions are per-reference properties. Linesize is also useful for
|
|
|
- * image flipping, frame to field filters, etc, and so is also per-reference.
|
|
|
- *
|
|
|
- * TODO: add anything necessary for frame reordering
|
|
|
- */
|
|
|
-typedef struct AVFilterBufferRef {
|
|
|
- AVFilterBuffer *buf; ///< the buffer that this is a reference to
|
|
|
- uint8_t *data[8]; ///< picture/audio data for each plane
|
|
|
- /**
|
|
|
- * pointers to the data planes/channels.
|
|
|
- *
|
|
|
- * For video, this should simply point to data[].
|
|
|
- *
|
|
|
- * For planar audio, each channel has a separate data pointer, and
|
|
|
- * linesize[0] contains the size of each channel buffer.
|
|
|
- * For packed audio, there is just one data pointer, and linesize[0]
|
|
|
- * contains the total size of the buffer for all channels.
|
|
|
- *
|
|
|
- * Note: Both data and extended_data will always be set, but for planar
|
|
|
- * audio with more channels that can fit in data, extended_data must be used
|
|
|
- * in order to access all channels.
|
|
|
- */
|
|
|
- uint8_t **extended_data;
|
|
|
- int linesize[8]; ///< number of bytes per line
|
|
|
-
|
|
|
- AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
|
|
|
- AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
|
|
|
-
|
|
|
- /**
|
|
|
- * presentation timestamp. The time unit may change during
|
|
|
- * filtering, as it is specified in the link and the filter code
|
|
|
- * may need to rescale the PTS accordingly.
|
|
|
- */
|
|
|
- int64_t pts;
|
|
|
- int64_t pos; ///< byte position in stream, -1 if unknown
|
|
|
-
|
|
|
- int format; ///< media format
|
|
|
-
|
|
|
- int perms; ///< permissions, see the AV_PERM_* flags
|
|
|
-
|
|
|
- enum AVMediaType type; ///< media type of buffer data
|
|
|
-
|
|
|
- AVDictionary *metadata; ///< dictionary containing metadata key=value tags
|
|
|
-} AVFilterBufferRef;
|
|
|
-
|
|
|
-/**
|
|
|
- * Copy properties of src to dst, without copying the actual data
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, const AVFilterBufferRef *src);
|
|
|
-
|
|
|
-/**
|
|
|
- * Add a new reference to a buffer.
|
|
|
- *
|
|
|
- * @param ref an existing reference to the buffer
|
|
|
- * @param pmask a bitmask containing the allowable permissions in the new
|
|
|
- * reference
|
|
|
- * @return a new reference to the buffer with the same properties as the
|
|
|
- * old, excluding any permissions denied by pmask
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
|
|
|
-
|
|
|
-/**
|
|
|
- * Remove a reference to a buffer. If this is the last reference to the
|
|
|
- * buffer, the buffer itself is also automatically freed.
|
|
|
- *
|
|
|
- * @param ref reference to the buffer, may be NULL
|
|
|
- *
|
|
|
- * @note it is recommended to use avfilter_unref_bufferp() instead of this
|
|
|
- * function
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-void avfilter_unref_buffer(AVFilterBufferRef *ref);
|
|
|
-
|
|
|
-/**
|
|
|
- * Remove a reference to a buffer and set the pointer to NULL.
|
|
|
- * If this is the last reference to the buffer, the buffer itself
|
|
|
- * is also automatically freed.
|
|
|
- *
|
|
|
- * @param ref pointer to the buffer reference
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-void avfilter_unref_bufferp(AVFilterBufferRef **ref);
|
|
|
-#endif
|
|
|
-
|
|
|
-/**
|
|
|
- * Get the number of channels of a buffer reference.
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_ref_get_channels(AVFilterBufferRef *ref);
|
|
|
-
|
|
|
-#if FF_API_AVFILTERPAD_PUBLIC
|
|
|
-/**
|
|
|
- * A filter pad used for either input or output.
|
|
|
- *
|
|
|
- * See doc/filter_design.txt for details on how to implement the methods.
|
|
|
- *
|
|
|
- * @warning this struct might be removed from public API.
|
|
|
- * users should call avfilter_pad_get_name() and avfilter_pad_get_type()
|
|
|
- * to access the name and type fields; there should be no need to access
|
|
|
- * any other fields from outside of libavfilter.
|
|
|
- */
|
|
|
-struct AVFilterPad {
|
|
|
- /**
|
|
|
- * Pad name. The name is unique among inputs and among outputs, but an
|
|
|
- * input may have the same name as an output. This may be NULL if this
|
|
|
- * pad has no need to ever be referenced by name.
|
|
|
- */
|
|
|
- const char *name;
|
|
|
-
|
|
|
- /**
|
|
|
- * AVFilterPad type.
|
|
|
- */
|
|
|
- enum AVMediaType type;
|
|
|
-
|
|
|
- /**
|
|
|
- * Input pads:
|
|
|
- * Minimum required permissions on incoming buffers. Any buffer with
|
|
|
- * insufficient permissions will be automatically copied by the filter
|
|
|
- * system to a new buffer which provides the needed access permissions.
|
|
|
- *
|
|
|
- * Output pads:
|
|
|
- * Guaranteed permissions on outgoing buffers. Any buffer pushed on the
|
|
|
- * link must have at least these permissions; this fact is checked by
|
|
|
- * asserts. It can be used to optimize buffer allocation.
|
|
|
- */
|
|
|
- attribute_deprecated int min_perms;
|
|
|
-
|
|
|
- /**
|
|
|
- * Input pads:
|
|
|
- * Permissions which are not accepted on incoming buffers. Any buffer
|
|
|
- * which has any of these permissions set will be automatically copied
|
|
|
- * by the filter system to a new buffer which does not have those
|
|
|
- * permissions. This can be used to easily disallow buffers with
|
|
|
- * AV_PERM_REUSE.
|
|
|
- *
|
|
|
- * Output pads:
|
|
|
- * Permissions which are automatically removed on outgoing buffers. It
|
|
|
- * can be used to optimize buffer allocation.
|
|
|
- */
|
|
|
- attribute_deprecated int rej_perms;
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated unused
|
|
|
- */
|
|
|
- int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
|
|
|
-
|
|
|
- /**
|
|
|
- * Callback function to get a video buffer. If NULL, the filter system will
|
|
|
- * use ff_default_get_video_buffer().
|
|
|
- *
|
|
|
- * Input video pads only.
|
|
|
- */
|
|
|
- AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h);
|
|
|
-
|
|
|
- /**
|
|
|
- * Callback function to get an audio buffer. If NULL, the filter system will
|
|
|
- * use ff_default_get_audio_buffer().
|
|
|
- *
|
|
|
- * Input audio pads only.
|
|
|
- */
|
|
|
- AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples);
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated unused
|
|
|
- */
|
|
|
- int (*end_frame)(AVFilterLink *link);
|
|
|
-
|
|
|
- /**
|
|
|
- * @deprecated unused
|
|
|
- */
|
|
|
- int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
|
|
|
-
|
|
|
- /**
|
|
|
- * Filtering callback. This is where a filter receives a frame with
|
|
|
- * audio/video data and should do its processing.
|
|
|
- *
|
|
|
- * Input pads only.
|
|
|
- *
|
|
|
- * @return >= 0 on success, a negative AVERROR on error. This function
|
|
|
- * must ensure that frame is properly unreferenced on error if it
|
|
|
- * hasn't been passed on to another filter.
|
|
|
- */
|
|
|
- int (*filter_frame)(AVFilterLink *link, AVFrame *frame);
|
|
|
-
|
|
|
- /**
|
|
|
- * Frame poll callback. This returns the number of immediately available
|
|
|
- * samples. It should return a positive value if the next request_frame()
|
|
|
- * is guaranteed to return one frame (with no delay).
|
|
|
- *
|
|
|
- * Defaults to just calling the source poll_frame() method.
|
|
|
- *
|
|
|
- * Output pads only.
|
|
|
- */
|
|
|
- int (*poll_frame)(AVFilterLink *link);
|
|
|
-
|
|
|
- /**
|
|
|
- * Frame request callback. A call to this should result in at least one
|
|
|
- * frame being output over the given link. This should return zero on
|
|
|
- * success, and another value on error.
|
|
|
- * See ff_request_frame() for the error codes with a specific
|
|
|
- * meaning.
|
|
|
- *
|
|
|
- * Output pads only.
|
|
|
- */
|
|
|
- int (*request_frame)(AVFilterLink *link);
|
|
|
-
|
|
|
- /**
|
|
|
- * Link configuration callback.
|
|
|
- *
|
|
|
- * For output pads, this should set the following link properties:
|
|
|
- * video: width, height, sample_aspect_ratio, time_base
|
|
|
- * audio: sample_rate.
|
|
|
- *
|
|
|
- * This should NOT set properties such as format, channel_layout, etc which
|
|
|
- * are negotiated between filters by the filter system using the
|
|
|
- * query_formats() callback before this function is called.
|
|
|
- *
|
|
|
- * For input pads, this should check the properties of the link, and update
|
|
|
- * the filter's internal state as necessary.
|
|
|
- *
|
|
|
- * For both input and output pads, this should return zero on success,
|
|
|
- * and another value on error.
|
|
|
- */
|
|
|
- int (*config_props)(AVFilterLink *link);
|
|
|
-
|
|
|
- /**
|
|
|
- * The filter expects a fifo to be inserted on its input link,
|
|
|
- * typically because it has a delay.
|
|
|
- *
|
|
|
- * input pads only.
|
|
|
- */
|
|
|
- int needs_fifo;
|
|
|
-
|
|
|
- /**
|
|
|
- * The filter expects writable frames from its input link,
|
|
|
- * duplicating data buffers if needed.
|
|
|
- *
|
|
|
- * input pads only.
|
|
|
- */
|
|
|
- int needs_writable;
|
|
|
-};
|
|
|
-#endif
|
|
|
-
|
|
|
/**
|
|
|
* Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
|
|
|
* AVFilter.inputs/outputs).
|
|
|
@@ -520,6 +194,21 @@ typedef struct AVFilter {
|
|
|
*****************************************************************
|
|
|
*/
|
|
|
|
|
|
+ /**
|
|
|
+ * Filter pre-initialization function
|
|
|
+ *
|
|
|
+ * This callback will be called immediately after the filter context is
|
|
|
+ * allocated, to allow allocating and initing sub-objects.
|
|
|
+ *
|
|
|
+ * If this callback is not NULL, the uninit callback will be called on
|
|
|
+ * allocation failure.
|
|
|
+ *
|
|
|
+ * @return 0 on success,
|
|
|
+ * AVERROR code on failure (but the code will be
|
|
|
+ * dropped and treated as ENOMEM by the calling code)
|
|
|
+ */
|
|
|
+ int (*preinit)(AVFilterContext *ctx);
|
|
|
+
|
|
|
/**
|
|
|
* Filter initialization function.
|
|
|
*
|
|
|
@@ -594,6 +283,8 @@ typedef struct AVFilter {
|
|
|
|
|
|
int priv_size; ///< size of private data to allocate for the filter
|
|
|
|
|
|
+ int flags_internal; ///< Additional flags for avfilter internal use only.
|
|
|
+
|
|
|
/**
|
|
|
* Used by the filter registration system. Must not be touched by any other
|
|
|
* code.
|
|
|
@@ -620,6 +311,20 @@ typedef struct AVFilter {
|
|
|
* used for providing binary data.
|
|
|
*/
|
|
|
int (*init_opaque)(AVFilterContext *ctx, void *opaque);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Filter activation function.
|
|
|
+ *
|
|
|
+ * Called when any processing is needed from the filter, instead of any
|
|
|
+ * filter_frame and request_frame on pads.
|
|
|
+ *
|
|
|
+ * The function must examine inlinks and outlinks and perform a single
|
|
|
+ * step of processing. If there is nothing to do, the function must do
|
|
|
+ * nothing and not return an error. If more steps are or may be
|
|
|
+ * possible, it must use ff_filter_set_ready() to schedule another
|
|
|
+ * activation.
|
|
|
+ */
|
|
|
+ int (*activate)(AVFilterContext *ctx);
|
|
|
} AVFilter;
|
|
|
|
|
|
/**
|
|
|
@@ -639,16 +344,10 @@ struct AVFilterContext {
|
|
|
|
|
|
AVFilterPad *input_pads; ///< array of input pads
|
|
|
AVFilterLink **inputs; ///< array of pointers to input links
|
|
|
-#if FF_API_FOO_COUNT
|
|
|
- attribute_deprecated unsigned input_count; ///< @deprecated use nb_inputs
|
|
|
-#endif
|
|
|
unsigned nb_inputs; ///< number of input pads
|
|
|
|
|
|
AVFilterPad *output_pads; ///< array of output pads
|
|
|
AVFilterLink **outputs; ///< array of pointers to output links
|
|
|
-#if FF_API_FOO_COUNT
|
|
|
- attribute_deprecated unsigned output_count; ///< @deprecated use nb_outputs
|
|
|
-#endif
|
|
|
unsigned nb_outputs; ///< number of output pads
|
|
|
|
|
|
void *priv; ///< private data for use by the filter
|
|
|
@@ -684,6 +383,45 @@ struct AVFilterContext {
|
|
|
void *enable; ///< parsed expression (AVExpr*)
|
|
|
double *var_values; ///< variable values for the enable expression
|
|
|
int is_disabled; ///< the enabled state from the last expression evaluation
|
|
|
+
|
|
|
+ /**
|
|
|
+ * For filters which will create hardware frames, sets the device the
|
|
|
+ * filter should create them in. All other filters will ignore this field:
|
|
|
+ * in particular, a filter which consumes or processes hardware frames will
|
|
|
+ * instead use the hw_frames_ctx field in AVFilterLink to carry the
|
|
|
+ * hardware context information.
|
|
|
+ */
|
|
|
+ AVBufferRef *hw_device_ctx;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Max number of threads allowed in this filter instance.
|
|
|
+ * If <= 0, its value is ignored.
|
|
|
+ * Overrides global number of threads set per filter graph.
|
|
|
+ */
|
|
|
+ int nb_threads;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Ready status of the filter.
|
|
|
+ * A non-0 value means that the filter needs activating;
|
|
|
+ * a higher value suggests a more urgent activation.
|
|
|
+ */
|
|
|
+ unsigned ready;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the number of extra hardware frames which the filter will
|
|
|
+ * allocate on its output links for use in following filters or by
|
|
|
+ * the caller.
|
|
|
+ *
|
|
|
+ * Some hardware filters require all frames that they will use for
|
|
|
+ * output to be defined in advance before filtering starts. For such
|
|
|
+ * filters, any hardware frame pools used for output must therefore be
|
|
|
+ * of fixed size. The extra frames set here are on top of any number
|
|
|
+ * that the filter needs internally in order to operate normally.
|
|
|
+ *
|
|
|
+ * This field must be set before the graph containing this filter is
|
|
|
+ * configured.
|
|
|
+ */
|
|
|
+ int extra_hw_frames;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -692,6 +430,11 @@ struct AVFilterContext {
|
|
|
* the pads involved. In addition, this link also contains the parameters
|
|
|
* which have been negotiated and agreed upon between the filter, such as
|
|
|
* image dimensions, format, etc.
|
|
|
+ *
|
|
|
+ * Applications must not normally access the link structure directly.
|
|
|
+ * Use the buffersrc and buffersink API instead.
|
|
|
+ * In the future, access to the header may be reserved for filters
|
|
|
+ * implementation.
|
|
|
*/
|
|
|
struct AVFilterLink {
|
|
|
AVFilterContext *src; ///< source filter
|
|
|
@@ -763,8 +506,6 @@ struct AVFilterLink {
|
|
|
AVLINK_INIT ///< complete
|
|
|
} init_state;
|
|
|
|
|
|
- struct AVFilterPool *pool;
|
|
|
-
|
|
|
/**
|
|
|
* Graph the filter belongs to.
|
|
|
*/
|
|
|
@@ -772,21 +513,28 @@ struct AVFilterLink {
|
|
|
|
|
|
/**
|
|
|
* Current timestamp of the link, as defined by the most recent
|
|
|
- * frame(s), in AV_TIME_BASE units.
|
|
|
+ * frame(s), in link time_base units.
|
|
|
*/
|
|
|
int64_t current_pts;
|
|
|
|
|
|
+ /**
|
|
|
+ * Current timestamp of the link, as defined by the most recent
|
|
|
+ * frame(s), in AV_TIME_BASE units.
|
|
|
+ */
|
|
|
+ int64_t current_pts_us;
|
|
|
+
|
|
|
/**
|
|
|
* Index in the age array.
|
|
|
*/
|
|
|
int age_index;
|
|
|
|
|
|
/**
|
|
|
- * Frame rate of the stream on the link, or 1/0 if unknown;
|
|
|
- * if left to 0/0, will be automatically be copied from the first input
|
|
|
+ * Frame rate of the stream on the link, or 1/0 if unknown or variable;
|
|
|
+ * if left to 0/0, will be automatically copied from the first input
|
|
|
* of the source filter if it exists.
|
|
|
*
|
|
|
* Sources should set it to the best estimation of the real frame rate.
|
|
|
+ * If the source frame rate is unknown or variable, set this to 1/0.
|
|
|
* Filters should update it if necessary depending on their function.
|
|
|
* Sinks can use it to set a default output frame rate.
|
|
|
* It is similar to the r_frame_rate field in AVStream.
|
|
|
@@ -820,46 +568,82 @@ struct AVFilterLink {
|
|
|
int max_samples;
|
|
|
|
|
|
/**
|
|
|
- * The buffer reference currently being received across the link by the
|
|
|
- * destination filter. This is used internally by the filter system to
|
|
|
- * allow automatic copying of buffers which do not have sufficient
|
|
|
- * permissions for the destination. This should not be accessed directly
|
|
|
- * by the filters.
|
|
|
+ * Number of channels.
|
|
|
+ */
|
|
|
+ int channels;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Link processing flags.
|
|
|
*/
|
|
|
- AVFilterBufferRef *cur_buf_copy;
|
|
|
+ unsigned flags;
|
|
|
|
|
|
/**
|
|
|
- * True if the link is closed.
|
|
|
- * If set, all attempts of start_frame, filter_frame or request_frame
|
|
|
- * will fail with AVERROR_EOF, and if necessary the reference will be
|
|
|
- * destroyed.
|
|
|
- * If request_frame returns AVERROR_EOF, this flag is set on the
|
|
|
- * corresponding link.
|
|
|
- * It can be set also be set by either the source or the destination
|
|
|
- * filter.
|
|
|
+ * Number of past frames sent through the link.
|
|
|
*/
|
|
|
- int closed;
|
|
|
+ int64_t frame_count_in, frame_count_out;
|
|
|
|
|
|
/**
|
|
|
- * Number of channels.
|
|
|
+ * A pointer to a FFFramePool struct.
|
|
|
*/
|
|
|
- int channels;
|
|
|
+ void *frame_pool;
|
|
|
|
|
|
/**
|
|
|
- * True if a frame is being requested on the link.
|
|
|
- * Used internally by the framework.
|
|
|
+ * True if a frame is currently wanted on the output of this filter.
|
|
|
+ * Set when ff_request_frame() is called by the output,
|
|
|
+ * cleared when a frame is filtered.
|
|
|
*/
|
|
|
- unsigned frame_requested;
|
|
|
+ int frame_wanted_out;
|
|
|
|
|
|
/**
|
|
|
- * Link processing flags.
|
|
|
+ * For hwaccel pixel formats, this should be a reference to the
|
|
|
+ * AVHWFramesContext describing the frames.
|
|
|
*/
|
|
|
- unsigned flags;
|
|
|
+ AVBufferRef *hw_frames_ctx;
|
|
|
+
|
|
|
+#ifndef FF_INTERNAL_FIELDS
|
|
|
|
|
|
/**
|
|
|
- * Number of past frames sent through the link.
|
|
|
+ * Internal structure members.
|
|
|
+ * The fields below this limit are internal for libavfilter's use
|
|
|
+ * and must in no way be accessed by applications.
|
|
|
*/
|
|
|
- int64_t frame_count;
|
|
|
+ char reserved[0xF000];
|
|
|
+
|
|
|
+#else /* FF_INTERNAL_FIELDS */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Queue of frames waiting to be filtered.
|
|
|
+ */
|
|
|
+ FFFrameQueue fifo;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * If set, the source filter can not generate a frame as is.
|
|
|
+ * The goal is to avoid repeatedly calling the request_frame() method on
|
|
|
+ * the same link.
|
|
|
+ */
|
|
|
+ int frame_blocked_in;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Link input status.
|
|
|
+ * If not zero, all attempts of filter_frame will fail with the
|
|
|
+ * corresponding code.
|
|
|
+ */
|
|
|
+ int status_in;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Timestamp of the input status change.
|
|
|
+ */
|
|
|
+ int64_t status_in_pts;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Link output status.
|
|
|
+ * If not zero, all attempts of request_frame will fail with the
|
|
|
+ * corresponding code.
|
|
|
+ */
|
|
|
+ int status_out;
|
|
|
+
|
|
|
+#endif /* FF_INTERNAL_FIELDS */
|
|
|
+
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -879,14 +663,21 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
|
|
*/
|
|
|
void avfilter_link_free(AVFilterLink **link);
|
|
|
|
|
|
+#if FF_API_FILTER_GET_SET
|
|
|
/**
|
|
|
* Get the number of channels of a link.
|
|
|
+ * @deprecated Use av_buffersink_get_channels()
|
|
|
*/
|
|
|
+attribute_deprecated
|
|
|
int avfilter_link_get_channels(AVFilterLink *link);
|
|
|
+#endif
|
|
|
|
|
|
/**
|
|
|
* Set the closed field of a link.
|
|
|
+ * @deprecated applications are not supposed to mess with links, they should
|
|
|
+ * close the sinks.
|
|
|
*/
|
|
|
+attribute_deprecated
|
|
|
void avfilter_link_set_closed(AVFilterLink *link, int closed);
|
|
|
|
|
|
/**
|
|
|
@@ -897,69 +688,6 @@ void avfilter_link_set_closed(AVFilterLink *link, int closed);
|
|
|
*/
|
|
|
int avfilter_config_links(AVFilterContext *filter);
|
|
|
|
|
|
-#if FF_API_AVFILTERBUFFER
|
|
|
-/**
|
|
|
- * Create a buffer reference wrapped around an already allocated image
|
|
|
- * buffer.
|
|
|
- *
|
|
|
- * @param data pointers to the planes of the image to reference
|
|
|
- * @param linesize linesizes for the planes of the image to reference
|
|
|
- * @param perms the required access permissions
|
|
|
- * @param w the width of the image specified by the data and linesize arrays
|
|
|
- * @param h the height of the image specified by the data and linesize arrays
|
|
|
- * @param format the pixel format of the image specified by the data and linesize arrays
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-AVFilterBufferRef *
|
|
|
-avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
|
|
|
- int w, int h, enum AVPixelFormat format);
|
|
|
-
|
|
|
-/**
|
|
|
- * Create an audio buffer reference wrapped around an already
|
|
|
- * allocated samples buffer.
|
|
|
- *
|
|
|
- * See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version
|
|
|
- * that can handle unknown channel layouts.
|
|
|
- *
|
|
|
- * @param data pointers to the samples plane buffers
|
|
|
- * @param linesize linesize for the samples plane buffers
|
|
|
- * @param perms the required access permissions
|
|
|
- * @param nb_samples number of samples per channel
|
|
|
- * @param sample_fmt the format of each sample in the buffer to allocate
|
|
|
- * @param channel_layout the channel layout of the buffer
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
|
|
|
- int linesize,
|
|
|
- int perms,
|
|
|
- int nb_samples,
|
|
|
- enum AVSampleFormat sample_fmt,
|
|
|
- uint64_t channel_layout);
|
|
|
-/**
|
|
|
- * Create an audio buffer reference wrapped around an already
|
|
|
- * allocated samples buffer.
|
|
|
- *
|
|
|
- * @param data pointers to the samples plane buffers
|
|
|
- * @param linesize linesize for the samples plane buffers
|
|
|
- * @param perms the required access permissions
|
|
|
- * @param nb_samples number of samples per channel
|
|
|
- * @param sample_fmt the format of each sample in the buffer to allocate
|
|
|
- * @param channels the number of channels of the buffer
|
|
|
- * @param channel_layout the channel layout of the buffer,
|
|
|
- * must be either 0 or consistent with channels
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data,
|
|
|
- int linesize,
|
|
|
- int perms,
|
|
|
- int nb_samples,
|
|
|
- enum AVSampleFormat sample_fmt,
|
|
|
- int channels,
|
|
|
- uint64_t channel_layout);
|
|
|
-
|
|
|
-#endif
|
|
|
-
|
|
|
-
|
|
|
#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
|
|
|
#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
|
|
|
|
|
|
@@ -969,14 +697,21 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **
|
|
|
*/
|
|
|
int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
|
|
|
|
|
|
-/** Initialize the filter system. Register all builtin filters. */
|
|
|
-void avfilter_register_all(void);
|
|
|
+/**
|
|
|
+ * Iterate over all registered filters.
|
|
|
+ *
|
|
|
+ * @param opaque a pointer where libavfilter will store the iteration state. Must
|
|
|
+ * point to NULL to start the iteration.
|
|
|
+ *
|
|
|
+ * @return the next registered filter or NULL when the iteration is
|
|
|
+ * finished
|
|
|
+ */
|
|
|
+const AVFilter *av_filter_iterate(void **opaque);
|
|
|
|
|
|
-#if FF_API_OLD_FILTER_REGISTER
|
|
|
-/** Uninitialize the filter system. Unregister all filters. */
|
|
|
+#if FF_API_NEXT
|
|
|
+/** Initialize the filter system. Register all builtin filters. */
|
|
|
attribute_deprecated
|
|
|
-void avfilter_uninit(void);
|
|
|
-#endif
|
|
|
+void avfilter_register_all(void);
|
|
|
|
|
|
/**
|
|
|
* Register a filter. This is only needed if you plan to use
|
|
|
@@ -988,69 +723,27 @@ void avfilter_uninit(void);
|
|
|
* @return 0 if the registration was successful, a negative value
|
|
|
* otherwise
|
|
|
*/
|
|
|
+attribute_deprecated
|
|
|
int avfilter_register(AVFilter *filter);
|
|
|
|
|
|
-/**
|
|
|
- * Get a filter definition matching the given name.
|
|
|
- *
|
|
|
- * @param name the filter name to find
|
|
|
- * @return the filter definition, if any matching one is registered.
|
|
|
- * NULL if none found.
|
|
|
- */
|
|
|
-#if !FF_API_NOCONST_GET_NAME
|
|
|
-const
|
|
|
-#endif
|
|
|
-AVFilter *avfilter_get_by_name(const char *name);
|
|
|
-
|
|
|
/**
|
|
|
* Iterate over all registered filters.
|
|
|
* @return If prev is non-NULL, next registered filter after prev or NULL if
|
|
|
* prev is the last filter. If prev is NULL, return the first registered filter.
|
|
|
*/
|
|
|
-const AVFilter *avfilter_next(const AVFilter *prev);
|
|
|
-
|
|
|
-#if FF_API_OLD_FILTER_REGISTER
|
|
|
-/**
|
|
|
- * If filter is NULL, returns a pointer to the first registered filter pointer,
|
|
|
- * if filter is non-NULL, returns the next pointer after filter.
|
|
|
- * If the returned pointer points to NULL, the last registered filter
|
|
|
- * was already reached.
|
|
|
- * @deprecated use avfilter_next()
|
|
|
- */
|
|
|
attribute_deprecated
|
|
|
-AVFilter **av_filter_next(AVFilter **filter);
|
|
|
+const AVFilter *avfilter_next(const AVFilter *prev);
|
|
|
#endif
|
|
|
|
|
|
-#if FF_API_AVFILTER_OPEN
|
|
|
/**
|
|
|
- * Create a filter instance.
|
|
|
+ * Get a filter definition matching the given name.
|
|
|
*
|
|
|
- * @param filter_ctx put here a pointer to the created filter context
|
|
|
- * on success, NULL on failure
|
|
|
- * @param filter the filter to create an instance of
|
|
|
- * @param inst_name Name to give to the new instance. Can be NULL for none.
|
|
|
- * @return >= 0 in case of success, a negative error code otherwise
|
|
|
- * @deprecated use avfilter_graph_alloc_filter() instead
|
|
|
+ * @param name the filter name to find
|
|
|
+ * @return the filter definition, if any matching one is registered.
|
|
|
+ * NULL if none found.
|
|
|
*/
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
|
|
|
-#endif
|
|
|
-
|
|
|
+const AVFilter *avfilter_get_by_name(const char *name);
|
|
|
|
|
|
-#if FF_API_AVFILTER_INIT_FILTER
|
|
|
-/**
|
|
|
- * Initialize a filter.
|
|
|
- *
|
|
|
- * @param filter the filter to initialize
|
|
|
- * @param args A string of parameters to use when initializing the filter.
|
|
|
- * The format and meaning of this string varies by filter.
|
|
|
- * @param opaque Any extra non-string data needed by the filter. The meaning
|
|
|
- * of this parameter varies by filter.
|
|
|
- * @return zero on success
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
|
|
|
-#endif
|
|
|
|
|
|
/**
|
|
|
* Initialize a filter with the supplied parameters.
|
|
|
@@ -1106,26 +799,6 @@ void avfilter_free(AVFilterContext *filter);
|
|
|
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
|
|
|
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
|
|
|
|
|
|
-#if FF_API_AVFILTERBUFFER
|
|
|
-/**
|
|
|
- * Copy the frame properties of src to dst, without copying the actual
|
|
|
- * image data.
|
|
|
- *
|
|
|
- * @return 0 on success, a negative number on error.
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
|
|
|
-
|
|
|
-/**
|
|
|
- * Copy the frame properties and data pointers of src to dst, without copying
|
|
|
- * the actual data.
|
|
|
- *
|
|
|
- * @return 0 on success, a negative number on error.
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
|
|
|
-#endif
|
|
|
-
|
|
|
/**
|
|
|
* @return AVClass for AVFilterContext.
|
|
|
*
|
|
|
@@ -1166,19 +839,12 @@ typedef int (avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *
|
|
|
|
|
|
typedef struct AVFilterGraph {
|
|
|
const AVClass *av_class;
|
|
|
-#if FF_API_FOO_COUNT
|
|
|
- attribute_deprecated
|
|
|
- unsigned filter_count_unused;
|
|
|
-#endif
|
|
|
AVFilterContext **filters;
|
|
|
-#if !FF_API_FOO_COUNT
|
|
|
unsigned nb_filters;
|
|
|
-#endif
|
|
|
|
|
|
char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
|
|
|
- char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
|
|
|
-#if FF_API_FOO_COUNT
|
|
|
- unsigned nb_filters;
|
|
|
+#if FF_API_LAVR_OPTS
|
|
|
+ attribute_deprecated char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
|
|
|
#endif
|
|
|
|
|
|
/**
|
|
|
@@ -1245,6 +911,8 @@ typedef struct AVFilterGraph {
|
|
|
|
|
|
/**
|
|
|
* Allocate a filter graph.
|
|
|
+ *
|
|
|
+ * @return the allocated filter graph on success or NULL.
|
|
|
*/
|
|
|
AVFilterGraph *avfilter_graph_alloc(void);
|
|
|
|
|
|
@@ -1276,20 +944,6 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
|
|
|
*/
|
|
|
AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name);
|
|
|
|
|
|
-#if FF_API_AVFILTER_OPEN
|
|
|
-/**
|
|
|
- * Add an existing filter instance to a filter graph.
|
|
|
- *
|
|
|
- * @param graphctx the filter graph
|
|
|
- * @param filter the filter to be added
|
|
|
- *
|
|
|
- * @deprecated use avfilter_graph_alloc_filter() to allocate a filter in a
|
|
|
- * filter graph
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
|
|
|
-#endif
|
|
|
-
|
|
|
/**
|
|
|
* Create and add a filter instance into an existing graph.
|
|
|
* The filter instance is created from the filter filt and inited
|
|
|
@@ -1373,7 +1027,6 @@ AVFilterInOut *avfilter_inout_alloc(void);
|
|
|
*/
|
|
|
void avfilter_inout_free(AVFilterInOut **inout);
|
|
|
|
|
|
-#if AV_HAVE_INCOMPATIBLE_LIBAV_ABI || !FF_API_OLD_GRAPH_PARSE
|
|
|
/**
|
|
|
* Add a graph described by a string to a graph.
|
|
|
*
|
|
|
@@ -1395,30 +1048,14 @@ void avfilter_inout_free(AVFilterInOut **inout);
|
|
|
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|
|
AVFilterInOut *inputs, AVFilterInOut *outputs,
|
|
|
void *log_ctx);
|
|
|
-#else
|
|
|
-/**
|
|
|
- * Add a graph described by a string to a graph.
|
|
|
- *
|
|
|
- * @param graph the filter graph where to link the parsed graph context
|
|
|
- * @param filters string to be parsed
|
|
|
- * @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
|
|
|
- * If non-NULL, *inputs is updated to contain the list of open inputs
|
|
|
- * after the parsing, should be freed with avfilter_inout_free().
|
|
|
- * @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
|
|
|
- * If non-NULL, *outputs is updated to contain the list of open outputs
|
|
|
- * after the parsing, should be freed with avfilter_inout_free().
|
|
|
- * @return non negative on success, a negative AVERROR code on error
|
|
|
- * @deprecated Use avfilter_graph_parse_ptr() instead.
|
|
|
- */
|
|
|
-attribute_deprecated
|
|
|
-int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|
|
- AVFilterInOut **inputs, AVFilterInOut **outputs,
|
|
|
- void *log_ctx);
|
|
|
-#endif
|
|
|
|
|
|
/**
|
|
|
* Add a graph described by a string to a graph.
|
|
|
*
|
|
|
+ * In the graph filters description, if the input label of the first
|
|
|
+ * filter is not specified, "in" is assumed; if the output label of
|
|
|
+ * the last filter is not specified, "out" is assumed.
|
|
|
+ *
|
|
|
* @param graph the filter graph where to link the parsed graph context
|
|
|
* @param filters string to be parsed
|
|
|
* @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
|