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"))
1181 presentation_delayed = 1;
1183 av_dlog(
NULL,
"IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%d\n",
1188 if (presentation_delayed) {
1238 av_dlog(
NULL,
"OUTdelayed:%d/%d pts:%s, dts:%s cur_dts:%s\n",
1252 *pkt_buf = pktl->
next;
1256 *pkt_buf_end =
NULL;
1270 int ret = 0, got_output = 0;
1281 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1286 &out_pkt.
data, &out_pkt.
size, data, size,
1295 got_output = !!out_pkt.
size;
1369 *pkt_buffer = pktl->
next;
1371 *pkt_buffer_end =
NULL;
1378 int ret = 0, i, got_packet = 0;
1406 cur_pkt.
pts < cur_pkt.
dts) {
1414 av_log(s,
AV_LOG_DEBUG,
"ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1426 "%s, packets or times may be invalid.\n",
1471 av_log(s,
AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
1508 int64_t last_dts = next_pkt->
dts;
1517 last_dts = pktl->
pkt.
dts;
1544 if (pktl && ret !=
AVERROR(EAGAIN)) {
1594 int first_audio_index = -1;
1607 first_audio_index = i;
1609 return first_audio_index >= 0 ? first_audio_index : 0;
1669 int *nb_index_entries,
1670 unsigned int *index_entries_allocated_size,
1676 if((
unsigned)*nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1686 index_entries_allocated_size,
1687 (*nb_index_entries + 1) *
1692 *index_entries= entries;
1697 index= (*nb_index_entries)++;
1698 ie= &entries[
index];
1699 assert(index==0 || ie[-1].timestamp < timestamp);
1701 ie= &entries[
index];
1705 memmove(entries + index + 1, entries + index,
sizeof(
AVIndexEntry)*(*nb_index_entries - index));
1706 (*nb_index_entries)++;
1707 }
else if(ie->
pos == pos && distance < ie->min_distance)
1726 timestamp, size, distance, flags);
1730 int64_t wanted_timestamp,
int flags)
1739 if(b && entries[b-1].timestamp < wanted_timestamp)
1745 if(timestamp >= wanted_timestamp)
1747 if(timestamp <= wanted_timestamp)
1767 wanted_timestamp, flags);
1771 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1773 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
1774 if (stream_index >= 0)
1783 int64_t ts_min, ts_max, ts;
1788 if (stream_index < 0)
1802 index=
FFMAX(index, 0);
1808 av_dlog(s,
"using cached pos_min=0x%"PRIx64
" dts_min=%s\n",
1815 assert(index < st->nb_index_entries);
1822 av_dlog(s,
"using cached pos_max=0x%"PRIx64
" pos_limit=0x%"PRIx64
" dts_max=%s\n",
1827 pos=
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->
read_timestamp);
1842 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
1843 int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
1844 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
1847 int64_t start_pos, filesize;
1854 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1859 if(ts_min >= target_ts){
1868 pos_max = filesize - 1;
1871 pos_max =
FFMAX(0, pos_max - step);
1879 int64_t tmp_pos= pos_max + 1;
1880 int64_t tmp_ts=
ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp);
1885 if(tmp_pos >= filesize)
1891 if(ts_max <= target_ts){
1896 if(ts_min > ts_max){
1898 }
else if(ts_min == ts_max){
1903 while (pos_min < pos_limit) {
1904 av_dlog(s,
"pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
1906 assert(pos_limit <= pos_max);
1909 int64_t approximate_keyframe_distance= pos_max - pos_limit;
1911 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min)
1912 + pos_min - approximate_keyframe_distance;
1913 }
else if(no_change==1){
1915 pos = (pos_min + pos_limit)>>1;
1923 else if(pos > pos_limit)
1932 av_dlog(s,
"%"PRId64
" %"PRId64
" %"PRId64
" / %s %s %s target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
1933 pos_min, pos, pos_max,
1935 pos_limit, start_pos, no_change);
1941 if (target_ts <= ts) {
1942 pos_limit = start_pos - 1;
1946 if (target_ts >= ts) {
1956 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1958 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
1959 av_dlog(s,
"pos=0x%"PRIx64
" %s<=%s<=%s\n",
1967 int64_t pos_min, pos_max;
1972 if (pos < pos_min) pos= pos_min;
1973 else if(pos > pos_max) pos= pos_max;
1981 int stream_index, int64_t timestamp,
int flags)
1988 st = s->
streams[stream_index];
1992 if(index < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
1995 if(index < 0 || index==st->nb_index_entries-1){
2013 }
while (read_status ==
AVERROR(EAGAIN));
2014 if (read_status < 0)
2021 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);
2045 int64_t timestamp,
int flags)
2057 if(stream_index < 0){
2059 if(stream_index < 0)
2100 if(min_ts > ts || max_ts < ts)
2110 if (stream_index == -1 && s->
nb_streams == 1) {
2117 time_base.
num * (int64_t)AV_TIME_BASE,
2137 if (ret<0 && ts != min_ts && max_ts != ts) {
2138 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2178 int64_t
start_time, start_time1, start_time_text, end_time, end_time1;
2179 int64_t
duration, duration1, filesize;
2184 start_time = INT64_MAX;
2185 start_time_text = INT64_MAX;
2186 end_time = INT64_MIN;
2187 duration = INT64_MIN;
2193 if (start_time1 < start_time_text)
2194 start_time_text = start_time1;
2196 start_time =
FFMIN(start_time, start_time1);
2199 end_time1 = start_time1
2201 end_time =
FFMAX(end_time, end_time1);
2212 duration =
FFMAX(duration, duration1);
2215 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text <
AV_TIME_BASE))
2216 start_time = start_time_text;
2217 else if(start_time > start_time_text)
2220 if (start_time != INT64_MAX) {
2222 if (end_time != INT64_MIN) {
2230 duration =
FFMAX(duration, end_time - start_time);
2238 double bitrate = (double)filesize * 8.0 * AV_TIME_BASE /
2240 if (bitrate >= 0 && bitrate <= INT_MAX)
2294 #define DURATION_MAX_READ_SIZE 250000LL
2295 #define DURATION_MAX_RETRY 4
2302 int read_size, i, ret;
2338 }
while(ret ==
AVERROR(EAGAIN));
2341 read_size += pkt->
size;
2346 duration = end_time = pkt->
pts;
2384 file_size =
FFMAX(0, file_size);
2411 av_dlog(ic,
"%d: start_time: %0.3f duration: %0.3f\n", i,
2415 av_dlog(ic,
"stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n",
2426 #define FAIL(errmsg) do { \
2428 *errmsg_ptr = errmsg; \
2435 FAIL(
"unspecified frame size");
2437 FAIL(
"unspecified sample format");
2439 FAIL(
"unspecified sample rate");
2441 FAIL(
"unspecified number of channels");
2443 FAIL(
"no decodable DTS frames");
2447 FAIL(
"unspecified size");
2449 FAIL(
"unspecified pixel format");
2452 FAIL(
"no frame in rv30/40 and no sar");
2456 FAIL(
"unspecified size");
2463 FAIL(
"unknown codec");
2471 int got_picture = 1, ret = 0;
2493 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
2510 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
2520 &got_picture, &pkt);
2527 &got_picture, &pkt);
2542 if(!pkt.
data && !got_picture)
2564 if(tag == tags[i].tag)
2585 if (sflags & (1 << (bps - 1))) {
2617 for(i=0; tags && tags[i]; i++){
2620 if (codec_tags->
id ==
id) {
2621 *tag = codec_tags->
tag;
2633 for(i=0; tags && tags[i]; i++){
2654 if (j != i && next_start > ch->
start && next_start < end)
2657 ch->
end = (end == INT64_MAX) ? ch->
start : end;
2662 if(i<60*12)
return (i+1)*1001;
2663 else return ((
const int[]){24,30,60,12,15,48})[i-60*12]*1000*12;
2687 #if FF_API_FORMAT_PARAMETERS
2696 int i, count, ret, read_size, j;
2729 "%s, packets or times may be invalid.\n",
2738 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
2757 #if FF_API_R_FRAME_RATE
2775 int fps_analyze_framecount = 20;
2784 fps_analyze_framecount *= 2;
2788 fps_analyze_framecount = 0;
2818 if (!ic->
streams[i]->r_frame_rate.num &&
2821 "Stream #%d: not enough frames to estimate rate; "
2822 "consider increasing probesize\n", i);
2843 goto find_stream_info_err;
2846 read_size += pkt->
size;
2854 "packet %d with DTS %"PRId64
", packet %d with DTS "
2867 "packet %d with DTS %"PRId64
", packet %d with DTS "
2897 #if FF_API_R_FRAME_RATE
2902 && pkt->
dts - (uint64_t)last < INT64_MAX){
2913 double sdts= dts*framerate/(1001*12);
2915 int64_t ticks=
llrint(sdts+j*0.5);
2916 double error= sdts - ticks + j*0.5;
2972 (options && i < orig_nb_streams) ?
2973 &options[i] :
NULL);
2978 "decoding for stream %d failed\n", st->
index);
2986 "Could not find codec parameters for stream %d (%s): %s\n"
2987 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
3012 double best_error = 0.01;
3024 if (error < best_error) {
3026 best_fps = std_fps.
num;
3031 best_fps, 12*1001, INT_MAX);
3042 double best_error= 0.01;
3056 if(error < best_error && best_error> 0.000000001){
3065 if (num && (!st->r_frame_rate.num || (
double)num/(12*1001) < 1.01 *
av_q2d(st->r_frame_rate)))
3066 av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
3069 if (!st->r_frame_rate.num){
3103 find_stream_info_err:
3136 int wanted_stream_nb,
3142 int ret =
AVERROR_STREAM_NOT_FOUND, best_count = -1, best_bitrate = -1, best_multiframe = -1, count, bitrate, multiframe;
3143 unsigned *program =
NULL;
3146 if (related_stream >= 0 && wanted_stream_nb < 0) {
3153 for (i = 0; i < nb_streams; i++) {
3154 int real_stream_index = program ? program[i] : i;
3159 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
3173 multiframe =
FFMIN(5, count);
3174 if ((best_multiframe > multiframe) ||
3175 (best_multiframe == multiframe && best_bitrate > bitrate) ||
3176 (best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count))
3179 best_bitrate = bitrate;
3180 best_multiframe = multiframe;
3181 ret = real_stream_index;
3183 if (program && i == nb_streams - 1 && ret < 0) {
3190 *decoder_ret = best_decoder;
3267 #if FF_API_CLOSE_INPUT_FILE
3297 #if FF_API_NEW_STREAM
3313 if (s->
nb_streams >= INT_MAX/
sizeof(*streams))
3356 #if FF_API_R_FRAME_RATE
3371 av_dlog(ac,
"new_program: id=0x%04x\n",
id);
3412 chapter->
start = start;
3460 if(strcmp(
"language", tag->
key)){
3461 const char *p = tag->
value;
3465 size_t len = strcspn(p,
"\x8\xa\xb\xc\xd");
3506 display_aspect_ratio.
num, display_aspect_ratio.
den);
3511 #if FF_API_R_FRAME_RATE
3512 if(st->r_frame_rate.den && st->r_frame_rate.num)
3555 is_output ?
"Output" :
"Input",
3558 is_output ?
"to" :
"from", url);
3563 int hours, mins, secs, us;
3601 int j, k, total = 0;
3606 name ? name->
value :
"");
3614 if (total < ic->nb_streams)
3624 #if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER
3625 FF_SYMVER(int64_t,
av_gettime, (
void),
"LIBAVFORMAT_54")
3637 const char *path,
int number)
3640 char *q, buf1[20],
c;
3641 int nd,
len, percentd_found;
3654 nd = nd * 10 + *p++ -
'0';
3666 snprintf(buf1,
sizeof(buf1),
"%0*d", nd, number);
3668 if ((q - buf + len) > buf_size - 1)
3670 memcpy(q, buf1, len);
3678 if ((q - buf) < buf_size - 1)
3682 if (!percentd_found)
3695 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3697 for(i=0;i<
size;i+=16) {
3704 PRINT(
" %02x", buf[i+j]);
3709 for(j=0;j<
len;j++) {
3711 if (c < ' ' || c >
'~')
3732 #define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
3756 void av_pkt_dump(FILE *f,
AVPacket *
pkt,
int dump_payload)
3769 void av_pkt_dump_log(
void *avcl,
int level,
AVPacket *
pkt,
int dump_payload)
3783 char *authorization,
int authorization_size,
3784 char *hostname,
int hostname_size,
3786 char *path,
int path_size,
3789 const char *p, *ls, *ls2, *at, *at2, *col, *brk;
3791 if (port_ptr) *port_ptr = -1;
3792 if (proto_size > 0) proto[0] = 0;
3793 if (authorization_size > 0) authorization[0] = 0;
3794 if (hostname_size > 0) hostname[0] = 0;
3795 if (path_size > 0) path[0] = 0;
3798 if ((p = strchr(url,
':'))) {
3810 ls = strchr(p,
'/');
3811 ls2 = strchr(p,
'?');
3815 ls =
FFMIN(ls, ls2);
3825 while ((at = strchr(p,
'@')) && at < ls) {
3827 FFMIN(authorization_size, at + 1 - at2));
3831 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
3834 FFMIN(hostname_size, brk - p));
3835 if (brk[1] ==
':' && port_ptr)
3836 *port_ptr = atoi(brk + 2);
3837 }
else if ((col = strchr(p,
':')) && col < ls) {
3839 FFMIN(col + 1 - p, hostname_size));
3840 if (port_ptr) *port_ptr = atoi(col + 1);
3843 FFMIN(ls + 1 - p, hostname_size));
3850 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
3853 'C',
'D',
'E',
'F' };
3854 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
3857 'c',
'd',
'e',
'f' };
3858 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
3860 for(i = 0; i < s; i++) {
3861 buff[i * 2] = hex_table[src[i] >> 4];
3862 buff[i * 2 + 1] = hex_table[src[i] & 0xF];
3879 if (c >=
'0' && c <=
'9')
3881 else if (c >=
'A' && c <=
'F')
3896 #if FF_API_SET_PTS_INFO
3897 void av_set_pts_info(
AVStream *s,
int pts_wrap_bits,
3898 unsigned int pts_num,
unsigned int pts_den)
3905 unsigned int pts_num,
unsigned int pts_den)
3909 if(new_tb.
num != pts_num)
3914 if(new_tb.
num <= 0 || new_tb.
den <= 0) {
3924 const char *authorization,
const char *hostname,
3925 int port,
const char *
fmt, ...)
3928 struct addrinfo hints = { 0 }, *ai;
3934 if (authorization && authorization[0])
3936 #if CONFIG_NETWORK && defined(AF_INET6)
3941 if (ai->ai_family == AF_INET6) {
3958 int len = strlen(str);
3961 vsnprintf(str + len, size > len ? size - len : 0, fmt, vl);
3992 const char *ptr = str;
3997 char *dest =
NULL, *dest_end;
3998 int key_len, dest_len = 0;
4001 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
4008 if (!(ptr = strchr(key,
'=')))
4011 key_len = ptr - key;
4013 callback_get_buf(context, key, key_len, &dest, &dest_len);
4014 dest_end = dest + dest_len - 1;
4018 while (*ptr && *ptr !=
'\"') {
4022 if (dest && dest < dest_end)
4026 if (dest && dest < dest_end)
4034 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
4035 if (dest && dest < dest_end)
4056 char *sep, *path_query;
4058 if (base && strstr(base,
"://") && rel[0] ==
'/') {
4061 sep = strstr(buf,
"://");
4064 if (rel[1] ==
'/') {
4069 sep = strchr(sep,
'/');
4078 if (!base || strstr(rel,
"://") || rel[0] ==
'/') {
4086 path_query = strchr(buf,
'?');
4087 if (path_query !=
NULL)
4091 if (rel[0] ==
'?') {
4097 sep = strrchr(buf,
'/');
4105 sep = strrchr(buf,
'/');
4107 if (!strcmp(sep ? &sep[1] : buf,
"..")) {
4124 struct tm time1 = {0}, time2 = {0};
4138 return ofmt->
query_codec(codec_id, std_compliance);
4182 if (channel_layout) {
4190 if (width || height) {
4197 bytestream_put_le32(&data, flags);
4199 bytestream_put_le32(&data, channels);
4201 bytestream_put_le64(&data, channel_layout);
4203 bytestream_put_le32(&data, sample_rate);
4204 if (width || height) {
4205 bytestream_put_le32(&data, width);
4206 bytestream_put_le32(&data, height);
4227 av_reduce(&stream_sample_aspect_ratio.
num, &stream_sample_aspect_ratio.
den,
4228 stream_sample_aspect_ratio.
num, stream_sample_aspect_ratio.
den, INT_MAX);
4229 if (stream_sample_aspect_ratio.
num <= 0 || stream_sample_aspect_ratio.
den <= 0)
4230 stream_sample_aspect_ratio = undef;
4232 av_reduce(&frame_sample_aspect_ratio.
num, &frame_sample_aspect_ratio.
den,
4233 frame_sample_aspect_ratio.
num, frame_sample_aspect_ratio.
den, INT_MAX);
4234 if (frame_sample_aspect_ratio.
num <= 0 || frame_sample_aspect_ratio.
den <= 0)
4235 frame_sample_aspect_ratio = undef;
4237 if (stream_sample_aspect_ratio.
num)
4238 return stream_sample_aspect_ratio;
4240 return frame_sample_aspect_ratio;
4246 if (*spec <= '9' && *spec >=
'0')
4247 return strtol(spec,
NULL, 0) == st->
index;
4248 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
4262 if (*spec++ ==
':') {
4266 return i == st->
index;
4270 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
4274 prog_id = strtol(spec, &endptr, 0);
4279 if (*endptr++ ==
':') {
4280 int stream_idx = strtol(endptr,
NULL, 0);
4281 return stream_idx >= 0 &&
4291 }
else if (*spec ==
'#') {
4294 sid = strtol(spec + 1, &endptr, 0);
4296 return st->
id == sid;
4306 static const uint8_t avci100_1080p_extradata[] = {
4308 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4309 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4310 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4311 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
4312 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
4313 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
4314 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
4315 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
4316 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4318 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4321 static const uint8_t avci100_1080i_extradata[] = {
4323 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4324 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
4325 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
4326 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
4327 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
4328 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
4329 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
4330 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
4331 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
4332 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
4333 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
4335 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
4338 static const uint8_t avci50_1080i_extradata[] = {
4340 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
4341 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
4342 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
4343 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
4344 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
4345 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
4346 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
4347 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
4348 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
4349 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
4350 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
4352 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
4355 static const uint8_t avci100_720p_extradata[] = {
4357 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
4358 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
4359 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
4360 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
4361 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
4362 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
4363 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
4364 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
4365 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
4366 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
4368 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
4375 data = avci100_1080p_extradata;
4376 size =
sizeof(avci100_1080p_extradata);
4378 data = avci100_1080i_extradata;
4379 size =
sizeof(avci100_1080i_extradata);
4382 data = avci50_1080i_extradata;
4383 size =
sizeof(avci50_1080i_extradata);
4385 data = avci100_720p_extradata;
4386 size =
sizeof(avci100_720p_extradata);
4402 if (!strcmp(pattern,
"*"))
4405 if (pattern[0] ==
'*')
4407 if (pattern[0] ==
'.')
4409 len_p = strlen(pattern);
4410 len_h = strlen(hostname);
4414 if (!strcmp(pattern, &hostname[len_h - len_p])) {
4417 if (hostname[len_h - len_p - 1] ==
'.')
4436 char *sep, *next =
NULL;
4437 start += strspn(start,
" ,");
4438 sep = start + strcspn(start,
" ,");