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