FFmpeg
Loading...
Searching...
No Matches
bsf_internal.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_BSF_INTERNAL_H
20#define AVCODEC_BSF_INTERNAL_H
21
23#include "libavutil/log.h"
24
25#include "bsf.h"
26#include "packet.h"
27#include "bsf/filters.h"
28
29typedef struct FFBitStreamFilter {
30 /**
31 * The public AVBitStreamFilter. See bsf.h for it.
32 */
34
40
41 // Graph based API
42
43 /**
44 * List of static inputs.
45 */
47
48 /**
49 * List of static outputs.
50 */
52
53 /**
54 * The number of entries in the list of inputs.
55 */
56 uint8_t nb_inputs;
57
58 /**
59 * The number of entries in the list of outputs.
60 */
61 uint8_t nb_outputs;
62
66
67 /**
68 * Filter activation function.
69 *
70 * Called when any processing is needed from the filter, instead of any
71 * filter_packet and request_packet on pads.
72 *
73 * The function must examine inlinks and outlinks and perform a single
74 * step of processing. If there is nothing to do, the function must do
75 * nothing and not return an error. If more steps are or may be
76 * possible, it must use ff_filter_set_ready() to schedule another
77 * activation.
78 */
81
83{
84 return (const FFBitStreamFilter*)bsf;
85}
86
87/**
88 * Called by the bitstream filters to get the next packet for filtering.
89 * The filter is responsible for either freeing the packet or passing it to the
90 * caller.
91 */
93
94/**
95 * Called by bitstream filters to get packet for filtering.
96 * The reference to packet is moved to provided packet structure.
97 *
98 * @param ctx pointer to AVBSFContext of filter
99 * @param pkt pointer to packet to move reference to
100 *
101 * @return 0 on success, negative AVERROR in case of failure
102 */
104
105const AVClass *ff_bsf_child_class_iterate(void **opaque);
106
107
108// Graph based API
109
112
113 /**
114 * Queue of packets waiting to be filtered.
115 */
117
118 /**
119 * If set, the source filter can not generate a packet as is.
120 * The goal is to avoid repeatedly calling the request_packet() method on
121 * the same link.
122 */
124
125 /**
126 * Link input status.
127 * If not zero, all attempts of filter_packet will fail with the
128 * corresponding code.
129 */
131
132 /**
133 * Timestamp of the input status change.
134 */
136
137 /**
138 * Link output status.
139 * If not zero, all attempts of request_packet will fail with the
140 * corresponding code.
141 */
143
144 /**
145 * True if a packet is currently wanted on the output of this filter.
146 * Set when ff_request_packet() is called by the output,
147 * cleared when a packet is filtered.
148 */
150
151 /**
152 * Index in the age array.
153 */
155
156 /** stage of the initialization of the link properties (dimensions, etc) */
157 enum {
158 AVLINK_UNINIT = 0, ///< not started
159 AVLINK_STARTINIT, ///< started, but incomplete
160 AVLINK_INIT ///< complete
163
168
170
171/**
172 * Run one round of processing on a filter graph.
173 */
175
177
179
181 /**
182 * The public AVBitStreamFilterContext. See bsf.h for it.
183 */
185
186 // AV_CLASS_STATE_FLAG_*
187 unsigned state_flags;
188
189 /**
190 * Ready status of the filter.
191 * A non-0 value means that the filter needs activating;
192 * a higher value suggests a more urgent activation.
193 */
194 unsigned ready;
196
201
202/**
203 * Free a filter context. This will also remove the filter from its
204 * filtergraph's list of filters.
205 *
206 * @param filter the filter to free
207 */
209
211 /**
212 * The public AVBitStreamFilterGraph. See bsf.h for it.
213 */
215
220
224
229
231{
232 return (const FFBitStreamFilterGraph*)graph;
233}
234
235/**
236 * Allocate a new filter context and return it.
237 *
238 * @param[in] filter what filter to create an instance of
239 * @param[in] inst_name name to give to the new filter context
240 * @param[out] ctx a pointer into which the pointer to the newly-allocated context
241 * will be written
242 *
243 * @return 0 on success, an AVERROR code on failure
244 */
245int ff_bsf_alloc(const AVBitStreamFilter *filter, const char *inst_name, AVBitStreamFilterContext **ctx);
246
247/**
248 * Remove a filter from a graph;
249 */
251
252#endif /* AVCODEC_BSF_INTERNAL_H */
const AVClass * ff_bsf_child_class_iterate(void **opaque)
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
Definition bsf.c:233
static BitStreamFilterLinkInternal * ff_link_internal(AVBitStreamFilterLink *link)
int ff_bsf_graph_run_once(AVBitStreamFilterGraph *graph)
Run one round of processing on a filter graph.
Definition bsfgraph.c:361
int ff_bsf_config_links(AVBitStreamFilterContext *filter)
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition bsf.c:254
void ff_bsf_graph_remove_filter(AVBitStreamFilterGraph *graph, AVBitStreamFilterContext *filter)
Remove a filter from a graph;.
Definition bsfgraph.c:64
int ff_bsf_alloc(const AVBitStreamFilter *filter, const char *inst_name, AVBitStreamFilterContext **ctx)
Allocate a new filter context and return it.
void ff_bsf_graph_update_heap(AVBitStreamFilterGraph *graph, BitStreamFilterLinkInternal *li)
Definition bsfgraph.c:353
static FFBitStreamFilterGraph * ffbsffiltergraph(AVBitStreamFilterGraph *graph)
static FFBitStreamFilterContext * ffbsfctx(AVBitStreamFilterContext *ctx)
void ff_bsf_free(AVBitStreamFilterContext *filter)
Free a filter context.
static const FFBitStreamFilterGraph * cffbsffiltergraph(const AVBitStreamFilterGraph *graph)
int ff_bsf_activate(AVBitStreamFilterContext *ctx)
static av_always_inline const FFBitStreamFilter * ff_bsf(const AVBitStreamFilter *bsf)
long long int64_t
Definition coverity.c:34
static AVPacket * pkt
#define av_always_inline
Definition attributes.h:72
The bitstream filter state.
Definition bsf.h:68
An instance of a filter.
Definition bsf.h:347
A filter pad used for either input or output.
Definition filters.h:35
Describe the class of an AVClass context structure.
Definition log.h:76
AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
This structure stores compressed data.
Definition packet.h:580
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.
AVBitStreamFilterLink l
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.
@ AVLINK_STARTINIT
started, but incomplete
AVBitStreamFilterContext p
The public AVBitStreamFilterContext.
unsigned ready
Ready status of the filter.
AVBitStreamFilterGraph p
The public AVBitStreamFilterGraph.
struct BitStreamFilterLinkInternal ** source_links
struct BitStreamFilterLinkInternal ** sink_links
uint8_t nb_inputs
The number of entries in the list of inputs.
void(* uninit)(AVBitStreamFilterContext *ctx)
int(* init)(AVBSFContext *ctx)
int(* preinit)(AVBitStreamFilterContext *ctx)
int(* filter)(AVBSFContext *ctx, AVPacket *pkt)
int(* activate)(AVBitStreamFilterContext *ctx)
Filter activation function.
void(* close)(AVBSFContext *ctx)
const struct AVBitStreamFilterPad * outputs
List of static outputs.
AVBitStreamFilter p
The public AVBitStreamFilter.
void(* flush)(AVBSFContext *ctx)
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)
Definition h263dsp.c:29
static AVFormatContext * ctx
Definition movenc.c:49