Go to the documentation of this file.
19 #include "config_components.h"
59 for (p = item_str; *p; p++) {
68 char *
arg, *p = item_str;
73 for (
int i = 0;
i < nb_points;
i++) {
84 if (
s->use_timestamps) {
87 if (sscanf(
arg,
"%"SCNd64, &points[
i]) != 1)
109 if (
s->timestamps_str &&
s->points_str) {
112 }
else if (
s->timestamps_str) {
113 s->use_timestamps = 1;
114 split_str =
s->timestamps_str;
115 }
else if (
s->points_str) {
116 split_str =
s->points_str;
125 s->points =
av_calloc(
s->nb_points,
sizeof(*
s->points));
133 s->points[
s->nb_points - 1] = INT64_MAX;
135 for (
int i = 0;
i <
s->nb_points;
i++) {
156 if (
s->use_timestamps) {
157 for (
int i = 0;
i <
s->nb_points - 1;
i++)
170 if (
s->use_timestamps) {
171 ret =
frame->pts >=
s->points[
s->current_point];
175 ret =
inlink->frame_count_out - 1 >=
s->points[
s->current_point];
178 ret =
inlink->sample_count_out -
frame->nb_samples >=
s->points[
s->current_point];
196 for (
int i =
s->current_point; i < s->nb_points;
i++) {
205 diff =
s->points[
s->current_point] -
inlink->sample_count_out;
209 if (
s->current_point >=
s->nb_points)
212 diff =
s->points[
s->current_point] -
inlink->sample_count_out;
214 if (
s->use_timestamps) {
219 if (max_samples <= 0 || max_samples > INT_MAX)
235 if (
s->current_point >=
s->nb_points) {
246 for (
int i =
s->current_point; i < s->nb_points;
i++)
250 for (
int i =
s->current_point; i < s->nb_points;
i++) {
265 #define OFFSET(x) offsetof(SegmentContext, x)
266 #define COMMON_OPTS \
267 { "timestamps", "timestamps of input at which to split input", OFFSET(timestamps_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, \
269 #if CONFIG_SEGMENT_FILTER
276 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
277 static const AVOption segment_options[] = {
300 .priv_class = &segment_class,
306 #endif // CONFIG_SEGMENT_FILTER
308 #if CONFIG_ASEGMENT_FILTER
315 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
316 static const AVOption asegment_options[] = {
339 .priv_class = &asegment_class,
345 #endif // CONFIG_ASEGMENT_FILTER
static int current_segment_finished(AVFilterContext *ctx, AVFrame *frame)
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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
static int parse_points(AVFilterContext *ctx, char *item_str, int nb_points, int64_t *points)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
const AVFilter ff_af_asegment
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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
char * av_asprintf(const char *fmt,...)
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.
const char * name
Filter name.
A link between two filters.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
static int activate(AVFilterContext *ctx)
Rational number (pair of numerator and denominator).
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
static void count_points(char *item_str, int *nb_items)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int init(AVFilterContext *ctx, enum AVMediaType type)
static AVRational av_make_q(int num, int den)
Create an AVRational.
#define AVFILTER_DEFINE_CLASS(fname)
#define i(width, name, range_min, range_max)
const AVFilter ff_vf_segment
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
enum AVMediaType type
AVFilterPad type.
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
static av_cold void uninit(AVFilterContext *ctx)
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
static int ref[MAX_W *MAX_W]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static int config_input(AVFilterLink *inlink)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true