Go to the documentation of this file.
66 *pctx =
ctx = &ctxi->
p;
90 if (
ctx->nb_inputs ) {
100 if (
ctx->nb_outputs) {
102 if (!
ctx->output_pads)
136 if (
src->nb_outputs <= srcpad ||
dst->nb_inputs <= dstpad ||
137 src->outputs[srcpad] ||
dst->inputs[dstpad])
146 if (
src->output_pads[srcpad].codec_ids &&
dst->input_pads[dstpad].codec_ids) {
150 if (
src->output_pads[srcpad].codec_ids[
i] ==
dst->input_pads[dstpad].codec_ids[j]) {
184 src->outputs[srcpad] =
dst->inputs[dstpad] =
link;
188 link->srcpad = &
src->output_pads[srcpad];
189 link->dstpad = &
dst->input_pads[dstpad];
239 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
244 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
250 if (
ctx->filter->priv_class)
284 char *parsed_key, *
value;
286 const char *shorthand =
NULL;
287 int additional_flags = 0;
289 if (priv_class && (o =
av_opt_next(&priv_class, o))) {
298 &parsed_key, &
value);
382 return pads[pad_idx].
name;
414 for (
i = 0;
i <
filter->nb_outputs;
i++) {
458 for (
i = 0;
i <
filter->nb_inputs;
i ++) {
466 "Not all input and output are properly linked (%d).\n",
i);
477 case AVLINK_STARTINIT:
486 if (!(config_link =
link->srcpad->config_props)) {
487 if (
link->src->nb_inputs != 1) {
489 "with more than one input "
490 "must set config_props() "
491 "callbacks on all outputs\n");
511 if (config_link && (
ret = config_link(
link)) < 0) {
513 "Failed to configure output pad on %s\n",
518 switch (
link->par->codec_type) {
535 if (
link->dstpad->codec_ids) {
538 if (
link->par->codec_id ==
link->dstpad->codec_ids[j])
553 if ((config_link =
link->dstpad->config_props))
554 if ((
ret = config_link(
link)) < 0) {
556 "Failed to configure input pad on %s\n",
598 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
607 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
624 if (
link->srcpad->request_packet)
626 else if (
link->src->inputs[0])
658 link->packet_count_out++;
673 link->packet_count_in++;
707 link->packet_count_out--;
709 if (ret < 0 && ret != li->status_out) {
722 unsigned out = 0, progress = 0;
726 if (!
filter->nb_outputs) {
757 for (
i = 0;
i <
ctx->nb_outputs;
i++)
759 if (
ctx->nb_outputs && nb_eofs ==
ctx->nb_outputs) {
760 for (
int j = 0; j <
ctx->nb_inputs; j++)
765 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
771 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
778 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
785 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
790 if (!
ctx->nb_outputs) {
813 *rpts =
link->current_pts;
822 *rpts =
link->current_pts;
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static int forward_status_change(AVBitStreamFilterContext *filter, BitStreamFilterLinkInternal *li_in)
#define AV_LOG_WARNING
Something somehow does not look correct.
const AVBitStreamFilterPad ff_default_bsf_pad[1]
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static const av_always_inline FFBitStreamFilter * ff_bsf(const AVBitStreamFilter *bsf)
int av_container_fifo_write(AVContainerFifo *cf, void *obj, unsigned flags)
Write the contents of obj to the FIFO.
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 status_out
Link output status.
int ff_bsf_inlink_acknowledge_status(AVBitStreamFilterLink *link, int *rstatus, int64_t *rpts)
void(* uninit)(AVBitStreamFilterContext *ctx)
#define AVERROR_EOF
End of file.
@ AV_OPT_FLAG_IMPLICIT_KEY
Accept to parse a value without a key; the key will then be returned as NULL.
#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
A filter pad used for either input or output.
int(* preinit)(AVBitStreamFilterContext *ctx)
static void * bsf_child_next(void *obj, void *prev)
void ff_bsf_link_set_in_status(AVBitStreamFilterLink *link, int status, int64_t pts)
unsigned ready
Ready status of the filter.
enum BitStreamFilterLinkInternal::@85 init_state
stage of the initialization of the link properties (dimensions, etc)
int ff_bsf_inlink_consume_packet(AVBitStreamFilterLink *link, AVPacket **rpkt)
uint8_t nb_inputs
The number of entries in the list of inputs.
static void free_link(AVBitStreamFilterLink *link)
static int filter_activate_default(AVBitStreamFilterContext *ctx)
void(* filter)(uint8_t *src, int stride, int qscale)
int ff_bsf_inlink_check_available_packet(AVBitStreamFilterLink *link)
int packet_blocked_in
If set, the source filter can not generate a packet as is.
void ff_bsf_inlink_request_packet(AVBitStreamFilterLink *link)
int status_in
Link input status.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
int packet_wanted_out
True if a packet is currently wanted on the output of this filter.
static int default_filter_packet(AVBitStreamFilterLink *link, AVPacket *pkt)
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
static int filter_packet_to_filter(AVBitStreamFilterLink *link)
#define FF_BSF_PAD_FLAG_NEEDS_WRITABLE
The filter expects writable packets from its input link, duplicating data buffers if needed.
int offset
Native access only.
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
int ff_bsf_request_packet(AVBitStreamFilterLink *link)
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
static FilteringContext * filter_ctx
void ff_bsf_free(AVBitStreamFilterContext *ctx)
Free a filter context.
const char * av_bsf_pad_get_name(const AVBitStreamFilterPad *pads, int pad_idx)
Get the name of an AVBitStreamFilterPad.
AVContainerFifo * fifo
Queue of packets waiting to be filtered.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static void filter_unblock(AVBitStreamFilterContext *filter)
Clear packet_blocked_in on all outputs.
int ff_bsf_outlink_packet_wanted(AVBitStreamFilterLink *link)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVClass bitstreamfilter_class
enum AVCodecID * codec_ids
A list of codec ids supported by the pad, terminated by AV_CODEC_ID_NONE.
static void consume_update(BitStreamFilterLinkInternal *li, const AVPacket *pkt)
int ff_bsf_config_links(AVBitStreamFilterContext *filter)
int flags
Flags modifying the (de)muxer behaviour.
int(* activate)(AVBitStreamFilterContext *ctx)
Filter activation function.
static int bsf_opt_parse(void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
Parse filter options into a dictionary.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t current_pts_us
Current timestamp of the link, as defined by the most recent packet(s), in AV_TIME_BASE units.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static AVFormatContext * ctx
int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags)
Read the next available object from the FIFO into obj.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int ff_bsf_filter_packet(AVBitStreamFilterLink *link, AVPacket *pkt)
Send a packet of data to the next filter.
int av_bsf_link(AVBitStreamFilterContext *src, unsigned srcpad, AVBitStreamFilterContext *dst, unsigned dstpad)
Link two filters together.
void ff_bsf_inlink_set_status(AVBitStreamFilterLink *link, int status)
int state_flags_offset
When non-zero, offset in the object to an unsigned int holding object state flags,...
AVBitStreamFilterContext p
The public AVBitStreamFilterContext.
static void update_link_current_pts(BitStreamFilterLinkInternal *li, int64_t pts)
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 link
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
int ff_bsf_alloc(const AVBitStreamFilter *filter, const char *inst_name, AVBitStreamFilterContext **pctx)
Allocate a new filter context and return it.
Rational number (pair of numerator and denominator).
#define FFERROR_BSF_NOT_READY
Special return code when activate() did not do anything.
@ AV_CLASS_STATE_INITIALIZED
Object initialization has finished and it is now in the 'runtime' stage.
size_t ff_bsf_inlink_queued_packets(AVBitStreamFilterLink *link)
int age_index
Index in the age array.
static int filter_packet_framed(AVBitStreamFilterLink *link, AVPacket *pkt)
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVClass * ff_bsf_child_class_iterate(void **opaque)
int ff_bsf_activate(AVBitStreamFilterContext *ctx)
static BitStreamFilterLinkInternal * ff_link_internal(AVBitStreamFilterLink *link)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
#define AV_NOPTS_VALUE
Undefined timestamp value.
const struct AVBitStreamFilterPad * outputs
List of static outputs.
AVRational time_base
Time base for the timestamps in this frame.
static void link_set_out_status(AVBitStreamFilterLink *link, int status, int64_t pts)
Set the status field of a link from the destination filter.
#define FF_BSF_PAD_FLAG_FREE_NAME
The pad's name is allocated and should be freed generically.
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 offset
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
#define AV_LOG_INFO
Standard information.
enum AVCodecID * av_bsf_pad_get_codec_ids(const AVBitStreamFilterPad *pads, int pad_idx)
Get the codec ids supported by an AVBitStreamFilterPad.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t current_pts
Current timestamp of the link, as defined by the most recent packet(s), in link time_base units.
void ff_bsf_graph_update_heap(AVBitStreamFilterGraph *graph, BitStreamFilterLinkInternal *li)
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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 default value
const struct AVBitStreamFilterPad * inputs
List of static inputs.
void * av_calloc(size_t nmemb, size_t size)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_container_fifo_free(AVContainerFifo **pcf)
Free a AVContainerFifo and everything in it.
const AVClass * av_class
A class for logging and AVOptions.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
int ff_bsf_outlink_get_status(AVBitStreamFilterLink *link)
const char * name
Pad name.
static int request_packet_to_filter(AVBitStreamFilterLink *link)
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
size_t av_container_fifo_can_read(const AVContainerFifo *cf)
Link properties exposed to filter code, but not external callers.
int av_bsf_init_str(AVBitStreamFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
void ff_bsf_set_ready(AVBitStreamFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int64_t status_in_pts
Timestamp of the input status change.
int av_bsf_init_dict(AVBitStreamFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
static const char * default_bsf_name(void *filter_ctx)
@ AV_CLASS_CATEGORY_BITSTREAM_FILTER
static FFBitStreamFilterGraph * ffbsffiltergraph(AVBitStreamFilterGraph *graph)
This structure stores compressed data.
static void link_free(AVBitStreamFilterLink **plink)
uint8_t nb_outputs
The number of entries in the list of outputs.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int(* init2)(AVBitStreamFilterContext *ctx)
char * name
Name of this format context, only used for logging purposes.
void ff_bsf_graph_remove_filter(AVBitStreamFilterGraph *graph, AVBitStreamFilterContext *filter)
Remove a filter from a graph;.
struct AVBitStreamFilterGraph * graph
Graph the filter belongs to.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
void * priv_data
Format private data.
static int64_t guess_status_pts(AVBitStreamFilterContext *ctx, int status, AVRational link_time_base)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
AVContainerFifo * av_container_fifo_alloc_avpacket(unsigned flags)
Allocate an AVContainerFifo instance for AVPacket.
static FFBitStreamFilterContext * ffbsfctx(AVBitStreamFilterContext *ctx)