54 #include "libavutil/ffversion.h"
70 return FFMPEG_CONFIGURATION;
75 #define LICENSE_PREFIX "libavformat license: "
79 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
97 timestamp < st->pts_wrap_reference)
110 MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
112 MAKE_ACCESSORS(AVFormatContext, format,
int, metadata_header_padding)
142 if ( (src-> codec_whitelist && !dst-> codec_whitelist)
176 #define SANE_CHUNK_SIZE (50000000)
182 if (remaining < size) {
185 s->
maxsize = newsize - !newsize;
187 remaining=
FFMAX(remaining, 0);
190 if (s->
maxsize>= 0 && remaining+1 < size) {
202 int64_t orig_pos = pkt->
pos;
203 int orig_size = pkt->
size;
207 int prev_size = pkt->
size;
225 if (ret != read_size) {
238 return pkt->
size > orig_size ? pkt->
size - orig_size :
ret;
268 static const struct {
292 "Probe with size=%d, packets=%d detected %s with score=%d\n",
295 for (i = 0; fmt_id_type[i].name; i++) {
296 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
344 "will be ignored with AVFMT_NOFILE format.\n");
369 (*plast_pktl)->next = pktl;
371 *packet_buffer = pktl;
386 if (copy.
size <= 0) {
388 "Attached picture on stream %d has invalid size, "
413 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
428 if ((ret =
init_input(s, filename, &tmp)) < 0)
473 if (id3v2_extra_meta) {
540 "Failed to reallocate probe buffer for stream %d\n",
553 "nothing to probe for stream %d\n", st->
index);
580 int64_t ref = pkt->
dts;
581 int i, pts_wrap_behavior;
582 int64_t pts_wrap_reference;
600 if (!first_program) {
627 program = first_program;
671 if (!pktl || ret ==
AVERROR(EAGAIN))
686 "Dropped corrupted packet (stream = %d)\n",
756 switch (st->codec->codec_type) {
758 if (st->r_frame_rate.num && !pc &&
s->iformat) {
759 *pnum = st->r_frame_rate.den;
760 *pden = st->r_frame_rate.num;
761 }
else if (st->time_base.num * 1000LL > st->time_base.den) {
762 *pnum = st->time_base.num;
763 *pden = st->time_base.den;
764 }
else if (codec_framerate.den * 1000LL > codec_framerate.num) {
768 codec_framerate.num * (int64_t)st->codec->ticks_per_frame,
771 if (pc && pc->repeat_pict) {
774 (*pnum) * (1LL + pc->repeat_pict),
781 if (st->codec->ticks_per_frame > 1 && !pc)
787 if (frame_size <= 0 || st->codec->sample_rate <= 0)
790 *pden = st->codec->sample_rate;
818 #if CONFIG_H264_DECODER
849 int64_t best_score = INT64_MAX;
850 for (i = 0; i<delay; i++) {
853 if (score < best_score) {
860 for (i = 0; i<delay; i++) {
862 int64_t
diff =
FFABS(pts_buffer[i] - dts)
921 pts_buffer[0] = pktl->
pkt.
pts;
922 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
923 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
954 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %d) in the queue\n",
988 int64_t next_dts, int64_t next_pts)
990 int num, den, presentation_delayed, delay, i;
1005 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1031 presentation_delayed = 0;
1037 presentation_delayed = 1;
1052 if (delay == 1 && pkt->
dts == pkt->
pts &&
1055 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1090 presentation_delayed = 1;
1094 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d delay:%d onein_oneout:%d\n",
1100 if ((delay == 0 || (delay == 1 && pc)) &&
1102 if (presentation_delayed) {
1120 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1121 next_dts != next_pts &&
1123 pkt->
pts = next_dts;
1175 *pkt_buf = pktl->
next;
1179 *pkt_buf_end =
NULL;
1193 int ret = 0, got_output = 0;
1204 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1206 int64_t next_pts = pkt->
pts;
1207 int64_t next_dts = pkt->
dts;
1211 &out_pkt.
data, &out_pkt.
size, data, size,
1220 got_output = !!out_pkt.
size;
1265 #if FF_API_DESTRUCT_PACKET
1301 *pkt_buffer = pktl->
next;
1303 *pkt_buffer_end =
NULL;
1315 int ret = 0, i, got_packet = 0;
1344 cur_pkt.
pts < cur_pkt.
dts) {
1346 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1354 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1364 "%s, packets or times may be invalid.\n",
1410 int discard_padding = 0;
1415 int64_t end_sample = sample +
duration;
1417 sample < st->last_discard_sample)
1426 AV_WL32(p + 4, discard_padding);
1446 memcpy(dst_data, src_sd->
data, src_sd->
size);
1465 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1466 "size=%d, duration=%d, flags=%d\n",
1502 int64_t last_dts = next_pkt->
dts;
1512 last_dts = pktl->
pkt.
dts;
1540 if (pktl && ret !=
AVERROR(EAGAIN)) {
1587 int best_stream = 0;
1588 int best_score = -1;
1612 if (score > best_score) {
1684 int *nb_index_entries,
1685 unsigned int *index_entries_allocated_size,
1686 int64_t pos, int64_t timestamp,
1692 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1705 index_entries_allocated_size,
1706 (*nb_index_entries + 1) *
1711 *index_entries = entries;
1717 index = (*nb_index_entries)++;
1718 ie = &entries[
index];
1719 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
1721 ie = &entries[
index];
1725 memmove(entries + index + 1, entries + index,
1727 (*nb_index_entries)++;
1728 }
else if (ie->
pos == pos && distance < ie->min_distance)
1748 timestamp, size, distance, flags);
1752 int64_t wanted_timestamp,
int flags)
1761 if (b && entries[b - 1].timestamp < wanted_timestamp)
1767 if (timestamp >= wanted_timestamp)
1769 if (timestamp <= wanted_timestamp)
1775 while (m >= 0 && m < nb_entries &&
1779 if (m == nb_entries)
1787 wanted_timestamp, flags);
1791 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1793 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1794 if (stream_index >= 0)
1800 int64_t target_ts,
int flags)
1804 int64_t ts_min, ts_max, ts;
1809 if (stream_index < 0)
1818 st = s->
streams[stream_index];
1826 index =
FFMAX(index, 0);
1848 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
1852 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
1868 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1870 int64_t step = 1024;
1871 int64_t limit, ts_max;
1873 int64_t pos_max = filesize - 1;
1876 pos_max =
FFMAX(0, (pos_max) - step);
1878 &pos_max, limit, read_timestamp);
1885 int64_t tmp_pos = pos_max + 1;
1887 &tmp_pos, INT64_MAX, read_timestamp);
1893 if (tmp_pos >= filesize)
1906 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1907 int64_t ts_min, int64_t ts_max,
1908 int flags, int64_t *ts_ret,
1910 int64_t *, int64_t))
1921 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1926 if (ts_min >= target_ts) {
1932 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
1934 pos_limit = pos_max;
1937 if (ts_max <= target_ts) {
1945 while (pos_min < pos_limit) {
1947 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1951 if (no_change == 0) {
1952 int64_t approximate_keyframe_distance = pos_max - pos_limit;
1954 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
1956 pos_min - approximate_keyframe_distance;
1957 }
else if (no_change == 1) {
1959 pos = (pos_min + pos_limit) >> 1;
1967 else if (pos > pos_limit)
1978 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1979 pos_min, pos, pos_max,
1981 pos_limit, start_pos, no_change);
1986 if (target_ts <= ts) {
1987 pos_limit = start_pos - 1;
1991 if (target_ts >= ts) {
2001 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2003 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2012 int64_t pos,
int flags)
2014 int64_t pos_min, pos_max;
2021 else if (pos > pos_max)
2032 int64_t timestamp,
int flags)
2039 st = s->
streams[stream_index];
2043 if (index < 0 && st->nb_index_entries &&
2044 timestamp < st->index_entries[0].timestamp)
2047 if (index < 0 || index == st->nb_index_entries - 1) {
2065 }
while (read_status ==
AVERROR(EAGAIN));
2066 if (read_status < 0)
2073 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);
2096 int64_t timestamp,
int flags)
2108 if (stream_index < 0) {
2110 if (stream_index < 0)
2113 st = s->
streams[stream_index];
2140 int64_t timestamp,
int flags)
2145 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2151 flags & ~AVSEEK_FLAG_BACKWARD);
2163 int64_t ts, int64_t max_ts,
int flags)
2165 if (min_ts > ts || max_ts < ts)
2167 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2178 if (stream_index == -1 && s->
nb_streams == 1) {
2185 time_base.
num * (int64_t)AV_TIME_BASE,
2206 if (ret<0 && ts != min_ts && max_ts != ts) {
2207 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2253 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2254 int64_t
duration, duration1, filesize;
2259 start_time = INT64_MAX;
2260 start_time_text = INT64_MAX;
2261 end_time = INT64_MIN;
2262 duration = INT64_MIN;
2269 if (start_time1 < start_time_text)
2270 start_time_text = start_time1;
2272 start_time =
FFMIN(start_time, start_time1);
2275 end_time1 = start_time1 +
2278 end_time =
FFMAX(end_time, end_time1);
2290 duration =
FFMAX(duration, duration1);
2293 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2294 start_time = start_time_text;
2295 else if (start_time > start_time_text)
2298 if (start_time != INT64_MAX) {
2300 if (end_time != INT64_MIN) {
2308 duration =
FFMAX(duration, end_time - start_time);
2316 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2318 if (bitrate >= 0 && bitrate <= INT_MAX)
2345 int i, show_warning = 0;
2390 "Estimating duration from bitrate, this may be inaccurate\n");
2393 #define DURATION_MAX_READ_SIZE 250000LL
2394 #define DURATION_MAX_RETRY 4
2401 int num, den, read_size, i,
ret;
2402 int found_duration = 0;
2416 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2429 is_end = found_duration;
2442 }
while (ret ==
AVERROR(EAGAIN));
2445 read_size += pkt->
size;
2502 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2504 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2532 file_size =
FFMAX(0, file_size);
2563 "stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2574 #define FAIL(errmsg) do { \
2576 *errmsg_ptr = errmsg; \
2582 FAIL(
"unknown codec");
2586 FAIL(
"unspecified frame size");
2589 FAIL(
"unspecified sample format");
2591 FAIL(
"unspecified sample rate");
2593 FAIL(
"unspecified number of channels");
2595 FAIL(
"no decodable DTS frames");
2599 FAIL(
"unspecified size");
2601 FAIL(
"unspecified pixel format");
2604 FAIL(
"no frame in rv30/40 and no sar");
2608 FAIL(
"unspecified size");
2622 int got_picture = 1,
ret = 0;
2645 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2664 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2673 &got_picture, &pkt);
2680 &got_picture, &pkt);
2695 if (!pkt.
data && !got_picture)
2717 if (tag == tags[i].tag)
2739 if (sflags & (1 << (bps - 1))) {
2781 for (i = 0; tags && tags[i]; i++) {
2784 if (codec_tags->
id ==
id) {
2785 *tag = codec_tags->
tag;
2797 for (i = 0; tags && tags[i]; i++) {
2822 if (j != i && next_start > ch->
start && next_start < end)
2825 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2832 return (i + 1) * 1001;
2836 return ((
const int[]) { 40, 48, 50, 60, 80, 120, 240})[i] * 1001 * 12;
2840 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i] * 1000 * 12;
2907 && ts - (uint64_t)last < INT64_MAX) {
2921 double sdts = dts*framerate/(1001*12);
2922 for (j= 0; j<2; j++) {
2923 int64_t ticks =
llrint(sdts+j*0.5);
2924 double error= sdts - ticks + j*0.5;
2941 if (error0 > 0.04 && error1 > 0.04) {
2976 double best_error= 0.01;
2990 for (k= 0; k<2; k++) {
2995 if (error < best_error && best_error> 0.000000001) {
3004 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3035 int64_t max_stream_analyze_duration;
3038 if (!max_analyze_duration)
3042 flush_codecs = probesize > 0;
3046 max_stream_analyze_duration = max_analyze_duration;
3047 if (!max_analyze_duration) {
3048 max_stream_analyze_duration =
3055 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d\n",
3081 "%s, packets or times may be invalid.\n",
3089 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3099 "Failed to open codec in av_find_stream_info\n");
3107 "Failed to open codec in av_find_stream_info\n");
3114 #if FF_API_R_FRAME_RATE
3124 int analyzed_all_streams;
3133 int fps_analyze_framecount = 20;
3142 fps_analyze_framecount *= 2;
3144 fps_analyze_framecount = 0;
3148 fps_analyze_framecount = 0;
3155 if (count < fps_analyze_framecount)
3168 analyzed_all_streams = 0;
3170 analyzed_all_streams = 1;
3182 if (read_size >= probesize) {
3185 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3192 "Stream #%d: not enough frames to estimate rate; "
3193 "consider increasing probesize\n", i);
3216 goto find_stream_info_err;
3219 goto find_stream_info_err;
3224 read_size += pkt->
size;
3231 "Non-increasing DTS in stream %d: packet %d with DTS "
3232 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3248 "DTS discontinuity in stream %d: packet %d with DTS "
3249 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3279 if (t >= (analyzed_all_streams ? max_analyze_duration : max_stream_analyze_duration)) {
3280 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds\n",
3281 max_analyze_duration,
3292 #if FF_API_R_FRAME_RATE
3316 (options && i < orig_nb_streams) ? &options[i] :
NULL);
3338 (options && i < orig_nb_streams)
3339 ? &options[i] :
NULL);
3344 "decoding for stream %d failed\n", st->
index);
3372 double best_error = 0.01;
3389 if (error < best_error) {
3391 best_fps = std_fps.
num;
3396 best_fps, 12 * 1001, INT_MAX);
3454 "Could not find codec parameters for stream %d (%s): %s\n"
3455 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3464 find_stream_info_err:
3474 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3497 int wanted_stream_nb,
int related_stream,
3498 AVCodec **decoder_ret,
int flags)
3502 unsigned *program =
NULL;
3505 if (related_stream >= 0 && wanted_stream_nb < 0) {
3513 int real_stream_index = program ? program[i] : i;
3518 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3520 if (wanted_stream_nb != real_stream_index &&
3539 if ((best_multiframe > multiframe) ||
3540 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3541 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >=
count))
3544 best_bitrate = bitrate;
3545 best_multiframe = multiframe;
3546 ret = real_stream_index;
3548 if (program && i == nb_streams - 1 && ret < 0) {
3556 *decoder_ret = (
AVCodec*)best_decoder;
3678 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3728 #if FF_API_R_FRAME_RATE
3769 int64_t
start, int64_t
end,
const char *title)
3775 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
3834 char *q, buf1[20],
c;
3835 int nd,
len, percentd_found;
3848 nd = nd * 10 + *p++ -
'0';
3861 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3863 if ((q - buf + len) > buf_size - 1)
3865 memcpy(q, buf1, len);
3873 if ((q - buf) < buf_size - 1)
3877 if (!percentd_found)
3887 char *authorization,
int authorization_size,
3888 char *hostname,
int hostname_size,
3889 int *port_ptr,
char *path,
int path_size,
const char *url)
3891 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3897 if (authorization_size > 0)
3898 authorization[0] = 0;
3899 if (hostname_size > 0)
3905 if ((p = strchr(url,
':'))) {
3919 ls = strchr(p,
'/');
3920 ls2 = strchr(p,
'?');
3924 ls =
FFMIN(ls, ls2);
3934 while ((at = strchr(p,
'@')) && at < ls) {
3936 FFMIN(authorization_size, at + 1 - at2));
3940 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3943 FFMIN(hostname_size, brk - p));
3944 if (brk[1] ==
':' && port_ptr)
3945 *port_ptr = atoi(brk + 2);
3946 }
else if ((col = strchr(p,
':')) && col < ls) {
3948 FFMIN(col + 1 - p, hostname_size));
3950 *port_ptr = atoi(col + 1);
3953 FFMIN(ls + 1 - p, hostname_size));
3960 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3963 'C',
'D',
'E',
'F' };
3964 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3967 'c',
'd',
'e',
'f' };
3968 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3970 for (i = 0; i <
s; i++) {
3971 buff[i * 2] = hex_table[src[i] >> 4];
3972 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3989 if (c >=
'0' && c <=
'9')
3991 else if (c >=
'A' && c <=
'F')
4007 unsigned int pts_num,
unsigned int pts_den)
4011 if (new_tb.
num != pts_num)
4013 "st:%d removing common factor %d from timebase\n",
4017 "st:%d has too large timebase, reducing\n", s->
index);
4019 if (new_tb.
num <= 0 || new_tb.
den <= 0) {
4021 "Ignoring attempt to set invalid timebase %d/%d for st:%d\n",
4034 const char *ptr = str;
4039 char *dest =
NULL, *dest_end;
4040 int key_len, dest_len = 0;
4043 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4050 if (!(ptr = strchr(key,
'=')))
4053 key_len = ptr - key;
4055 callback_get_buf(context, key, key_len, &dest, &dest_len);
4056 dest_end = dest + dest_len - 1;
4060 while (*ptr && *ptr !=
'\"') {
4064 if (dest && dest < dest_end)
4068 if (dest && dest < dest_end)
4076 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4077 if (dest && dest < dest_end)
4096 struct tm time1 = { 0 }, time2 = { 0 };
4097 const char *ret1, *ret2;
4110 unsigned int codec_tag;
4112 return ofmt->
query_codec(codec_id, std_compliance);
4159 if (channel_layout) {
4167 if (width || height) {
4174 bytestream_put_le32(&data, flags);
4176 bytestream_put_le32(&data, channels);
4178 bytestream_put_le64(&data, channel_layout);
4180 bytestream_put_le32(&data, sample_rate);
4181 if (width || height) {
4182 bytestream_put_le32(&data, width);
4183 bytestream_put_le32(&data, height);
4195 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4196 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4197 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4198 stream_sample_aspect_ratio = undef;
4200 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4201 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4202 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4203 frame_sample_aspect_ratio = undef;
4205 if (stream_sample_aspect_ratio.
num)
4206 return stream_sample_aspect_ratio;
4208 return frame_sample_aspect_ratio;
4217 if (avg_fr.
num > 0 && avg_fr.
den > 0 && fr.
num > 0 && fr.
den > 0 &&
4224 if ( codec_fr.
num > 0 && codec_fr.
den > 0 &&
4235 if (*spec <= '9' && *spec >=
'0')
4236 return strtol(spec,
NULL, 0) == st->
index;
4237 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4251 if (*spec++ ==
':') {
4255 return i == st->
index;
4259 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4263 prog_id = strtol(spec, &endptr, 0);
4268 if (*endptr++ ==
':') {
4269 int stream_idx = strtol(endptr,
NULL, 0);
4270 return stream_idx >= 0 &&
4280 }
else if (*spec ==
'#' ||
4281 (*spec ==
'i' && *(spec + 1) ==
':')) {
4284 spec += 1 + (*spec ==
'i');
4285 stream_id = strtol(spec, &endptr, 0);
4287 return stream_id == st->
id;
4288 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
4294 val = strchr(spec,
':');
4302 if (!val || !strcmp(tag->
value, val + 1))
4311 }
else if (*spec ==
'u') {
4342 static const uint8_t avci100_1080p_extradata[] = {
4344 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4345 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4346 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4347 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4348 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4349 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4350 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4351 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4352 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4354 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4357 static const uint8_t avci100_1080i_extradata[] = {
4359 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4360 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4361 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4362 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4363 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4364 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4365 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4366 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4367 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4368 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4369 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
4371 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4374 static const uint8_t avci50_1080p_extradata[] = {
4376 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4377 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4378 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4379 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4380 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4381 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
4382 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
4383 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
4384 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
4386 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4389 static const uint8_t avci50_1080i_extradata[] = {
4391 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4392 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4393 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4394 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4395 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4396 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4397 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4398 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4399 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4400 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4401 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4403 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4406 static const uint8_t avci100_720p_extradata[] = {
4408 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4409 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4410 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4411 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4412 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4413 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4414 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4415 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4416 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4417 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4419 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4422 static const uint8_t avci50_720p_extradata[] = {
4424 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
4425 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4426 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4427 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
4428 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
4429 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
4430 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
4431 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
4432 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
4434 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4443 data = avci100_1080p_extradata;
4444 size =
sizeof(avci100_1080p_extradata);
4446 data = avci100_1080i_extradata;
4447 size =
sizeof(avci100_1080i_extradata);
4451 data = avci50_1080p_extradata;
4452 size =
sizeof(avci50_1080p_extradata);
4454 data = avci50_1080i_extradata;
4455 size =
sizeof(avci50_1080i_extradata);
4458 data = avci100_720p_extradata;
4459 size =
sizeof(avci100_720p_extradata);
4461 data = avci50_720p_extradata;
4462 size =
sizeof(avci50_720p_extradata);
4504 if (sd->
type == type) {
unsigned int nb_chapters
Number of chapters in AVChapter array.
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
unsigned int max_index_size
Maximum amount of memory in bytes to use for the index of each stream.
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.
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
int64_t first_dts
Timestamp corresponding to the last dts sync point.
int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
const struct AVCodec * codec
const char const char void * val
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int shift(int a, int b)
int av_demuxer_open(AVFormatContext *ic)
void av_free_packet(AVPacket *pkt)
Free a packet.
char * recommended_encoder_configuration
String containing paris of key and values describing recommended encoder configuration.
This structure describes decoded (raw) audio or video data.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
ptrdiff_t const GLvoid * data
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.
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.
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 start_skip_samples
If not 0, the number of samples that should be skipped from the start of the stream (the samples are ...
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
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...
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
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.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
void av_codec_set_pkt_timebase(AVCodecContext *avctx, AVRational val)
int index
stream index in AVFormatContext
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int avio_flags
avio flags, used to force AVIO_FLAG_DIRECT.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t * av_stream_get_side_data(AVStream *st, enum AVPacketSideDataType type, int *size)
Get side information from stream.
void ff_network_close(void)
int event_flags
Flags for the user to detect events happening on the file.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVInputFormat * av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
int duration
Duration of the current frame.
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
int ctx_flags
Flags signalling stream properties.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
int64_t maxsize
max filesize, used to limit allocations This field is internal to libavformat and access from outside...
int av_dup_packet(AVPacket *pkt)
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header. ...
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
int64_t last_dts_for_order_check
Internal data to analyze DTS and detect faulty mpeg streams.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
unsigned int nb_stream_indexes
int ff_network_inited_globally
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int64_t start_time
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Opaque data information usually continuous.
int ff_network_init(void)
int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
timestamp utils, mostly useful for debugging/logging purposes
unsigned avformat_version(void)
Return the LIBAVFORMAT_VERSION_INT constant.
const char * avformat_license(void)
Return the libavformat license.
attribute_deprecated void(* destruct)(struct AVPacket *)
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, or 0 if no associated fourCC code can be found.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
struct AVStream::@141 * info
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 nb_side_data
The number of elements in the AVStream.side_data array.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
char * av_small_strptime(const char *p, const char *fmt, struct tm *dt)
Simplified version of strptime.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int inject_global_side_data
Internal data to inject global side data.
const char * avformat_configuration(void)
Return the libavformat build-time configuration.
int64_t bytes_read
Bytes read statistic This field is internal to libavformat and access from outside is not allowed...
static double av_q2d(AVRational a)
Convert rational to double.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
AVProgram * av_new_program(AVFormatContext *ac, int id)
int64_t probesize2
Maximum size of the data read from input for determining the input container format.
int avformat_network_init(void)
Do global initialization of network components.
char * av_strndup(const char *s, size_t len)
Duplicate a substring of the string s.
int fps_probe_size
The number of frames used for determining the framerate in avformat_find_stream_info().
#define AV_LOG_VERBOSE
Detailed information.
static void copy(LZOContext *c, int cnt)
Copies bytes from input to output buffer with checking.
const AVCodecDescriptor * av_codec_get_codec_descriptor(const AVCodecContext *avctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
enum AVDiscard discard
selects which program to discard and which to feed to the caller
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
unsigned int * stream_index
enum AVCodecID video_codec_id
Forced video codec_id.
int64_t rfps_duration_sum
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int correct_ts_overflow
Correct single timestamp overflows.
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
int max_ts_probe
Maximum number of packets to read while waiting for the first timestamp.
int format_probesize
number of bytes to read maximally to identify format.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int nb_decoded_frames
Number of internally decoded frames, used internally in libavformat, do not access its lifetime diffe...
int64_t pos
Byte position of currently parsed frame in stream.
int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
Get the index for a specific timestamp.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
struct AVCodecParser * parser
#define MAKE_ACCESSORS(str, name, type, field)
int64_t pts_wrap_reference
reference dts for wrap detection
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
unsigned int avpriv_toupper4(unsigned int x)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define PARSER_FLAG_COMPLETE_FRAMES
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int avcodec_is_open(AVCodecContext *s)
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
int64_t convergence_duration
Time difference in AVStream->time_base units from the pts of this packet to the point at which the ou...
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_read_play(AVFormatContext *s)
Start playing a network-based stream (e.g.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int rc_max_rate
maximum bitrate
simple assert() macros that are a bit more flexible than ISO C assert().
#define PARSER_FLAG_USE_CODEC_TS
int64_t av_gcd(int64_t a, int64_t b)
Return the greatest common divisor of a and b.
enum AVPacketSideDataType type
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet. ...
static const uint8_t offset[127][2]
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
AVInputFormat * av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
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.
AVCodec * audio_codec
Forced audio codec.
int flags
A combination of AV_PKT_FLAG values.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int seek_count
seek statistic This field is internal to libavformat and access from outside is not allowed...
char * format_whitelist
',' separated list of allowed demuxers.
AVCodecContext * codec
Codec context associated with this stream.
static AVPacket flush_pkt
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_packet_merge_side_data(AVPacket *pkt)
static float distance(float x, float y, int band)
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
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.
common internal API header
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int64_t fps_first_dts
Those are used for average framerate estimation.
int av_read_pause(AVFormatContext *s)
Pause a network-based stream (e.g.
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.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
char filename[1024]
input or output filename
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int update_initial_durations_done
Internal data to prevent doing update_initial_durations() twice.
#define AV_TIME_BASE
Internal time base represented as integer.
enum AVCodecID audio_codec_id
Forced audio codec_id.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
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.
static const chunk_decoder decoder[8]
int width
picture width / height.
int64_t offset
byte offset from starting packet start
int av_find_default_stream_index(AVFormatContext *s)
int64_t convergence_duration
Time difference in stream time base units from the pts of this packet to the point at which the outpu...
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
void av_parser_close(AVCodecParserContext *s)
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int probe_score
format probing score.
Usually treated as AVMEDIA_TYPE_DATA.
Opaque data information usually sparse.
int64_t skip_initial_bytes
Skip initial bytes when opening stream.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
preferred ID for MPEG-1/2 video decoding
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]
int64_t av_gettime(void)
Get the current time in microseconds.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int64_t end
chapter start/end time in time_base units
int avformat_queue_attached_pictures(AVFormatContext *s)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_INFO
Standard information.
int64_t pts_reorder_error[MAX_REORDER_DELAY+1]
Internal data to generate dts from pts.
AVCodecParserContext * av_parser_init(int codec_id)
enum AVMediaType codec_type
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
int debug
Flags to enable debugging.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
char * av_strdup(const char *s)
Duplicate the string s.
int sample_rate
samples per second
AVIOContext * pb
I/O context.
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int io_repositioned
IO repositioned flag.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
attribute_deprecated int max_analyze_duration
int pts_wrap_behavior
behavior on wrap detection
double(* duration_error)[2][MAX_STD_TIMEBASES]
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
rational number numerator/denominator
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
Recommmends skipping the specified number of samples.
const AVClass * av_class
A class for logging and AVOptions.
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int found_decoder
0 -> decoder has not been searched for yet.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
This structure contains the data a format has to probe a file.
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avio_pause(AVIOContext *h, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (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.
This struct describes the properties of a single codec described by an AVCodecID. ...
int seek2any
Force seeking to any (also non key) frames.
int64_t codec_info_duration
static int64_t pts
Global timestamp for the audio frames.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int64_t duration
Decoding: duration of the stream, in stream time base.
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
int(* split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
struct AVPacketList * next
int pts_wrap_behavior
Options for behavior, when a wrap is detected.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
Add a value to a timestamp.
AVCodec * video_codec
Forced video codec.
int disposition
AV_DISPOSITION_* bit field.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc)
int pts_wrap_bits
number of bits in pts (used for wrapping control)
AVRational time_base
time base in which the start/end timestamps are specified
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
Read an ID3v2 tag, including supported extra metadata and chapters.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
struct AVInputFormat * iformat
The input container format.
int64_t max_analyze_duration2
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
void avformat_close_input(AVFormatContext **ps)
Close an opened input AVFormatContext.
int64_t codec_info_duration_fields
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE...
unsigned int index_entries_allocated_size
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
int skip_to_keyframe
Indicates that everything up to the next keyframe should be discarded.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
AVCodec * subtitle_codec
Forced subtitle codec.
#define FF_ENABLE_DEPRECATION_WARNINGS
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int channels
number of audio channels
char * codec_whitelist
',' separated list of allowed decoders.
struct AVCodecParserContext * parser
void * priv_data
Format private data.
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
const struct PixelFormatTag * avpriv_get_raw_pix_fmt_tags(void)
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
int repeat_pict
This field is used for proper frame duration computation in lavf.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int avformat_flush(AVFormatContext *s)
Discard all internally buffered data.
enum AVFieldOrder field_order
Field order.
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
unbuffered private I/O API
#define FFSWAP(type, a, b)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
int use_wallclock_as_timestamps
forces the use of wallclock timestamps as pts/dts of packets This has undefined results in the presen...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
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 key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare 2 integers modulo mod.
uint8_t * subtitle_header
Header containing style information for text subtitles.