36 #define IO_BUFFER_SIZE 32768 43 #define SHORT_SEEK_THRESHOLD 4096 53 return prev ?
NULL :
internal->h;
61 #define OFFSET(x) offsetof(AVIOContext,x) 62 #define E AV_OPT_FLAG_ENCODING_PARAM 63 #define D AV_OPT_FLAG_DECODING_PARAM 65 {
"protocol_whitelist",
"List of protocols that are allowed to be used",
OFFSET(protocol_whitelist),
AV_OPT_TYPE_STRING, { .str =
NULL }, CHAR_MIN, CHAR_MAX,
D },
88 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
115 s->
pos = buffer_size;
132 unsigned char *buffer,
138 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
253 whence &= ~AVSEEK_FORCE;
262 if (whence != SEEK_CUR && whence != SEEK_SET)
265 if (whence == SEEK_CUR) {
269 if (offset > INT64_MAX - offset1)
284 offset1 = offset - pos;
291 offset1 <= buffer_size + short_seek) &&
294 (whence != SEEK_END || force)) {
300 }
else if(!s->
write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->
seek && offset > 0) {
303 pos -=
FFMIN(buffer_size>>1, pos);
304 if ((res = s->
seek(s->
opaque, pos, SEEK_SET)) < 0)
311 return avio_seek(s, offset, SEEK_SET | force);
319 if ((res = s->
seek(s->
opaque, offset, SEEK_SET)) < 0)
350 if ((size = s->
seek(s->
opaque, -1, SEEK_END)) < 0)
390 avio_write(s, (
const unsigned char *) str, len);
411 av_log(s,
AV_LOG_ERROR,
"Invalid UTF8 sequence in avio_put_str16%s\n", be ?
"be" :
"le");
426 #define PUT_STR16(type, big_endian) \ 427 int avio_put_str16 ## type(AVIOContext *s, const char *str) \ 429 return put_str16(s, str, big_endian); \ 459 avio_wl32(s, (uint32_t)(val & 0xffffffff));
466 avio_wb32(s, (uint32_t)(val & 0xffffffff));
536 #if FF_API_OLD_AVIO_EOF_0 590 }
else if (len < 0) {
628 unsigned long (*update_checksum)(
unsigned long c,
const uint8_t *p,
unsigned int len),
664 }
else if (len < 0) {
816 if (c && i < maxlen-1)
818 }
while (c !=
'\n' && c !=
'\r' && c);
845 end = (c ==
'\r' || c ==
'\n' || c ==
'\0');
848 }
while (!end && len <
sizeof(tmp));
887 buflen =
FFMIN(buflen - 1, maxlen);
888 for (i = 0; i < buflen; i++)
892 for (; i < maxlen; i++)
898 #define GET_STR16(type, read) \ 899 int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\ 904 return AVERROR(EINVAL); \ 905 while (ret + 1 < maxlen) {\ 908 GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\ 911 PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\ 936 val= (val<<7) + (tmp&127);
944 return ffurl_read(internal->h, buf, buf_size);
956 return ffurl_seek(internal->h, offset, whence);
968 if (!internal->h->prot->url_read_pause)
970 return internal->h->prot->url_read_pause(internal->h, pause);
976 if (!internal->h->prot->url_read_seek)
978 return internal->h->prot->url_read_seek(internal->h, stream_index, timestamp, flags);
985 int buffer_size, max_packet_size;
988 if (max_packet_size) {
989 buffer_size = max_packet_size;
1021 (*s)->max_packet_size = max_packet_size;
1062 if (buf_size < filled || s->seekable || !s->
read_packet)
1070 memcpy(buffer, s->
buffer, filled);
1076 if (checksum_ptr_offset >= 0)
1113 int64_t buffer_start;
1115 int overlap, new_size, alloc_size;
1126 if ((buffer_start = s->
pos - buffer_size) > buf_size) {
1131 overlap = buf_size - buffer_start;
1132 new_size = buf_size + buffer_size - overlap;
1135 if (alloc_size > buf_size)
1136 if (!(buf = (*bufp) =
av_realloc_f(buf, 1, alloc_size)))
1139 if (new_size > buf_size) {
1140 memcpy(buf + buf_size, s->
buffer + overlap, buffer_size - overlap);
1141 buf_size = new_size;
1161 const char *whitelist,
const char *blacklist
1229 ret =
vsnprintf(buf,
sizeof(buf), fmt, ap);
1243 int64_t timestamp,
int flags)
1255 else if (pos !=
AVERROR(ENOSYS))
1310 unsigned new_size, new_allocated_size;
1313 new_size = d->
pos + buf_size;
1315 if (new_size < d->pos || new_size > INT_MAX/2)
1317 while (new_size > new_allocated_size) {
1318 if (!new_allocated_size)
1319 new_allocated_size = new_size;
1321 new_allocated_size += new_allocated_size / 2 + 1;
1333 memcpy(d->
buffer + d->
pos, buf, buf_size);
1342 unsigned char buf1[4];
1359 if (whence == SEEK_CUR)
1361 else if (whence == SEEK_END)
1363 if (offset < 0 || offset > 0x7fffffffLL)
1372 unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1374 if (
sizeof(
DynBuffer) + io_buffer_size < io_buffer_size)
1387 (*s)->max_packet_size = max_packet_size;
1398 if (max_packet_size <= 0)
1447 return size - padding;
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void avio_wl64(AVIOContext *s, uint64_t val)
const char const char void * val
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t avio_rb64(AVIOContext *s)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
#define av_realloc_f(p, o, n)
void avio_wb16(AVIOContext *s, unsigned int val)
static int64_t io_read_seek(void *opaque, int stream_index, int64_t timestamp, int flags)
#define AV_LOG_WARNING
Something somehow does not look correct.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define LIBAVUTIL_VERSION_INT
unsigned char * buf_ptr
Current position in the buffer.
int writeout_count
writeout statistic This field is internal to libavformat and access from outside is not allowed...
unsigned char * buf_end
End of the data, may be less than buffer+buffer_size if the read function returned less data than req...
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int write_flag
true if open for writing
int is_streamed
true if streamed (no seek possible), default = false
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AVIO_SEEKABLE_TIME
Seeking by timestamp with avio_seek_time() is possible.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
void ffio_fill(AVIOContext *s, int b, int count)
#define AVIO_FLAG_READ
read-only
const char * av_default_item_name(void *ptr)
Return the context name.
unsigned int avio_rl24(AVIOContext *s)
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
int min_packet_size
Try to buffer at least this amount of data before flushing it.
int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
#define AVIO_FLAG_WRITE
write-only
unsigned char * buffer
Start of the buffer.
void avio_wl24(AVIOContext *s, unsigned int val)
void avio_w8(AVIOContext *s, int b)
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
void * opaque
A private pointer, passed to the read/write/seek/...
void avio_wb32(AVIOContext *s, unsigned int val)
static const AVClass * ff_avio_child_class_next(const AVClass *prev)
static int io_read_packet(void *opaque, uint8_t *buf, int buf_size)
Trailer data, which doesn't contain actual content, but only for finalizing the output file...
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
void avio_wl32(AVIOContext *s, unsigned int val)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
static void fill_buffer(AVIOContext *s)
static int io_read_pause(void *opaque, int pause)
static av_cold int end(AVCodecContext *avctx)
unsigned long ffio_get_checksum(AVIOContext *s)
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
Public header for CRC hash function implementation.
int64_t bytes_read
Bytes read statistic This field is internal to libavformat and access from outside is not allowed...
char * protocol_whitelist
',' separated list of allowed protocols.
#define AVERROR_EOF
End of file.
int ffio_set_buf_size(AVIOContext *s, int buf_size)
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
void avio_wb24(AVIOContext *s, unsigned int val)
void avio_wl16(AVIOContext *s, unsigned int val)
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
static void flush_buffer(AVIOContext *s)
Callback for checking whether to abort blocking functions.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int avio_rb24(AVIOContext *s)
const AVIOInterruptCB int_cb
static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
const char * protocol_whitelist
static const AVOption ff_avio_options[]
int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp)
Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting its contents.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static void * ff_avio_child_next(void *obj, void *prev)
#define SHORT_SEEK_THRESHOLD
Do seeks within this distance ahead of the current buffer by skipping data instead of calling the pro...
static const uint8_t offset[127][2]
int direct
avio_read and avio_write should if possible be satisfied directly instead of going through a buffer...
unsigned int avio_rl16(AVIOContext *s)
static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
int seek_count
seek statistic This field is internal to libavformat and access from outside is not allowed...
int avio_pause(AVIOContext *s, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e.g.
unsigned int avio_rl32(AVIOContext *s)
This is any, unlabelled data.
int(* read_packet)(void *opaque, uint8_t *buf, int buf_size)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL.
const AVClass ff_avio_class
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
unsigned char * checksum_ptr
int avio_printf(AVIOContext *s, const char *fmt,...)
AVIODataMarkerType
Different data types that can be returned via the AVIO write_data_type callback.
int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
int64_t(* seek)(void *opaque, int64_t offset, int whence)
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
void avio_context_free(AVIOContext **ps)
Free the supplied IO context and everything associated with it.
static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
#define GET_STR16(type, read)
static volatile int checksum
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
int buffer_size
Maximum buffer size.
void avio_wb64(AVIOContext *s, uint64_t val)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int(* short_seek_get)(void *opaque)
A callback that is used instead of short_seek_threshold.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
Open a write only packetized memory stream with a maximum packet size of 'max_packet_size'.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
char * av_strdup(const char *s)
Duplicate a string.
const char * protocol_blacklist
#define PUT_STR16(type, big_endian)
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
static int io_short_seek(void *opaque)
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file...
static int url_resetbuf(AVIOContext *s, int flags)
uint64_t avio_rl64(AVIOContext *s)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int(* write_packet)(void *opaque, uint8_t *buf, int buf_size)
Describe the class of an AVClass context structure.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AVSEEK_FORCE
Passing this flag as the "whence" parameter to a seek function causes it to seek by any means (like r...
#define AVIO_FLAG_DIRECT
Use direct mode.
unsigned int avio_rb16(AVIOContext *s)
int short_seek_threshold
Threshold to favor readahead over seek.
#define PUT_UTF16(val, tmp, PUT_16BIT)
Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
int ignore_boundary_point
If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT, but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly small chunks of data returned from the callback).
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int error
contains the error code or 0 if no error happened
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int ff_get_v_length(uint64_t val)
Get the length in bytes which is needed to store val as v.
int ffurl_close(URLContext *h)
const AVClass ffurl_context_class
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
int orig_buffer_size
Original buffer size used internally after probing and ensure seekback to reset the buffer size This ...
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
enum AVIODataMarkerType current_type
Internal, not meant to be used from outside of AVIOContext.
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int(* read_pause)(void *opaque, int pause)
Pause or resume playback for network streaming protocols - e.g.
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_opt_free(void *obj)
Free all allocated objects in obj.
const OptionDef options[]
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h...
const struct URLProtocol * prot
int(* write_data_type)(void *opaque, uint8_t *buf, int buf_size, enum AVIODataMarkerType type, int64_t time)
A callback that is used instead of write_packet.
unsigned long(* update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size)
int ffio_fdopen(AVIOContext **s, URLContext *h)
Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h...
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
int64_t pos
position in the file of the current buffer
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
uint64_t ffio_read_varlen(AVIOContext *bc)
int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
Read a whole line of text from AVIOContext to an AVBPrint buffer.
unsigned int avio_rb32(AVIOContext *s)
unsigned char * buf_ptr_max
Maximum reached position before a backward seek in the write buffer, used keeping track of already wr...
A point in the output bytestream where a decoder can start decoding (i.e.
static int put_str16(AVIOContext *s, const char *str, const int be)
int eof_reached
true if eof reached
static int io_write_packet(void *opaque, uint8_t *buf, int buf_size)
void ff_put_v(AVIOContext *bc, uint64_t val)
Put val using a variable number of bytes.
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
static void writeout(AVIOContext *s, const uint8_t *data, int len)
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
char * protocol_blacklist
',' separated list of disallowed protocols.
int max_packet_size
if non zero, the stream is packetized with this max packet size
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unbuffered private I/O API
int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
Same as ff_get_line but strip the white-space characters in the text tail.
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int avio_r8(AVIOContext *s)
int min_packet_size
if non zero, the stream is packetized with this min packet size
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...
int64_t(* read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp in stream with the specified stream_index.
static int64_t io_seek(void *opaque, int64_t offset, int whence)
Header data; this needs to be present for the stream to be decodeable.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t avio_seek_time(AVIOContext *s, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int64_t(* url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags)