FFmpeg
Loading...
Searching...
No Matches
avformat.c
Go to the documentation of this file.
1/*
2 * Various functions used by both muxers and demuxers
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "config_components.h"
23
24#include <math.h>
25#include "libavutil/avassert.h"
26#include "libavutil/avstring.h"
28#include "libavutil/frame.h"
29#include "libavutil/iamf.h"
30#include "libavutil/mem.h"
31#include "libavutil/opt.h"
32#include "libavutil/pixfmt.h"
33#include "libavutil/samplefmt.h"
34#include "libavcodec/avcodec.h"
35#include "libavcodec/codec.h"
36#include "libavcodec/bsf.h"
38#include "packet_internal.h"
39#include "avformat.h"
40#include "avformat_internal.h"
41#include "avio.h"
42#include "demux.h"
43#include "mux.h"
44#include "internal.h"
45#include "url.h"
46
48{
49 AVStream *st = *pst;
50 FFStream *const sti = ffstream(st);
51
52 if (!st)
53 return;
54
55 if (st->attached_pic.data)
57
60 av_bsf_free(&sti->bsfc);
62 av_freep(&sti->probe_data.buf);
63
65
67
68 if (sti->info) {
70 av_freep(&sti->info);
71 }
72
75 av_freep(&st->priv_data);
76
77 av_freep(pst);
78}
79
81{
82 AVStreamGroup *stg = *pstg;
83
84 if (!stg)
85 return;
86
87#if FF_API_STREAM_GROUP_ENTRIES
89 av_freep(&stg->streams);
91#endif
92 for (int i = 0; i < stg->nb_entries; i++)
93 av_freep(&stg->entries[i]);
94 av_freep(&stg->entries);
96 &stg->nb_coded_side_data);
98 av_freep(&stg->priv_data);
99 switch (stg->type) {
102 break;
103 }
106 break;
107 }
111#if FF_API_STREAM_GROUP_ENTRIES
113 av_packet_side_data_free(&stg->params.tile_grid->coded_side_data,
114 &stg->params.tile_grid->nb_coded_side_data);
116#endif
118 break;
120 av_opt_free(stg->params.tref);
121 av_freep(&stg->params.tref);
122 break;
128 break;
129 default:
130 break;
131 }
132
133 av_freep(pstg);
134}
135
137{
138 av_assert0(s->nb_streams>0);
139 av_assert0(s->streams[ s->nb_streams - 1 ] == st);
140
141 ff_free_stream(&s->streams[ --s->nb_streams ]);
142}
143
145{
146 av_assert0(s->nb_stream_groups > 0);
147 av_assert0(s->stream_groups[ s->nb_stream_groups - 1 ] == stg);
148
149 ff_free_stream_group(&s->stream_groups[ --s->nb_stream_groups ]);
150}
151
152/* XXX: suppress the packet queue */
163
165{
167 FFFormatContext *si;
168
169 if (!s)
170 return;
171 fci = ff_fc_internal(s);
172 si = &fci->fc;
173
174 if (s->oformat && ffofmt(s->oformat)->deinit && fci->initialized)
175 ffofmt(s->oformat)->deinit(s);
176
177 av_opt_free(s);
178 if (s->iformat && s->iformat->priv_class && s->priv_data)
179 av_opt_free(s->priv_data);
180 if (s->oformat && s->oformat->priv_class && s->priv_data)
181 av_opt_free(s->priv_data);
182
183 for (unsigned i = 0; i < s->nb_streams; i++)
184 ff_free_stream(&s->streams[i]);
185 for (unsigned i = 0; i < s->nb_stream_groups; i++)
186 ff_free_stream_group(&s->stream_groups[i]);
187 s->nb_stream_groups = 0;
188 s->nb_streams = 0;
189
190 for (unsigned i = 0; i < s->nb_programs; i++) {
191 av_dict_free(&s->programs[i]->metadata);
192 av_freep(&s->programs[i]->stream_index);
193 av_freep(&s->programs[i]);
194 }
195 s->nb_programs = 0;
196
197 av_freep(&s->programs);
198 av_freep(&s->priv_data);
199 while (s->nb_chapters--) {
200 av_dict_free(&s->chapters[s->nb_chapters]->metadata);
201 av_freep(&s->chapters[s->nb_chapters]);
202 }
203 av_freep(&s->chapters);
204 av_dict_free(&s->metadata);
206#if CONFIG_LIBCURL_PROTOCOL
208#endif
209 av_packet_free(&si->pkt);
212 av_freep(&s->streams);
213 av_freep(&s->stream_groups);
214 if (s->iformat)
216 av_freep(&s->url);
217 av_freep(&s->name);
218 av_free(s);
219}
220
221/**
222 * Copy all stream parameters from source to destination stream, with the
223 * exception of the index field, which is usually set by avformat_new_stream().
224 *
225 * @param dst pointer to destination AVStream
226 * @param src pointer to source AVStream
227 * @return >=0 on success, AVERROR code on error
228 */
230{
231 int ret;
232
233 dst->id = src->id;
234 dst->time_base = src->time_base;
235 dst->start_time = src->start_time;
236 dst->duration = src->duration;
237 dst->nb_frames = src->nb_frames;
238 dst->disposition = src->disposition;
239 dst->discard = src->discard;
240 dst->sample_aspect_ratio = src->sample_aspect_ratio;
241 dst->avg_frame_rate = src->avg_frame_rate;
242 dst->event_flags = src->event_flags;
243 dst->r_frame_rate = src->r_frame_rate;
244 dst->pts_wrap_bits = src->pts_wrap_bits;
245
246 av_dict_free(&dst->metadata);
247 ret = av_dict_copy(&dst->metadata, src->metadata, 0);
248 if (ret < 0)
249 return ret;
250
251 ret = avcodec_parameters_copy(dst->codecpar, src->codecpar);
252 if (ret < 0)
253 return ret;
254
255 av_packet_unref(&dst->attached_pic);
256 if (src->attached_pic.data) {
257 ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);
258 if (ret < 0)
259 return ret;
260 }
261
262 return 0;
263}
264
266{
267 AVStream *st;
268 int ret;
269
270 st = avformat_new_stream(dst_ctx, NULL);
271 if (!st)
272 return NULL;
273
274 ret = stream_params_copy(st, src);
275 if (ret < 0) {
276 ff_remove_stream(dst_ctx, st);
277 return NULL;
278 }
279
280 return st;
281}
282
284{
285 switch(type) {
286 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: return "IAMF Audio Element";
287 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix Presentation";
288 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
289 case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC (Split video and enhancement)";
290 case AV_STREAM_GROUP_PARAMS_TREF: return "Track Reference";
291 case AV_STREAM_GROUP_PARAMS_DOLBY_VISION: return "Dolby Vision (Split base and enhancement layer)";
292 case AV_STREAM_GROUP_PARAMS_GAIN_MAP: return "Gain Map (Split base rendition and gain map)";
293 }
294 return NULL;
295}
296
298{
299 AVProgram *program = NULL;
300 int ret;
301
302 av_log(ac, AV_LOG_TRACE, "new_program: id=0x%04x\n", id);
303
304 for (unsigned i = 0; i < ac->nb_programs; i++)
305 if (ac->programs[i]->id == id)
306 program = ac->programs[i];
307
308 if (!program) {
309 program = av_mallocz(sizeof(*program));
310 if (!program)
311 return NULL;
312 ret = av_dynarray_add_nofree(&ac->programs, &ac->nb_programs, program);
313 if (ret < 0) {
314 av_free(program);
315 return NULL;
316 }
317 program->discard = AVDISCARD_NONE;
318 program->pmt_version = -1;
319 program->id = id;
322 program->start_time =
323 program->end_time = AV_NOPTS_VALUE;
324 }
325 return program;
326}
327
328int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned idx)
329{
330 AVProgram *program = NULL;
331 void *tmp;
332
333 if (idx >= ac->nb_streams) {
334 av_log(ac, AV_LOG_ERROR, "stream index %d is greater than stream count %d\n", idx, ac->nb_streams);
335 return AVERROR(EINVAL);
336 }
337
338 for (unsigned i = 0; i < ac->nb_programs; i++) {
339 if (ac->programs[i]->id != progid)
340 continue;
341 program = ac->programs[i];
342 for (unsigned j = 0; j < program->nb_stream_indexes; j++)
343 if (program->stream_index[j] == idx)
344 return 0;
345
346 tmp = av_realloc_array(program->stream_index, program->nb_stream_indexes+1, sizeof(unsigned int));
347 if (!tmp)
348 return AVERROR(ENOMEM);
349 program->stream_index = tmp;
350 program->stream_index[program->nb_stream_indexes++] = idx;
351 return 0;
352 }
353
354 av_log(ac, AV_LOG_ERROR, "no program with id %d found\n", progid);
355 return AVERROR(EINVAL);
356}
357
358void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
359{
360 av_program_add_stream_index2(ac, progid, idx);
361 return;
362}
363
365{
366 const AVProgram *src_prog = NULL;
367 AVProgram *dst_prog = NULL;
368 int ret, idx = -1, match = -1;
369 int overwrite = flags & AVFMT_PROGCOPY_OVERWRITE;
370
372 return AVERROR(EINVAL);
374 match = 0;
376 match = 1;
377
378 for (unsigned i = 0; i < src->nb_programs; i++) {
379 if (src->programs[i]->id == progid) {
380 if (src_prog) {
381 av_log(dst, AV_LOG_ERROR, "multiple programs found in source with same id 0x%04x. Not copying.\n", progid);
382 return AVERROR(EINVAL);
383 } else {
384 src_prog = src->programs[i];
385 }
386 }
387 }
388
389 if (!src_prog) {
390 av_log(dst, AV_LOG_ERROR, "source program not found: id=0x%04x\n", progid);
391 return AVERROR(EINVAL);
392 }
393
394 for (unsigned i = 0; i < dst->nb_programs; i++) {
395 if (dst->programs[i]->id == progid) {
396 if (idx > -1) {
397 av_log(dst, AV_LOG_ERROR, "multiple programs found in target with same id 0x%04x. Not copying.\n", progid);
398 return AVERROR(EINVAL);
399 } else {
400 idx = i;
401 }
402 }
403 }
404
405 if (idx >= 0 && !overwrite)
406 return AVERROR(EEXIST);
407
408 av_log(dst, AV_LOG_TRACE, "%s program: id=0x%04x\n", idx >= 0 ? "overwriting" : "copying", progid);
409
410 if (idx >= 0) {
411 dst_prog = dst->programs[idx];
412 av_dict_free(&dst_prog->metadata);
413 av_freep(&dst_prog->stream_index);
414 dst_prog->nb_stream_indexes = 0;
415 } else {
416 dst_prog = av_new_program(dst, progid);
417 if (!dst_prog)
418 return AVERROR(ENOMEM);
419 }
420
421 /* public fields */
422 dst_prog->id = src_prog->id;
423 dst_prog->flags = src_prog->flags;
424 dst_prog->discard = src_prog->discard;
425 dst_prog->program_num = src_prog->program_num;
426 dst_prog->pmt_pid = src_prog->pmt_pid;
427 dst_prog->pcr_pid = src_prog->pcr_pid;
428 dst_prog->pmt_version = src_prog->pmt_version;
429
430 if (match == -1 && src->nb_streams) {
431 match = 0;
432 for (unsigned i = 0; i < src->nb_streams && !match; i++) {
433 int src_id = src->streams[i]->id;
434 if (!src_id) {
435 match = 1;
436 break;
437 }
438 for (unsigned j=i+1; j < src->nb_streams; j++) {
439 int sib_id = src->streams[j]->id;
440 if (src_id == sib_id) {
441 match = 1;
442 break;
443 }
444 }
445 }
446 }
447
448 for (unsigned i = 0; i < dst->nb_streams; i++) {
449 int dst_val = match ? i : dst->streams[i]->id;
450
451 for (unsigned j = 0; j < src_prog->nb_stream_indexes; j++) {
452 int src_val = match ? src_prog->stream_index[j] : src->streams[src_prog->stream_index[j]]->id;
453
454 if (dst_val == src_val) {
455 ret = av_program_add_stream_index2(dst, dst_prog->id, i);
456 if (ret < 0)
457 return ret;
458 }
459 }
460 }
461
462 ret = av_dict_copy(&dst_prog->metadata, src_prog->metadata, 0);
463 if (ret < 0)
464 return ret;
465
466 return 0;
467}
468
470{
471 for (unsigned i = 0; i < ic->nb_programs; i++) {
472 if (ic->programs[i] == last) {
473 last = NULL;
474 } else {
475 if (!last)
476 for (unsigned j = 0; j < ic->programs[i]->nb_stream_indexes; j++)
477 if (ic->programs[i]->stream_index[j] == s)
478 return ic->programs[i];
479 }
480 }
481 return NULL;
482}
483
485{
486 int best_stream = 0;
487 int best_score = INT_MIN;
488
489 if (s->nb_streams <= 0)
490 return -1;
491 for (unsigned i = 0; i < s->nb_streams; i++) {
492 const AVStream *const st = s->streams[i];
493 const FFStream *const sti = cffstream(st);
494 int score = 0;
497 score -= 400;
498 if (st->codecpar->width && st->codecpar->height)
499 score += 50;
500 score+= 25;
501 }
503 if (st->codecpar->sample_rate)
504 score += 50;
505 }
506 if (sti->codec_info_nb_frames)
507 score += 12;
508
509 if (st->discard != AVDISCARD_ALL)
510 score += 200;
511
512 if (score > best_score) {
513 best_score = score;
514 best_stream = i;
515 }
516 }
517 return best_stream;
518}
519
521 int wanted_stream_nb, int related_stream,
522 const AVCodec **decoder_ret, int flags)
523{
524 int nb_streams = ic->nb_streams;
525 int ret = AVERROR_STREAM_NOT_FOUND;
526 int best_count = -1, best_multiframe = -1, best_disposition = -1;
527 int count, multiframe, disposition;
528 int64_t best_bitrate = -1;
530 unsigned *program = NULL;
531 const AVCodec *decoder = NULL, *best_decoder = NULL;
532
533 if (related_stream >= 0 && wanted_stream_nb < 0) {
534 AVProgram *p = av_find_program_from_stream(ic, NULL, related_stream);
535 if (p) {
536 program = p->stream_index;
537 nb_streams = p->nb_stream_indexes;
538 }
539 }
540 for (unsigned i = 0; i < nb_streams; i++) {
541 int real_stream_index = program ? program[i] : i;
542 AVStream *st = ic->streams[real_stream_index];
543 AVCodecParameters *par = st->codecpar;
545 if (par->codec_type != type)
546 continue;
547 if (desc && (desc->props & AV_CODEC_PROP_ENHANCEMENT))
548 continue;
549 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
550 continue;
551 if (type == AVMEDIA_TYPE_AUDIO && !(par->ch_layout.nb_channels && par->sample_rate))
552 continue;
553 if (decoder_ret) {
554 decoder = ff_find_decoder(ic, st, par->codec_id);
555 if (!decoder) {
556 if (ret < 0)
558 continue;
559 }
560 }
563 count = ffstream(st)->codec_info_nb_frames;
564 bitrate = par->bit_rate;
565 multiframe = FFMIN(5, count);
566 if ((best_disposition > disposition) ||
567 (best_disposition == disposition && best_multiframe > multiframe) ||
568 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate > bitrate) ||
569 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count))
570 continue;
571 best_disposition = disposition;
572 best_count = count;
573 best_bitrate = bitrate;
574 best_multiframe = multiframe;
575 ret = real_stream_index;
576 best_decoder = decoder;
577 if (program && i == nb_streams - 1 && ret < 0) {
578 program = NULL;
580 /* no related stream found, try again with everything */
581 i = 0;
582 }
583 }
584 if (decoder_ret)
585 *decoder_ret = best_decoder;
586 return ret;
587}
588
589/**
590 * Matches a stream specifier (but ignores requested index).
591 *
592 * @param indexptr set to point to the requested stream index if there is one
593 *
594 * @return <0 on error
595 * 0 if st is NOT a matching stream
596 * >0 if st is a matching stream
597 */
599 const char *spec, const char **indexptr,
600 const AVStreamGroup **g, const AVProgram **p)
601{
602 int match = 1; /* Stores if the specifier matches so far. */
603 while (*spec) {
604 if (*spec <= '9' && *spec >= '0') { /* opt:index */
605 if (indexptr)
606 *indexptr = spec;
607 return match;
608 } else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
609 *spec == 't' || *spec == 'V') { /* opt:[vasdtV] */
610 enum AVMediaType type;
611 int nopic = 0;
612
613 switch (*spec++) {
614 case 'v': type = AVMEDIA_TYPE_VIDEO; break;
615 case 'a': type = AVMEDIA_TYPE_AUDIO; break;
616 case 's': type = AVMEDIA_TYPE_SUBTITLE; break;
617 case 'd': type = AVMEDIA_TYPE_DATA; break;
618 case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
619 case 'V': type = AVMEDIA_TYPE_VIDEO; nopic = 1; break;
620 default: av_assert0(0);
621 }
622 if (*spec && *spec++ != ':') /* If we are not at the end, then another specifier must follow. */
623 return AVERROR(EINVAL);
624
625 if (type != st->codecpar->codec_type)
626 match = 0;
627 if (nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC))
628 match = 0;
629 } else if (*spec == 'g' && *(spec + 1) == ':') {
630 int64_t group_idx = -1, group_id = -1;
631 int found = 0;
632 char *endptr;
633 spec += 2;
634 if (*spec == '#' || (*spec == 'i' && *(spec + 1) == ':')) {
635 spec += 1 + (*spec == 'i');
636 group_id = strtol(spec, &endptr, 0);
637 if (spec == endptr || (*endptr && *endptr++ != ':'))
638 return AVERROR(EINVAL);
639 spec = endptr;
640 } else {
641 group_idx = strtol(spec, &endptr, 0);
642 /* Disallow empty id and make sure that if we are not at the end, then another specifier must follow. */
643 if (spec == endptr || (*endptr && *endptr++ != ':'))
644 return AVERROR(EINVAL);
645 spec = endptr;
646 }
647 if (match) {
648 if (group_id > 0) {
649 for (unsigned i = 0; i < s->nb_stream_groups; i++) {
650 if (group_id == s->stream_groups[i]->id) {
651 group_idx = i;
652 break;
653 }
654 }
655 }
656 if (group_idx < 0 || group_idx >= s->nb_stream_groups)
657 return AVERROR(EINVAL);
658 for (unsigned j = 0; j < s->stream_groups[group_idx]->nb_entries; j++) {
659 if (s->stream_groups[group_idx]->entries[j]->type != AV_STREAM_GROUP_ENTRY_STREAM)
660 continue;
661 if (st->index == s->stream_groups[group_idx]->entries[j]->stream->index) {
662 found = 1;
663 if (g)
664 *g = s->stream_groups[group_idx];
665 break;
666 }
667 }
668 }
669 if (!found)
670 match = 0;
671 } else if (*spec == 'p' && *(spec + 1) == ':') {
672 int prog_id;
673 int found = 0;
674 char *endptr;
675 spec += 2;
676 prog_id = strtol(spec, &endptr, 0);
677 /* Disallow empty id and make sure that if we are not at the end, then another specifier must follow. */
678 if (spec == endptr || (*endptr && *endptr++ != ':'))
679 return AVERROR(EINVAL);
680 spec = endptr;
681 if (match) {
682 for (unsigned i = 0; i < s->nb_programs; i++) {
683 if (s->programs[i]->id != prog_id)
684 continue;
685
686 for (unsigned j = 0; j < s->programs[i]->nb_stream_indexes; j++) {
687 if (st->index == s->programs[i]->stream_index[j]) {
688 found = 1;
689 if (p)
690 *p = s->programs[i];
691 i = s->nb_programs;
692 break;
693 }
694 }
695 }
696 }
697 if (!found)
698 match = 0;
699 } else if (*spec == '#' ||
700 (*spec == 'i' && *(spec + 1) == ':')) {
701 int stream_id;
702 char *endptr;
703 spec += 1 + (*spec == 'i');
704 stream_id = strtol(spec, &endptr, 0);
705 if (spec == endptr || *endptr) /* Disallow empty id and make sure we are at the end. */
706 return AVERROR(EINVAL);
707 return match && (stream_id == st->id);
708 } else if (*spec == 'm' && *(spec + 1) == ':') {
709 const AVDictionaryEntry *tag;
710 int ret;
711
712 if (match) {
713 spec += 2;
714 const char *val = strchr(spec, ':');
715
716 char *key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
717 if (!key)
718 return AVERROR(ENOMEM);
719
720 tag = av_dict_get(st->metadata, key, NULL, 0);
721 if (tag) {
722 if (!val || !strcmp(tag->value, val + 1))
723 ret = 1;
724 else
725 ret = 0;
726 } else
727 ret = 0;
728
729 av_freep(&key);
730 }
731 return match && ret;
732 } else if (*spec == 'u' && *(spec + 1) == '\0') {
733 const AVCodecParameters *par = st->codecpar;
734 int val;
735 switch (par->codec_type) {
737 val = par->sample_rate && par->ch_layout.nb_channels;
738 if (par->format == AV_SAMPLE_FMT_NONE)
739 return 0;
740 break;
742 val = par->width && par->height;
743 if (par->format == AV_PIX_FMT_NONE)
744 return 0;
745 break;
747 val = 0;
748 break;
749 default:
750 val = 1;
751 break;
752 }
753 return match && (par->codec_id != AV_CODEC_ID_NONE && val != 0);
754 } else {
755 return AVERROR(EINVAL);
756 }
757 }
758
759 return match;
760}
761
763 const char *spec)
764{
765 int ret, index;
766 char *endptr;
767 const char *indexptr = NULL;
768 const AVStreamGroup *g = NULL;
769 const AVProgram *p = NULL;
770 int nb_streams;
771
772 ret = match_stream_specifier(s, st, spec, &indexptr, &g, &p);
773 if (ret < 0)
774 goto error;
775
776 if (!indexptr)
777 return ret;
778
779 index = strtol(indexptr, &endptr, 0);
780 if (*endptr) { /* We can't have anything after the requested index. */
781 ret = AVERROR(EINVAL);
782 goto error;
783 }
784
785 /* This is not really needed but saves us a loop for simple stream index specifiers. */
786 if (spec == indexptr)
787 return (index == st->index);
788
789 /* If we requested a matching stream index, we have to ensure st is that. */
790 nb_streams = g ? g->nb_entries : (p ? p->nb_stream_indexes : s->nb_streams);
791 for (int i = 0; i < nb_streams && index >= 0; i++) {
792 if (g && g->entries[i]->type != AV_STREAM_GROUP_ENTRY_STREAM)
793 continue;
794 unsigned idx = g ? g->entries[i]->stream->index : (p ? p->stream_index[i] : i);
795 const AVStream *candidate = s->streams[idx];
796 ret = match_stream_specifier(s, candidate, spec, NULL, NULL, NULL);
797 if (ret < 0)
798 goto error;
799 if (ret > 0 && index-- == 0 && st == candidate)
800 return 1;
801 }
802 return 0;
803
804error:
805 if (ret == AVERROR(EINVAL))
806 av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
807 return ret;
808}
809
811{
812 AVRational undef = {0, 1};
813 AVRational stream_sample_aspect_ratio = stream ? stream->sample_aspect_ratio : undef;
814 AVRational codec_sample_aspect_ratio = stream && stream->codecpar ? stream->codecpar->sample_aspect_ratio : undef;
815 AVRational frame_sample_aspect_ratio = frame ? frame->sample_aspect_ratio : codec_sample_aspect_ratio;
816
817 av_reduce(&stream_sample_aspect_ratio.num, &stream_sample_aspect_ratio.den,
818 stream_sample_aspect_ratio.num, stream_sample_aspect_ratio.den, INT_MAX);
819 if (stream_sample_aspect_ratio.num <= 0 || stream_sample_aspect_ratio.den <= 0)
820 stream_sample_aspect_ratio = undef;
821
822 av_reduce(&frame_sample_aspect_ratio.num, &frame_sample_aspect_ratio.den,
823 frame_sample_aspect_ratio.num, frame_sample_aspect_ratio.den, INT_MAX);
824 if (frame_sample_aspect_ratio.num <= 0 || frame_sample_aspect_ratio.den <= 0)
825 frame_sample_aspect_ratio = undef;
826
827 if (stream_sample_aspect_ratio.num)
828 return stream_sample_aspect_ratio;
829 else
830 return frame_sample_aspect_ratio;
831}
832
834{
835 AVRational fr = st->r_frame_rate;
837 AVRational avg_fr = st->avg_frame_rate;
838
839 if (avg_fr.num > 0 && avg_fr.den > 0 && fr.num > 0 && fr.den > 0 &&
840 av_q2d(avg_fr) < 70 && av_q2d(fr) > 210) {
841 fr = avg_fr;
842 }
843
844 if (desc && (desc->props & AV_CODEC_PROP_FIELDS)) {
845 const AVCodecContext *const avctx = ffstream(st)->avctx;
846 AVRational codec_fr = avctx->framerate;
847
848 if ( codec_fr.num > 0 && codec_fr.den > 0 &&
849 (fr.num == 0 || av_q2d(codec_fr) < av_q2d(fr)*0.7 && fabs(1.0 - av_q2d(av_div_q(avg_fr, fr))) > 0.1))
850 fr = codec_fr;
851 }
852
853 return fr;
854}
855
856void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,
857 unsigned int pts_num, unsigned int pts_den)
858{
859 FFStream *const sti = ffstream(st);
860 AVRational new_tb;
861 if (av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)) {
862 if (new_tb.num != pts_num)
864 "st:%d removing common factor %d from timebase\n",
865 st->index, pts_num / new_tb.num);
866 } else
868 "st:%d has too large timebase, reducing\n", st->index);
869
870 if (new_tb.num <= 0 || new_tb.den <= 0) {
872 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
873 new_tb.num, new_tb.den,
874 st->index);
875 return;
876 }
877 st->time_base = new_tb;
878 if (sti->avctx)
879 sti->avctx->pkt_timebase = new_tb;
880 st->pts_wrap_bits = pts_wrap_bits;
881}
882
884 enum AVCodecID codec_id)
885{
886 switch (st->codecpar->codec_type) {
888 if (s->video_codec) return s->video_codec;
889 break;
891 if (s->audio_codec) return s->audio_codec;
892 break;
894 if (s->subtitle_codec) return s->subtitle_codec;
895 break;
896 }
897
899}
900
902{
903#define OFF(field) offsetof(AVFormatContext, field)
904 static const unsigned offsets[] = {
905 OFF(codec_whitelist), OFF(format_whitelist),
906 OFF(protocol_whitelist), OFF(protocol_blacklist),
907 };
908#undef OFF
909 av_assert0(!dst->codec_whitelist &&
910 !dst->format_whitelist &&
911 !dst->protocol_whitelist &&
912 !dst->protocol_blacklist);
913 for (unsigned i = 0; i < FF_ARRAY_ELEMS(offsets); i++) {
914 const char *src_str = *(char *const*)((const char*)src + offsets[i]);
915
916 if (src_str) {
917 char *dst_str = av_strdup(src_str);
918 if (!dst_str) {
919 av_log(dst, AV_LOG_ERROR, "Failed to duplicate black/whitelist\n");
920 return AVERROR(ENOMEM);
921 }
922
923 *(char **)((char*)dst + offsets[i]) = dst_str;
924 }
925 }
926 if (src->recursion_limit <= 0) {
927 av_log(dst, AV_LOG_ERROR, "Too deep recursion\n");
928 return AVERROR_INVALIDDATA;
929 }
930 dst->recursion_limit = src->recursion_limit - 1;
931 return 0;
932}
933
935{
937 if (!d)
938 return 0;
939 if ((d->type == AVMEDIA_TYPE_VIDEO || d->type == AVMEDIA_TYPE_AUDIO) &&
941 return 0;
942 return 1;
943}
944
946{
947 av_assert0(url);
948 av_freep(&s->url);
949 s->url = url;
950}
951
953{
954 URLComponents uc;
955 av_assert0(url);
956 char proto[64];
957
958 int ret = ff_url_decompose(&uc, url, NULL);
959 if (ret < 0)
960 return ret;
961 av_strlcpy(proto, uc.scheme, FFMIN(sizeof(proto), uc.url_component_end_scheme - uc.scheme));
962
963 if (s->protocol_whitelist && av_match_list(proto, s->protocol_whitelist, ',') <= 0) {
964 av_log(s, AV_LOG_ERROR, "Protocol '%s' not on whitelist '%s'!\n", proto, s->protocol_whitelist);
965 return AVERROR(EINVAL);
966 }
967
968 if (s->protocol_blacklist && av_match_list(proto, s->protocol_blacklist, ',') > 0) {
969 av_log(s, AV_LOG_ERROR, "Protocol '%s' on blacklist '%s'!\n", proto, s->protocol_blacklist);
970 return AVERROR(EINVAL);
971 }
972
973 char *urldup = av_strdup(url);
974 if (!urldup)
975 return AVERROR(ENOMEM);
976
977 av_freep(&s->url);
978 s->url = urldup;
979 return 0;
980}
981
982
984{
985 int ret = 0;
986 if (*pb)
987 ret = s->io_close2(s, *pb);
988 *pb = NULL;
989 return ret;
990}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static double val(void *priv, double ch)
Definition aeval.c:77
static const char *const format[]
Definition af_aiir.c:445
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Libavcodec external API header.
void ff_flush_packet_queue(AVFormatContext *s)
Definition avformat.c:153
int ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition avformat.c:983
int ff_copy_whiteblacklists(AVFormatContext *dst, const AVFormatContext *src)
Copies the whilelists from one context to the other.
Definition avformat.c:901
int ff_is_intra_only(enum AVCodecID id)
Definition avformat.c:934
static int match_stream_specifier(const AVFormatContext *s, const AVStream *st, const char *spec, const char **indexptr, const AVStreamGroup **g, const AVProgram **p)
Matches a stream specifier (but ignores requested index).
Definition avformat.c:598
int ff_format_check_set_url(AVFormatContext *s, const char *url)
Set AVFormatContext url field to a av_strdup of the provided pointer.
Definition avformat.c:952
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:856
static int stream_params_copy(AVStream *dst, const AVStream *src)
Copy all stream parameters from source to destination stream, with the exception of the index field,...
Definition avformat.c:229
void ff_remove_stream(AVFormatContext *s, AVStream *st)
Remove a stream from its AVFormatContext and free it.
Definition avformat.c:136
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, const AVCodec **decoder_ret, int flags)
Definition avformat.c:520
void ff_free_stream(AVStream **pst)
Frees a stream without modifying the corresponding AVFormatContext.
Definition avformat.c:47
void ff_format_set_url(AVFormatContext *s, char *url)
Set AVFormatContext url field to the provided pointer.
Definition avformat.c:945
void ff_free_stream_group(AVStreamGroup **pstg)
Frees a stream group without modifying the corresponding AVFormatContext.
Definition avformat.c:80
int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned idx)
Definition avformat.c:328
void ff_remove_stream_group(AVFormatContext *s, AVStreamGroup *stg)
Remove a stream group from its AVFormatContext and free it.
Definition avformat.c:144
AVStream * ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src)
Create a new stream and copy to it all parameters from a source stream, with the exception of the ind...
Definition avformat.c:265
void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
Definition avformat.c:358
#define OFF(field)
const AVCodec * ff_find_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
Definition avformat.c:883
Main libavformat public API header.
@ AV_STREAM_GROUP_ENTRY_STREAM
Definition avformat.h:1172
#define AV_PTS_WRAP_IGNORE
Options for behavior on timestamp wrap detection.
Definition avformat.h:757
#define AV_DISPOSITION_HEARING_IMPAIRED
The stream is intended for hearing impaired audiences.
Definition avformat.h:678
AVStreamGroupParamsType
Definition avformat.h:1157
@ AV_STREAM_GROUP_PARAMS_DOLBY_VISION
Definition avformat.h:1164
@ AV_STREAM_GROUP_PARAMS_TREF
Definition avformat.h:1163
@ AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION
Definition avformat.h:1160
@ AV_STREAM_GROUP_PARAMS_TILE_GRID
Definition avformat.h:1161
@ AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT
Definition avformat.h:1159
@ AV_STREAM_GROUP_PARAMS_LCEVC
Definition avformat.h:1162
@ AV_STREAM_GROUP_PARAMS_GAIN_MAP
Definition avformat.h:1165
#define AV_DISPOSITION_VISUAL_IMPAIRED
The stream is intended for visually impaired audiences.
Definition avformat.h:682
#define AV_DISPOSITION_ATTACHED_PIC
The stream is stored in the file as an attached picture/"cover art" (e.g.
Definition avformat.h:694
#define AV_DISPOSITION_DEFAULT
The stream should be chosen by default among other streams of the same type, unless the user has expl...
Definition avformat.h:641
static av_always_inline FormatContextInternal * ff_fc_internal(AVFormatContext *s)
Buffered I/O operations.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Definition codec_par.c:107
void avcodec_parameters_free(AVCodecParameters **ppar)
Definition codec_par.c:67
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static __device__ float fabs(float a)
static AVFrame * frame
enum AVCodecID id
Definition dts2pts.c:607
const char * key
static unsigned int nb_streams
Definition ffprobe.c:390
reference-counted frame API
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:47
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
#define AV_CODEC_PROP_FIELDS
Video codec supports separate coding of fields in interlaced frames.
Definition codec_desc.h:97
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
Definition codec_desc.h:72
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition allcodecs.c:996
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
#define AV_CODEC_PROP_ENHANCEMENT
Video codec contains enhancement information meant to be applied to other existing frames,...
Definition codec_desc.h:105
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition options.c:168
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AVDISCARD_ALL
discard all
Definition defs.h:246
@ AVDISCARD_NONE
discard nothing
Definition defs.h:240
void av_packet_side_data_free(AVPacketSideData **psd, int *pnb_sd)
Convenience function to free all the side data stored in an array, and the array itself.
Definition packet.c:659
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:435
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition packet.c:443
void av_parser_close(AVCodecParserContext *s)
Definition parser.c:203
#define AVFMT_PROGCOPY_MATCH_BY_INDEX
match streams using stream index
Definition avformat.h:2266
const char * avformat_stream_group_name(enum AVStreamGroupParamsType type)
Definition avformat.c:283
AVProgram * av_new_program(AVFormatContext *ac, int id)
Definition avformat.c:297
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_program_copy(AVFormatContext *dst, const AVFormatContext *src, int progid, int flags)
Copy an AVProgram from one AVFormatContext to another.
Definition avformat.c:364
#define AVFMT_PROGCOPY_MATCH_BY_ID
match streams using stream id
Definition avformat.h:2265
#define AVFMT_PROGCOPY_OVERWRITE
overwrite pre-existing program having same ID
Definition avformat.h:2267
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition avformat.c:164
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
Definition avformat.c:469
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
Definition avformat.c:833
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
Definition avformat.c:762
int av_find_default_stream_index(AVFormatContext *s)
Definition avformat.c:484
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio.
Definition avformat.c:810
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition dict.c:233
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition dict.c:60
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition dict.c:247
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
Definition error.h:54
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
Definition error.h:67
#define AVERROR(e)
Definition error.h:45
void av_iamf_audio_element_free(AVIAMFAudioElement **paudio_element)
Free an AVIAMFAudioElement and all its contents.
Definition iamf.c:338
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **pmix_presentation)
Free an AVIAMFMixPresentation and all its contents.
Definition iamf.c:536
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition rational.c:35
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition rational.c:88
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition mem.c:419
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
Definition mem.c:390
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:318
AVMediaType
Definition avutil.h:198
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition avutil.h:204
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition avutil.h:202
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition avutil.h:199
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition avstring.c:85
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition avstring.c:443
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition opt.c:2029
int index
Definition gxfenc.c:90
static const int offsets[]
Definition hevc_pel.c:34
uint32_t type
Definition jpegmpfenc.c:80
static const chunk_decoder decoder[8]
Definition dfa.c:331
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:365
static av_always_inline const FFStream * cffstream(const AVStream *st)
Definition internal.h:370
void ff_curl_loop_free(struct CurlLoop **loop)
Release a libcurl event loop and set *loop to NULL.
Definition libcurl.c:1081
void ff_packet_list_free(PacketList *list)
Wipe the list and unref all the packets in it.
Immersive Audio Model and Formats API header.
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition internal.h:71
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition internal.h:72
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
uint32_t tag
Definition movenc.c:2128
static const FFOutputFormat * ffofmt(const AVOutputFormat *fmt)
Definition mux.h:167
#define av_strdup(s)
Definition ops_static.c:55
AVOptions.
pixel format definitions
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
#define FF_ARRAY_ELEMS(a)
int nb_channels
Number of channels in this layout.
main external API structure.
Definition avcodec.h:443
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
Definition avcodec.h:554
AVRational framerate
Definition avcodec.h:563
This struct describes the properties of a single codec described by an AVCodecID.
Definition codec_desc.h:38
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition codec_desc.h:54
enum AVMediaType type
Definition codec_desc.h:40
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
int height
The height of the video frame in pixels.
Definition codec_par.h:150
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
AVRational sample_aspect_ratio
The aspect ratio (width/height) which a single pixel should have when displayed.
Definition codec_par.h:161
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
AVCodec.
Definition codec.h:175
Format I/O context.
Definition avformat.h:1400
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition avformat.h:1456
AVProgram ** programs
Definition avformat.h:1614
unsigned int nb_programs
Definition avformat.h:1613
AVStream ** streams
A list of all streams in the file.
Definition avformat.h:1468
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
Bytestream IO Context.
Definition avio.h:160
uint8_t * data
Definition packet.h:610
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition avformat.h:475
New fields can be added to the end with minor version bumps.
Definition avformat.h:1324
int pmt_pid
Definition avformat.h:1333
unsigned int nb_stream_indexes
Definition avformat.h:1329
int64_t start_time
Definition avformat.h:1344
int program_num
Definition avformat.h:1332
int64_t end_time
Definition avformat.h:1345
unsigned int * stream_index
Definition avformat.h:1328
int pcr_pid
Definition avformat.h:1334
int64_t pts_wrap_reference
reference dts for wrap detection
Definition avformat.h:1347
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition avformat.h:1327
int pts_wrap_behavior
behavior on wrap detection
Definition avformat.h:1348
int pmt_version
Definition avformat.h:1335
AVDictionary * metadata
Definition avformat.h:1330
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
struct AVStreamGroupTileGrid::@036353327352337314037001273105074056331305251354 * offsets
An nb_tiles sized array of offsets in pixels from the topleft edge of the canvas, indicating where ea...
unsigned int nb_entries
Number of elements in AVStreamGroup.entries.
Definition avformat.h:1285
enum AVStreamGroupParamsType type
Group type.
Definition avformat.h:1211
struct AVIAMFMixPresentation * iamf_mix_presentation
Definition avformat.h:1218
AVStreamGroupEntry ** entries
A list of streams or child groups in the group.
Definition avformat.h:1298
struct AVStreamGroupTileGrid * tile_grid
Definition avformat.h:1219
void * priv_data
Definition avformat.h:1190
struct AVStreamGroupTREF * tref
Definition avformat.h:1228
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition avformat.h:1311
AVDictionary * metadata
Metadata that applies to the whole group.
Definition avformat.h:1239
union AVStreamGroup::@313244315204024013007202273061153315146016101155 params
Group type-specific parameters.
struct AVIAMFAudioElement * iamf_audio_element
Definition avformat.h:1217
AVPacketSideData * coded_side_data
Additional data associated with the group.
Definition avformat.h:1306
struct AVStreamGroupLayeredVideo * layered_video
Definition avformat.h:1220
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition avformat.h:846
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition avformat.h:839
AVDictionary * metadata
Definition avformat.h:848
void * priv_data
Definition avformat.h:793
int id
Format-specific stream ID.
Definition avformat.h:780
int index
stream index in AVFormatContext
Definition avformat.h:774
int pts_wrap_bits
Number of bits in timestamps.
Definition avformat.h:911
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
Definition avformat.h:866
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:857
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition avformat.h:807
AVRational r_frame_rate
Real base framerate of the stream.
Definition avformat.h:902
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
Definition avformat.h:837
PacketList packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
Definition internal.h:86
AVDictionary * id3v2_meta
ID3v2 tag useful for MP3 demuxing.
Definition internal.h:118
struct CurlLoop * curl_loop
Shared libcurl event loop, created on demand on the first use.
Definition internal.h:127
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
Definition internal.h:104
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
Definition internal.h:111
void(* deinit)(AVFormatContext *)
Deinitialize format.
Definition mux.h:154
double(* duration_error)[2][MAX_STD_TIMEBASES]
Definition demux.h:197
struct AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
Definition internal.h:163
struct AVBSFContext * bsfc
bitstream filter to run on stream
Definition internal.h:153
AVProbeData probe_data
Definition internal.h:305
struct AVBSFContext * bsf
Definition internal.h:173
const struct AVCodecDescriptor * codec_desc
Definition internal.h:362
struct AVCodecParserContext * parser
Definition internal.h:322
struct FFStreamInfo * info
Stream information used internally by avformat_find_stream_info()
Definition internal.h:189
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
Definition internal.h:337
struct FFStream::@143263315346311247247365102337045232073206113210 extract_extradata
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition internal.h:191
int codec_info_nb_frames
Number of frames that have been demuxed during avformat_find_stream_info()
Definition internal.h:342
PacketList parse_queue
Packets split by the parser get queued here.
PacketList raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
int raw_packet_buffer_size
Sum of the size of packets in raw_packet_buffer, in bytes.
int initialized
Whether or not avformat_init_output has already been called.
const char * scheme
possibly including lavf-specific options
Definition url.h:364
#define av_free(p)
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
static uint8_t tmp[40]
Definition aes_ctr.c:52
int64_t bitrate
Definition av1_levels.c:47
#define src
Definition vp8dsp.c:248
int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
Parse an URL to find the components.
Definition url.c:91
unbuffered private I/O API
enum AVCodecID codec_id
const char * g
Definition vf_curves.c:128