Go to the documentation of this file.
37 #define IO_BUFFER_SIZE 32768
44 #define SHORT_SEEK_THRESHOLD 32768
49 return prev ?
NULL :
s->opaque;
55 *iter = (
void*)(uintptr_t)
c;
59 #define OFFSET(x) offsetof(AVIOContext,x)
60 #define E AV_OPT_FLAG_ENCODING_PARAM
61 #define D AV_OPT_FLAG_DECODING_PARAM
63 {
"protocol_whitelist",
"List of protocols that are allowed to be used",
OFFSET(protocol_whitelist),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, 0,
D },
86 int (*
read_packet)(
void *opaque, uint8_t *buf,
int buf_size),
88 int (*
write_packet)(
void *opaque, uint8_t *buf,
int buf_size),
90 int (*
write_packet)(
void *opaque,
const uint8_t *buf,
int buf_size),
92 int64_t (*
seek)(
void *opaque, int64_t
offset,
int whence))
96 memset(
ctx, 0,
sizeof(*
ctx));
99 ctx->orig_buffer_size =
100 s->buffer_size = buffer_size;
115 s->min_packet_size = 0;
116 s->max_packet_size = 0;
117 s->update_checksum =
NULL;
121 s->pos = buffer_size;
122 s->buf_end =
s->buffer + buffer_size;
124 s->read_pause =
NULL;
127 s->write_data_type =
NULL;
128 s->ignore_boundary_point = 0;
149 int (*
read_packet)(
void *opaque, uint8_t *buf,
int buf_size),
151 int (*
write_packet)(
void *opaque, uint8_t *buf,
int buf_size),
153 int (*
write_packet)(
void *opaque,
const uint8_t *buf,
int buf_size),
155 int64_t (*
seek)(
void *opaque, int64_t
offset,
int whence))
175 if (
s->write_data_type)
176 #if FF_API_AVIO_WRITE_NONCONST
177 ret =
s->write_data_type(
s->opaque, (uint8_t *)
data,
179 ret =
s->write_data_type(
s->opaque,
data,
184 else if (
s->write_packet)
193 ctx->bytes_written +=
len;
194 s->bytes_written =
ctx->bytes_written;
196 if (
s->pos +
len >
ctx->written_output_size) {
197 ctx->written_output_size = s->pos + len;
203 ctx->current_type = AVIO_DATA_MARKER_UNKNOWN;
206 ctx->writeout_count++;
212 s->buf_ptr_max =
FFMAX(
s->buf_ptr,
s->buf_ptr_max);
213 if (
s->write_flag &&
s->buf_ptr_max >
s->buffer) {
215 if (
s->update_checksum) {
216 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
217 s->buf_ptr_max -
s->checksum_ptr);
218 s->checksum_ptr =
s->buffer;
221 s->buf_ptr =
s->buf_ptr_max =
s->buffer;
223 s->buf_end =
s->buffer;
230 if (
s->buf_ptr >=
s->buf_end)
237 int len =
FFMIN(
s->buf_end -
s->buf_ptr, count);
238 memset(
s->buf_ptr,
b,
len);
241 if (
s->buf_ptr >=
s->buf_end)
252 if (
s->direct && !
s->update_checksum) {
259 memcpy(
s->buf_ptr, buf,
len);
262 if (
s->buf_ptr >=
s->buf_end)
272 int seekback =
s->write_flag ?
FFMIN(0,
s->buf_ptr -
s->buf_ptr_max) : 0;
294 buffer_size =
s->buf_end -
s->buffer;
296 pos =
s->pos - (
s->write_flag ? 0 : buffer_size);
298 if (whence != SEEK_CUR && whence != SEEK_SET)
301 if (whence == SEEK_CUR) {
302 offset1 =
pos + (
s->buf_ptr -
s->buffer);
305 if (
offset > INT64_MAX - offset1)
312 short_seek =
ctx->short_seek_threshold;
313 if (
ctx->short_seek_get) {
314 int tmp =
ctx->short_seek_get(
s->opaque);
315 short_seek =
FFMAX(
tmp, short_seek);
319 s->buf_ptr_max =
FFMAX(
s->buf_ptr_max,
s->buf_ptr);
320 if ((!
s->direct || !
s->seek) &&
321 offset1 >= 0 && offset1 <= (
s->write_flag ?
s->buf_ptr_max -
s->buffer : buffer_size)) {
323 s->buf_ptr =
s->buffer + offset1;
325 offset1 <= buffer_size + short_seek) &&
326 !
s->write_flag && offset1 >= 0 &&
327 (!
s->direct || !
s->seek) &&
328 (whence != SEEK_END || force)) {
329 while(
s->pos <
offset && !
s->eof_reached)
333 s->buf_ptr =
s->buf_end - (
s->pos -
offset);
334 }
else if(!
s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 &&
s->seek &&
offset > 0) {
338 if ((res =
s->seek(
s->opaque,
pos, SEEK_SET)) < 0)
341 s->buf_ptr =
s->buffer;
353 if ((res =
s->seek(
s->opaque,
offset, SEEK_SET)) < 0)
357 s->buf_end =
s->buffer;
358 s->buf_ptr =
s->buf_ptr_max =
s->buffer;
378 if (
ctx->written_output_size)
379 return ctx->written_output_size;
385 if ((
size =
s->seek(
s->opaque, -1, SEEK_END)) < 0)
388 s->seek(
s->opaque,
s->pos, SEEK_SET);
401 return s->eof_reached;
433 const uint8_t *q = str;
461 #define PUT_STR16(type, big_endian) \
462 int avio_put_str16 ## type(AVIOContext *s, const char *str) \
464 return put_str16(s, str, big_endian); \
512 if (
s->buf_ptr -
s->buffer >=
s->min_packet_size)
516 if (!
s->write_data_type)
542 ctx->last_time = time;
551 ret =
s->read_packet(
s->opaque, buf,
size);
561 int max_buffer_size =
s->max_packet_size ?
563 uint8_t *dst =
s->buf_end -
s->buffer + max_buffer_size <=
s->buffer_size ?
564 s->buf_end :
s->buffer;
565 int len =
s->buffer_size - (dst -
s->buffer);
568 if (!
s->read_packet &&
s->buf_ptr >=
s->buf_end)
575 if (
s->update_checksum && dst ==
s->buffer) {
576 if (
s->buf_end >
s->checksum_ptr)
577 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
578 s->buf_end -
s->checksum_ptr);
579 s->checksum_ptr =
s->buffer;
583 if (
s->read_packet &&
ctx->orig_buffer_size &&
584 s->buffer_size >
ctx->orig_buffer_size &&
len >=
ctx->orig_buffer_size) {
585 if (dst ==
s->buffer &&
s->buf_ptr != dst) {
590 s->checksum_ptr = dst =
s->buffer;
592 len =
ctx->orig_buffer_size;
600 }
else if (
len < 0) {
606 s->buf_end = dst +
len;
632 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
633 s->buf_ptr -
s->checksum_ptr);
634 s->update_checksum =
NULL;
640 unsigned long checksum)
643 if (
s->update_checksum) {
644 s->checksum = checksum;
645 s->checksum_ptr =
s->buf_ptr;
652 if (
s->buf_ptr >=
s->buf_end)
654 if (
s->buf_ptr <
s->buf_end)
655 return *
s->buf_ptr++;
666 if (
len == 0 ||
s->write_flag) {
667 if((
s->direct ||
size >
s->buffer_size) && !
s->update_checksum &&
s->read_packet) {
675 }
else if (
len < 0) {
686 s->buf_ptr =
s->buffer;
687 s->buf_end =
s->buffer;
691 len =
s->buf_end -
s->buf_ptr;
696 memcpy(buf,
s->buf_ptr,
len);
703 if (
s->error)
return s->error;
721 if (
s->buf_end -
s->buf_ptr >=
size && !
s->write_flag) {
738 if (
s->read_packet &&
s->write_flag) {
745 len =
s->buf_end -
s->buf_ptr;
748 len =
s->buf_end -
s->buf_ptr;
752 memcpy(buf,
s->buf_ptr,
len);
755 if (
s->error)
return s->error;
823 if (
c &&
i < maxlen-1)
825 }
while (
c !=
'\n' &&
c !=
'\r' &&
c);
866 }
while (!end &&
len <
sizeof(
tmp) &&
867 ((max_len < 0) || (
read +
len < max_len)));
870 }
while (!end && ((max_len < 0) || (
read < max_len)));
920 buflen =
FFMIN(buflen - 1, maxlen);
921 for (
i = 0;
i < buflen;
i++)
925 for (;
i < maxlen;
i++)
931 #define GET_STR16(type, read) \
932 int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
937 return AVERROR(EINVAL); \
938 while (ret + 1 < maxlen) {\
941 GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\
944 PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\
977 int buffer_size, max_packet_size;
979 max_packet_size =
h->max_packet_size;
980 if (max_packet_size) {
981 buffer_size = max_packet_size;
986 if (buffer_size > INT_MAX/2)
1000 (*s)->protocol_whitelist =
av_strdup(
h->protocol_whitelist);
1001 if (!(*s)->protocol_whitelist &&
h->protocol_whitelist) {
1005 (*s)->protocol_blacklist =
av_strdup(
h->protocol_blacklist);
1006 if (!(*s)->protocol_blacklist &&
h->protocol_blacklist) {
1013 (*s)->max_packet_size = max_packet_size;
1014 (*s)->min_packet_size =
h->min_packet_size;
1016 (*s)->read_pause = (
int (*)(
void *,
int))
h->prot->url_read_pause;
1018 (int64_t (*)(
void *,
int, int64_t,
int))
h->prot->url_read_seek;
1020 if (
h->prot->url_read_seek)
1041 const char *
opts[] = {
1042 "headers",
"user_agent",
"cookies",
"http_proxy",
"referer",
"rw_timeout",
"icy",
NULL };
1043 const char **opt =
opts;
1044 uint8_t *buf =
NULL;
1049 if (buf[0] !=
'\0') {
1065 if (
s->update_checksum &&
s->buf_ptr >
s->checksum_ptr) {
1066 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
1067 s->buf_ptr -
s->checksum_ptr);
1074 int max_buffer_size =
s->max_packet_size ?
1076 ptrdiff_t filled =
s->buf_end -
s->buf_ptr;
1078 if (buf_size <= s->buf_end -
s->buf_ptr)
1081 if (buf_size > INT_MAX - max_buffer_size)
1084 buf_size += max_buffer_size - 1;
1086 if (buf_size +
s->buf_ptr -
s->buffer <=
s->buffer_size ||
s->seekable || !
s->read_packet)
1090 if (buf_size <= s->buffer_size) {
1092 memmove(
s->buffer,
s->buf_ptr, filled);
1098 memcpy(
buffer,
s->buf_ptr, filled);
1101 s->buffer_size = buf_size;
1103 s->buf_ptr =
s->buffer;
1104 s->buf_end =
s->buffer + filled;
1105 s->checksum_ptr =
s->buffer;
1112 if (
ctx->maxsize >= 0) {
1114 int64_t remaining =
ctx->maxsize -
pos;
1115 if (remaining <
size) {
1117 if (!
ctx->maxsize ||
ctx->maxsize < newsize)
1118 ctx->maxsize = newsize - !newsize;
1119 if (
pos >
ctx->maxsize &&
ctx->maxsize >= 0)
1121 if (
ctx->maxsize >= 0)
1122 remaining =
ctx->maxsize -
pos;
1125 if (
ctx->maxsize >= 0 && remaining < size && size > 1) {
1127 "Truncating packet of size %d to %"PRId64
"\n",
1128 size, remaining + !remaining);
1129 size = remaining + !remaining;
1145 s->buffer_size = buf_size;
1146 s->buf_ptr =
s->buf_ptr_max =
buffer;
1156 if (!
s->buffer_size)
1159 if (buf_size <= s->buffer_size)
1166 data_size =
s->write_flag ? (
s->buf_ptr -
s->buffer) : (
s->buf_end -
s->buf_ptr);
1168 memcpy(
buffer,
s->write_flag ?
s->buffer :
s->buf_ptr, data_size);
1172 s->buffer_size = buf_size;
1173 s->buf_ptr =
s->write_flag ? (
s->buffer + data_size) :
s->buffer;
1175 s->buf_ptr_max =
s->buffer + data_size;
1177 s->buf_end =
s->write_flag ? (
s->buffer +
s->buffer_size) : (
s->buf_ptr + data_size);
1187 s->buf_end =
s->buffer +
s->buffer_size;
1190 s->buf_end =
s->buffer;
1198 int64_t buffer_start;
1200 int overlap, new_size, alloc_size;
1201 uint8_t *buf = *bufp;
1203 if (
s->write_flag) {
1208 buffer_size =
s->buf_end -
s->buffer;
1211 if ((buffer_start =
s->pos - buffer_size) > buf_size) {
1216 overlap = buf_size - buffer_start;
1217 new_size = buf_size + buffer_size - overlap;
1219 alloc_size =
FFMAX(
s->buffer_size, new_size);
1220 if (alloc_size > buf_size)
1221 if (!(buf = (*bufp) =
av_realloc_f(buf, 1, alloc_size)))
1224 if (new_size > buf_size) {
1225 memcpy(buf + buf_size,
s->buffer + overlap, buffer_size - overlap);
1226 buf_size = new_size;
1230 s->buf_ptr =
s->buffer = buf;
1231 s->buffer_size = alloc_size;
1233 s->buf_end =
s->buf_ptr + buf_size;
1246 const char *whitelist,
const char *blacklist
1287 "Statistics: %"PRId64
" bytes written, %d seeks, %d writeouts\n",
1288 ctx->bytes_written,
ctx->seek_count,
ctx->writeout_count);
1291 ctx->bytes_read,
ctx->seek_count);
1341 for(; *strings; strings++)
1342 avio_write(
s, (
const unsigned char *)*strings, strlen(*strings));
1349 return s->read_pause(
s->opaque, pause);
1353 int64_t timestamp,
int flags)
1358 ret =
s->read_seek(
s->opaque, stream_index, timestamp,
flags);
1361 s->buf_ptr =
s->buf_end;
1362 pos =
s->seek(
s->opaque, 0, SEEK_CUR);
1415 #if FF_API_AVIO_WRITE_NONCONST
1416 static int dyn_buf_write(
void *opaque, uint8_t *buf,
int buf_size)
1425 new_size = (unsigned)
d->pos + buf_size;
1426 if (new_size < d->
pos || new_size > INT_MAX)
1428 if (new_size >
d->allocated_size) {
1429 unsigned new_allocated_size =
d->allocated_size ?
d->allocated_size
1432 while (new_size > new_allocated_size)
1433 new_allocated_size += new_allocated_size / 2 + 1;
1435 new_allocated_size =
FFMIN(new_allocated_size, INT_MAX);
1437 if ((err =
av_reallocp(&
d->buffer, new_allocated_size)) < 0) {
1438 d->allocated_size = 0;
1442 d->allocated_size = new_allocated_size;
1444 memcpy(
d->buffer +
d->pos, buf, buf_size);
1446 if (
d->pos >
d->size)
1451 #if FF_API_AVIO_WRITE_NONCONST
1457 unsigned char buf1[4];
1474 if (whence == SEEK_CUR)
1476 else if (whence == SEEK_END)
1490 unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1492 if (
sizeof(*
ret) + io_buffer_size < io_buffer_size)
1498 d->io_buffer_size = io_buffer_size;
1503 (*s)->max_packet_size = max_packet_size;
1514 if (max_packet_size <= 0)
1529 if (!
s->error && !
d->size) {
1530 *pbuffer =
d->io_buffer;
1531 return FFMAX(
s->buf_ptr,
s->buf_ptr_max) -
s->buffer;
1536 *pbuffer =
d->buffer;
1544 int max_packet_size =
s->max_packet_size;
1547 1,
d,
NULL,
s->write_packet,
s->seek);
1548 s->max_packet_size = max_packet_size;
1549 d->pos =
d->size = 0;
1564 if (!
s->max_packet_size) {
1572 *pbuffer =
d->buffer;
1577 return size - padding;
1592 #if FF_API_AVIO_WRITE_NONCONST
1593 static int null_buf_write(
void *opaque, uint8_t *buf,
int buf_size)
1601 if (
d->pos >
d->size)
static void error(const char *err)
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.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
#define AV_LOG_WARNING
Something somehow does not look correct.
static int put_str16(AVIOContext *s, const char *str, const int be)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
@ AVIO_DATA_MARKER_BOUNDARY_POINT
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
const AVClass ffurl_context_class
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
unsigned int avio_rl24(AVIOContext *s)
static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
#define AVERROR_EOF
End of file.
void avio_wl24(AVIOContext *s, unsigned int val)
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
unsigned long ffio_get_checksum(AVIOContext *s)
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.
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
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.
#define AV_LOG_VERBOSE
Detailed information.
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
int ffurl_close(URLContext *h)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
void avio_wl32(AVIOContext *s, unsigned int val)
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.
unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
AVIODataMarkerType
Different data types that can be returned via the AVIO write_data_type callback.
void avio_w8(AVIOContext *s, int b)
static void update_checksum(AVIOContext *s)
static void fill_buffer(AVIOContext *s)
Callback for checking whether to abort blocking functions.
void ffio_reset_dyn_buf(AVIOContext *s)
Reset a dynamic buffer.
int ffurl_get_short_seek(void *urlcontext)
Return the current short seek threshold value for this URL.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static double val(void *priv, double ch)
void avio_wb24(AVIOContext *s, unsigned int val)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
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)
static void * ff_avio_child_next(void *obj, void *prev)
void avio_print_string_array(AVIOContext *s, const char *strings[])
Write a NULL terminated array of strings to the context.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
static void flush_buffer(AVIOContext *s)
int ffio_copy_url_options(AVIOContext *pb, AVDictionary **avio_opts)
Read url related dictionary options from the AVIOContext and write to the given dictionary.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, int64_t max_len)
Read a whole null-terminated string of text from AVIOContext to an AVBPrint buffer overwriting its co...
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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.
int64_t bytes_read
Bytes read statistic.
void avio_wb32(AVIOContext *s, unsigned int val)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int null_buf_write(void *opaque, const uint8_t *buf, int buf_size)
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.
void ffio_fill(AVIOContext *s, int b, int64_t count)
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AVIO_FLAG_WRITE
write-only
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int dyn_packet_buf_write(void *opaque, const uint8_t *buf, int buf_size)
void avio_context_free(AVIOContext **ps)
Free the supplied IO context and everything associated with it.
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
void ffio_init_write_context(FFIOContext *s, uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for writing.
#define av_realloc_f(p, o, n)
int ffio_limit(AVIOContext *s, int size)
#define LIBAVUTIL_VERSION_INT
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Describe the class of an AVClass context structure.
static const AVOption ff_avio_options[]
@ AVIO_DATA_MARKER_TRAILER
Trailer data, which doesn't contain actual content, but only for finalizing the output file.
#define PUT_UTF16(val, tmp, PUT_16BIT)
int orig_buffer_size
Original buffer size used after probing to ensure seekback and to reset the buffer size.
int avio_printf(AVIOContext *s, const char *fmt,...)
const char * av_default_item_name(void *ptr)
Return the context name.
static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp, FFBPrintReadStringMode mode, int64_t max_len)
static void BS_FUNC() seek(BSCTX *bc, unsigned pos)
Seek to the given bit position.
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define SHORT_SEEK_THRESHOLD
Do seeks within this distance ahead of the current buffer by skipping data instead of calling the pro...
int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap)
Writes a formatted string to the context taking a va_list.
static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int avio_pause(AVIOContext *s, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e....
unsigned int avio_rb24(AVIOContext *s)
const OptionDef options[]
unsigned int avio_rb16(AVIOContext *s)
int ffio_realloc_buf(AVIOContext *s, int buf_size)
Reallocate a given buffer for AVIOContext.
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.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AVIO_SEEKABLE_TIME
Seeking by timestamp with avio_seek_time() is possible.
unsigned int avio_rl16(AVIOContext *s)
uint64_t avio_rl64(AVIOContext *s)
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.
@ AVIO_DATA_MARKER_SYNC_POINT
A point in the output bytestream where a decoder can start decoding (i.e.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
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.
static int dyn_buf_write(void *opaque, const uint8_t *buf, int buf_size)
unsigned int avio_rl32(AVIOContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int ffurl_write2(void *urlcontext, const uint8_t *buf, int size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
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'.
#define i(width, name, range_min, range_max)
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, const 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.
#define PUT_STR16(type, big_endian)
uint64_t ffio_read_varlen(AVIOContext *bc)
static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, FFBPrintReadStringMode mode, int64_t max_len)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
#define GET_STR16(type, read)
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
const AVIOInterruptCB int_cb
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
void avio_wb64(AVIOContext *s, uint64_t val)
@ AVIO_DATA_MARKER_UNKNOWN
This is any, unlabelled data.
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ffurl_read2(void *urlcontext, uint8_t *buf, int size)
int64_t ffurl_seek2(void *urlcontext, int64_t pos, int whence)
#define AV_INPUT_BUFFER_PADDING_SIZE
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int avio_r8(AVIOContext *s)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static int url_resetbuf(AVIOContext *s, int flags)
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
@ AVIO_DATA_MARKER_HEADER
Header data; this needs to be present for the stream to be decodeable.
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
#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.
int(* write_packet)(void *opaque, const uint8_t *buf, int buf_size)
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
int ffio_fdopen(AVIOContext **s, URLContext *h)
Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void avio_wb16(AVIOContext *s, unsigned int val)
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static int set_buf_size(AVIOContext *s, int buf_size)
unsigned int avio_rb32(AVIOContext *s)
#define flags(name, subs,...)
void ffio_init_context(FFIOContext *ctx, 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, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
static void writeout(AVIOContext *s, const uint8_t *data, int len)
static const AVClass * child_class_iterate(void **iter)
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
void avio_wl64(AVIOContext *s, uint64_t val)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
uint64_t avio_rb64(AVIOContext *s)
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...