FFmpeg
options.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #include "avformat.h"
21 #include "avformat_internal.h"
22 #include "avio_internal.h"
23 #include "demux.h"
24 #include "internal.h"
25 
26 #include "libavcodec/avcodec.h"
27 #include "libavcodec/codec_par.h"
28 
29 #include "libavutil/avassert.h"
30 #include "libavutil/iamf.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/intmath.h"
33 #include "libavutil/mem.h"
34 #include "libavutil/opt.h"
35 
36 /**
37  * @file
38  * Options definition for AVFormatContext.
39  */
40 
42 #include "options_table.h"
44 
45 static const char* format_to_name(void* ptr)
46 {
48  if(fc->iformat) return fc->iformat->name;
49  else if(fc->oformat) return fc->oformat->name;
50  else return fc->av_class->class_name;
51 }
52 
53 static void *format_child_next(void *obj, void *prev)
54 {
55  AVFormatContext *s = obj;
56  if (!prev && s->priv_data &&
57  ((s->iformat && s->iformat->priv_class) ||
58  s->oformat && s->oformat->priv_class))
59  return s->priv_data;
60  if (s->pb && s->pb->av_class && prev != s->pb)
61  return s->pb;
62  return NULL;
63 }
64 
65 enum {
70 
71 };
72 
73 #define ITER_STATE_SHIFT 16
74 
75 static const AVClass *format_child_class_iterate(void **iter)
76 {
77  // we use the low 16 bits of iter as the value to be passed to
78  // av_(de)muxer_iterate()
79  void *val = (void*)(((uintptr_t)*iter) & ((1 << ITER_STATE_SHIFT) - 1));
80  unsigned int state = ((uintptr_t)*iter) >> ITER_STATE_SHIFT;
81  const AVClass *ret = NULL;
82 
84  ret = &ff_avio_class;
85  state++;
86  goto finish;
87  }
88 
89  if (state == CHILD_CLASS_ITER_MUX) {
90  const AVOutputFormat *ofmt;
91 
92  while ((ofmt = av_muxer_iterate(&val))) {
93  ret = ofmt->priv_class;
94  if (ret)
95  goto finish;
96  }
97 
98  val = NULL;
99  state++;
100  }
101 
102  if (state == CHILD_CLASS_ITER_DEMUX) {
103  const AVInputFormat *ifmt;
104 
105  while ((ifmt = av_demuxer_iterate(&val))) {
106  ret = ifmt->priv_class;
107  if (ret)
108  goto finish;
109  }
110  val = NULL;
111  state++;
112  }
113 
114 finish:
115  // make sure none av_(de)muxer_iterate does not set the high bits of val
116  av_assert0(!((uintptr_t)val >> ITER_STATE_SHIFT));
117  *iter = (void*)((uintptr_t)val | (state << ITER_STATE_SHIFT));
118  return ret;
119 }
120 
121 static AVClassCategory get_category(void *ptr)
122 {
123  AVFormatContext* s = ptr;
124  if(s->iformat) return AV_CLASS_CATEGORY_DEMUXER;
125  else return AV_CLASS_CATEGORY_MUXER;
126 }
127 
129  .class_name = "AVFormatContext",
130  .item_name = format_to_name,
131  .option = avformat_options,
132  .version = LIBAVUTIL_VERSION_INT,
133  .child_next = format_child_next,
134  .child_class_iterate = format_child_class_iterate,
136  .get_category = get_category,
137 };
138 
140  const char *url, int flags, AVDictionary **options)
141 {
142  int loglevel;
143 
144  if (!strcmp(url, s->url) ||
145  s->iformat && !strcmp(s->iformat->name, "image2") ||
146  s->oformat && !strcmp(s->oformat->name, "image2")
147  ) {
148  loglevel = AV_LOG_DEBUG;
149  } else
150  loglevel = AV_LOG_INFO;
151 
152  av_log(s, loglevel, "Opening \'%s\' for %s\n", url, flags & AVIO_FLAG_WRITE ? "writing" : "reading");
153 
154  return ffio_open_whitelist(pb, url, flags, &s->interrupt_callback, options, s->protocol_whitelist, s->protocol_blacklist);
155 }
156 
158 {
159  return avio_close(pb);
160 }
161 
163 {
165  FFFormatContext *si;
167 
168  fci = av_mallocz(sizeof(*fci));
169  if (!fci)
170  return NULL;
171 
172  si = &fci->fc;
173  s = &si->pub;
174  s->av_class = &av_format_context_class;
175  s->io_open = io_open_default;
176  s->io_close2= io_close2_default;
177 
179 
180  si->pkt = av_packet_alloc();
181  si->parse_pkt = av_packet_alloc();
182  if (!si->pkt || !si->parse_pkt) {
184  return NULL;
185  }
186 
187 #if FF_API_LAVF_SHORTEST
188  fci->shortest_end = AV_NOPTS_VALUE;
189 #endif
190 
191  return s;
192 }
193 
194 #if FF_API_GET_DUR_ESTIMATE_METHOD
195 enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx)
196 {
198 }
199 #endif
200 
202 {
203  return &av_format_context_class;
204 }
205 
206 #define DISPOSITION_OPT(ctx) \
207  { "disposition", NULL, offsetof(ctx, disposition), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, \
208  .flags = AV_OPT_FLAG_ENCODING_PARAM, .unit = "disposition" }, \
209  { "default", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "disposition" }, \
210  { "dub", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "disposition" }, \
211  { "original", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "disposition" }, \
212  { "comment", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "disposition" }, \
213  { "lyrics", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "disposition" }, \
214  { "karaoke", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "disposition" }, \
215  { "forced", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "disposition" }, \
216  { "hearing_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "disposition" }, \
217  { "visual_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "disposition" }, \
218  { "clean_effects", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "disposition" }, \
219  { "attached_pic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC }, .unit = "disposition" }, \
220  { "timed_thumbnails", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_TIMED_THUMBNAILS }, .unit = "disposition" }, \
221  { "non_diegetic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_NON_DIEGETIC }, .unit = "disposition" }, \
222  { "captions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "disposition" }, \
223  { "descriptions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "disposition" }, \
224  { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" }, \
225  { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" }, \
226  { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" }, \
227  { "multilayer", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_MULTILAYER }, .unit = "disposition" }
228 
229 static const AVOption stream_options[] = {
231  { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
232  .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
233  { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
234  { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
235  { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
236  { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
237  { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
238  { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
239  { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
240  { NULL }
241 };
242 
243 static const AVClass stream_class = {
244  .class_name = "AVStream",
245  .item_name = av_default_item_name,
246  .version = LIBAVUTIL_VERSION_INT,
247  .option = stream_options,
248 };
249 
251 {
252  return &stream_class;
253 }
254 
256 {
257  FFFormatContext *const si = ffformatcontext(s);
258  FFStream *sti;
259  AVStream *st;
260  AVStream **streams;
261 
262  if (s->nb_streams >= s->max_streams) {
263  av_log(s, AV_LOG_ERROR, "Number of streams exceeds max_streams parameter"
264  " (%d), see the documentation if you wish to increase it\n",
265  s->max_streams);
266  return NULL;
267  }
268  streams = av_realloc_array(s->streams, s->nb_streams + 1, sizeof(*streams));
269  if (!streams)
270  return NULL;
271  s->streams = streams;
272 
273  sti = av_mallocz(sizeof(*sti));
274  if (!sti)
275  return NULL;
276  st = &sti->pub;
277 
278  st->av_class = &stream_class;
280  if (!st->codecpar)
281  goto fail;
282 
283  sti->fmtctx = s;
284 
285  if (s->iformat) {
287  if (!sti->avctx)
288  goto fail;
289 
290  sti->info = av_mallocz(sizeof(*sti->info));
291  if (!sti->info)
292  goto fail;
293 
294 #if FF_API_R_FRAME_RATE
295  sti->info->last_dts = AV_NOPTS_VALUE;
296 #endif
299 
300  /* default pts setting is MPEG-like */
301  avpriv_set_pts_info(st, 33, 1, 90000);
302  /* we set the current DTS to 0 so that formats without any timestamps
303  * but durations get some timestamps, formats with some unknown
304  * timestamps have their first few packets buffered and the
305  * timestamps corrected before they are returned to the user */
306  sti->cur_dts = RELATIVE_TS_BASE;
307  } else {
308  sti->cur_dts = AV_NOPTS_VALUE;
309  }
310 
311  st->index = s->nb_streams;
313  st->duration = AV_NOPTS_VALUE;
314  sti->first_dts = AV_NOPTS_VALUE;
315  sti->probe_packets = s->max_probe_packets;
318 
321  for (int i = 0; i < MAX_REORDER_DELAY + 1; i++)
322  sti->pts_buffer[i] = AV_NOPTS_VALUE;
323 
324  st->sample_aspect_ratio = (AVRational) { 0, 1 };
325 #if FF_API_INTERNAL_TIMING
326  sti->transferred_mux_tb = (AVRational) { 0, 1 };;
327 #endif
328 
329 #if FF_API_AVSTREAM_SIDE_DATA
330  sti->inject_global_side_data = si->inject_global_side_data;
331 #endif
332 
333  sti->need_context_update = 1;
334 
335  s->streams[s->nb_streams++] = st;
336  return st;
337 fail:
338  ff_free_stream(&st);
339  return NULL;
340 }
341 
342 #define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
343 #define OFFSET(x) offsetof(AVStreamGroupTileGrid, x)
344 static const AVOption tile_grid_options[] = {
345  { "grid_size", "size of the output canvas", OFFSET(coded_width),
346  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS },
347  { "output_size", "size of valid pixels in output image meant for presentation", OFFSET(width),
348  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS },
349  { "background_color", "set a background color for unused pixels",
350  OFFSET(background), AV_OPT_TYPE_COLOR, { .str = "black"}, 0, 0, FLAGS },
351  { "horizontal_offset", NULL, OFFSET(horizontal_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
352  { "vertical_offset", NULL, OFFSET(vertical_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
353  { NULL },
354 };
355 #undef OFFSET
356 
357 static const AVClass tile_grid_class = {
358  .class_name = "AVStreamGroupTileGrid",
359  .version = LIBAVUTIL_VERSION_INT,
360  .option = tile_grid_options,
361 };
362 
363 #define OFFSET(x) offsetof(AVStreamGroupLCEVC, x)
364 static const AVOption lcevc_options[] = {
365  { "video_size", "size of video after LCEVC enhancement has been applied", OFFSET(width),
366  AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS },
367  { NULL },
368 };
369 #undef OFFSET
370 
371 static const AVClass lcevc_class = {
372  .class_name = "AVStreamGroupLCEVC",
373  .version = LIBAVUTIL_VERSION_INT,
374  .option = lcevc_options,
375 };
376 
377 static void *stream_group_child_next(void *obj, void *prev)
378 {
379  AVStreamGroup *stg = obj;
380  if (!prev) {
381  switch(stg->type) {
383  return stg->params.iamf_audio_element;
385  return stg->params.iamf_mix_presentation;
387  return stg->params.tile_grid;
389  return stg->params.lcevc;
390  default:
391  break;
392  }
393  }
394  return NULL;
395 }
396 
397 #undef FLAGS
398 
399 static const AVClass *stream_group_child_iterate(void **opaque)
400 {
401  uintptr_t i = (uintptr_t)*opaque;
402  const AVClass *ret = NULL;
403 
404  switch(i) {
406  i++;
407  // fall-through
410  break;
413  break;
415  ret = &tile_grid_class;
416  break;
418  ret = &lcevc_class;
419  break;
420  default:
421  break;
422  }
423 
424  if (ret)
425  *opaque = (void*)(i + 1);
426  return ret;
427 }
428 
429 static const AVOption stream_group_options[] = {
431  {"id", "Set group id", offsetof(AVStreamGroup, id), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM },
432  { NULL }
433 };
434 
435 static const AVClass stream_group_class = {
436  .class_name = "AVStreamGroup",
437  .item_name = av_default_item_name,
438  .version = LIBAVUTIL_VERSION_INT,
439  .option = stream_group_options,
440  .child_next = stream_group_child_next,
441  .child_class_iterate = stream_group_child_iterate,
442 };
443 
445 {
446  return &stream_group_class;
447 }
448 
452 {
453  AVStreamGroup **stream_groups;
454  AVStreamGroup *stg;
455  FFStreamGroup *stgi;
456 
457  stream_groups = av_realloc_array(s->stream_groups, s->nb_stream_groups + 1,
458  sizeof(*stream_groups));
459  if (!stream_groups)
460  return NULL;
461  s->stream_groups = stream_groups;
462 
463  stgi = av_mallocz(sizeof(*stgi));
464  if (!stgi)
465  return NULL;
466  stg = &stgi->pub;
467 
469  av_opt_set_defaults(stg);
470  stg->type = type;
471  switch (type) {
474  if (!stg->params.iamf_audio_element)
475  goto fail;
476  break;
479  if (!stg->params.iamf_mix_presentation)
480  goto fail;
481  break;
483  stg->params.tile_grid = av_mallocz(sizeof(*stg->params.tile_grid));
484  if (!stg->params.tile_grid)
485  goto fail;
488  break;
490  stg->params.lcevc = av_mallocz(sizeof(*stg->params.lcevc));
491  if (!stg->params.lcevc)
492  goto fail;
493  stg->params.lcevc->av_class = &lcevc_class;
495  break;
496  default:
497  goto fail;
498  }
499 
500  if (options) {
502  goto fail;
503  }
504 
505  stgi->fmtctx = s;
506  stg->index = s->nb_stream_groups;
507 
508  s->stream_groups[s->nb_stream_groups++] = stg;
509 
510  return stg;
511 fail:
512  ff_free_stream_group(&stg);
513  return NULL;
514 }
515 
517 {
518  AVStream **streams = av_realloc_array(stg->streams, stg->nb_streams + 1,
519  sizeof(*stg->streams));
520  if (!streams)
521  return AVERROR(ENOMEM);
522 
523  stg->streams = streams;
524  stg->streams[stg->nb_streams++] = st;
525 
526  return 0;
527 }
528 
530 {
531  const FFStreamGroup *stgi = cffstreamgroup(stg);
532  const FFStream *sti = cffstream(st);
533 
534  if (stgi->fmtctx != sti->fmtctx)
535  return AVERROR(EINVAL);
536 
537  for (int i = 0; i < stg->nb_streams; i++)
538  if (stg->streams[i]->index == st->index)
539  return AVERROR(EEXIST);
540 
541  return stream_group_add_stream(stg, st);
542 }
543 
544 static int option_is_disposition(const AVOption *opt)
545 {
546  return opt->type == AV_OPT_TYPE_CONST &&
547  opt->unit && !strcmp(opt->unit, "disposition");
548 }
549 
550 int av_disposition_from_string(const char *disp)
551 {
552  for (const AVOption *opt = stream_options; opt->name; opt++)
553  if (option_is_disposition(opt) && !strcmp(disp, opt->name))
554  return opt->default_val.i64;
555  return AVERROR(EINVAL);
556 }
557 
558 const char *av_disposition_to_string(int disposition)
559 {
560  int val;
561 
562  if (disposition <= 0)
563  return NULL;
564 
565  val = 1 << ff_ctz(disposition);
566  for (const AVOption *opt = stream_options; opt->name; opt++)
567  if (option_is_disposition(opt) && opt->default_val.i64 == val)
568  return opt->name;
569 
570  return NULL;
571 }
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:605
FFStreamInfo::fps_last_dts
int64_t fps_last_dts
Definition: demux.h:168
iamf.h
AVStreamGroup::params
union AVStreamGroup::@365 params
Group type-specific parameters.
AVCodec
AVCodec.
Definition: codec.h:187
AVStreamGroupParamsType
AVStreamGroupParamsType
Definition: avformat.h:1123
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
ffio_open_whitelist
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
Definition: avio.c:471
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
opt.h
AVStreamGroup::tile_grid
struct AVStreamGroupTileGrid * tile_grid
Definition: avformat.h:1169
DISPOSITION_OPT
#define DISPOSITION_OPT(ctx)
Definition: options.c:206
AV_STREAM_GROUP_PARAMS_LCEVC
@ AV_STREAM_GROUP_PARAMS_LCEVC
Definition: avformat.h:1128
CHILD_CLASS_ITER_DONE
@ CHILD_CLASS_ITER_DONE
Definition: options.c:69
ITER_STATE_SHIFT
#define ITER_STATE_SHIFT
Definition: options.c:73
FFStream::first_dts
int64_t first_dts
Timestamp corresponding to the last dts sync point.
Definition: internal.h:348
ff_ctz
#define ff_ctz
Definition: intmath.h:107
stream_group_add_stream
static int stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Definition: options.c:516
FFStream::last_IP_pts
int64_t last_IP_pts
Definition: internal.h:316
ffformatcontext
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition: internal.h:127
format_child_class_iterate
static const AVClass * format_child_class_iterate(void **iter)
Definition: options.c:75
FLAGS
#define FLAGS
Definition: options.c:342
CHILD_CLASS_ITER_MUX
@ CHILD_CLASS_ITER_MUX
Definition: options.c:67
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:201
AVOption
AVOption.
Definition: opt.h:429
AVFormatContext::duration_estimation_method
enum AVDurationEstimationMethod duration_estimation_method
The duration field can be estimated through various ways, and this field can be used to know how the ...
Definition: avformat.h:1731
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:472
lcevc_options
static const AVOption lcevc_options[]
Definition: options.c:364
AVDictionary
Definition: dict.c:34
cffstream
static const av_always_inline FFStream * cffstream(const AVStream *st)
Definition: internal.h:363
FFStream::last_dts_for_order_check
int64_t last_dts_for_order_check
Internal data to analyze DTS and detect faulty mpeg streams.
Definition: internal.h:291
av_disposition_to_string
const char * av_disposition_to_string(int disposition)
Definition: options.c:558
stream_group_class
static const AVClass stream_group_class
Definition: options.c:435
FormatContextInternal
Definition: avformat_internal.h:33
state
static struct @464 state
ff_free_stream_group
void ff_free_stream_group(AVStreamGroup **pstg)
Frees a stream group without modifying the corresponding AVFormatContext.
Definition: avformat.c:84
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: avformat.c:867
finish
static void finish(void)
Definition: movenc.c:373
AVStreamGroup::av_class
const AVClass * av_class
A class for AVOptions.
Definition: avformat.h:1138
fail
#define fail()
Definition: checkasm.h:189
FFStreamInfo::fps_first_dts
int64_t fps_first_dts
Those are used for average framerate estimation.
Definition: demux.h:166
FFStream::avctx
struct AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
Definition: internal.h:160
AVDISCARD_NONE
@ AVDISCARD_NONE
discard nothing
Definition: defs.h:215
val
static double val(void *priv, double ch)
Definition: aeval.c:77
av_iamf_audio_element_alloc
AVIAMFAudioElement * av_iamf_audio_element_alloc(void)
Allocates a AVIAMFAudioElement, and initializes its fields with default values.
Definition: iamf.c:322
av_stream_group_get_class
const AVClass * av_stream_group_get_class(void)
Get the AVClass for AVStreamGroup.
Definition: options.c:444
type
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 type
Definition: writing_filters.txt:86
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:807
AV_PTS_WRAP_IGNORE
#define AV_PTS_WRAP_IGNORE
Options for behavior on timestamp wrap detection.
Definition: avformat.h:737
AVStreamGroupTileGrid::av_class
const AVClass * av_class
Definition: avformat.h:988
stream_group_child_next
static void * stream_group_child_next(void *obj, void *prev)
Definition: options.c:377
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
AVInputFormat
Definition: avformat.h:548
AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION
@ AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION
Definition: avformat.h:1126
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:149
s
#define s(width, name)
Definition: cbs_vp9.c:198
lcevc_class
static const AVClass lcevc_class
Definition: options.c:371
FFStreamInfo::last_dts
int64_t last_dts
Definition: demux.h:145
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:217
FFStreamGroup::fmtctx
AVFormatContext * fmtctx
Definition: avformat_internal.h:134
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:263
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
AVStreamGroup::index
unsigned int index
Group index in AVFormatContext.
Definition: avformat.h:1145
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
ctx
AVFormatContext * ctx
Definition: movenc.c:49
RELATIVE_TS_BASE
#define RELATIVE_TS_BASE
Definition: avformat_internal.h:112
AVDISCARD_BIDIR
@ AVDISCARD_BIDIR
discard all bidirectional frames
Definition: defs.h:218
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Definition: options.c:255
AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_DEMUXER
Definition: log.h:33
FFFormatContext
Definition: internal.h:64
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:221
AVFormatContext
Format I/O context.
Definition: avformat.h:1300
FFStream::pub
AVStream pub
The public context.
Definition: internal.h:136
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:771
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
CHILD_CLASS_ITER_AVIO
@ CHILD_CLASS_ITER_AVIO
Definition: options.c:66
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
avformat_options
static const AVOption avformat_options[]
Definition: options_table.h:36
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition: opt.h:323
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVDurationEstimationMethod
AVDurationEstimationMethod
The duration of a video can be estimated through various ways, and this enum can be used to know how ...
Definition: avformat.h:1280
AVOutputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:538
FormatContextInternal::fc
FFFormatContext fc
Definition: avformat_internal.h:34
stream_group_options
static const AVOption stream_group_options[]
Definition: options.c:429
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:352
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
format_to_name
FF_DISABLE_DEPRECATION_WARNINGS static const FF_ENABLE_DEPRECATION_WARNINGS char * format_to_name(void *ptr)
Definition: options.c:45
stream_group_child_iterate
static const AVClass * stream_group_child_iterate(void **opaque)
Definition: options.c:399
av_disposition_from_string
int av_disposition_from_string(const char *disp)
Definition: options.c:550
avformat_stream_group_add_stream
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Add an already allocated stream to a stream group.
Definition: options.c:529
AV_STREAM_GROUP_PARAMS_TILE_GRID
@ AV_STREAM_GROUP_PARAMS_TILE_GRID
Definition: avformat.h:1127
options
const OptionDef options[]
AVDISCARD_NONKEY
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition: defs.h:220
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
FFFormatContext::parse_pkt
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
Definition: internal.h:104
avformat_alloc_context
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:162
AVDISCARD_DEFAULT
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
Definition: defs.h:216
FFStream
Definition: internal.h:132
ff_free_stream
void ff_free_stream(AVStream **pst)
Frees a stream without modifying the corresponding AVFormatContext.
Definition: avformat.c:45
AVClass::category
AVClassCategory category
Category used for visualization (like color).
Definition: log.h:132
CHILD_CLASS_ITER_DEMUX
@ CHILD_CLASS_ITER_DEMUX
Definition: options.c:68
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AVStreamGroup::iamf_audio_element
struct AVIAMFAudioElement * iamf_audio_element
Definition: avformat.h:1167
av_iamf_mix_presentation_alloc
AVIAMFMixPresentation * av_iamf_mix_presentation_alloc(void)
Allocates a AVIAMFMixPresentation, and initializes its fields with default values.
Definition: iamf.c:520
av_demuxer_iterate
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:607
AVOption::name
const char * name
Definition: opt.h:430
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:826
FFStream::pts_wrap_behavior
int pts_wrap_behavior
Options for behavior, when a wrap is detected.
Definition: internal.h:271
AVStreamGroup::lcevc
struct AVStreamGroupLCEVC * lcevc
Definition: avformat.h:1170
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: packet.c:63
AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT
@ AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT
Definition: avformat.h:1125
FFStream::probe_packets
int probe_packets
Number of packets to buffer for codec probing.
Definition: internal.h:322
AVStreamGroup::streams
AVStream ** streams
A list of streams in the group.
Definition: avformat.h:1201
AVStreamGroup::iamf_mix_presentation
struct AVIAMFMixPresentation * iamf_mix_presentation
Definition: avformat.h:1168
avformat_internal.h
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
av_iamf_audio_element_get_class
const AVClass * av_iamf_audio_element_get_class(void)
Definition: iamf.c:317
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
get_category
static AVClassCategory get_category(void *ptr)
Definition: options.c:121
OFFSET
#define OFFSET(x)
Definition: options.c:363
AVClassCategory
AVClassCategory
Definition: log.h:28
AV_STREAM_GROUP_PARAMS_NONE
@ AV_STREAM_GROUP_PARAMS_NONE
Definition: avformat.h:1124
AVDISCARD_NONINTRA
@ AVDISCARD_NONINTRA
discard all non intra frames
Definition: defs.h:219
AVOutputFormat
Definition: avformat.h:509
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
tile_grid_class
static const AVClass tile_grid_class
Definition: options.c:357
avio_internal.h
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
internal.h
io_close2_default
static int io_close2_default(AVFormatContext *s, AVIOContext *pb)
Definition: options.c:157
AVStream::av_class
const AVClass * av_class
A class for AVOptions.
Definition: avformat.h:752
stream_class
static const AVClass stream_class
Definition: options.c:243
ff_avio_class
const AVClass ff_avio_class
Definition: avio.c:98
FFStream::pts_buffer
int64_t pts_buffer[MAX_REORDER_DELAY+1]
Definition: internal.h:286
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
demux.h
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:748
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
avformat.h
FFStreamGroup::pub
AVStreamGroup pub
The public context.
Definition: avformat_internal.h:132
AVOption::type
enum AVOptionType type
Definition: opt.h:445
av_iamf_mix_presentation_get_class
const AVClass * av_iamf_mix_presentation_get_class(void)
Definition: iamf.c:515
AVStreamGroup
Definition: avformat.h:1134
format_child_next
static void * format_child_next(void *obj, void *prev)
Definition: options.c:53
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:754
av_muxer_iterate
const AVOutputFormat * av_muxer_iterate(void **opaque)
Iterate over all registered muxers.
Definition: allformats.c:586
AV_CLASS_CATEGORY_MUXER
@ AV_CLASS_CATEGORY_MUXER
Definition: log.h:32
AVStreamGroup::nb_streams
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
Definition: avformat.h:1188
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avformat_free_context
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: avformat.c:149
stream_options
static const AVOption stream_options[]
Definition: options.c:229
FFStream::info
struct FFStreamInfo * info
Stream information used internally by avformat_find_stream_info()
Definition: internal.h:186
io_open_default
static int io_open_default(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
Definition: options.c:139
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:356
mem.h
AVStreamGroup::type
enum AVStreamGroupParamsType type
Group type.
Definition: avformat.h:1161
AVOption::unit
const char * unit
The logical unit to which the option belongs.
Definition: opt.h:479
FFFormatContext::pkt
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
Definition: internal.h:111
avformat_stream_group_create
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
Definition: options.c:449
codec_par.h
FFStream::cur_dts
int64_t cur_dts
Definition: internal.h:349
FFStream::need_context_update
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
Definition: internal.h:177
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
avio_close
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: avio.c:616
options_table.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FFStream::fmtctx
AVFormatContext * fmtctx
Definition: internal.h:138
tile_grid_options
static const AVOption tile_grid_options[]
Definition: options.c:344
FFStreamGroup
Definition: avformat_internal.h:128
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:797
width
#define width
Definition: dsp.h:85
av_stream_get_class
const AVClass * av_stream_get_class(void)
Get the AVClass for AVStream.
Definition: options.c:250
AVDISCARD_NONREF
@ AVDISCARD_NONREF
discard all non reference
Definition: defs.h:217
FFFormatContext::pub
AVFormatContext pub
The public context.
Definition: internal.h:68
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AVStreamGroupLCEVC::av_class
const AVClass * av_class
Definition: avformat.h:1107
option_is_disposition
static int option_is_disposition(const AVOption *opt)
Definition: options.c:544
FFStream::pts_wrap_reference
int64_t pts_wrap_reference
Internal data to check for wrapping of the time stamp.
Definition: internal.h:259
AVInputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:578
MAX_REORDER_DELAY
#define MAX_REORDER_DELAY
Definition: hw_base_encode.h:28
cffstreamgroup
static const av_always_inline FFStreamGroup * cffstreamgroup(const AVStreamGroup *stg)
Definition: avformat_internal.h:142
av_format_context_class
static const AVClass av_format_context_class
Definition: options.c:128
intmath.h