30 #include "libavutil/avassert.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/dict.h"
33 #include "libavutil/pixdesc.h"
36 #include "libavutil/avassert.h"
37 #include "libavutil/avstring.h"
38 #include "libavutil/mathematics.h"
39 #include "libavutil/parseutils.h"
40 #include "libavutil/time.h"
41 #include "libavutil/timestamp.h"
71 #define LICENSE_PREFIX "libavformat license: "
75 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
93 timestamp < st->pts_wrap_reference)
109 if(f)
return f->
next;
115 if(f)
return f->
next;
145 ext = strrchr(filename,
'.');
151 while (*p !=
'\0' && *p !=
',' && q-ext1<
sizeof(ext1)-1)
172 namelen = strlen(name);
173 while ((p = strchr(names,
','))) {
174 len =
FFMAX(p - names, namelen);
183 const char *mime_type)
186 int score_max, score;
189 #if CONFIG_IMAGE2_MUXER
190 if (!short_name && filename &&
209 if (score > score_max) {
218 const char *filename,
const char *mime_type,
enum AVMediaType type){
222 #if CONFIG_IMAGE2_MUXER
223 if(!strcmp(fmt->
name,
"image2") || !strcmp(fmt->
name,
"image2pipe")){
252 if(remaining < size){
255 s->
maxsize= newsize - !newsize;
257 remaining=
FFMAX(remaining, 0);
260 if(s->
maxsize>=0 && remaining+1 < size){
271 int orig_size =
size;
286 if (pkt->
size < orig_size)
298 old_size = pkt->
size;
318 int score, nodat = 0, score_max=0;
322 lpd.
buf = zerobuffer;
347 if (score > score_max) {
350 }
else if (score == score_max)
353 *score_ret= score_max;
362 if(score_ret > *score_max){
363 *score_max= score_ret;
376 static const struct {
397 for (i = 0; fmt_id_type[i].name; i++) {
398 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
428 #define PROBE_BUF_MIN 2048
429 #define PROBE_BUF_MAX (1<<20)
432 const char *filename,
void *logctx,
433 unsigned int offset,
unsigned int max_probe_size)
436 unsigned char *buf =
NULL;
438 int ret = 0, probe_size, buf_offset = 0;
440 if (!max_probe_size) {
446 "Specified probe size value %u cannot be < %u\n", max_probe_size,
PROBE_BUF_MIN);
450 if (offset >= max_probe_size) {
462 probe_size =
FFMIN(probe_size<<1,
FFMAX(max_probe_size, probe_size+1))) {
466 if (probe_size < offset) {
477 if ((ret =
avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) {
495 av_log(logctx,
AV_LOG_WARNING,
"Format %s detected only with low score of %d, misdetection possible!\n", (*fmt)->name, score);
497 av_log(logctx,
AV_LOG_DEBUG,
"Format %s probed with size=%d and score=%d\n", (*fmt)->name, probe_size, score);
525 "will be ignored with AVFMT_NOFILE format.\n");
548 (*plast_pktl)->next = pktl;
550 *packet_buffer = pktl;
580 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
592 if ((ret =
init_input(s, filename, &tmp)) < 0)
629 if (id3v2_extra_meta) {
748 if (!pktl || ret ==
AVERROR(EAGAIN))
763 "Dropped corrupted packet (stream = %d)\n",
797 #if FF_API_READ_PACKET
859 if (st->r_frame_rate.num && !pc) {
860 *pnum = st->r_frame_rate.den;
861 *pden = st->r_frame_rate.num;
883 if (frame_size <= 0 || st->codec->sample_rate <= 0)
914 #if CONFIG_H264_DECODER
951 if (!first_program) {
976 program = first_program;
1031 pts_buffer[0]= pktl->
pkt.
pts;
1032 for(i=0; i<delay && pts_buffer[i] > pts_buffer[i+1]; i++)
1033 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i+1]);
1035 pktl->
pkt.
dts= pts_buffer[0];
1101 int num, den, presentation_delayed, delay, i;
1116 presentation_delayed = 0;
1122 presentation_delayed = 1;
1136 if(strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2"))
1183 presentation_delayed = 1;
1185 av_dlog(
NULL,
"IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d\n",
1190 if (presentation_delayed) {
1240 av_dlog(
NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1254 *pkt_buf = pktl->
next;
1258 *pkt_buf_end =
NULL;
1272 int ret = 0, got_output = 0;
1283 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1288 &out_pkt.
data, &out_pkt.
size, data, size,
1297 got_output = !!out_pkt.
size;
1371 *pkt_buffer = pktl->
next;
1373 *pkt_buffer_end =
NULL;
1380 int ret = 0, i, got_packet = 0;
1408 cur_pkt.
pts < cur_pkt.
dts) {
1416 av_log(s,
AV_LOG_DEBUG,
"ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1428 "%s, packets or times may be invalid.\n",
1473 av_log(s,
AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1510 int64_t last_dts = next_pkt->
dts;
1519 last_dts = pktl->
pkt.
dts;
1547 if (pktl && ret !=
AVERROR(EAGAIN)) {
1597 int first_audio_index = -1;
1610 first_audio_index = i;
1612 return first_audio_index >= 0 ? first_audio_index : 0;
1672 int *nb_index_entries,
1673 unsigned int *index_entries_allocated_size,
1679 if((
unsigned)*nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1689 index_entries_allocated_size,
1690 (*nb_index_entries + 1) *
1695 *index_entries= entries;
1700 index= (*nb_index_entries)++;
1701 ie= &entries[
index];
1702 assert(index==0 || ie[-1].timestamp < timestamp);
1704 ie= &entries[
index];
1708 memmove(entries + index + 1, entries + index,
sizeof(
AVIndexEntry)*(*nb_index_entries - index));
1709 (*nb_index_entries)++;
1710 }
else if(ie->
pos == pos && distance < ie->min_distance)
1729 timestamp, size, distance, flags);
1733 int64_t wanted_timestamp,
int flags)
1742 if(b && entries[b-1].timestamp < wanted_timestamp)
1748 if(timestamp >= wanted_timestamp)
1750 if(timestamp <= wanted_timestamp)
1770 wanted_timestamp, flags);
1774 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1776 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1777 if (stream_index >= 0)
1786 int64_t ts_min, ts_max, ts;
1791 if (stream_index < 0)
1805 index=
FFMAX(index, 0);
1811 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1818 assert(index < st->nb_index_entries);
1825 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
" dts_max=%s\n",
1830 pos=
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->
read_timestamp);
1845 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1846 int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
1847 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1850 int64_t start_pos, filesize;
1857 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1862 if(ts_min >= target_ts){
1871 pos_max = filesize - 1;
1874 pos_max =
FFMAX(0, pos_max - step);
1882 int64_t tmp_pos= pos_max + 1;
1883 int64_t tmp_ts=
ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp);
1888 if(tmp_pos >= filesize)
1894 if(ts_max <= target_ts){
1899 if(ts_min > ts_max){
1901 }
else if(ts_min == ts_max){
1906 while (pos_min < pos_limit) {
1907 av_dlog(s,
"pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1909 assert(pos_limit <= pos_max);
1912 int64_t approximate_keyframe_distance= pos_max - pos_limit;
1914 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min)
1915 + pos_min - approximate_keyframe_distance;
1916 }
else if(no_change==1){
1918 pos = (pos_min + pos_limit)>>1;
1926 else if(pos > pos_limit)
1935 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1936 pos_min, pos, pos_max,
1938 pos_limit, start_pos, no_change);
1944 if (target_ts <= ts) {
1945 pos_limit = start_pos - 1;
1949 if (target_ts >= ts) {
1959 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1961 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1962 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
1970 int64_t pos_min, pos_max;
1975 if (pos < pos_min) pos= pos_min;
1976 else if(pos > pos_max) pos= pos_max;
1984 int stream_index, int64_t timestamp,
int flags)
1991 st = s->
streams[stream_index];
1995 if(index < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
1998 if(index < 0 || index==st->nb_index_entries-1){
2016 }
while (read_status ==
AVERROR(EAGAIN));
2017 if (read_status < 0)
2024 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);
2048 int64_t timestamp,
int flags)
2060 if(stream_index < 0){
2062 if(stream_index < 0)
2103 if(min_ts > ts || max_ts < ts)
2113 if (stream_index == -1 && s->
nb_streams == 1) {
2120 time_base.
num * (int64_t)AV_TIME_BASE,
2140 if (ret<0 && ts != min_ts && max_ts != ts) {
2141 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2181 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2182 int64_t
duration, duration1, filesize;
2187 start_time = INT64_MAX;
2188 start_time_text = INT64_MAX;
2189 end_time = INT64_MIN;
2190 duration = INT64_MIN;
2196 if (start_time1 < start_time_text)
2197 start_time_text = start_time1;
2199 start_time =
FFMIN(start_time, start_time1);
2202 end_time1 = start_time1
2204 end_time =
FFMAX(end_time, end_time1);
2215 duration =
FFMAX(duration, duration1);
2218 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2219 start_time = start_time_text;
2220 else if(start_time > start_time_text)
2223 if (start_time != INT64_MAX) {
2225 if (end_time != INT64_MIN) {
2233 duration =
FFMAX(duration, end_time - start_time);
2241 double bitrate = (double)filesize * 8.0 * AV_TIME_BASE /
2243 if (bitrate >= 0 && bitrate <= INT_MAX)
2297 #define DURATION_MAX_READ_SIZE 250000LL
2298 #define DURATION_MAX_RETRY 4
2305 int read_size, i, ret;
2341 }
while(ret ==
AVERROR(EAGAIN));
2344 read_size += pkt->
size;
2349 duration = end_time = pkt->
pts;
2387 file_size =
FFMAX(0, file_size);
2414 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2418 av_dlog(ic,
"stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2429 #define FAIL(errmsg) do { \
2431 *errmsg_ptr = errmsg; \
2438 FAIL(
"unspecified frame size");
2440 FAIL(
"unspecified sample format");
2442 FAIL(
"unspecified sample rate");
2444 FAIL(
"unspecified number of channels");
2446 FAIL(
"no decodable DTS frames");
2450 FAIL(
"unspecified size");
2452 FAIL(
"unspecified pixel format");
2455 FAIL(
"no frame in rv30/40 and no sar");
2459 FAIL(
"unspecified size");
2466 FAIL(
"unknown codec");
2474 int got_picture = 1, ret = 0;
2496 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2513 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2523 &got_picture, &pkt);
2530 &got_picture, &pkt);
2545 if(!pkt.
data && !got_picture)
2567 if(tag == tags[i].tag)
2588 if (sflags & (1 << (bps - 1))) {
2620 for(i=0; tags && tags[i]; i++){
2623 if (codec_tags->
id ==
id) {
2624 *tag = codec_tags->
tag;
2636 for(i=0; tags && tags[i]; i++){
2657 if (j != i && next_start > ch->
start && next_start < end)
2660 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2665 if(i<60*12)
return (i+1)*1001;
2666 else return ((
const int[]){24,30,60,12,15,48})[i-60*12]*1000*12;
2690 #if FF_API_FORMAT_PARAMETERS
2699 int i, count, ret, read_size, j;
2732 "%s, packets or times may be invalid.\n",
2741 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
2760 #if FF_API_R_FRAME_RATE
2778 int fps_analyze_framecount = 20;
2787 fps_analyze_framecount *= 2;
2791 fps_analyze_framecount = 0;
2821 if (!ic->
streams[i]->r_frame_rate.num &&
2824 "Stream #%d: not enough frames to estimate rate; "
2825 "consider increasing probesize\n", i);
2846 goto find_stream_info_err;
2851 read_size += pkt->
size;
2858 "packet %d with DTS %"PRId64
", packet %d with DTS "
2871 "packet %d with DTS %"PRId64
", packet %d with DTS "
2901 #if FF_API_R_FRAME_RATE
2906 && pkt->
dts - (uint64_t)last < INT64_MAX){
2917 double sdts= dts*framerate/(1001*12);
2919 int64_t ticks=
llrint(sdts+j*0.5);
2920 double error= sdts - ticks + j*0.5;
2976 (options && i < orig_nb_streams) ?
2977 &options[i] :
NULL);
2982 "decoding for stream %d failed\n", st->
index);
2990 "Could not find codec parameters for stream %d (%s): %s\n"
2991 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3016 double best_error = 0.01;
3028 if (error < best_error) {
3030 best_fps = std_fps.
num;
3035 best_fps, 12*1001, INT_MAX);
3046 double best_error= 0.01;
3060 if(error < best_error && best_error> 0.000000001){
3069 if (num && (!st->r_frame_rate.num || (
double)num/(12*1001) < 1.01 *
av_q2d(st->r_frame_rate)))
3070 av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
3073 if (!st->r_frame_rate.num){
3107 find_stream_info_err:
3140 int wanted_stream_nb,
3146 int ret =
AVERROR_STREAM_NOT_FOUND, best_count = -1, best_bitrate = -1, best_multiframe = -1, count, bitrate, multiframe;
3147 unsigned *program =
NULL;
3150 if (related_stream >= 0 && wanted_stream_nb < 0) {
3157 for (i = 0; i < nb_streams; i++) {
3158 int real_stream_index = program ? program[i] : i;
3163 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3177 multiframe =
FFMIN(5, count);
3178 if ((best_multiframe > multiframe) ||
3179 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3180 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count))
3183 best_bitrate = bitrate;
3184 best_multiframe = multiframe;
3185 ret = real_stream_index;
3187 if (program && i == nb_streams - 1 && ret < 0) {
3194 *decoder_ret = best_decoder;
3271 #if FF_API_CLOSE_INPUT_FILE
3301 #if FF_API_NEW_STREAM
3317 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3360 #if FF_API_R_FRAME_RATE
3375 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3416 chapter->
start = start;
3464 if(strcmp(
"language", tag->
key)){
3465 const char *p = tag->
value;
3469 size_t len = strcspn(p,
"\x8\xa\xb\xc\xd");
3510 display_aspect_ratio.
num, display_aspect_ratio.
den);
3515 #if FF_API_R_FRAME_RATE
3516 if(st->r_frame_rate.den && st->r_frame_rate.num)
3559 is_output ?
"Output" :
"Input",
3562 is_output ?
"to" :
"from", url);
3567 int hours, mins, secs, us;
3605 int j, k, total = 0;
3610 name ? name->
value :
"");
3618 if (total < ic->nb_streams)
3628 #if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER
3629 FF_SYMVER(int64_t,
av_gettime, (
void),
"LIBAVFORMAT_54")
3641 const char *path,
int number)
3644 char *q, buf1[20],
c;
3645 int nd,
len, percentd_found;
3658 nd = nd * 10 + *p++ -
'0';
3670 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3672 if ((q - buf + len) > buf_size - 1)
3674 memcpy(q, buf1, len);
3682 if ((q - buf) < buf_size - 1)
3686 if (!percentd_found)
3699 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3701 for(i=0;i<
size;i+=16) {
3708 PRINT(
" %02x", buf[i+j]);
3713 for(j=0;j<
len;j++) {
3715 if (c < ' ' || c >
'~')
3736 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3760 void av_pkt_dump(FILE *f,
AVPacket *
pkt,
int dump_payload)
3773 void av_pkt_dump_log(
void *avcl,
int level,
AVPacket *
pkt,
int dump_payload)
3787 char *authorization,
int authorization_size,
3788 char *hostname,
int hostname_size,
3790 char *path,
int path_size,
3793 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3795 if (port_ptr) *port_ptr = -1;
3796 if (proto_size > 0) proto[0] = 0;
3797 if (authorization_size > 0) authorization[0] = 0;
3798 if (hostname_size > 0) hostname[0] = 0;
3799 if (path_size > 0) path[0] = 0;
3802 if ((p = strchr(url,
':'))) {
3814 ls = strchr(p,
'/');
3815 ls2 = strchr(p,
'?');
3819 ls =
FFMIN(ls, ls2);
3829 while ((at = strchr(p,
'@')) && at < ls) {
3831 FFMIN(authorization_size, at + 1 - at2));
3835 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3838 FFMIN(hostname_size, brk - p));
3839 if (brk[1] ==
':' && port_ptr)
3840 *port_ptr = atoi(brk + 2);
3841 }
else if ((col = strchr(p,
':')) && col < ls) {
3843 FFMIN(col + 1 - p, hostname_size));
3844 if (port_ptr) *port_ptr = atoi(col + 1);
3847 FFMIN(ls + 1 - p, hostname_size));
3854 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3857 'C',
'D',
'E',
'F' };
3858 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3861 'c',
'd',
'e',
'f' };
3862 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3864 for(i = 0; i < s; i++) {
3865 buff[i * 2] = hex_table[src[i] >> 4];
3866 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3883 if (c >=
'0' && c <=
'9')
3885 else if (c >=
'A' && c <=
'F')
3900 #if FF_API_SET_PTS_INFO
3901 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
3902 unsigned int pts_num,
unsigned int pts_den)
3909 unsigned int pts_num,
unsigned int pts_den)
3913 if(new_tb.
num != pts_num)
3918 if(new_tb.
num <= 0 || new_tb.
den <= 0) {
3928 const char *authorization,
const char *hostname,
3929 int port,
const char *
fmt, ...)
3932 struct addrinfo hints = { 0 }, *ai;
3938 if (authorization && authorization[0])
3940 #if CONFIG_NETWORK && defined(AF_INET6)
3945 if (ai->ai_family == AF_INET6) {
3962 int len = strlen(str);
3965 vsnprintf(str + len, size > len ? size - len : 0, fmt, vl);
3996 const char *ptr = str;
4001 char *dest =
NULL, *dest_end;
4002 int key_len, dest_len = 0;
4005 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4012 if (!(ptr = strchr(key,
'=')))
4015 key_len = ptr - key;
4017 callback_get_buf(context, key, key_len, &dest, &dest_len);
4018 dest_end = dest + dest_len - 1;
4022 while (*ptr && *ptr !=
'\"') {
4026 if (dest && dest < dest_end)
4030 if (dest && dest < dest_end)
4038 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4039 if (dest && dest < dest_end)
4060 char *sep, *path_query;
4062 if (base && strstr(base,
"://") && rel[0] ==
'/') {
4065 sep = strstr(buf,
"://");
4068 if (rel[1] ==
'/') {
4073 sep = strchr(sep,
'/');
4082 if (!base || strstr(rel,
"://") || rel[0] ==
'/') {
4090 path_query = strchr(buf,
'?');
4091 if (path_query !=
NULL)
4095 if (rel[0] ==
'?') {
4101 sep = strrchr(buf,
'/');
4109 sep = strrchr(buf,
'/');
4111 if (!strcmp(sep ? &sep[1] : buf,
"..")) {
4128 struct tm time1 = {0}, time2 = {0};
4142 return ofmt->
query_codec(codec_id, std_compliance);
4186 if (channel_layout) {
4194 if (width || height) {
4201 bytestream_put_le32(&data, flags);
4203 bytestream_put_le32(&data, channels);
4205 bytestream_put_le64(&data, channel_layout);
4207 bytestream_put_le32(&data, sample_rate);
4208 if (width || height) {
4209 bytestream_put_le32(&data, width);
4210 bytestream_put_le32(&data, height);
4231 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4232 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4233 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4234 stream_sample_aspect_ratio = undef;
4236 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4237 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4238 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4239 frame_sample_aspect_ratio = undef;
4241 if (stream_sample_aspect_ratio.
num)
4242 return stream_sample_aspect_ratio;
4244 return frame_sample_aspect_ratio;
4250 if (*spec <= '9' && *spec >=
'0')
4251 return strtol(spec,
NULL, 0) == st->
index;
4252 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4266 if (*spec++ ==
':') {
4270 return i == st->
index;
4274 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4278 prog_id = strtol(spec, &endptr, 0);
4283 if (*endptr++ ==
':') {
4284 int stream_idx = strtol(endptr,
NULL, 0);
4285 return stream_idx >= 0 &&
4295 }
else if (*spec ==
'#') {
4298 sid = strtol(spec + 1, &endptr, 0);
4300 return st->
id == sid;
4310 static const uint8_t avci100_1080p_extradata[] = {
4312 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4313 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4314 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4315 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4316 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4317 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4318 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4319 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4320 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4322 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4325 static const uint8_t avci100_1080i_extradata[] = {
4327 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4328 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4329 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4330 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4331 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4332 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4333 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4334 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4335 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4336 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4337 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
4339 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4342 static const uint8_t avci50_1080i_extradata[] = {
4344 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4345 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4346 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4347 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4348 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4349 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4350 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4351 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4352 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4353 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4354 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4356 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4359 static const uint8_t avci100_720p_extradata[] = {
4361 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4362 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4363 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4364 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4365 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4366 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4367 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4368 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4369 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4370 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4372 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4379 data = avci100_1080p_extradata;
4380 size =
sizeof(avci100_1080p_extradata);
4382 data = avci100_1080i_extradata;
4383 size =
sizeof(avci100_1080i_extradata);
4386 data = avci50_1080i_extradata;
4387 size =
sizeof(avci50_1080i_extradata);
4389 data = avci100_720p_extradata;
4390 size =
sizeof(avci100_720p_extradata);
4406 if (!strcmp(pattern,
"*"))
4409 if (pattern[0] ==
'*')
4411 if (pattern[0] ==
'.')
4413 len_p = strlen(pattern);
4414 len_h = strlen(hostname);
4418 if (!strcmp(pattern, &hostname[len_h - len_p])) {
4421 if (hostname[len_h - len_p - 1] ==
'.')
4440 char *sep, *next =
NULL;
4441 start += strspn(start,
" ,");
4442 sep = start + strcspn(start,
" ,");