55#define SANE_CHUNK_SIZE (50000000)
61 int orig_size =
pkt->size;
65 int prev_size =
pkt->size;
83 if (ret != read_size) {
95 return pkt->size > orig_size ?
pkt->size - orig_size : ret;
100#if FF_API_INIT_PACKET
171 if (sflags & (1 << (
bps - 1))) {
214 for (
int i = 0; tags && tags[
i];
i++) {
217 if (codec_tags->
id ==
id) {
229 for (
int i = 0; tags && tags[
i];
i++) {
264 uint64_t ntp_ts, frac_part, sec;
268 sec = ntp_time_us / 1000000;
269 usec = ntp_time_us % 1000000;
272 frac_part = usec * 0xFFFFFFFFULL;
273 frac_part /= 1000000;
275 if (sec > 0xFFFFFFFFULL)
286 uint64_t sec = ntp_ts >> 32;
287 uint64_t frac_part = ntp_ts & 0xFFFFFFFFULL;
288 uint64_t usec = (frac_part * 1000000) / 0xFFFFFFFFULL;
290 return (sec * 1000000) + usec;
297 int nd, percentd_found;
309 if (nd >= INT_MAX / 10 - 255)
311 nd = nd * 10 + *p++ -
'0';
362 char *authorization,
int authorization_size,
363 char *hostname,
int hostname_size,
364 int *port_ptr,
char *path,
int path_size,
const char *url)
366 const char *p, *ls, *at, *at2, *col, *brk;
372 if (authorization_size > 0)
373 authorization[0] = 0;
374 if (hostname_size > 0)
380 if ((p = strchr(url,
':'))) {
394 ls = p + strcspn(p,
"/?#");
401 while ((at = strchr(p,
'@')) && at < ls) {
403 FFMIN(authorization_size, at + 1 - at2));
407 if (*p ==
'[' && (brk = strchr(p,
']')) && brk < ls) {
410 FFMIN(hostname_size, brk - p));
411 if (brk[1] ==
':' && port_ptr)
412 *port_ptr = atoi(brk + 2);
413 }
else if ((col = strchr(p,
':')) && col < ls) {
415 FFMIN(col + 1 - p, hostname_size));
417 *port_ptr = atoi(col + 1);
420 FFMIN(ls + 1 - p, hostname_size));
431 if (!path || !
temp) {
441 for ( ; *
pos !=
'\0'; ++
pos) {
442 if (*
pos ==
'/' || *
pos ==
'\\') {
445 ret = mkdir(
temp, 0755);
446 if (ret < 0 && errno != EEXIST) {
456 if ((*(
pos - 1) !=
'/') && (*(
pos - 1) !=
'\\')) {
457 ret = mkdir(
temp, 0755);
466 static const char hex_table_uc[16] = {
'0',
'1',
'2',
'3',
469 'C',
'D',
'E',
'F' };
470 static const char hex_table_lc[16] = {
'0',
'1',
'2',
'3',
473 'c',
'd',
'e',
'f' };
474 const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
476 for (
int i = 0;
i <
s;
i++) {
477 buff[
i * 2] = hex_table[
src[
i] >> 4];
478 buff[
i * 2 + 1] = hex_table[
src[
i] & 0xF];
496 if (
c >=
'0' &&
c <=
'9')
498 else if (
c >=
'A' &&
c <=
'F')
516 const char *ptr = str;
521 char *dest =
NULL, *dest_end;
522 int key_len, dest_len = 0;
525 while (*ptr && (
av_isspace(*ptr) || *ptr ==
','))
532 if (!(ptr = strchr(
key,
'=')))
537 callback_get_buf(context,
key, key_len, &dest, &dest_len);
538 dest_end = dest ? dest + dest_len - 1 :
NULL;
542 while (*ptr && *ptr !=
'\"') {
546 if (dest && dest < dest_end)
550 if (dest && dest < dest_end)
558 for (; *ptr && !(
av_isspace(*ptr) || *ptr ==
','); ptr++)
559 if (dest && dest < dest_end)
618 int microsecs = timestamp % 1000000;
619 time_t seconds = timestamp / 1000000 - (microsecs < 0);
620 struct tm *ptm, tmbuf;
624 if (!strftime(buf,
sizeof(buf),
"%Y-%m-%dT%H:%M:%S", ptm))
626 av_strlcatf(buf,
sizeof(buf),
".%06dZ", microsecs + (microsecs < 0) * 1000000);
635 char decoded_name[128];
652 size_t len = strcspn(str,
"=&");
655 if (!allow_unknown) {
663 len = strcspn(str,
"&");
665 }
else if (*str ==
'&' || *str ==
'\0') {
679 len = strcspn(str,
"&");
702 uint8_t *p =
av_malloc(fam_offset + bp->len);
707 memcpy(p, struct_ptr, fam_offset);
708 memcpy(p + fam_offset, bp->str, bp->len);
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
int ffio_limit(AVIOContext *s, int size)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_COUNT_ONLY
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int avformat_network_init(void)
Do global initialization of network libraries.
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
Return in 'buf' the path with 'd' replaced by a number.
#define AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
Ignore truncated output instead of returning an error.
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_get_frame_filename(char *buf, int buf_size, const char *path, int number)
#define AV_FRAME_FILENAME_FLAGS_MULTIPLE
Allow multiple d.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
common internal api header.
unsigned int ff_toupper4(unsigned int x)
common internal API header
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Memory handling functions.
int ff_network_init(void)
Initialize the network subsystem.
void ff_network_close(void)
miscellaneous OS support macros and functions.
This struct describes the properties of an encoded stream.
int extradata_size
Size of the extradata content in bytes.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
This structure stores compressed data.
int64_t av_gettime(void)
Get the current time in microseconds.
int ff_urldecode_len(char *dest, size_t dest_len, const char *url, size_t url_max_len, int decode_plus_sign)
Decodes an URL from its percent-encoded form back into normal representation.