19#include "config_components.h"
55 for (p = item_str; *p; p++) {
64 char *
arg, *p = item_str;
69 for (
int i = 0;
i < nb_points;
i++) {
80 if (
s->use_timestamps) {
83 if (sscanf(
arg,
"%"SCNd64, &points[
i]) != 1)
105 if (
s->timestamps_str &&
s->points_str) {
108 }
else if (
s->timestamps_str) {
109 s->use_timestamps = 1;
110 split_str =
s->timestamps_str;
111 }
else if (
s->points_str) {
112 split_str =
s->points_str;
121 s->points =
av_calloc(
s->nb_points,
sizeof(*
s->points));
129 s->points[
s->nb_points - 1] = INT64_MAX;
131 for (
int i = 0;
i <
s->nb_points;
i++) {
152 if (
s->use_timestamps) {
153 for (
int i = 0;
i <
s->nb_points - 1;
i++)
167 if (
s->use_timestamps) {
168 ret =
frame->pts >=
s->points[
s->current_point];
170 switch (inlink->
type) {
194 for (
int i =
s->current_point;
i < s->nb_points;
i++) {
198 switch (inlink->
type) {
207 if (
s->current_point >=
s->nb_points)
212 if (
s->use_timestamps) {
217 if (max_samples <= 0 || max_samples > INT_MAX)
233 if (
s->current_point >=
s->nb_points) {
244 for (
int i =
s->current_point;
i < s->nb_points;
i++)
248 for (
int i =
s->current_point;
i < s->nb_points;
i++) {
263#define OFFSET(x) offsetof(SegmentContext, x)
265 { "timestamps", "timestamps of input at which to split input", OFFSET(timestamps_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, \
267#if CONFIG_SEGMENT_FILTER
274#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
275static const AVOption segment_options[] = {
295 .p.priv_class = &segment_class,
305#if CONFIG_ASEGMENT_FILTER
312#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
313static const AVOption asegment_options[] = {
331 .p.name =
"asegment",
333 .p.priv_class = &asegment_class,
static int config_input(AVFilterLink *inlink)
const FFFilter ff_af_asegment
const FFFilter ff_vf_segment
static AVFormatContext * ctx
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
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.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
static int config_input(AVFilterLink *inlink)
static int current_segment_finished(AVFilterContext *ctx, AVFrame *frame)
static void count_points(char *item_str, int *nb_items)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int parse_points(AVFilterContext *ctx, char *item_str, int nb_points, int64_t *points)
@ 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_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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().
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
Describe the class of an AVClass context structure.
A link between two filters.
enum AVMediaType type
filter media type
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
enum AVMediaType type
AVFilterPad type.
const char * name
Pad name.
This structure describes decoded (raw) audio or video data.
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
static int ref[MAX_W *MAX_W]
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)