75 #define LICENSE_PREFIX "libavformat license: "
89 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
107 timestamp < st->internal->pts_wrap_reference)
116 #if FF_API_FORMAT_GET_SET
118 #if FF_API_LAVF_FFSERVER
130 #if FF_API_OLD_OPEN_CALLBACKS
153 s->internal->inject_global_side_data = 1;
154 for (
i = 0;
i <
s->nb_streams;
i++) {
166 dst-> codec_whitelist =
av_strdup(
src->codec_whitelist);
170 if ( (
src-> codec_whitelist && !dst-> codec_whitelist)
171 || (
src-> format_whitelist && !dst-> format_whitelist)
182 #if FF_API_LAVF_AVCTX
191 if (
s->video_codec)
return s->video_codec;
194 if (
s->audio_codec)
return s->audio_codec;
197 if (
s->subtitle_codec)
return s->subtitle_codec;
208 #if CONFIG_H264_DECODER
234 #if FF_API_FORMAT_GET_SET
237 return s->probe_score;
242 #define SANE_CHUNK_SIZE (50000000)
246 if (
s->maxsize>= 0) {
249 if (remaining <
size) {
251 if (!
s->maxsize ||
s->maxsize<newsize)
252 s->maxsize = newsize - !newsize;
253 if (
pos >
s->maxsize &&
s->maxsize >= 0)
256 remaining =
s->maxsize -
pos;
259 if (
s->maxsize >= 0 && remaining < size && size > 1) {
261 "Truncating packet of size %d to %"PRId64
"\n",
262 size, remaining + !remaining);
263 size = remaining + !remaining;
295 if (ret != read_size) {
312 #if FF_API_INIT_PACKET
343 static const struct {
371 "Probe with size=%d, packets=%d detected %s with score=%d\n",
374 for (
i = 0; fmt_id_type[
i].name;
i++) {
375 if (!strcmp(fmt->
name, fmt_id_type[
i].name)) {
385 #if FF_API_LAVF_AVCTX
401 #if FF_API_DEMUXER_OPEN
434 s, 0,
s->format_probesize);
437 "will be ignored with AVFMT_NOFILE format.\n");
451 s, 0,
s->format_probesize);
457 for (
i = 0;
i <
s->nb_streams;
i++)
460 if (
s->streams[
i]->attached_pic.size <= 0) {
462 "Attached picture on stream %d has invalid size, "
468 &
s->internal->raw_packet_buffer_end,
469 &
s->streams[
i]->attached_pic,
480 for (
i = 0;
i <
s->nb_streams;
i++) {
497 #if FF_API_LAVF_AVCTX
523 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
538 if (!(
s->url =
av_strdup(filename ? filename :
""))) {
543 #if FF_API_FORMAT_FILENAME
545 av_strlcpy(
s->filename, filename ? filename :
"",
sizeof(
s->filename));
550 s->probe_score = ret;
552 if (!
s->protocol_whitelist &&
s->pb &&
s->pb->protocol_whitelist) {
553 s->protocol_whitelist =
av_strdup(
s->pb->protocol_whitelist);
554 if (!
s->protocol_whitelist) {
560 if (!
s->protocol_blacklist &&
s->pb &&
s->pb->protocol_blacklist) {
561 s->protocol_blacklist =
av_strdup(
s->pb->protocol_blacklist);
562 if (!
s->protocol_blacklist) {
568 if (
s->format_whitelist &&
av_match_list(
s->iformat->name,
s->format_whitelist,
',') <= 0) {
587 if (
s->iformat->priv_data_size > 0) {
588 if (!(
s->priv_data =
av_mallocz(
s->iformat->priv_data_size))) {
592 if (
s->iformat->priv_class) {
593 *(
const AVClass **)
s->priv_data =
s->iformat->priv_class;
604 #if FF_API_DEMUXER_OPEN
607 if (
s->iformat->read_header)
609 if ((ret =
s->iformat->read_header(
s)) < 0)
613 s->metadata =
s->internal->id3v2_meta;
614 s->internal->id3v2_meta =
NULL;
615 }
else if (
s->internal->id3v2_meta) {
620 if (id3v2_extra_meta) {
621 if (!strcmp(
s->iformat->name,
"mp3") || !strcmp(
s->iformat->name,
"aac") ||
622 !strcmp(
s->iformat->name,
"tta") || !strcmp(
s->iformat->name,
"wav")) {
637 #if FF_API_DEMUXER_OPEN
640 if (
s->pb && !
s->internal->data_offset)
648 for (
i = 0;
i <
s->nb_streams;
i++)
649 s->streams[
i]->internal->orig_codec_id =
s->streams[
i]->codecpar->codec_id;
659 if (
s->iformat->read_close)
660 s->iformat->read_close(
s);
677 if (
s->video_codec_id)
681 if (
s->audio_codec_id)
685 if (
s->subtitle_codec_id)
689 if (
s->data_codec_id)
707 "Failed to reallocate probe buffer for stream %d\n",
720 "nothing to probe for stream %d\n", st->
index);
724 end=
s->internal->raw_packet_buffer_remaining_size <= 0
748 int i, pts_wrap_behavior;
767 if (!first_program) {
769 if (
s->streams[default_stream_index]->internal->pts_wrap_reference ==
AV_NOPTS_VALUE) {
770 for (
i = 0;
i <
s->nb_streams;
i++) {
773 s->streams[
i]->internal->pts_wrap_reference = pts_wrap_reference;
774 s->streams[
i]->internal->pts_wrap_behavior = pts_wrap_behavior;
794 program = first_program;
798 s->streams[program->
stream_index[
i]]->internal->pts_wrap_reference = pts_wrap_reference;
799 s->streams[program->
stream_index[
i]]->internal->pts_wrap_behavior = pts_wrap_behavior;
816 #if FF_API_INIT_PACKET
832 if (
s->internal->raw_packet_buffer_remaining_size <= 0)
837 &
s->internal->raw_packet_buffer_end,
pkt);
838 s->internal->raw_packet_buffer_remaining_size +=
pkt->
size;
843 ret =
s->iformat->read_packet(
s,
pkt);
852 if (!pktl || ret ==
AVERROR(EAGAIN))
854 for (
i = 0;
i <
s->nb_streams;
i++) {
872 "Packet corrupt (stream = %d, dts = %s)",
883 "Invalid stream index.\n");
903 if (
s->use_wallclock_as_timestamps)
910 &
s->internal->raw_packet_buffer_end,
916 pkt1 = &
s->internal->raw_packet_buffer_end->pkt;
917 s->internal->raw_packet_buffer_remaining_size -= pkt1->
size;
950 #if FF_API_LAVF_AVCTX
967 }
else if (codec_framerate.
den * 1000LL > codec_framerate.
num) {
1022 #if CONFIG_H264_DECODER
1039 if (pktl ==
s->internal->packet_buffer_end)
1040 return s->internal->parse_queue;
1053 int64_t best_score = INT64_MAX;
1054 for (
i = 0;
i<delay;
i++) {
1057 if (score < best_score) {
1059 dts = pts_buffer[
i];
1064 for (
i = 0;
i<delay;
i++) {
1081 dts = pts_buffer[0];
1093 AVStream *st =
s->streams[stream_index];
1102 for (; pkt_buffer; pkt_buffer =
get_next_pkt(
s, st, pkt_buffer)) {
1107 pts_buffer[0] = pkt_buffer->
pkt.
pts;
1108 for (
i = 0; i<delay && pts_buffer[i] > pts_buffer[
i + 1];
i++)
1119 AVStream *st =
s->streams[stream_index];
1120 PacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1140 for (pktl_it = pktl; pktl_it; pktl_it =
get_next_pkt(
s, st, pktl_it)) {
1172 PacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1190 av_log(
s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
1198 pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1230 int num, den, presentation_delayed, delay,
i;
1245 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1271 presentation_delayed = 0;
1277 presentation_delayed = 1;
1295 if ( strcmp(
s->iformat->name,
"mov,mp4,m4a,3gp,3g2,mj2")
1296 && strcmp(
s->iformat->name,
"flv"))
1312 if (
pkt->
duration > 0 && (
s->internal->packet_buffer ||
s->internal->parse_queue))
1330 presentation_delayed = 1;
1334 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1340 if ((delay == 0 || (delay == 1 && pc)) &&
1342 if (presentation_delayed) {
1360 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1361 next_dts != next_pts &&
1409 #if FF_API_CONVERGENCE_DURATION
1424 int stream_index,
int flush)
1426 AVPacket *out_pkt =
s->internal->parse_pkt;
1427 AVStream *st =
s->streams[stream_index];
1430 int ret = 0, got_output =
flush;
1439 while (
size > 0 || (
flush && got_output)) {
1455 got_output = !!out_pkt->
size;
1466 if (!out_pkt->
buf) {
1489 (
AVRational) { 1, st->internal->avctx->sample_rate },
1515 &
s->internal->parse_queue_end,
1541 int ret,
i, got_packet = 0;
1544 while (!got_packet && !
s->internal->parse_queue) {
1553 for (
i = 0;
i <
s->nb_streams;
i++) {
1570 av_log(
s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1587 #if FF_API_LAVF_AVCTX
1605 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1613 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1623 "%s, packets or times may be invalid.\n",
1665 if (!got_packet &&
s->internal->parse_queue)
1670 int discard_padding = 0;
1677 sample < st->internal->last_discard_sample)
1686 AV_WL32(p + 4, discard_padding);
1706 memcpy(dst_data, src_sd->
data, src_sd->
size);
1720 #if FF_API_LAVF_AVCTX
1726 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1727 "size=%d, duration=%"PRId64
", flags=%d\n",
1749 ret =
s->internal->packet_buffer
1751 &
s->internal->packet_buffer_end,
pkt)
1765 int wrap_bits =
s->streams[next_pkt->
stream_index]->pts_wrap_bits;
1779 last_dts = pktl->
pkt.
dts;
1792 pktl =
s->internal->packet_buffer;
1800 &
s->internal->packet_buffer_end,
pkt);
1807 if (pktl && ret !=
AVERROR(EAGAIN)) {
1815 &
s->internal->packet_buffer_end,
1858 int best_stream = 0;
1859 int best_score = INT_MIN;
1861 if (
s->nb_streams <= 0)
1863 for (
i = 0;
i <
s->nb_streams;
i++) {
1883 if (score > best_score) {
1900 for (
i = 0;
i <
s->nb_streams;
i++) {
1920 if (
s->internal->inject_global_side_data)
1931 for (
i = 0;
i <
s->nb_streams;
i++) {
1943 AVStream *st =
s->streams[stream_index];
1944 unsigned int max_entries =
s->max_index_size /
sizeof(
AVIndexEntry);
1955 int *nb_index_entries,
1956 unsigned int *index_entries_allocated_size,
1963 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1969 if (size < 0 || size > 0x3FFFFFFF)
1976 index_entries_allocated_size,
1977 (*nb_index_entries + 1) *
1982 *index_entries = entries;
1988 index = (*nb_index_entries)++;
1989 ie = &entries[
index];
1992 ie = &entries[
index];
1996 memmove(entries +
index + 1, entries +
index,
1998 (*nb_index_entries)++;
1999 }
else if (ie->
pos ==
pos && distance < ie->min_distance)
2032 if (
b && entries[
b - 1].timestamp < wanted_timestamp)
2041 if (m ==
b && entries[m].timestamp >= wanted_timestamp) {
2048 if (timestamp >= wanted_timestamp)
2050 if (timestamp <= wanted_timestamp)
2056 while (m >= 0 && m < nb_entries &&
2060 if (m == nb_entries)
2077 "Protocol name not provided, cannot determine if input is local or "
2078 "a network protocol, buffers and access patterns cannot be configured "
2079 "optimally without knowing the protocol\n");
2082 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
2085 for (ist1 = 0; ist1 <
s->nb_streams; ist1++) {
2087 for (ist2 = 0; ist2 <
s->nb_streams; ist2++) {
2102 if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
2113 if (
s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) {
2122 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, pos_delta/2);
2125 if (skip < (1<<23)) {
2126 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, skip);
2133 wanted_timestamp,
flags);
2139 int64_t ts = read_timestamp(
s, stream_index, ppos, pos_limit);
2140 if (stream_index >= 0)
2149 int64_t pos_min = 0, pos_max = 0,
pos, pos_limit;
2155 if (stream_index < 0)
2164 st =
s->streams[stream_index];
2194 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
2219 int64_t pos_max = filesize - 1;
2222 pos_max =
FFMAX(0, (pos_max) - step);
2224 &pos_max, limit, read_timestamp);
2231 int64_t tmp_pos = pos_max + 1;
2233 &tmp_pos, INT64_MAX, read_timestamp);
2239 if (tmp_pos >= filesize)
2266 pos_min =
s->internal->data_offset;
2272 if (ts_min >= target_ts) {
2278 if ((ret =
ff_find_last_ts(
s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
2280 pos_limit = pos_max;
2283 if (ts_max <= target_ts) {
2291 while (pos_min < pos_limit) {
2293 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2297 if (no_change == 0) {
2298 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2302 pos_min - approximate_keyframe_distance;
2303 }
else if (no_change == 1) {
2305 pos = (pos_min + pos_limit) >> 1;
2313 else if (
pos > pos_limit)
2324 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2325 pos_min,
pos, pos_max,
2327 pos_limit, start_pos, no_change);
2332 if (target_ts <= ts) {
2333 pos_limit = start_pos - 1;
2337 if (target_ts >= ts) {
2362 pos_min =
s->internal->data_offset;
2367 else if (
pos > pos_max)
2372 s->io_repositioned = 1;
2385 st =
s->streams[stream_index];
2389 if (index < 0 && st->nb_index_entries &&
2390 timestamp < st->index_entries[0].timestamp)
2393 if (index < 0 || index == st->nb_index_entries - 1) {
2404 if ((ret =
avio_seek(
s->pb,
s->internal->data_offset, SEEK_SET)) < 0)
2412 }
while (read_status ==
AVERROR(EAGAIN));
2413 if (read_status < 0)
2421 av_log(
s,
AV_LOG_ERROR,
"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
2434 if (
s->iformat->read_seek)
2435 if (
s->iformat->read_seek(
s, stream_index, timestamp,
flags) >= 0)
2458 if (stream_index < 0) {
2460 if (stream_index < 0)
2463 st =
s->streams[stream_index];
2470 if (
s->iformat->read_seek) {
2472 ret =
s->iformat->read_seek(
s, stream_index, timestamp,
flags);
2478 if (
s->iformat->read_timestamp &&
2494 if (
s->iformat->read_seek2 && !
s->iformat->read_seek) {
2495 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2515 if (min_ts > ts || max_ts < ts)
2517 if (stream_index < -1 || stream_index >= (
int)
s->nb_streams)
2524 if (
s->iformat->read_seek2) {
2528 if (stream_index == -1 &&
s->nb_streams == 1) {
2540 ret =
s->iformat->read_seek2(
s, stream_index, min_ts,
2548 if (
s->iformat->read_timestamp) {
2554 if (
s->iformat->read_seek || 1) {
2557 if (ret<0 && ts != min_ts && max_ts != ts) {
2604 int64_t start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
2610 start_time_text = INT64_MAX;
2611 end_time = INT64_MIN;
2612 end_time_text = INT64_MIN;
2614 duration_text = INT64_MIN;
2624 start_time_text =
FFMIN(start_time_text, start_time1);
2630 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
2631 end_time1 += start_time1;
2633 end_time_text =
FFMAX(end_time_text, end_time1);
2635 end_time =
FFMAX(end_time, end_time1);
2648 duration_text =
FFMAX(duration_text, duration1);
2658 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time <
AV_TIME_BASE))
2659 end_time = end_time_text;
2660 else if (end_time < end_time_text)
2670 if (end_time != INT64_MIN) {
2718 int i, show_warning = 0;
2765 "Estimating duration from bitrate, this may be inaccurate\n");
2768 #define DURATION_MAX_READ_SIZE 250000LL
2769 #define DURATION_MAX_RETRY 6
2776 int num, den, read_size,
i, ret;
2777 int found_duration = 0;
2791 "start time for stream %d is not set in estimate_timings_from_pts\n",
i);
2800 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
2801 goto skip_duration_calc;
2809 is_end = found_duration;
2822 }
while (ret ==
AVERROR(EAGAIN));
2925 file_size =
FFMAX(0, file_size);
2955 if (st->time_base.den)
2961 "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64
" kb/s\n",
2973 #define FAIL(errmsg) do { \
2975 *errmsg_ptr = errmsg; \
2981 FAIL(
"unknown codec");
2985 FAIL(
"unspecified frame size");
2988 FAIL(
"unspecified sample format");
2990 FAIL(
"unspecified sample rate");
2992 FAIL(
"unspecified number of channels");
2994 FAIL(
"no decodable DTS frames");
2998 FAIL(
"unspecified size");
3000 FAIL(
"unspecified pixel format");
3003 FAIL(
"no frame in rv30/40 and no sar");
3007 FAIL(
"unspecified size");
3022 int got_picture = 1, ret = 0;
3026 int do_skip_frame = 0;
3052 if (
s->codec_whitelist)
3096 &got_picture, &
pkt);
3109 if (!
pkt.
data && !got_picture)
3113 if (do_skip_frame) {
3145 if (bps <= 0 || bps > 64)
3160 if (sflags & (1 << (
bps - 1))) {
3204 for (
i = 0; tags && tags[
i];
i++) {
3207 if (codec_tags->
id ==
id) {
3220 for (
i = 0; tags && tags[
i];
i++) {
3235 return (ch1 > ch2) - (ch1 < ch2);
3247 if (
s->duration > 0 &&
s->start_time < INT64_MAX -
s->duration)
3248 max_time =
s->duration +
3251 for (
i = 0;
i <
s->nb_chapters;
i++)
3252 timetable[
i] =
s->chapters[
i];
3255 for (
i = 0;
i <
s->nb_chapters;
i++)
3262 if (
i + 1 <
s->nb_chapters) {
3266 if (next_start > ch->
start && next_start < end)
3269 ch->
end = (end == INT64_MAX || end < ch->
start) ? ch->
start : end;
3278 return (
i + 1) * 1001;
3282 return (
i + 31) * 1001 * 12;
3286 return ((
const int[]) { 80, 120, 240})[
i] * 1001 * 12;
3290 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[
i] * 1000 * 12;
3301 if (
c->time_base.den >= 101LL *
c->time_base.num ||
3302 c->time_base.den < 5LL *
c->time_base.num ||
3354 && ts - (uint64_t)last < INT64_MAX) {
3369 for (j= 0; j<2; j++) {
3371 double error= sdts - ticks + j*0.5;
3390 if (error0 > 0.04 && error1 > 0.04) {
3426 double best_error= 0.01;
3441 for (k= 0; k<2; k++) {
3446 if (error < best_error && best_error> 0.000000001) {
3455 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3577 side_data->
size = 0;
3597 memcpy(dst_data, sd_src->
data, sd_src->
size);
3604 int i, count = 0, ret = 0, j;
3614 int64_t max_stream_analyze_duration;
3615 int64_t max_subtitle_analyze_duration;
3617 int eof_reached = 0;
3620 flush_codecs = probesize > 0;
3624 max_stream_analyze_duration = max_analyze_duration;
3625 max_subtitle_analyze_duration = max_analyze_duration;
3626 if (!max_analyze_duration) {
3627 max_stream_analyze_duration =
3637 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
3655 #if FF_API_LAVF_AVCTX
3675 "%s, packets or times may be invalid.\n",
3685 goto find_stream_info_err;
3704 && codec && !avctx->
codec) {
3707 "Failed to open codec in %s\n",__FUNCTION__);
3712 if (codec && !avctx->
codec)
3715 "Failed to open codec in %s\n",__FUNCTION__);
3722 #if FF_API_R_FRAME_RATE
3732 int analyzed_all_streams;
3741 int fps_analyze_framecount = 20;
3751 fps_analyze_framecount *= 2;
3753 fps_analyze_framecount = 0;
3757 fps_analyze_framecount = 0;
3764 if (count < fps_analyze_framecount)
3783 analyzed_all_streams = 0;
3784 if (!missing_streams || !*missing_streams)
3786 analyzed_all_streams = 1;
3798 if (read_size >= probesize) {
3801 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3808 "Stream #%d: not enough frames to estimate rate; "
3809 "consider increasing probesize\n",
i);
3830 goto unref_then_goto_end;
3845 goto unref_then_goto_end;
3854 "Non-increasing DTS in stream %d: packet %d with DTS "
3855 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3871 "DTS discontinuity in stream %d: packet %d with DTS "
3872 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3905 if (analyzed_all_streams) limit = max_analyze_duration;
3907 else limit = max_stream_analyze_duration;
3910 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3928 #if FF_API_R_FRAME_RATE
3937 goto unref_then_goto_end;
3961 for (stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
3962 st = ic->
streams[stream_index];
3966 if (codec && !avctx->
codec) {
3972 "Failed to open codec in %s\n",__FUNCTION__);
4004 "decoding for stream %d failed\n", st->
index);
4027 double best_error = 0.01;
4045 if (
error < best_error) {
4047 best_fps = std_fps.
num;
4053 if (
error < best_error) {
4055 best_fps = std_fps.
num;
4061 best_fps, 12 * 1001, INT_MAX);
4123 goto find_stream_info_err;
4129 "Could not find codec parameters for stream %d (%s): %s\n"
4130 "Consider increasing the value for the 'analyzeduration' (%"PRId64
") and 'probesize' (%"PRId64
") options\n",
4139 goto find_stream_info_err;
4148 goto find_stream_info_err;
4151 goto find_stream_info_err;
4154 #if FF_API_LAVF_AVCTX
4158 goto find_stream_info_err;
4177 goto find_stream_info_err;
4193 find_stream_info_err:
4204 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
4208 unref_then_goto_end:
4210 goto find_stream_info_err;
4231 int wanted_stream_nb,
int related_stream,
4236 int best_count = -1, best_multiframe = -1, best_disposition = -1;
4237 int count, multiframe, disposition;
4240 unsigned *program =
NULL;
4243 if (related_stream >= 0 && wanted_stream_nb < 0) {
4251 int real_stream_index = program ? program[
i] :
i;
4256 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
4272 multiframe =
FFMIN(5, count);
4273 if ((best_disposition > disposition) ||
4274 (best_disposition == disposition && best_multiframe > multiframe) ||
4275 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate >
bitrate) ||
4276 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate ==
bitrate && best_count >= count))
4278 best_disposition = disposition;
4281 best_multiframe = multiframe;
4282 ret = real_stream_index;
4292 *decoder_ret = (
AVCodec*)best_decoder;
4300 if (
s->iformat->read_play)
4301 return s->iformat->read_play(
s);
4309 if (
s->iformat->read_pause)
4310 return s->iformat->read_pause(
s);
4344 if (
src->nb_side_data) {
4351 for (
i = 0;
i <
src->nb_side_data;
i++) {
4353 src->side_data[
i].size);
4362 #if FF_API_LAVF_FFSERVER
4365 if (
src->recommended_encoder_configuration) {
4366 const char *conf_str =
src->recommended_encoder_configuration;
4413 #if FF_API_LAVF_AVCTX
4419 #if FF_API_LAVF_FFSERVER
4443 if (
s->oformat &&
s->oformat->deinit &&
s->internal->initialized)
4444 s->oformat->deinit(
s);
4447 if (
s->iformat &&
s->iformat->priv_class &&
s->priv_data)
4449 if (
s->oformat &&
s->oformat->priv_class &&
s->priv_data)
4452 for (
i = 0;
i <
s->nb_streams;
i++)
4456 for (
i = 0;
i <
s->nb_programs;
i++) {
4465 while (
s->nb_chapters--) {
4492 if ((
s->iformat && strcmp(
s->iformat->name,
"image2") &&
s->iformat->flags &
AVFMT_NOFILE) ||
4499 if (
s->iformat->read_close)
4500 s->iformat->read_close(
s);
4515 if (
s->nb_streams >=
FFMIN(
s->max_streams, INT_MAX/
sizeof(*streams))) {
4516 if (
s->max_streams < INT_MAX/
sizeof(*streams))
4517 av_log(
s,
AV_LOG_ERROR,
"Number of streams exceeds max_streams parameter (%d), see the documentation if you wish to increase it\n",
s->max_streams);
4523 s->streams = streams;
4529 #if FF_API_LAVF_AVCTX
4557 #if FF_API_LAVF_AVCTX
4575 st->
index =
s->nb_streams;
4590 #if FF_API_R_FRAME_RATE
4600 s->streams[
s->nb_streams++] = st;
4638 #if FF_API_CHAPTER_ID_INT
4649 av_log(
s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
4653 if (!
s->nb_chapters) {
4654 s->internal->chapter_ids_monotonic = 1;
4655 }
else if (!
s->internal->chapter_ids_monotonic ||
s->chapters[
s->nb_chapters-1]->id >=
id) {
4656 s->internal->chapter_ids_monotonic = 0;
4657 for (
i = 0;
i <
s->nb_chapters;
i++)
4658 if (
s->chapters[
i]->id ==
id)
4659 chapter =
s->chapters[
i];
4675 chapter->
start = start;
4716 uint64_t ntp_ts, frac_part, sec;
4720 sec = ntp_time_us / 1000000;
4721 usec = ntp_time_us % 1000000;
4724 frac_part = usec * 0xFFFFFFFFULL;
4725 frac_part /= 1000000;
4727 if (sec > 0xFFFFFFFFULL)
4731 ntp_ts |= frac_part;
4739 char *q, buf1[20],
c;
4740 int nd,
len, percentd_found;
4753 if (nd >= INT_MAX / 10 - 255)
4755 nd = nd * 10 + *p++ -
'0';
4769 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
4771 if ((q - buf +
len) > buf_size - 1)
4773 memcpy(q, buf1,
len);
4781 if ((q - buf) < buf_size - 1)
4785 if (!percentd_found)
4800 char *authorization,
int authorization_size,
4801 char *hostname,
int hostname_size,
4802 int *port_ptr,
char *path,
int path_size,
const char *url)
4804 const char *p, *ls, *at, *at2, *col, *brk;
4810 if (authorization_size > 0)
4811 authorization[0] = 0;
4812 if (hostname_size > 0)
4818 if ((p = strchr(url,
':'))) {
4832 ls = p + strcspn(p,
"/?#");
4839 while ((at = strchr(p,
'@')) && at < ls) {
4841 FFMIN(authorization_size, at + 1 - at2));
4845 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
4848 FFMIN(hostname_size, brk - p));
4849 if (brk[1] ==
':' && port_ptr)
4850 *port_ptr = atoi(brk + 2);
4851 }
else if ((col = strchr(p,
':')) && col < ls) {
4853 FFMIN(col + 1 - p, hostname_size));
4855 *port_ptr = atoi(col + 1);
4858 FFMIN(ls + 1 - p, hostname_size));
4869 if (!path || !
temp) {
4879 for ( ; *
pos !=
'\0'; ++
pos) {
4880 if (*
pos ==
'/' || *
pos ==
'\\') {
4883 ret = mkdir(
temp, 0755);
4888 if ((*(
pos - 1) !=
'/') || (*(
pos - 1) !=
'\\')) {
4889 ret = mkdir(
temp, 0755);
4899 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
4902 'C',
'D',
'E',
'F' };
4903 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
4906 'c',
'd',
'e',
'f' };
4907 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
4909 for (
i = 0;
i <
s;
i++) {
4910 buff[
i * 2] = hex_table[
src[
i] >> 4];
4911 buff[
i * 2 + 1] = hex_table[
src[
i] & 0xF];
4928 if (
c >=
'0' &&
c <=
'9')
4930 else if (
c >=
'A' &&
c <=
'F')
4946 unsigned int pts_num,
unsigned int pts_den)
4950 if (new_tb.
num != pts_num)
4952 "st:%d removing common factor %d from timebase\n",
4953 s->index, pts_num / new_tb.
num);
4956 "st:%d has too large timebase, reducing\n",
s->index);
4958 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4960 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4965 s->time_base = new_tb;
4966 #if FF_API_LAVF_AVCTX
4968 s->codec->pkt_timebase = new_tb;
4971 s->internal->avctx->pkt_timebase = new_tb;
4972 s->pts_wrap_bits = pts_wrap_bits;
4978 const char *ptr =
str;
4983 char *dest =
NULL, *dest_end;
4984 int key_len, dest_len = 0;
4987 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4994 if (!(ptr = strchr(
key,
'=')))
4997 key_len = ptr -
key;
4999 callback_get_buf(context,
key, key_len, &dest, &dest_len);
5000 dest_end = dest ? dest + dest_len - 1 :
NULL;
5004 while (*ptr && *ptr !=
'\"') {
5008 if (dest && dest < dest_end)
5012 if (dest && dest < dest_end)
5020 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
5021 if (dest && dest < dest_end)
5032 for (
i = 0;
i <
s->nb_streams;
i++)
5033 if (
s->streams[
i]->id ==
id)
5042 unsigned int codec_tag;
5090 if (channel_layout) {
5109 bytestream_put_le64(&
data, channel_layout);
5126 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
5127 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
5128 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
5129 stream_sample_aspect_ratio = undef;
5131 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
5132 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
5133 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
5134 frame_sample_aspect_ratio = undef;
5136 if (stream_sample_aspect_ratio.
num)
5137 return stream_sample_aspect_ratio;
5139 return frame_sample_aspect_ratio;
5148 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
5155 if ( codec_fr.
num > 0 && codec_fr.
den > 0 &&
5173 const char *spec,
const char **indexptr,
AVProgram **p)
5177 if (*spec <= '9' && *spec >=
'0') {
5181 }
else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
5182 *spec ==
't' || *spec ==
'V') {
5195 if (*spec && *spec++ !=
':')
5198 #if FF_API_LAVF_AVCTX
5210 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
5215 prog_id = strtol(spec, &endptr, 0);
5217 if (spec == endptr || (*endptr && *endptr++ !=
':'))
5221 for (
i = 0;
i <
s->nb_programs;
i++) {
5222 if (
s->programs[
i]->id != prog_id)
5225 for (j = 0; j <
s->programs[
i]->nb_stream_indexes; j++) {
5226 if (st->
index ==
s->programs[
i]->stream_index[j]) {
5229 *p =
s->programs[
i];
5238 }
else if (*spec ==
'#' ||
5239 (*spec ==
'i' && *(spec + 1) ==
':')) {
5242 spec += 1 + (*spec ==
'i');
5243 stream_id = strtol(spec, &endptr, 0);
5244 if (spec == endptr || *endptr)
5246 return match && (stream_id == st->
id);
5247 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
5254 val = strchr(spec,
':');
5262 if (!
val || !strcmp(
tag->value,
val + 1))
5271 return match && ret;
5272 }
else if (*spec ==
'u' && *(spec + 1) ==
'\0') {
5274 #if FF_API_LAVF_AVCTX
5283 #if FF_API_LAVF_AVCTX
5284 val =
val || (codec->sample_rate && codec->channels);
5295 #if FF_API_LAVF_AVCTX
5296 val =
val || (codec->width && codec->height);
5312 #if FF_API_LAVF_AVCTX
5331 const char *indexptr =
NULL;
5342 index = strtol(indexptr, &endptr, 0);
5349 if (spec == indexptr)
5354 for (
int i = 0; i < nb_streams && index >= 0;
i++) {
5359 if (ret > 0 &&
index-- == 0 && st == candidate)
5372 static const uint8_t avci100_1080p_extradata[] = {
5374 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
5375 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
5376 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
5377 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
5378 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
5379 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
5380 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
5381 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
5382 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5384 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
5387 static const uint8_t avci100_1080i_extradata[] = {
5389 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
5390 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
5391 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
5392 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
5393 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
5394 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
5395 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
5396 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
5397 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
5398 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
5399 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
5401 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
5404 static const uint8_t avci50_1080p_extradata[] = {
5406 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
5407 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
5408 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
5409 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
5410 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
5411 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
5412 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
5413 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
5414 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
5416 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
5419 static const uint8_t avci50_1080i_extradata[] = {
5421 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
5422 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
5423 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
5424 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
5425 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
5426 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
5427 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
5428 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
5429 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
5430 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
5431 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
5433 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
5436 static const uint8_t avci100_720p_extradata[] = {
5438 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
5439 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
5440 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
5441 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
5442 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
5443 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
5444 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
5445 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
5446 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
5447 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
5449 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
5452 static const uint8_t avci50_720p_extradata[] = {
5454 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
5455 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
5456 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
5457 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
5458 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
5459 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
5460 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
5461 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
5462 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
5464 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
5473 data = avci100_1080p_extradata;
5474 size =
sizeof(avci100_1080p_extradata);
5476 data = avci100_1080i_extradata;
5477 size =
sizeof(avci100_1080i_extradata);
5481 data = avci50_1080p_extradata;
5482 size =
sizeof(avci50_1080p_extradata);
5484 data = avci50_1080i_extradata;
5485 size =
sizeof(avci50_1080i_extradata);
5488 data = avci100_720p_extradata;
5489 size =
sizeof(avci100_720p_extradata);
5491 data = avci50_720p_extradata;
5492 size =
sizeof(avci50_720p_extradata);
5600 const char * shorthand[2] = {
NULL};
5603 shorthand[0] = opt->
name;
5619 "Automatically inserted bitstream filter '%s'; args='%s'\n",
5620 name, args ? args :
"");
5638 memset(
pkt, 0,
sizeof(*
pkt));
5644 memcpy(t, new_pkt.
data, new_pkt.
size);
5667 "Failed to open bitstream filter %s for stream %d with codec %s",
5695 s->io_close(
s, *pb);
5711 *timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
5786 #if FF_API_LAVF_AVCTX
5802 if (!strcmp(ofmt->
name,
"avi")) {
5803 #if FF_API_R_FRAME_RATE
5853 #if FF_API_LAVF_AVCTX
5867 #if FF_API_FORMAT_FILENAME
static void flush(AVCodecContext *avctx)
static double val(void *priv, double ch)
static const char *const format[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define PARSER_FLAG_USE_CODEC_TS
#define PARSER_FLAG_COMPLETE_FRAMES
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int avio_pause(AVIOContext *h, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e....
#define AVIO_FLAG_READ
read-only
int64_t avio_size(AVIOContext *s)
Get the filesize.
#define AVIO_FLAG_WRITE
write-only
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
int ffio_realloc_buf(AVIOContext *s, int buf_size)
Reallocate a given buffer for AVIOContext.
void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
Wipe the list and unref all the packets in it.
int avpriv_packet_list_get(PacketList **pkt_buffer, PacketList **pkt_buffer_end, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
void av_init_packet(AVPacket *pkt)
int avpriv_packet_list_put(PacketList **packet_buffer, PacketList **plast_pktl, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, buffer_size_t *size)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, buffer_size_t size)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
#define flags(name, subs,...)
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
#define FFSWAP(type, a, b)
#define MKTAG(a, b, c, d)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define FFMPEG_CONFIGURATION
static __device__ float fabs(float a)
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
const OptionDef options[]
static int64_t start_time
static AVCodecContext * dec_ctx
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
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.
void * av_opt_ptr(const AVClass *class, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
void av_opt_free(void *obj)
Free all allocated objects in obj.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
int av_codec_is_decoder(const AVCodec *codec)
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
@ AV_CODEC_ID_DVB_SUBTITLE
@ AV_CODEC_ID_DVB_TELETEXT
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
@ AV_AUDIO_SERVICE_TYPE_EFFECTS
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
@ AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED
@ AV_AUDIO_SERVICE_TYPE_COMMENTARY
@ AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONE
discard nothing
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt)
Return a value representing the fourCC code associated to the pixel format pix_fmt,...
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
attribute_deprecated int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
int avcodec_is_open(AVCodecContext *s)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
AVCodecParserContext * av_parser_init(int codec_id)
void av_parser_close(AVCodecParserContext *s)
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
const char * avformat_license(void)
Return the libavformat license.
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as stream side data.
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
int avformat_network_init(void)
Do global initialization of network libraries.
AVProgram * av_new_program(AVFormatContext *ac, int id)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int av_demuxer_open(AVFormatContext *ic)
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
int avformat_flush(AVFormatContext *s)
Discard all internally buffered data.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
ff_const59 AVInputFormat * av_probe_input_format3(ff_const59 AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
ff_const59 AVInputFormat * av_probe_input_format2(ff_const59 AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **ps)
Close an opened input AVFormatContext.
int avformat_open_input(AVFormatContext **ps, const char *filename, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
Return in 'buf' the path with 'd' replaced by a number.
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.
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
int avformat_queue_attached_pictures(AVFormatContext *s)
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
AVRational av_stream_get_codec_timebase(const AVStream *st)
Get the internal codec timebase from a stream.
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.
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
#define AV_FRAME_FILENAME_FLAGS_MULTIPLE
Allow multiple d.
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
int av_find_default_stream_index(AVFormatContext *s)
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
Get the index for a specific timestamp.
int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt, AVStream *ost, const AVStream *ist, enum AVTimebaseSource copy_tb)
Transfer internal timing information from one stream to another.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_BSF_NOT_FOUND
Bitstream filter not found.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
Add a value to a timestamp.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
@ AV_ROUND_UP
Round toward +infinity.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare the remainders of two integer operands divided by a common divisor.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_NONE
Undefined.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
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.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create chapters for all CHAP tags found in the ID3v2 header.
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
static const chunk_decoder decoder[8]
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
common internal api header.
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
unsigned int avpriv_toupper4(unsigned int x)
common internal API header
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
#define MAKE_ACCESSORS(str, name, type, field)
#define AV_MUTEX_INITIALIZER
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static float distance(float x, float y, int band)
int ff_network_init(void)
void ff_network_close(void)
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
const struct PixelFormatTag * avpriv_get_raw_pix_fmt_tags(void)
static int shift(int a, int b)
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
AVCodecParameters * par_in
Parameters of the input stream.
AVRational time_base_in
The timebase used for the timestamps of the input packets.
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
const struct AVBitStreamFilter * filter
struct AVBitStreamFilterContext * next
const AVClass * priv_class
A class for the private data, used to declare bitstream filter private AVOptions.
int id
unique ID to identify the chapter
int64_t end
chapter start/end time in time_base units
AVRational time_base
time base in which the start/end timestamps are specified
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
enum AVSampleFormat sample_fmt
audio sample format
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
enum AVMediaType codec_type
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int64_t bit_rate
the average bitrate
const struct AVCodec * codec
unsigned properties
Properties of the stream that gets decoded.
int sample_rate
samples per second
uint8_t * subtitle_header
Header containing style information for text subtitles.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int channels
number of audio channels
int coded_width
Bitstream width / height, may be different from width/height e.g.
uint64_t channel_layout
Audio channel layout.
int frame_size
Number of samples per channel in an audio frame.
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
enum AVDiscard skip_frame
Skip decoding for selected frames.
This struct describes the properties of a single codec described by an AVCodecID.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
enum AVFieldOrder field_order
Video only.
uint64_t channel_layout
Audio only.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
AVRational sample_aspect_ratio
Video only.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
Audio only.
int duration
Duration of the current frame.
int64_t pos
Byte position of currently parsed frame in stream.
int repeat_pict
This field is used for proper frame duration computation in lavf.
attribute_deprecated int64_t convergence_duration
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
int64_t offset
byte offset from starting packet start
const char * name
Name of the codec implementation.
int capabilities
Codec capabilities.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVIOContext * pb
I/O context.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
int flags
Flags modifying the (de)muxer behaviour.
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
int ctx_flags
Flags signalling stream properties.
ff_const59 struct AVInputFormat * iformat
The input container format.
int fps_probe_size
The number of frames used for determining the framerate in avformat_find_stream_info().
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
enum AVDurationEstimationMethod duration_estimation_method
The duration field can be estimated through various ways, and this field can be used to know how the ...
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
char * codec_whitelist
',' separated list of allowed decoders.
char * format_whitelist
',' separated list of allowed demuxers.
void * priv_data
Format private data.
int64_t probesize
Maximum size of the data read from input for determining the input container format.
AVStream ** streams
A list of all streams in the file.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int max_ts_probe
Maximum number of packets to read while waiting for the first timestamp.
char * protocol_whitelist
',' separated list of allowed protocols.
char * protocol_blacklist
',' separated list of disallowed protocols.
int skip_estimate_duration_from_pts
Skip duration calcuation in estimate_timings_from_pts.
This structure describes decoded (raw) audio or video data.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int64_t bytes_read
Bytes read statistic This field is internal to libavformat and access from outside is not allowed.
int seek_count
seek statistic This field is internal to libavformat and access from outside is not allowed.
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
enum AVPacketSideDataType type
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int flags
A combination of AV_PKT_FLAG values.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int64_t pos
byte position in stream, -1 if unknown
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
This structure contains the data a format has to probe a file.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
New fields can be added to the end with minor version bumps.
unsigned int nb_stream_indexes
unsigned int * stream_index
int64_t pts_wrap_reference
reference dts for wrap detection
enum AVDiscard discard
selects which program to discard and which to feed to the caller
int pts_wrap_behavior
behavior on wrap detection
Rational number (pair of numerator and denominator).
int nb_decoded_frames
Number of internally decoded frames, used internally in libavformat, do not access its lifetime diffe...
int64_t first_discard_sample
If not 0, the first audio sample that should be discarded from the stream.
int64_t pts_wrap_reference
Internal data to check for wrapping of the time stamp.
int64_t codec_info_duration_fields
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet.
struct AVStreamInternal::@260 * info
Stream information used internally by avformat_find_stream_info()
int skip_to_keyframe
Indicates that everything up to the next keyframe should be discarded.
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
int avctx_inited
1 if avctx has been initialized with the values from the codec parameters
struct AVStreamInternal::@259 extract_extradata
int inject_global_side_data
Internal data to inject global side data.
int64_t fps_first_dts
Those are used for average framerate estimation.
double(* duration_error)[2][MAX_STD_TIMEBASES]
int64_t pts_reorder_error[MAX_REORDER_DELAY+1]
Internal data to generate dts from pts.
uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]
int found_decoder
0 -> decoder has not been searched for yet.
int64_t last_dts_for_order_check
Internal data to analyze DTS and detect faulty mpeg streams.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
int64_t start_skip_samples
If not 0, the number of samples that should be skipped from the start of the stream (the samples are ...
int64_t rfps_duration_sum
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
int pts_wrap_behavior
Options for behavior, when a wrap is detected.
enum AVCodecID orig_codec_id
int64_t codec_info_duration
AVBSFContext * bsfc
bitstream filter to run on stream
int update_initial_durations_done
Internal data to prevent doing update_initial_durations() twice.
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
unsigned int index_entries_allocated_size
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int probe_packets
Number of packets to buffer for codec probing.
int64_t first_dts
Timestamp corresponding to the last dts sync point.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t nb_frames
number of frames in this stream if known or 0
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int64_t duration
Decoding: duration of the stream, in stream time base.
struct AVCodecParserContext * parser
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int pts_wrap_bits
number of bits in pts (used for wrapping control)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
attribute_deprecated AVCodecContext * codec
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVStreamParseType need_parsing
int nb_side_data
The number of elements in the AVStream.side_data array.
AVRational r_frame_rate
Real base framerate of the stream.
int codec_info_nb_frames
Number of frames that have been demuxed during avformat_find_stream_info()
attribute_deprecated char * recommended_encoder_configuration
String containing pairs of key and values describing recommended encoder configuration.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
int disposition
AV_DISPOSITION_* bit field.
static void error(const char *err)
static int ref[MAX_W *MAX_W]
int64_t av_gettime(void)
Get the current time in microseconds.
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
unbuffered private I/O API
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const uint8_t offset[127][2]