FFmpeg
bsf.c
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 #include <string.h>
20 
21 #include "config.h"
22 
23 #include "libavutil/avassert.h"
24 #include "libavutil/log.h"
25 #include "libavutil/mem.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/avstring.h"
28 #include "libavutil/bprint.h"
29 
30 #include "bsf.h"
31 #include "bsf_internal.h"
32 #include "codec_desc.h"
33 #include "codec_par.h"
34 
35 #define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
36 
37 typedef struct FFBSFContext {
40  int eof;
41 } FFBSFContext;
42 
44 {
45  return (FFBSFContext *)ctx;
46 }
47 
49 {
51  FFBSFContext *bsfi;
52 
53  if (!pctx || !*pctx)
54  return;
55  ctx = *pctx;
56  bsfi = ffbsfcontext(ctx);
57 
58  if (ctx->priv_data) {
59  if (ctx->filter->close)
60  ctx->filter->close(ctx);
61  if (ctx->filter->priv_class)
64  }
65  av_packet_free(&bsfi->buffer_pkt);
66 
67  avcodec_parameters_free(&ctx->par_in);
68  avcodec_parameters_free(&ctx->par_out);
69 
70  av_freep(pctx);
71 }
72 
73 static void *bsf_child_next(void *obj, void *prev)
74 {
75  AVBSFContext *ctx = obj;
76  if (!prev && ctx->filter->priv_class)
77  return ctx->priv_data;
78  return NULL;
79 }
80 
81 static const char *bsf_to_name(void *bsf)
82 {
83  return ((AVBSFContext *)bsf)->filter->name;
84 }
85 
86 static const AVClass bsf_class = {
87  .class_name = "AVBSFContext",
88  .item_name = bsf_to_name,
89  .version = LIBAVUTIL_VERSION_INT,
90  .child_next = bsf_child_next,
91  .child_class_iterate = ff_bsf_child_class_iterate,
93 };
94 
96 {
97  return &bsf_class;
98 }
99 
101 {
102  AVBSFContext *ctx;
103  FFBSFContext *bsfi;
104  int ret;
105 
106  bsfi = av_mallocz(sizeof(*bsfi));
107  if (!bsfi)
108  return AVERROR(ENOMEM);
109  ctx = &bsfi->pub;
110 
111  ctx->av_class = &bsf_class;
112  ctx->filter = filter;
113 
114  ctx->par_in = avcodec_parameters_alloc();
115  ctx->par_out = avcodec_parameters_alloc();
116  if (!ctx->par_in || !ctx->par_out) {
117  ret = AVERROR(ENOMEM);
118  goto fail;
119  }
120  /* allocate priv data and init private options */
121  if (filter->priv_data_size) {
122  ctx->priv_data = av_mallocz(filter->priv_data_size);
123  if (!ctx->priv_data) {
124  ret = AVERROR(ENOMEM);
125  goto fail;
126  }
127  if (filter->priv_class) {
128  *(const AVClass **)ctx->priv_data = filter->priv_class;
130  }
131  }
132  bsfi->buffer_pkt = av_packet_alloc();
133  if (!bsfi->buffer_pkt) {
134  ret = AVERROR(ENOMEM);
135  goto fail;
136  }
137 
138  *pctx = ctx;
139  return 0;
140 fail:
141  av_bsf_free(&ctx);
142  return ret;
143 }
144 
146 {
147  int ret, i;
148 
149  /* check that the codec is supported */
150  if (ctx->filter->codec_ids) {
151  for (i = 0; ctx->filter->codec_ids[i] != AV_CODEC_ID_NONE; i++)
152  if (ctx->par_in->codec_id == ctx->filter->codec_ids[i])
153  break;
154  if (ctx->filter->codec_ids[i] == AV_CODEC_ID_NONE) {
155  const AVCodecDescriptor *desc = avcodec_descriptor_get(ctx->par_in->codec_id);
156  av_log(ctx, AV_LOG_ERROR, "Codec '%s' (%d) is not supported by the "
157  "bitstream filter '%s'. Supported codecs are: ",
158  desc ? desc->name : "unknown", ctx->par_in->codec_id, ctx->filter->name);
159  for (i = 0; ctx->filter->codec_ids[i] != AV_CODEC_ID_NONE; i++) {
160  enum AVCodecID codec_id = ctx->filter->codec_ids[i];
161  av_log(ctx, AV_LOG_ERROR, "%s (%d) ",
163  }
164  av_log(ctx, AV_LOG_ERROR, "\n");
165  return AVERROR(EINVAL);
166  }
167  }
168 
169  /* initialize output parameters to be the same as input
170  * init below might overwrite that */
171  ret = avcodec_parameters_copy(ctx->par_out, ctx->par_in);
172  if (ret < 0)
173  return ret;
174 
175  ctx->time_base_out = ctx->time_base_in;
176 
177  if (ctx->filter->init) {
178  ret = ctx->filter->init(ctx);
179  if (ret < 0)
180  return ret;
181  }
182 
183  return 0;
184 }
185 
187 {
188  FFBSFContext *const bsfi = ffbsfcontext(ctx);
189 
190  bsfi->eof = 0;
191 
193 
194  if (ctx->filter->flush)
195  ctx->filter->flush(ctx);
196 }
197 
199 {
200  FFBSFContext *const bsfi = ffbsfcontext(ctx);
201  int ret;
202 
203  if (!pkt || IS_EMPTY(pkt)) {
204  if (pkt)
206  bsfi->eof = 1;
207  return 0;
208  }
209 
210  if (bsfi->eof) {
211  av_log(ctx, AV_LOG_ERROR, "A non-NULL packet sent after an EOF.\n");
212  return AVERROR(EINVAL);
213  }
214 
215  if (!IS_EMPTY(bsfi->buffer_pkt))
216  return AVERROR(EAGAIN);
217 
219  if (ret < 0)
220  return ret;
222 
223  return 0;
224 }
225 
227 {
228  return ctx->filter->filter(ctx, pkt);
229 }
230 
232 {
233  FFBSFContext *const bsfi = ffbsfcontext(ctx);
234  AVPacket *tmp_pkt;
235 
236  if (bsfi->eof)
237  return AVERROR_EOF;
238 
239  if (IS_EMPTY(bsfi->buffer_pkt))
240  return AVERROR(EAGAIN);
241 
242  tmp_pkt = av_packet_alloc();
243  if (!tmp_pkt)
244  return AVERROR(ENOMEM);
245 
246  *pkt = bsfi->buffer_pkt;
247  bsfi->buffer_pkt = tmp_pkt;
248 
249  return 0;
250 }
251 
253 {
254  FFBSFContext *const bsfi = ffbsfcontext(ctx);
255 
256  if (bsfi->eof)
257  return AVERROR_EOF;
258 
259  if (IS_EMPTY(bsfi->buffer_pkt))
260  return AVERROR(EAGAIN);
261 
263 
264  return 0;
265 }
266 
267 typedef struct BSFListContext {
268  const AVClass *class;
269 
271  int nb_bsfs;
272 
273  unsigned idx; // index of currently processed BSF
274 
275  char * item_name;
277 
278 
279 static int bsf_list_init(AVBSFContext *bsf)
280 {
281  BSFListContext *lst = bsf->priv_data;
282  int ret, i;
283  const AVCodecParameters *cod_par = bsf->par_in;
284  AVRational tb = bsf->time_base_in;
285 
286  for (i = 0; i < lst->nb_bsfs; ++i) {
287  ret = avcodec_parameters_copy(lst->bsfs[i]->par_in, cod_par);
288  if (ret < 0)
289  goto fail;
290 
291  lst->bsfs[i]->time_base_in = tb;
292 
293  ret = av_bsf_init(lst->bsfs[i]);
294  if (ret < 0)
295  goto fail;
296 
297  cod_par = lst->bsfs[i]->par_out;
298  tb = lst->bsfs[i]->time_base_out;
299  }
300 
301  bsf->time_base_out = tb;
302  ret = avcodec_parameters_copy(bsf->par_out, cod_par);
303 
304 fail:
305  return ret;
306 }
307 
309 {
310  BSFListContext *lst = bsf->priv_data;
311  int ret, eof = 0;
312 
313  if (!lst->nb_bsfs)
314  return ff_bsf_get_packet_ref(bsf, out);
315 
316  while (1) {
317  /* get a packet from the previous filter up the chain */
318  if (lst->idx)
319  ret = av_bsf_receive_packet(lst->bsfs[lst->idx-1], out);
320  else
321  ret = ff_bsf_get_packet_ref(bsf, out);
322  if (ret == AVERROR(EAGAIN)) {
323  if (!lst->idx)
324  return ret;
325  lst->idx--;
326  continue;
327  } else if (ret == AVERROR_EOF) {
328  eof = 1;
329  } else if (ret < 0)
330  return ret;
331 
332  /* send it to the next filter down the chain */
333  if (lst->idx < lst->nb_bsfs) {
334  ret = av_bsf_send_packet(lst->bsfs[lst->idx], eof ? NULL : out);
335  av_assert1(ret != AVERROR(EAGAIN));
336  if (ret < 0) {
338  return ret;
339  }
340  lst->idx++;
341  eof = 0;
342  } else if (eof) {
343  return ret;
344  } else {
345  return 0;
346  }
347  }
348 }
349 
350 static void bsf_list_flush(AVBSFContext *bsf)
351 {
352  BSFListContext *lst = bsf->priv_data;
353 
354  for (int i = 0; i < lst->nb_bsfs; i++)
355  av_bsf_flush(lst->bsfs[i]);
356  lst->idx = 0;
357 }
358 
359 static void bsf_list_close(AVBSFContext *bsf)
360 {
361  BSFListContext *lst = bsf->priv_data;
362  int i;
363 
364  for (i = 0; i < lst->nb_bsfs; ++i)
365  av_bsf_free(&lst->bsfs[i]);
366  av_freep(&lst->bsfs);
367  av_freep(&lst->item_name);
368 }
369 
370 static const char *bsf_list_item_name(void *ctx)
371 {
372  static const char *null_filter_name = "null";
373  AVBSFContext *bsf_ctx = ctx;
374  BSFListContext *lst = bsf_ctx->priv_data;
375 
376  if (!lst->nb_bsfs)
377  return null_filter_name;
378 
379  if (!lst->item_name) {
380  int i;
381  AVBPrint bp;
382  av_bprint_init(&bp, 16, 128);
383 
384  av_bprintf(&bp, "bsf_list(");
385  for (i = 0; i < lst->nb_bsfs; i++)
386  av_bprintf(&bp, i ? ",%s" : "%s", lst->bsfs[i]->filter->name);
387  av_bprintf(&bp, ")");
388 
389  av_bprint_finalize(&bp, &lst->item_name);
390  }
391 
392  return lst->item_name;
393 }
394 
395 static const AVClass bsf_list_class = {
396  .class_name = "bsf_list",
397  .item_name = bsf_list_item_name,
398  .version = LIBAVUTIL_VERSION_INT,
399 };
400 
401 static const AVBitStreamFilter list_bsf = {
402  .name = "bsf_list",
403  .priv_data_size = sizeof(BSFListContext),
404  .priv_class = &bsf_list_class,
405  .init = bsf_list_init,
408  .close = bsf_list_close,
409 };
410 
411 struct AVBSFList {
413  int nb_bsfs;
414 };
415 
417 {
418  return av_mallocz(sizeof(AVBSFList));
419 }
420 
422 {
423  int i;
424 
425  if (!*lst)
426  return;
427 
428  for (i = 0; i < (*lst)->nb_bsfs; ++i)
429  av_bsf_free(&(*lst)->bsfs[i]);
430  av_free((*lst)->bsfs);
431  av_freep(lst);
432 }
433 
435 {
436  return av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs, bsf);
437 }
438 
439 static int bsf_list_append_internal(AVBSFList *lst, const char *bsf_name, const char *options, AVDictionary ** options_dict)
440 {
441  int ret;
442  const AVBitStreamFilter *filter;
443  AVBSFContext *bsf;
444 
445  filter = av_bsf_get_by_name(bsf_name);
446  if (!filter)
447  return AVERROR_BSF_NOT_FOUND;
448 
449  ret = av_bsf_alloc(filter, &bsf);
450  if (ret < 0)
451  return ret;
452 
453  if (options && filter->priv_class) {
454  const AVOption *opt = av_opt_next(bsf->priv_data, NULL);
455  const char * shorthand[2] = {NULL};
456 
457  if (opt)
458  shorthand[0] = opt->name;
459 
460  ret = av_opt_set_from_string(bsf->priv_data, options, shorthand, "=", ":");
461  if (ret < 0)
462  goto end;
463  }
464 
465  if (options_dict) {
466  ret = av_opt_set_dict2(bsf, options_dict, AV_OPT_SEARCH_CHILDREN);
467  if (ret < 0)
468  goto end;
469  }
470 
471  ret = av_bsf_list_append(lst, bsf);
472 
473 end:
474  if (ret < 0)
475  av_bsf_free(&bsf);
476 
477  return ret;
478 }
479 
480 int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary ** options)
481 {
482  return bsf_list_append_internal(lst, bsf_name, NULL, options);
483 }
484 
486 {
487  int ret = 0;
489 
490  if ((*lst)->nb_bsfs == 1) {
491  *bsf = (*lst)->bsfs[0];
492  av_freep(&(*lst)->bsfs);
493  (*lst)->nb_bsfs = 0;
494  goto end;
495  }
496 
497  ret = av_bsf_alloc(&list_bsf, bsf);
498  if (ret < 0)
499  return ret;
500 
501  ctx = (*bsf)->priv_data;
502 
503  ctx->bsfs = (*lst)->bsfs;
504  ctx->nb_bsfs = (*lst)->nb_bsfs;
505 
506 end:
507  av_freep(lst);
508  return ret;
509 }
510 
511 static int bsf_parse_single(char *str, AVBSFList *bsf_lst)
512 {
513  char *bsf_name, *bsf_options_str;
514 
515  bsf_name = av_strtok(str, "=", &bsf_options_str);
516  if (!bsf_name)
517  return AVERROR(EINVAL);
518 
519  return bsf_list_append_internal(bsf_lst, bsf_name, bsf_options_str, NULL);
520 }
521 
522 int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
523 {
524  AVBSFList *lst;
525  int ret;
526 
527  if (!str)
528  return av_bsf_get_null_filter(bsf_lst);
529 
530  lst = av_bsf_list_alloc();
531  if (!lst)
532  return AVERROR(ENOMEM);
533 
534  do {
535  char *bsf_str = av_get_token(&str, ",");
536  ret = bsf_parse_single(bsf_str, lst);
537  av_free(bsf_str);
538  if (ret < 0)
539  goto end;
540  } while (*str && *++str);
541 
542  ret = av_bsf_list_finalize(&lst, bsf_lst);
543 end:
544  if (ret < 0)
545  av_bsf_list_free(&lst);
546  return ret;
547 }
548 
550 {
551 #if CONFIG_NULL_BSF
552  extern const AVBitStreamFilter ff_null_bsf;
553  return av_bsf_alloc(&ff_null_bsf, bsf);
554 #else
555  return av_bsf_alloc(&list_bsf, bsf);
556 #endif
557 }
FFBSFContext::pub
AVBSFContext pub
Definition: bsf.c:38
AVBSFList::nb_bsfs
int nb_bsfs
Definition: bsf.c:413
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:417
AVBSFContext::par_in
AVCodecParameters * par_in
Parameters of the input stream.
Definition: bsf.h:69
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
AVERROR
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
bsf_internal.h
opt.h
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1361
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:234
out
FILE * out
Definition: movenc.c:54
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:68
av_get_token
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
Definition: avstring.c:151
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBitStreamFilter::name
const char * name
Definition: bsf.h:91
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:145
BSFListContext::bsfs
AVBSFContext ** bsfs
Definition: bsf.c:270
av_bsf_list_alloc
AVBSFList * av_bsf_list_alloc(void)
Allocate empty list of bitstream filters.
Definition: bsf.c:416
bsf_list_append_internal
static int bsf_list_append_internal(AVBSFList *lst, const char *bsf_name, const char *options, AVDictionary **options_dict)
Definition: bsf.c:439
AVOption
AVOption.
Definition: opt.h:247
avcodec_parameters_free
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
Definition: codec_par.c:61
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
AVDictionary
Definition: dict.c:30
ff_bsf_get_packet
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
Definition: bsf.c:231
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:75
AVBSFContext
The bitstream filter state.
Definition: bsf.h:47
av_bsf_get_by_name
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
Definition: bitstream_filters.c:78
BSFListContext
Definition: bsf.c:267
bsf.h
fail
#define fail()
Definition: checkasm.h:127
ffbsfcontext
static av_always_inline FFBSFContext * ffbsfcontext(AVBSFContext *ctx)
Definition: bsf.c:43
bsf_child_next
static void * bsf_child_next(void *obj, void *prev)
Definition: bsf.c:73
av_bsf_get_null_filter
int av_bsf_get_null_filter(AVBSFContext **bsf)
Get null/pass-through bitstream filter.
Definition: bsf.c:549
AVBSFContext::par_out
AVCodecParameters * par_out
Parameters of the output stream.
Definition: bsf.h:75
FFBSFContext::eof
int eof
Definition: bsf.c:40
BSFListContext::nb_bsfs
int nb_bsfs
Definition: bsf.c:271
BSFListContext::idx
unsigned idx
Definition: bsf.c:273
bsf_list_filter
static int bsf_list_filter(AVBSFContext *bsf, AVPacket *out)
Definition: bsf.c:308
bsf_list_flush
static void bsf_list_flush(AVBSFContext *bsf)
Definition: bsf.c:350
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
list_bsf
static const AVBitStreamFilter list_bsf
Definition: bsf.c:401
av_bsf_list_free
void av_bsf_list_free(AVBSFList **lst)
Free list of bitstream filters.
Definition: bsf.c:421
av_strtok
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().
Definition: avstring.c:186
av_bsf_get_class
const AVClass * av_bsf_get_class(void)
Get the AVClass for AVBSFContext.
Definition: bsf.c:95
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVBSFContext::time_base_in
AVRational time_base_in
The timebase used for the timestamps of the input packets.
Definition: bsf.h:81
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:369
av_bsf_list_finalize
int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf)
Finalize list of bitstream filters.
Definition: bsf.c:485
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:593
NULL
#define NULL
Definition: coverity.c:32
av_bsf_list_parse_str
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
Definition: bsf.c:522
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_opt_set_from_string
int av_opt_set_from_string(void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
Parse the key-value pairs list in opts.
Definition: opt.c:1562
AVERROR_BSF_NOT_FOUND
#define AVERROR_BSF_NOT_FOUND
Bitstream filter not found.
Definition: error.h:51
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1614
av_packet_move_ref
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:474
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:47
ff_bsf_child_class_iterate
const AVClass * ff_bsf_child_class_iterate(void **opaque)
Definition: bitstream_filters.c:94
options
const OptionDef options[]
bsf_class
static const AVClass bsf_class
Definition: bsf.c:86
ff_null_bsf
const AVBitStreamFilter ff_null_bsf
Definition: null_bsf.c:27
IS_EMPTY
#define IS_EMPTY(pkt)
Definition: bsf.c:35
AVClass::category
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
Definition: log.h:114
bsf_list_item_name
static const char * bsf_list_item_name(void *ctx)
Definition: bsf.c:370
FFBSFContext
Definition: bsf.c:37
AVOption::name
const char * name
Definition: opt.h:248
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:559
av_opt_set_dict2
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition: opt.c:1634
av_packet_make_refcounted
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
Definition: avpacket.c:480
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:64
bsf_list_class
static const AVClass bsf_list_class
Definition: bsf.c:395
bsf_parse_single
static int bsf_parse_single(char *str, AVBSFList *bsf_lst)
Definition: bsf.c:511
av_bsf_list_append2
int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary **options)
Construct new bitstream filter context given it's name and options and append it to the list of bitst...
Definition: bsf.c:480
avcodec_parameters_copy
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
Definition: codec_par.c:72
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:453
bsf_list_init
static int bsf_list_init(AVBSFContext *bsf)
Definition: bsf.c:279
bprint.h
log.h
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:226
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
BSFListContext::item_name
char * item_name
Definition: bsf.c:275
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFBSFContext::buffer_pkt
AVPacket * buffer_pkt
Definition: bsf.c:39
tb
#define tb
Definition: regdef.h:68
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
avcodec_parameters_alloc
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
Definition: codec_par.c:51
AVBSFContext::time_base_out
AVRational time_base_out
The timebase used for the timestamps of the output packets.
Definition: bsf.h:87
av_opt_next
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
Definition: opt.c:45
AVBSFContext::priv_data
void * priv_data
Opaque filter-specific private data.
Definition: bsf.h:62
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVFormatContext::av_class
const AVClass * av_class
A class for logging and AVOptions.
Definition: avformat.h:1102
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:93
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:198
av_bsf_list_append
int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf)
Append bitstream filter to the list of bitstream filters.
Definition: bsf.c:434
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:186
av_dynarray_add_nofree
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition: mem.c:322
AVBSFList
Structure for chain/list of bitstream filters.
Definition: bsf.c:411
AVBitStreamFilter
Definition: bsf.h:90
bsf_list_close
static void bsf_list_close(AVBSFContext *bsf)
Definition: bsf.c:359
AVBSFContext::filter
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
Definition: bsf.h:56
desc
const char * desc
Definition: libsvtav1.c:79
mem.h
AV_CLASS_CATEGORY_BITSTREAM_FILTER
@ AV_CLASS_CATEGORY_BITSTREAM_FILTER
Definition: log.h:37
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
codec_par.h
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:48
convert_header.str
string str
Definition: convert_header.py:20
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
ff_bsf_get_packet_ref
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition: bsf.c:252
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3514
bsf_to_name
static const char * bsf_to_name(void *bsf)
Definition: bsf.c:81
avstring.h
codec_desc.h
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1125
av_bsf_alloc
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
Definition: bsf.c:100
AVBSFList::bsfs
AVBSFContext ** bsfs
Definition: bsf.c:412