33 return ctx->name ?
ctx->name :
ctx->filter->name;
39 if (!prev &&
ctx->filter &&
ctx->filter->priv_class &&
ctx->priv_data)
40 return ctx->priv_data;
45 .class_name =
"AVBitStreamFilterContext",
59 int ret =
AVERROR(ENOMEM), preinited = 0;
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];
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 ++) {
464 if (!link->
src || !link->
dst) {
466 "Not all input and output are properly linked (%d).\n",
i);
477 case AVLINK_STARTINIT:
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",
541 av_log(link->
dst,
AV_LOG_ERROR,
"Unsupported input codec id %s (%d). Supported input pad codecs are: ",
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++) {
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) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const AVClass * ff_bsf_child_class_iterate(void **opaque)
void ff_bsf_set_ready(AVBitStreamFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
static int filter_packet_framed(AVBitStreamFilterLink *link, AVPacket *pkt)
int ff_bsf_inlink_acknowledge_status(AVBitStreamFilterLink *link, int *rstatus, int64_t *rpts)
int ff_bsf_inlink_consume_packet(AVBitStreamFilterLink *link, AVPacket **rpkt)
int ff_bsf_outlink_packet_wanted(AVBitStreamFilterLink *link)
static const char * default_bsf_name(void *filter_ctx)
static void consume_update(BitStreamFilterLinkInternal *li, const AVPacket *pkt)
static int filter_activate_default(AVBitStreamFilterContext *ctx)
int ff_bsf_config_links(AVBitStreamFilterContext *filter)
static int filter_packet_to_filter(AVBitStreamFilterLink *link)
static int request_packet_to_filter(AVBitStreamFilterLink *link)
int ff_bsf_filter_packet(AVBitStreamFilterLink *link, AVPacket *pkt)
Send a packet of data to the next filter.
int ff_bsf_outlink_get_status(AVBitStreamFilterLink *link)
static int bsf_opt_parse(void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
Parse filter options into a dictionary.
void ff_bsf_link_set_in_status(AVBitStreamFilterLink *link, int status, int64_t pts)
static void filter_unblock(AVBitStreamFilterContext *filter)
Clear packet_blocked_in on all outputs.
static void link_set_out_status(AVBitStreamFilterLink *link, int status, int64_t pts)
Set the status field of a link from the destination filter.
static void * bsf_child_next(void *obj, void *prev)
static const AVClass bitstreamfilter_class
static int default_filter_packet(AVBitStreamFilterLink *link, AVPacket *pkt)
void ff_bsf_inlink_set_status(AVBitStreamFilterLink *link, int status)
static void link_free(AVBitStreamFilterLink **plink)
void ff_bsf_free(AVBitStreamFilterContext *ctx)
Free a filter context.
size_t ff_bsf_inlink_queued_packets(AVBitStreamFilterLink *link)
static int forward_status_change(AVBitStreamFilterContext *filter, BitStreamFilterLinkInternal *li_in)
int ff_bsf_request_packet(AVBitStreamFilterLink *link)
int ff_bsf_alloc(const AVBitStreamFilter *filter, const char *inst_name, AVBitStreamFilterContext **pctx)
Allocate a new filter context and return it.
int ff_bsf_activate(AVBitStreamFilterContext *ctx)
static void update_link_current_pts(BitStreamFilterLinkInternal *li, int64_t pts)
static int64_t guess_status_pts(AVBitStreamFilterContext *ctx, int status, AVRational link_time_base)
const AVBitStreamFilterPad ff_default_bsf_pad[1]
void ff_bsf_inlink_request_packet(AVBitStreamFilterLink *link)
int ff_bsf_inlink_check_available_packet(AVBitStreamFilterLink *link)
static void free_link(AVBitStreamFilterLink *link)
static BitStreamFilterLinkInternal * ff_link_internal(AVBitStreamFilterLink *link)
void ff_bsf_graph_remove_filter(AVBitStreamFilterGraph *graph, AVBitStreamFilterContext *filter)
Remove a filter from a graph;.
void ff_bsf_graph_update_heap(AVBitStreamFilterGraph *graph, BitStreamFilterLinkInternal *li)
static FFBitStreamFilterGraph * ffbsffiltergraph(AVBitStreamFilterGraph *graph)
static FFBitStreamFilterContext * ffbsfctx(AVBitStreamFilterContext *ctx)
static av_always_inline const FFBitStreamFilter * ff_bsf(const AVBitStreamFilter *bsf)
#define i(width, name, range_min, range_max)
AVCodecParameters * avcodec_parameters_alloc(void)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
void avcodec_parameters_free(AVCodecParameters **ppar)
int av_container_fifo_write(AVContainerFifo *cf, void *obj, unsigned flags)
Write the contents of obj to the FIFO.
void av_container_fifo_free(AVContainerFifo **pcf)
Free a AVContainerFifo and everything in it.
int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags)
Read the next available object from the FIFO into obj.
size_t av_container_fifo_can_read(const AVContainerFifo *cf)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
enum AVCodecID * av_bsf_pad_get_codec_ids(const AVBitStreamFilterPad *pads, int pad_idx)
Get the codec ids supported by an AVBitStreamFilterPad.
int av_bsf_init_dict(AVBitStreamFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
int av_bsf_init_str(AVBitStreamFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
int av_bsf_link(AVBitStreamFilterContext *src, unsigned srcpad, AVBitStreamFilterContext *dst, unsigned dstpad)
Link two filters together.
const char * av_bsf_pad_get_name(const AVBitStreamFilterPad *pads, int pad_idx)
Get the name of an AVBitStreamFilterPad.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVCodecID
Identify the syntax and semantics of the bitstream.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVContainerFifo * av_container_fifo_alloc_avpacket(unsigned flags)
Allocate an AVContainerFifo instance for AVPacket.
int av_packet_make_writable(AVPacket *pkt)
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
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.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
void av_opt_free(void *obj)
Free all allocated objects in obj.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
@ AV_OPT_FLAG_IMPLICIT_KEY
Accept to parse a value without a key; the key will then be returned as NULL.
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
#define FF_BSF_PAD_FLAG_NEEDS_WRITABLE
The filter expects writable packets from its input link, duplicating data buffers if needed.
#define FFERROR_BSF_NOT_READY
Special return code when activate() did not do anything.
#define FF_BSF_PAD_FLAG_FREE_NAME
The pad's name is allocated and should be freed generically.
@ AV_CLASS_STATE_INITIALIZED
Object initialization has finished and it is now in the 'runtime' stage.
@ AV_CLASS_CATEGORY_BITSTREAM_FILTER
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
AVBitStreamFilterPad * output_pads
array of output pads
unsigned nb_inputs
number of input pads
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
AVBitStreamFilterLink ** outputs
array of pointers to output links
AVBitStreamFilterPad * input_pads
array of input pads
char * name
name of this filter instance
AVBitStreamFilterLink ** inputs
array of pointers to input links
Link properties exposed to filter code, but not external callers.
AVBitStreamFilterPad * dstpad
input pad on the dest filter
struct AVBitStreamFilterGraph * graph
Graph the filter belongs to.
int64_t current_pts
Current timestamp of the link, as defined by the most recent packet(s), in link time_base units.
int64_t current_pts_us
Current timestamp of the link, as defined by the most recent packet(s), in AV_TIME_BASE units.
int64_t packet_count_in
Number of past packets sent through the link.
AVBitStreamFilterContext * src
source filter
AVBitStreamFilterContext * dst
dest filter
AVBitStreamFilterPad * srcpad
output pad on the source filter
A filter pad used for either input or output.
const char * name
Pad name.
int(* config_props)(AVBitStreamFilterLink *link)
Link configuration callback.
enum AVCodecID * codec_ids
A list of codec ids supported by the pad, terminated by AV_CODEC_ID_NONE.
int(* request_packet)(AVBitStreamFilterLink *link)
Packet request callback.
Describe the class of an AVClass context structure.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int offset
Native access only.
This structure stores compressed data.
Rational number (pair of numerator and denominator).
int status_out
Link output status.
int packet_blocked_in
If set, the source filter can not generate a packet as is.
int packet_wanted_out
True if a packet is currently wanted on the output of this filter.
int64_t status_in_pts
Timestamp of the input status change.
AVContainerFifo * fifo
Queue of packets waiting to be filtered.
enum BitStreamFilterLinkInternal::@063320061117101100004225063044155055066225214332 init_state
stage of the initialization of the link properties (dimensions, etc)
int status_in
Link input status.
int age_index
Index in the age array.
AVBitStreamFilterContext p
The public AVBitStreamFilterContext.
unsigned ready
Ready status of the filter.
uint8_t nb_inputs
The number of entries in the list of inputs.
void(* uninit)(AVBitStreamFilterContext *ctx)
int(* preinit)(AVBitStreamFilterContext *ctx)
int(* activate)(AVBitStreamFilterContext *ctx)
Filter activation function.
const struct AVBitStreamFilterPad * outputs
List of static outputs.
uint8_t nb_outputs
The number of entries in the list of outputs.
int(* init2)(AVBitStreamFilterContext *ctx)
const struct AVBitStreamFilterPad * inputs
List of static inputs.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx
static FilteringContext * filter_ctx