FFmpeg
aviobuf.c
Go to the documentation of this file.
1 /*
2  * buffered I/O
3  * Copyright (c) 2000,2001 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/bprint.h"
23 #include "libavutil/crc.h"
24 #include "libavutil/dict.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/log.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/avassert.h"
29 #include "avformat.h"
30 #include "avio.h"
31 #include "avio_internal.h"
32 #include "internal.h"
33 #include "url.h"
34 #include <stdarg.h>
35 
36 #define IO_BUFFER_SIZE 32768
37 
38 /**
39  * Do seeks within this distance ahead of the current buffer by skipping
40  * data instead of calling the protocol seek function, for seekable
41  * protocols.
42  */
43 #define SHORT_SEEK_THRESHOLD 32768
44 
45 static void *ff_avio_child_next(void *obj, void *prev)
46 {
47  AVIOContext *s = obj;
48  return prev ? NULL : s->opaque;
49 }
50 
51 static const AVClass *child_class_iterate(void **iter)
52 {
53  const AVClass *c = *iter ? NULL : &ffurl_context_class;
54  *iter = (void*)(uintptr_t)c;
55  return c;
56 }
57 
58 #define OFFSET(x) offsetof(AVIOContext,x)
59 #define E AV_OPT_FLAG_ENCODING_PARAM
60 #define D AV_OPT_FLAG_DECODING_PARAM
61 static const AVOption ff_avio_options[] = {
62  {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
63  { NULL },
64 };
65 
67  .class_name = "AVIOContext",
68  .item_name = av_default_item_name,
69  .version = LIBAVUTIL_VERSION_INT,
70  .option = ff_avio_options,
71  .child_next = ff_avio_child_next,
72  .child_class_iterate = child_class_iterate,
73 };
74 
75 static void fill_buffer(AVIOContext *s);
76 static int url_resetbuf(AVIOContext *s, int flags);
77 
79  unsigned char *buffer,
80  int buffer_size,
81  int write_flag,
82  void *opaque,
83  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
84  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
85  int64_t (*seek)(void *opaque, int64_t offset, int whence))
86 {
87  memset(s, 0, sizeof(AVIOContext));
88 
89  s->buffer = buffer;
90  s->orig_buffer_size =
91  s->buffer_size = buffer_size;
92  s->buf_ptr = buffer;
93  s->buf_ptr_max = buffer;
94  s->opaque = opaque;
95  s->direct = 0;
96 
98 
99  s->write_packet = write_packet;
100  s->read_packet = read_packet;
101  s->seek = seek;
102  s->pos = 0;
103  s->eof_reached = 0;
104  s->error = 0;
105  s->seekable = seek ? AVIO_SEEKABLE_NORMAL : 0;
106  s->min_packet_size = 0;
107  s->max_packet_size = 0;
108  s->update_checksum = NULL;
109  s->short_seek_threshold = SHORT_SEEK_THRESHOLD;
110 
111  if (!read_packet && !write_flag) {
112  s->pos = buffer_size;
113  s->buf_end = s->buffer + buffer_size;
114  }
115  s->read_pause = NULL;
116  s->read_seek = NULL;
117 
118  s->write_data_type = NULL;
119  s->ignore_boundary_point = 0;
120  s->current_type = AVIO_DATA_MARKER_UNKNOWN;
121  s->last_time = AV_NOPTS_VALUE;
122  s->short_seek_get = NULL;
123  s->written = 0;
124 
125  return 0;
126 }
127 
129  unsigned char *buffer,
130  int buffer_size,
131  int write_flag,
132  void *opaque,
133  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
134  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
135  int64_t (*seek)(void *opaque, int64_t offset, int whence))
136 {
137  AVIOContext *s = av_malloc(sizeof(AVIOContext));
138  if (!s)
139  return NULL;
140  ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
141  read_packet, write_packet, seek);
142  return s;
143 }
144 
146 {
147  av_freep(ps);
148 }
149 
150 static void writeout(AVIOContext *s, const uint8_t *data, int len)
151 {
152  if (!s->error) {
153  int ret = 0;
154  if (s->write_data_type)
155  ret = s->write_data_type(s->opaque, (uint8_t *)data,
156  len,
157  s->current_type,
158  s->last_time);
159  else if (s->write_packet)
160  ret = s->write_packet(s->opaque, (uint8_t *)data, len);
161  if (ret < 0) {
162  s->error = ret;
163  } else {
164  if (s->pos + len > s->written)
165  s->written = s->pos + len;
166  }
167  }
168  if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT ||
169  s->current_type == AVIO_DATA_MARKER_BOUNDARY_POINT) {
170  s->current_type = AVIO_DATA_MARKER_UNKNOWN;
171  }
172  s->last_time = AV_NOPTS_VALUE;
173  s->writeout_count ++;
174  s->pos += len;
175 }
176 
178 {
179  s->buf_ptr_max = FFMAX(s->buf_ptr, s->buf_ptr_max);
180  if (s->write_flag && s->buf_ptr_max > s->buffer) {
181  writeout(s, s->buffer, s->buf_ptr_max - s->buffer);
182  if (s->update_checksum) {
183  s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
184  s->buf_ptr_max - s->checksum_ptr);
185  s->checksum_ptr = s->buffer;
186  }
187  }
188  s->buf_ptr = s->buf_ptr_max = s->buffer;
189  if (!s->write_flag)
190  s->buf_end = s->buffer;
191 }
192 
193 void avio_w8(AVIOContext *s, int b)
194 {
195  av_assert2(b>=-128 && b<=255);
196  *s->buf_ptr++ = b;
197  if (s->buf_ptr >= s->buf_end)
198  flush_buffer(s);
199 }
200 
201 void ffio_fill(AVIOContext *s, int b, int count)
202 {
203  while (count > 0) {
204  int len = FFMIN(s->buf_end - s->buf_ptr, count);
205  memset(s->buf_ptr, b, len);
206  s->buf_ptr += len;
207 
208  if (s->buf_ptr >= s->buf_end)
209  flush_buffer(s);
210 
211  count -= len;
212  }
213 }
214 
215 void avio_write(AVIOContext *s, const unsigned char *buf, int size)
216 {
217  if (s->direct && !s->update_checksum) {
218  avio_flush(s);
219  writeout(s, buf, size);
220  return;
221  }
222  while (size > 0) {
223  int len = FFMIN(s->buf_end - s->buf_ptr, size);
224  memcpy(s->buf_ptr, buf, len);
225  s->buf_ptr += len;
226 
227  if (s->buf_ptr >= s->buf_end)
228  flush_buffer(s);
229 
230  buf += len;
231  size -= len;
232  }
233 }
234 
236 {
237  int seekback = s->write_flag ? FFMIN(0, s->buf_ptr - s->buf_ptr_max) : 0;
238  flush_buffer(s);
239  if (seekback)
240  avio_seek(s, seekback, SEEK_CUR);
241 }
242 
243 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
244 {
245  int64_t offset1;
246  int64_t pos;
247  int force = whence & AVSEEK_FORCE;
248  int buffer_size;
249  int short_seek;
250  whence &= ~AVSEEK_FORCE;
251 
252  if(!s)
253  return AVERROR(EINVAL);
254 
255  if ((whence & AVSEEK_SIZE))
256  return s->seek ? s->seek(s->opaque, offset, AVSEEK_SIZE) : AVERROR(ENOSYS);
257 
258  buffer_size = s->buf_end - s->buffer;
259  // pos is the absolute position that the beginning of s->buffer corresponds to in the file
260  pos = s->pos - (s->write_flag ? 0 : buffer_size);
261 
262  if (whence != SEEK_CUR && whence != SEEK_SET)
263  return AVERROR(EINVAL);
264 
265  if (whence == SEEK_CUR) {
266  offset1 = pos + (s->buf_ptr - s->buffer);
267  if (offset == 0)
268  return offset1;
269  if (offset > INT64_MAX - offset1)
270  return AVERROR(EINVAL);
271  offset += offset1;
272  }
273  if (offset < 0)
274  return AVERROR(EINVAL);
275 
276  short_seek = s->short_seek_threshold;
277  if (s->short_seek_get)
278  short_seek = FFMAX(s->short_seek_get(s->opaque), short_seek);
279 
280  offset1 = offset - pos; // "offset1" is the relative offset from the beginning of s->buffer
281  s->buf_ptr_max = FFMAX(s->buf_ptr_max, s->buf_ptr);
282  if ((!s->direct || !s->seek) &&
283  offset1 >= 0 && offset1 <= (s->write_flag ? s->buf_ptr_max - s->buffer : buffer_size)) {
284  /* can do the seek inside the buffer */
285  s->buf_ptr = s->buffer + offset1;
286  } else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) ||
287  offset1 <= buffer_size + short_seek) &&
288  !s->write_flag && offset1 >= 0 &&
289  (!s->direct || !s->seek) &&
290  (whence != SEEK_END || force)) {
291  while(s->pos < offset && !s->eof_reached)
292  fill_buffer(s);
293  if (s->eof_reached)
294  return AVERROR_EOF;
295  s->buf_ptr = s->buf_end - (s->pos - offset);
296  } else if(!s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->seek && offset > 0) {
297  int64_t res;
298 
299  pos -= FFMIN(buffer_size>>1, pos);
300  if ((res = s->seek(s->opaque, pos, SEEK_SET)) < 0)
301  return res;
302  s->buf_end =
303  s->buf_ptr = s->buffer;
304  s->pos = pos;
305  s->eof_reached = 0;
306  fill_buffer(s);
307  return avio_seek(s, offset, SEEK_SET | force);
308  } else {
309  int64_t res;
310  if (s->write_flag) {
311  flush_buffer(s);
312  }
313  if (!s->seek)
314  return AVERROR(EPIPE);
315  if ((res = s->seek(s->opaque, offset, SEEK_SET)) < 0)
316  return res;
317  s->seek_count ++;
318  if (!s->write_flag)
319  s->buf_end = s->buffer;
320  s->buf_ptr = s->buf_ptr_max = s->buffer;
321  s->pos = offset;
322  }
323  s->eof_reached = 0;
324  return offset;
325 }
326 
327 int64_t avio_skip(AVIOContext *s, int64_t offset)
328 {
329  return avio_seek(s, offset, SEEK_CUR);
330 }
331 
333 {
334  int64_t size;
335 
336  if (!s)
337  return AVERROR(EINVAL);
338 
339  if (s->written)
340  return s->written;
341 
342  if (!s->seek)
343  return AVERROR(ENOSYS);
344  size = s->seek(s->opaque, 0, AVSEEK_SIZE);
345  if (size < 0) {
346  if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0)
347  return size;
348  size++;
349  s->seek(s->opaque, s->pos, SEEK_SET);
350  }
351  return size;
352 }
353 
355 {
356  if(!s)
357  return 0;
358  if(s->eof_reached){
359  s->eof_reached=0;
360  fill_buffer(s);
361  }
362  return s->eof_reached;
363 }
364 
365 void avio_wl32(AVIOContext *s, unsigned int val)
366 {
367  avio_w8(s, (uint8_t) val );
368  avio_w8(s, (uint8_t)(val >> 8 ));
369  avio_w8(s, (uint8_t)(val >> 16));
370  avio_w8(s, val >> 24 );
371 }
372 
373 void avio_wb32(AVIOContext *s, unsigned int val)
374 {
375  avio_w8(s, val >> 24 );
376  avio_w8(s, (uint8_t)(val >> 16));
377  avio_w8(s, (uint8_t)(val >> 8 ));
378  avio_w8(s, (uint8_t) val );
379 }
380 
381 int avio_put_str(AVIOContext *s, const char *str)
382 {
383  int len = 1;
384  if (str) {
385  len += strlen(str);
386  avio_write(s, (const unsigned char *) str, len);
387  } else
388  avio_w8(s, 0);
389  return len;
390 }
391 
392 static inline int put_str16(AVIOContext *s, const char *str, const int be)
393 {
394  const uint8_t *q = str;
395  int ret = 0;
396  int err = 0;
397 
398  while (*q) {
399  uint32_t ch;
400  uint16_t tmp;
401 
402  GET_UTF8(ch, *q++, goto invalid;)
403  PUT_UTF16(ch, tmp, be ? avio_wb16(s, tmp) : avio_wl16(s, tmp);
404  ret += 2;)
405  continue;
406 invalid:
407  av_log(s, AV_LOG_ERROR, "Invalid UTF8 sequence in avio_put_str16%s\n", be ? "be" : "le");
408  err = AVERROR(EINVAL);
409  if (!*(q-1))
410  break;
411  }
412  if (be)
413  avio_wb16(s, 0);
414  else
415  avio_wl16(s, 0);
416  if (err)
417  return err;
418  ret += 2;
419  return ret;
420 }
421 
422 #define PUT_STR16(type, big_endian) \
423 int avio_put_str16 ## type(AVIOContext *s, const char *str) \
424 { \
425 return put_str16(s, str, big_endian); \
426 }
427 
428 PUT_STR16(le, 0)
429 PUT_STR16(be, 1)
430 
431 #undef PUT_STR16
432 
433 void avio_wl64(AVIOContext *s, uint64_t val)
434 {
435  avio_wl32(s, (uint32_t)(val & 0xffffffff));
436  avio_wl32(s, (uint32_t)(val >> 32));
437 }
438 
439 void avio_wb64(AVIOContext *s, uint64_t val)
440 {
441  avio_wb32(s, (uint32_t)(val >> 32));
442  avio_wb32(s, (uint32_t)(val & 0xffffffff));
443 }
444 
445 void avio_wl16(AVIOContext *s, unsigned int val)
446 {
447  avio_w8(s, (uint8_t)val);
448  avio_w8(s, (int)val >> 8);
449 }
450 
451 void avio_wb16(AVIOContext *s, unsigned int val)
452 {
453  avio_w8(s, (int)val >> 8);
454  avio_w8(s, (uint8_t)val);
455 }
456 
457 void avio_wl24(AVIOContext *s, unsigned int val)
458 {
459  avio_wl16(s, val & 0xffff);
460  avio_w8(s, (int)val >> 16);
461 }
462 
463 void avio_wb24(AVIOContext *s, unsigned int val)
464 {
465  avio_wb16(s, (int)val >> 8);
466  avio_w8(s, (uint8_t)val);
467 }
468 
470 {
472  if (s->buf_ptr - s->buffer >= s->min_packet_size)
473  avio_flush(s);
474  return;
475  }
476  if (!s->write_data_type)
477  return;
478  // If ignoring boundary points, just treat it as unknown
479  if (type == AVIO_DATA_MARKER_BOUNDARY_POINT && s->ignore_boundary_point)
481  // Avoid unnecessary flushes if we are already in non-header/trailer
482  // data and setting the type to unknown
484  (s->current_type != AVIO_DATA_MARKER_HEADER &&
485  s->current_type != AVIO_DATA_MARKER_TRAILER))
486  return;
487 
488  switch (type) {
491  // For header/trailer, ignore a new marker of the same type;
492  // consecutive header/trailer markers can be merged.
493  if (type == s->current_type)
494  return;
495  break;
496  }
497 
498  // If we've reached here, we have a new, noteworthy marker.
499  // Flush the previous data and mark the start of the new data.
500  avio_flush(s);
501  s->current_type = type;
502  s->last_time = time;
503 }
504 
505 static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
506 {
507  int ret;
508 
509  if (!s->read_packet)
510  return AVERROR(EINVAL);
511  ret = s->read_packet(s->opaque, buf, size);
512  av_assert2(ret || s->max_packet_size);
513  return ret;
514 }
515 
516 /* Input stream */
517 
518 static void fill_buffer(AVIOContext *s)
519 {
520  int max_buffer_size = s->max_packet_size ?
521  s->max_packet_size : IO_BUFFER_SIZE;
522  uint8_t *dst = s->buf_end - s->buffer + max_buffer_size <= s->buffer_size ?
523  s->buf_end : s->buffer;
524  int len = s->buffer_size - (dst - s->buffer);
525 
526  /* can't fill the buffer without read_packet, just set EOF if appropriate */
527  if (!s->read_packet && s->buf_ptr >= s->buf_end)
528  s->eof_reached = 1;
529 
530  /* no need to do anything if EOF already reached */
531  if (s->eof_reached)
532  return;
533 
534  if (s->update_checksum && dst == s->buffer) {
535  if (s->buf_end > s->checksum_ptr)
536  s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
537  s->buf_end - s->checksum_ptr);
538  s->checksum_ptr = s->buffer;
539  }
540 
541  /* make buffer smaller in case it ended up large after probing */
542  if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size && len >= s->orig_buffer_size) {
543  if (dst == s->buffer && s->buf_ptr != dst) {
544  int ret = ffio_set_buf_size(s, s->orig_buffer_size);
545  if (ret < 0)
546  av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n");
547 
548  s->checksum_ptr = dst = s->buffer;
549  }
550  len = s->orig_buffer_size;
551  }
552 
553  len = read_packet_wrapper(s, dst, len);
554  if (len == AVERROR_EOF) {
555  /* do not modify buffer if EOF reached so that a seek back can
556  be done without rereading data */
557  s->eof_reached = 1;
558  } else if (len < 0) {
559  s->eof_reached = 1;
560  s->error= len;
561  } else {
562  s->pos += len;
563  s->buf_ptr = dst;
564  s->buf_end = dst + len;
565  s->bytes_read += len;
566  }
567 }
568 
569 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
570  unsigned int len)
571 {
573 }
574 
575 unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf,
576  unsigned int len)
577 {
579 }
580 
581 unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf,
582  unsigned int len)
583 {
585 }
586 
588 {
589  s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
590  s->buf_ptr - s->checksum_ptr);
591  s->update_checksum = NULL;
592  return s->checksum;
593 }
594 
596  unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
597  unsigned long checksum)
598 {
599  s->update_checksum = update_checksum;
600  if (s->update_checksum) {
601  s->checksum = checksum;
602  s->checksum_ptr = s->buf_ptr;
603  }
604 }
605 
606 /* XXX: put an inline version */
608 {
609  if (s->buf_ptr >= s->buf_end)
610  fill_buffer(s);
611  if (s->buf_ptr < s->buf_end)
612  return *s->buf_ptr++;
613  return 0;
614 }
615 
616 int avio_read(AVIOContext *s, unsigned char *buf, int size)
617 {
618  int len, size1;
619 
620  size1 = size;
621  while (size > 0) {
622  len = FFMIN(s->buf_end - s->buf_ptr, size);
623  if (len == 0 || s->write_flag) {
624  if((s->direct || size > s->buffer_size) && !s->update_checksum) {
625  // bypass the buffer and read data directly into buf
626  len = read_packet_wrapper(s, buf, size);
627  if (len == AVERROR_EOF) {
628  /* do not modify buffer if EOF reached so that a seek back can
629  be done without rereading data */
630  s->eof_reached = 1;
631  break;
632  } else if (len < 0) {
633  s->eof_reached = 1;
634  s->error= len;
635  break;
636  } else {
637  s->pos += len;
638  s->bytes_read += len;
639  size -= len;
640  buf += len;
641  // reset the buffer
642  s->buf_ptr = s->buffer;
643  s->buf_end = s->buffer/* + len*/;
644  }
645  } else {
646  fill_buffer(s);
647  len = s->buf_end - s->buf_ptr;
648  if (len == 0)
649  break;
650  }
651  } else {
652  memcpy(buf, s->buf_ptr, len);
653  buf += len;
654  s->buf_ptr += len;
655  size -= len;
656  }
657  }
658  if (size1 == size) {
659  if (s->error) return s->error;
660  if (avio_feof(s)) return AVERROR_EOF;
661  }
662  return size1 - size;
663 }
664 
665 int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
666 {
667  int ret = avio_read(s, buf, size);
668  if (ret == size)
669  return ret;
670  if (ret < 0 && ret != AVERROR_EOF)
671  return ret;
672  return AVERROR_INVALIDDATA;
673 }
674 
675 int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
676 {
677  if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {
678  *data = s->buf_ptr;
679  s->buf_ptr += size;
680  return size;
681  } else {
682  *data = buf;
683  return avio_read(s, buf, size);
684  }
685 }
686 
687 int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
688 {
689  int len;
690 
691  if (size < 0)
692  return AVERROR(EINVAL);
693 
694  if (s->read_packet && s->write_flag) {
695  len = read_packet_wrapper(s, buf, size);
696  if (len > 0)
697  s->pos += len;
698  return len;
699  }
700 
701  len = s->buf_end - s->buf_ptr;
702  if (len == 0) {
703  fill_buffer(s);
704  len = s->buf_end - s->buf_ptr;
705  }
706  if (len > size)
707  len = size;
708  memcpy(buf, s->buf_ptr, len);
709  s->buf_ptr += len;
710  if (!len) {
711  if (s->error) return s->error;
712  if (avio_feof(s)) return AVERROR_EOF;
713  }
714  return len;
715 }
716 
717 unsigned int avio_rl16(AVIOContext *s)
718 {
719  unsigned int val;
720  val = avio_r8(s);
721  val |= avio_r8(s) << 8;
722  return val;
723 }
724 
725 unsigned int avio_rl24(AVIOContext *s)
726 {
727  unsigned int val;
728  val = avio_rl16(s);
729  val |= avio_r8(s) << 16;
730  return val;
731 }
732 
733 unsigned int avio_rl32(AVIOContext *s)
734 {
735  unsigned int val;
736  val = avio_rl16(s);
737  val |= avio_rl16(s) << 16;
738  return val;
739 }
740 
742 {
743  uint64_t val;
744  val = (uint64_t)avio_rl32(s);
745  val |= (uint64_t)avio_rl32(s) << 32;
746  return val;
747 }
748 
749 unsigned int avio_rb16(AVIOContext *s)
750 {
751  unsigned int val;
752  val = avio_r8(s) << 8;
753  val |= avio_r8(s);
754  return val;
755 }
756 
757 unsigned int avio_rb24(AVIOContext *s)
758 {
759  unsigned int val;
760  val = avio_rb16(s) << 8;
761  val |= avio_r8(s);
762  return val;
763 }
764 unsigned int avio_rb32(AVIOContext *s)
765 {
766  unsigned int val;
767  val = avio_rb16(s) << 16;
768  val |= avio_rb16(s);
769  return val;
770 }
771 
772 int ff_get_line(AVIOContext *s, char *buf, int maxlen)
773 {
774  int i = 0;
775  char c;
776 
777  do {
778  c = avio_r8(s);
779  if (c && i < maxlen-1)
780  buf[i++] = c;
781  } while (c != '\n' && c != '\r' && c);
782  if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s))
783  avio_skip(s, -1);
784 
785  buf[i] = 0;
786  return i;
787 }
788 
789 int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
790 {
791  int len = ff_get_line(s, buf, maxlen);
792  while (len > 0 && av_isspace(buf[len - 1]))
793  buf[--len] = '\0';
794  return len;
795 }
796 
797 int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
798 {
799  int len, end;
800  int64_t read = 0;
801  char tmp[1024];
802  char c;
803 
804  do {
805  len = 0;
806  do {
807  c = avio_r8(s);
808  end = (c == '\r' || c == '\n' || c == '\0');
809  if (!end)
810  tmp[len++] = c;
811  } while (!end && len < sizeof(tmp));
813  read += len;
814  } while (!end);
815 
816  if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s))
817  avio_skip(s, -1);
818 
819  if (!c && s->error)
820  return s->error;
821 
822  if (!c && !read && avio_feof(s))
823  return AVERROR_EOF;
824 
825  return read;
826 }
827 
829 {
830  int64_t ret;
831 
832  av_bprint_clear(bp);
834  if (ret < 0)
835  return ret;
836 
837  if (!av_bprint_is_complete(bp))
838  return AVERROR(ENOMEM);
839 
840  return bp->len;
841 }
842 
843 int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
844 {
845  int i;
846 
847  if (buflen <= 0)
848  return AVERROR(EINVAL);
849  // reserve 1 byte for terminating 0
850  buflen = FFMIN(buflen - 1, maxlen);
851  for (i = 0; i < buflen; i++)
852  if (!(buf[i] = avio_r8(s)))
853  return i + 1;
854  buf[i] = 0;
855  for (; i < maxlen; i++)
856  if (!avio_r8(s))
857  return i + 1;
858  return maxlen;
859 }
860 
861 #define GET_STR16(type, read) \
862  int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
863 {\
864  char* q = buf;\
865  int ret = 0;\
866  if (buflen <= 0) \
867  return AVERROR(EINVAL); \
868  while (ret + 1 < maxlen) {\
869  uint8_t tmp;\
870  uint32_t ch;\
871  GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\
872  if (!ch)\
873  break;\
874  PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\
875  }\
876  *q = 0;\
877  return ret;\
878 }\
879 
880 GET_STR16(le, avio_rl16)
882 
883 #undef GET_STR16
884 
886 {
887  uint64_t val;
888  val = (uint64_t)avio_rb32(s) << 32;
889  val |= (uint64_t)avio_rb32(s);
890  return val;
891 }
892 
894  uint64_t val = 0;
895  int tmp;
896 
897  do{
898  tmp = avio_r8(bc);
899  val= (val<<7) + (tmp&127);
900  }while(tmp&128);
901  return val;
902 }
903 
905 {
906  uint8_t *buffer = NULL;
907  int buffer_size, max_packet_size;
908 
909  max_packet_size = h->max_packet_size;
910  if (max_packet_size) {
911  buffer_size = max_packet_size; /* no need to bufferize more than one packet */
912  } else {
913  buffer_size = IO_BUFFER_SIZE;
914  }
915  if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
916  if (buffer_size > INT_MAX/2)
917  return AVERROR(EINVAL);
918  buffer_size *= 2;
919  }
920  buffer = av_malloc(buffer_size);
921  if (!buffer)
922  return AVERROR(ENOMEM);
923 
924  *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
925  (int (*)(void *, uint8_t *, int)) ffurl_read,
926  (int (*)(void *, uint8_t *, int)) ffurl_write,
927  (int64_t (*)(void *, int64_t, int))ffurl_seek);
928  if (!*s)
929  goto fail;
930 
931  (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
932  if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
933  avio_closep(s);
934  goto fail;
935  }
936  (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
937  if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
938  avio_closep(s);
939  goto fail;
940  }
941  (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
942 
943  (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
944  (*s)->max_packet_size = max_packet_size;
945  (*s)->min_packet_size = h->min_packet_size;
946  if(h->prot) {
947  (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
948  (*s)->read_seek =
949  (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
950 
951  if (h->prot->url_read_seek)
952  (*s)->seekable |= AVIO_SEEKABLE_TIME;
953  }
954  (*s)->short_seek_get = (int (*)(void *))ffurl_get_short_seek;
955  (*s)->av_class = &ff_avio_class;
956  return 0;
957 fail:
958  av_freep(&buffer);
959  return AVERROR(ENOMEM);
960 }
961 
963 {
964  if (!s)
965  return NULL;
966 
967  if (s->opaque && s->read_packet == (int (*)(void *, uint8_t *, int))ffurl_read)
968  return s->opaque;
969  else
970  return NULL;
971 }
972 
974 {
975  if (s->update_checksum && s->buf_ptr > s->checksum_ptr) {
976  s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
977  s->buf_ptr - s->checksum_ptr);
978  }
979 }
980 
981 int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
982 {
983  uint8_t *buffer;
984  int max_buffer_size = s->max_packet_size ?
985  s->max_packet_size : IO_BUFFER_SIZE;
986  ptrdiff_t filled = s->buf_end - s->buf_ptr;
987 
988  if (buf_size <= s->buf_end - s->buf_ptr)
989  return 0;
990 
991  buf_size += max_buffer_size - 1;
992 
993  if (buf_size + s->buf_ptr - s->buffer <= s->buffer_size || s->seekable || !s->read_packet)
994  return 0;
995  av_assert0(!s->write_flag);
996 
997  if (buf_size <= s->buffer_size) {
999  memmove(s->buffer, s->buf_ptr, filled);
1000  } else {
1001  buffer = av_malloc(buf_size);
1002  if (!buffer)
1003  return AVERROR(ENOMEM);
1004  update_checksum(s);
1005  memcpy(buffer, s->buf_ptr, filled);
1006  av_free(s->buffer);
1007  s->buffer = buffer;
1008  s->buffer_size = buf_size;
1009  }
1010  s->buf_ptr = s->buffer;
1011  s->buf_end = s->buffer + filled;
1012  s->checksum_ptr = s->buffer;
1013  return 0;
1014 }
1015 
1016 int ffio_set_buf_size(AVIOContext *s, int buf_size)
1017 {
1018  uint8_t *buffer;
1019  buffer = av_malloc(buf_size);
1020  if (!buffer)
1021  return AVERROR(ENOMEM);
1022 
1023  av_free(s->buffer);
1024  s->buffer = buffer;
1025  s->orig_buffer_size =
1026  s->buffer_size = buf_size;
1027  s->buf_ptr = s->buf_ptr_max = buffer;
1028  url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ);
1029  return 0;
1030 }
1031 
1032 int ffio_realloc_buf(AVIOContext *s, int buf_size)
1033 {
1034  uint8_t *buffer;
1035  int data_size;
1036 
1037  if (!s->buffer_size)
1038  return ffio_set_buf_size(s, buf_size);
1039 
1040  if (buf_size <= s->buffer_size)
1041  return 0;
1042 
1043  buffer = av_malloc(buf_size);
1044  if (!buffer)
1045  return AVERROR(ENOMEM);
1046 
1047  data_size = s->write_flag ? (s->buf_ptr - s->buffer) : (s->buf_end - s->buf_ptr);
1048  if (data_size > 0)
1049  memcpy(buffer, s->write_flag ? s->buffer : s->buf_ptr, data_size);
1050  av_free(s->buffer);
1051  s->buffer = buffer;
1052  s->orig_buffer_size = buf_size;
1053  s->buffer_size = buf_size;
1054  s->buf_ptr = s->write_flag ? (s->buffer + data_size) : s->buffer;
1055  if (s->write_flag)
1056  s->buf_ptr_max = s->buffer + data_size;
1057 
1058  s->buf_end = s->write_flag ? (s->buffer + s->buffer_size) : (s->buf_ptr + data_size);
1059 
1060  return 0;
1061 }
1062 
1063 static int url_resetbuf(AVIOContext *s, int flags)
1064 {
1066 
1067  if (flags & AVIO_FLAG_WRITE) {
1068  s->buf_end = s->buffer + s->buffer_size;
1069  s->write_flag = 1;
1070  } else {
1071  s->buf_end = s->buffer;
1072  s->write_flag = 0;
1073  }
1074  return 0;
1075 }
1076 
1077 int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_size)
1078 {
1079  int64_t buffer_start;
1080  int buffer_size;
1081  int overlap, new_size, alloc_size;
1082  uint8_t *buf = *bufp;
1083 
1084  if (s->write_flag) {
1085  av_freep(bufp);
1086  return AVERROR(EINVAL);
1087  }
1088 
1089  buffer_size = s->buf_end - s->buffer;
1090 
1091  /* the buffers must touch or overlap */
1092  if ((buffer_start = s->pos - buffer_size) > buf_size) {
1093  av_freep(bufp);
1094  return AVERROR(EINVAL);
1095  }
1096 
1097  overlap = buf_size - buffer_start;
1098  new_size = buf_size + buffer_size - overlap;
1099 
1100  alloc_size = FFMAX(s->buffer_size, new_size);
1101  if (alloc_size > buf_size)
1102  if (!(buf = (*bufp) = av_realloc_f(buf, 1, alloc_size)))
1103  return AVERROR(ENOMEM);
1104 
1105  if (new_size > buf_size) {
1106  memcpy(buf + buf_size, s->buffer + overlap, buffer_size - overlap);
1107  buf_size = new_size;
1108  }
1109 
1110  av_free(s->buffer);
1111  s->buf_ptr = s->buffer = buf;
1112  s->buffer_size = alloc_size;
1113  s->pos = buf_size;
1114  s->buf_end = s->buf_ptr + buf_size;
1115  s->eof_reached = 0;
1116 
1117  return 0;
1118 }
1119 
1120 int avio_open(AVIOContext **s, const char *filename, int flags)
1121 {
1122  return avio_open2(s, filename, flags, NULL, NULL);
1123 }
1124 
1125 int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
1127  const char *whitelist, const char *blacklist
1128  )
1129 {
1130  URLContext *h;
1131  int err;
1132 
1133  *s = NULL;
1134 
1135  err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
1136  if (err < 0)
1137  return err;
1138  err = ffio_fdopen(s, h);
1139  if (err < 0) {
1140  ffurl_close(h);
1141  return err;
1142  }
1143  return 0;
1144 }
1145 
1146 int avio_open2(AVIOContext **s, const char *filename, int flags,
1148 {
1149  return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
1150 }
1151 
1153 {
1154  URLContext *h;
1155 
1156  if (!s)
1157  return 0;
1158 
1159  avio_flush(s);
1160  h = s->opaque;
1161  s->opaque = NULL;
1162 
1163  av_freep(&s->buffer);
1164  if (s->write_flag)
1165  av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n", s->seek_count, s->writeout_count);
1166  else
1167  av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);
1168  av_opt_free(s);
1169 
1170  avio_context_free(&s);
1171 
1172  return ffurl_close(h);
1173 }
1174 
1176 {
1177  int ret = avio_close(*s);
1178  *s = NULL;
1179  return ret;
1180 }
1181 
1182 int avio_printf(AVIOContext *s, const char *fmt, ...)
1183 {
1184  va_list ap;
1185  AVBPrint bp;
1186 
1187  av_bprint_init(&bp, 0, INT_MAX);
1188  va_start(ap, fmt);
1189  av_vbprintf(&bp, fmt, ap);
1190  va_end(ap);
1191  if (!av_bprint_is_complete(&bp)) {
1192  av_bprint_finalize(&bp, NULL);
1193  s->error = AVERROR(ENOMEM);
1194  return AVERROR(ENOMEM);
1195  }
1196  avio_write(s, bp.str, bp.len);
1197  av_bprint_finalize(&bp, NULL);
1198  return bp.len;
1199 }
1200 
1201 void avio_print_string_array(AVIOContext *s, const char *strings[])
1202 {
1203  for(; *strings; strings++)
1204  avio_write(s, (const unsigned char *)*strings, strlen(*strings));
1205 }
1206 
1207 int avio_pause(AVIOContext *s, int pause)
1208 {
1209  if (!s->read_pause)
1210  return AVERROR(ENOSYS);
1211  return s->read_pause(s->opaque, pause);
1212 }
1213 
1214 int64_t avio_seek_time(AVIOContext *s, int stream_index,
1215  int64_t timestamp, int flags)
1216 {
1217  int64_t ret;
1218  if (!s->read_seek)
1219  return AVERROR(ENOSYS);
1220  ret = s->read_seek(s->opaque, stream_index, timestamp, flags);
1221  if (ret >= 0) {
1222  int64_t pos;
1223  s->buf_ptr = s->buf_end; // Flush buffer
1224  pos = s->seek(s->opaque, 0, SEEK_CUR);
1225  if (pos >= 0)
1226  s->pos = pos;
1227  else if (pos != AVERROR(ENOSYS))
1228  ret = pos;
1229  }
1230  return ret;
1231 }
1232 
1233 int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
1234 {
1235  int ret;
1236  char buf[1024];
1237  while (max_size) {
1238  ret = avio_read(h, buf, FFMIN(max_size, sizeof(buf)));
1239  if (ret == AVERROR_EOF)
1240  return 0;
1241  if (ret <= 0)
1242  return ret;
1243  av_bprint_append_data(pb, buf, ret);
1244  if (!av_bprint_is_complete(pb))
1245  return AVERROR(ENOMEM);
1246  max_size -= ret;
1247  }
1248  return 0;
1249 }
1250 
1252 {
1253  int ret;
1254  URLContext *sc = s->opaque;
1255  URLContext *cc = NULL;
1256  ret = ffurl_accept(sc, &cc);
1257  if (ret < 0)
1258  return ret;
1259  return ffio_fdopen(c, cc);
1260 }
1261 
1263 {
1264  URLContext *cc = c->opaque;
1265  return ffurl_handshake(cc);
1266 }
1267 
1268 /* output in a dynamic buffer */
1269 
1270 typedef struct DynBuffer {
1272  uint8_t *buffer;
1274  uint8_t io_buffer[1];
1275 } DynBuffer;
1276 
1277 static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
1278 {
1279  DynBuffer *d = opaque;
1280  unsigned new_size;
1281 
1282  /* reallocate buffer if needed */
1283  new_size = (unsigned)d->pos + buf_size;
1284  if (new_size < d->pos || new_size > INT_MAX)
1285  return AVERROR(ERANGE);
1286  if (new_size > d->allocated_size) {
1287  unsigned new_allocated_size = d->allocated_size ? d->allocated_size
1288  : new_size;
1289  int err;
1290  while (new_size > new_allocated_size)
1291  new_allocated_size += new_allocated_size / 2 + 1;
1292 
1293  new_allocated_size = FFMIN(new_allocated_size, INT_MAX);
1294 
1295  if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) {
1296  d->allocated_size = 0;
1297  d->size = 0;
1298  return err;
1299  }
1300  d->allocated_size = new_allocated_size;
1301  }
1302  memcpy(d->buffer + d->pos, buf, buf_size);
1303  d->pos = new_size;
1304  if (d->pos > d->size)
1305  d->size = d->pos;
1306  return buf_size;
1307 }
1308 
1309 static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
1310 {
1311  unsigned char buf1[4];
1312  int ret;
1313 
1314  /* packetized write: output the header */
1315  AV_WB32(buf1, buf_size);
1316  ret = dyn_buf_write(opaque, buf1, 4);
1317  if (ret < 0)
1318  return ret;
1319 
1320  /* then the data */
1321  return dyn_buf_write(opaque, buf, buf_size);
1322 }
1323 
1324 static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
1325 {
1326  DynBuffer *d = opaque;
1327 
1328  if (whence == SEEK_CUR)
1329  offset += d->pos;
1330  else if (whence == SEEK_END)
1331  offset += d->size;
1332  if (offset < 0)
1333  return AVERROR(EINVAL);
1334  if (offset > INT_MAX)
1335  return AVERROR(ERANGE);
1336  d->pos = offset;
1337  return 0;
1338 }
1339 
1340 static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
1341 {
1342  DynBuffer *d;
1343  unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1344 
1345  if (sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
1346  return AVERROR(ERANGE);
1347  d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
1348  if (!d)
1349  return AVERROR(ENOMEM);
1350  d->io_buffer_size = io_buffer_size;
1351  *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL,
1352  max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
1353  max_packet_size ? NULL : dyn_buf_seek);
1354  if(!*s) {
1355  av_free(d);
1356  return AVERROR(ENOMEM);
1357  }
1358  (*s)->max_packet_size = max_packet_size;
1359  return 0;
1360 }
1361 
1363 {
1364  return url_open_dyn_buf_internal(s, 0);
1365 }
1366 
1367 int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
1368 {
1369  if (max_packet_size <= 0)
1370  return AVERROR(EINVAL);
1371  return url_open_dyn_buf_internal(s, max_packet_size);
1372 }
1373 
1374 int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
1375 {
1376  DynBuffer *d;
1377 
1378  if (!s) {
1379  *pbuffer = NULL;
1380  return 0;
1381  }
1382  d = s->opaque;
1383 
1384  if (!s->error && !d->size) {
1385  *pbuffer = d->io_buffer;
1386  return FFMAX(s->buf_ptr, s->buf_ptr_max) - s->buffer;
1387  }
1388 
1389  avio_flush(s);
1390 
1391  *pbuffer = d->buffer;
1392 
1393  return d->size;
1394 }
1395 
1397 {
1398  DynBuffer *d = s->opaque;
1399  int max_packet_size = s->max_packet_size;
1400 
1401  ffio_init_context(s, d->io_buffer, d->io_buffer_size, 1, d, NULL,
1402  s->write_packet, s->seek);
1403  s->max_packet_size = max_packet_size;
1404  d->pos = d->size = 0;
1405 }
1406 
1407 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
1408 {
1409  DynBuffer *d;
1410  int size;
1411  static const char padbuf[AV_INPUT_BUFFER_PADDING_SIZE] = {0};
1412  int padding = 0;
1413 
1414  if (!s) {
1415  *pbuffer = NULL;
1416  return 0;
1417  }
1418 
1419  /* don't attempt to pad fixed-size packet buffers */
1420  if (!s->max_packet_size) {
1421  avio_write(s, padbuf, sizeof(padbuf));
1422  padding = AV_INPUT_BUFFER_PADDING_SIZE;
1423  }
1424 
1425  avio_flush(s);
1426 
1427  d = s->opaque;
1428  *pbuffer = d->buffer;
1429  size = d->size;
1430  av_free(d);
1431 
1432  avio_context_free(&s);
1433 
1434  return size - padding;
1435 }
1436 
1438 {
1439  DynBuffer *d;
1440 
1441  if (!*s)
1442  return;
1443 
1444  d = (*s)->opaque;
1445  av_free(d->buffer);
1446  av_free(d);
1448 }
1449 
1450 static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
1451 {
1452  DynBuffer *d = opaque;
1453 
1454  d->pos += buf_size;
1455  if (d->pos > d->size)
1456  d->size = d->pos;
1457  return buf_size;
1458 }
1459 
1461 {
1462  int ret = url_open_dyn_buf_internal(s, 0);
1463  if (ret >= 0) {
1464  AVIOContext *pb = *s;
1466  }
1467  return ret;
1468 }
1469 
1471 {
1472  DynBuffer *d = s->opaque;
1473  int size;
1474 
1475  avio_flush(s);
1476 
1477  size = d->size;
1478  av_free(d);
1479 
1480  avio_context_free(&s);
1481 
1482  return size;
1483 }
ff_get_chomp_line
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.
Definition: aviobuf.c:789
be
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
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:187
put_str16
static int put_str16(AVIOContext *s, const char *str, const int be)
Definition: aviobuf.c:392
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:354
AVIO_DATA_MARKER_BOUNDARY_POINT
@ AVIO_DATA_MARKER_BOUNDARY_POINT
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
Definition: avio.h:128
null_buf_write
static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
Definition: aviobuf.c:1450
ffurl_context_class
const AVClass ffurl_context_class
Definition: avio.c:64
D
#define D
Definition: aviobuf.c:60
AVERROR
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
opt.h
avio_get_dyn_buf
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1374
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
url_open_dyn_buf_internal
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
Definition: aviobuf.c:1340
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
ffurl_seek
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.
Definition: avio.c:425
avio_rl24
unsigned int avio_rl24(AVIOContext *s)
Definition: aviobuf.c:725
dyn_buf_seek
static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
Definition: aviobuf.c:1324
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
avio_wl24
void avio_wl24(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:457
av_isspace
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition: avstring.h:227
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:27
ffio_get_checksum
unsigned long ffio_get_checksum(AVIOContext *s)
Definition: aviobuf.c:587
DynBuffer::buffer
uint8_t * buffer
Definition: aviobuf.c:1272
ffio_open_null_buf
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
Definition: aviobuf.c:1460
ffio_geturlcontext
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
Definition: aviobuf.c:962
AVOption
AVOption.
Definition: opt.h:248
b
#define b
Definition: input.c:41
AVSEEK_SIZE
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
Definition: avio.h:531
IO_BUFFER_SIZE
#define IO_BUFFER_SIZE
Definition: aviobuf.c:36
data
const char data[16]
Definition: mxf.c:142
avio_seek_time
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.
Definition: aviobuf.c:1214
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:197
avio_accept
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
Definition: aviobuf.c:1251
ffurl_close
int ffurl_close(URLContext *h)
Definition: avio.c:458
DynBuffer::io_buffer
uint8_t io_buffer[1]
Definition: aviobuf.c:1274
avio_put_str
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
Definition: aviobuf.c:381
ffio_fill
void ffio_fill(AVIOContext *s, int b, int count)
Definition: aviobuf.c:201
AVDictionary
Definition: dict.c:30
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:365
av_bprint_append_data
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
Definition: bprint.c:158
avio_read_to_bprint
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.
Definition: aviobuf.c:1233
ff_crcEDB88320_update
unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:575
AVIODataMarkerType
AVIODataMarkerType
Different data types that can be returned via the AVIO write_data_type callback.
Definition: avio.h:111
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:193
update_checksum
static void update_checksum(AVIOContext *s)
Definition: aviobuf.c:973
fill_buffer
static void fill_buffer(AVIOContext *s)
Definition: aviobuf.c:518
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AVIOInterruptCB
Callback for checking whether to abort blocking functions.
Definition: avio.h:58
crc.h
ffio_reset_dyn_buf
void ffio_reset_dyn_buf(AVIOContext *s)
Reset a dynamic buffer.
Definition: aviobuf.c:1396
fail
#define fail()
Definition: checkasm.h:134
AV_CRC_16_ANSI_LE
@ AV_CRC_16_ANSI_LE
Definition: crc.h:55
val
static double val(void *priv, double ch)
Definition: aeval.c:76
avio_wb24
void avio_wb24(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:463
type
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
Definition: writing_filters.txt:86
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:445
ffio_open_whitelist
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
Definition: aviobuf.c:1125
OFFSET
#define OFFSET(x)
Definition: aviobuf.c:58
ff_avio_child_next
static void * ff_avio_child_next(void *obj, void *prev)
Definition: aviobuf.c:45
avio_print_string_array
void avio_print_string_array(AVIOContext *s, const char *strings[])
Write a NULL terminated array of strings to the context.
Definition: aviobuf.c:1201
GET_UTF8
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
Definition: common.h:499
flush_buffer
static void flush_buffer(AVIOContext *s)
Definition: aviobuf.c:177
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:181
avio_write_marker
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
Definition: aviobuf.c:469
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:235
ffurl_open_whitelist
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.
Definition: avio.c:306
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:373
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
ffio_read_size
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:665
ff_avio_class
const AVClass ff_avio_class
Definition: aviobuf.c:66
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1407
DynBuffer::pos
int pos
Definition: aviobuf.c:1271
ffio_set_buf_size
int ffio_set_buf_size(AVIOContext *s, int buf_size)
Definition: aviobuf.c:1016
ffio_read_indirect
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
Definition: aviobuf.c:675
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:675
avio_context_free
void avio_context_free(AVIOContext **ps)
Free the supplied IO context and everything associated with it.
Definition: aviobuf.c:145
if
if(ret)
Definition: filter_design.txt:179
ffurl_accept
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
Definition: avio.c:226
av_vbprintf
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
Definition: bprint.c:117
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:33
ffio_init_context
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))
Definition: aviobuf.c:78
internal.h
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:616
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
ff_avio_options
static const AVOption ff_avio_options[]
Definition: aviobuf.c:61
NULL
#define NULL
Definition: coverity.c:32
DynBuffer
Definition: aviobuf.c:1270
AVIO_DATA_MARKER_TRAILER
@ AVIO_DATA_MARKER_TRAILER
Trailer data, which doesn't contain actual content, but only for finalizing the output file.
Definition: avio.h:140
PUT_UTF16
#define PUT_UTF16(val, tmp, PUT_16BIT)
Definition: common.h:586
avio_printf
int avio_printf(AVIOContext *s, const char *fmt,...)
Definition: aviobuf.c:1182
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1611
SHORT_SEEK_THRESHOLD
#define SHORT_SEEK_THRESHOLD
Do seeks within this distance ahead of the current buffer by skipping data instead of calling the pro...
Definition: aviobuf.c:43
read_packet_wrapper
static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
Definition: aviobuf.c:505
c
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
Definition: undefined.txt:32
avio_pause
int avio_pause(AVIOContext *s, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e....
Definition: aviobuf.c:1207
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:185
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
avio_rb24
unsigned int avio_rb24(AVIOContext *s)
Definition: aviobuf.c:757
dyn_packet_buf_write
static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
Definition: aviobuf.c:1309
options
const OptionDef options[]
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:749
ffio_realloc_buf
int ffio_realloc_buf(AVIOContext *s, int buf_size)
Reallocate a given buffer for AVIOContext.
Definition: aviobuf.c:1032
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
ff_read_line_to_bprint_overwrite
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.
Definition: aviobuf.c:828
FFMAX
#define FFMAX(a, b)
Definition: common.h:103
ffio_free_dyn_buf
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
Definition: aviobuf.c:1437
size
int size
Definition: twinvq_data.h:10344
avio.h
ffio_ensure_seekback
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition: aviobuf.c:981
av_reallocp
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:167
avio_open
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:1120
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AVIO_SEEKABLE_TIME
#define AVIO_SEEKABLE_TIME
Seeking by timestamp with avio_seek_time() is possible.
Definition: avio.h:45
dyn_buf_write
static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
Definition: aviobuf.c:1277
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:717
avio_rl64
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:741
ffio_rewind_with_probe_data
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.
Definition: aviobuf.c:1077
AVIO_DATA_MARKER_SYNC_POINT
@ AVIO_DATA_MARKER_SYNC_POINT
A point in the output bytestream where a decoder can start decoding (i.e.
Definition: avio.h:122
avio_close
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: aviobuf.c:1152
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AVIOContext::write_packet
int(* write_packet)(void *opaque, uint8_t *buf, int buf_size)
Definition: avio.h:236
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
offset
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
Definition: writing_filters.txt:86
avio_open2
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.
Definition: aviobuf.c:1146
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:733
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:215
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:243
ffurl_get_short_seek
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL.
Definition: avio.c:641
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:729
ffio_init_checksum
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
Definition: aviobuf.c:595
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
ffio_open_dyn_packet_buf
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'.
Definition: aviobuf.c:1367
bprint.h
i
int i
Definition: input.c:407
URLContext
Definition: url.h:38
log.h
avio_internal.h
PUT_STR16
#define PUT_STR16(type, big_endian)
Definition: aviobuf.c:422
ffio_read_varlen
uint64_t ffio_read_varlen(AVIOContext *bc)
Definition: aviobuf.c:893
ff_read_line_to_bprint
int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
Read a whole line of text from AVIOContext to an AVBPrint buffer.
Definition: aviobuf.c:797
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
url.h
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:243
ff_get_line
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
Definition: aviobuf.c:772
GET_STR16
#define GET_STR16(type, read)
Definition: aviobuf.c:861
len
int len
Definition: vorbis_enc_data.h:426
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:513
AV_CRC_32_IEEE
@ AV_CRC_32_IEEE
Definition: crc.h:53
DynBuffer::io_buffer_size
int io_buffer_size
Definition: aviobuf.c:1273
avio_wb64
void avio_wb64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:439
AVIO_DATA_MARKER_UNKNOWN
@ AVIO_DATA_MARKER_UNKNOWN
This is any, unlabelled data.
Definition: avio.h:135
avio_get_str
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition: aviobuf.c:843
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
checksum
static volatile int checksum
Definition: adler32.c:30
dict.h
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: avcodec.h:192
av_bprint_clear
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:227
ff_crc04C11DB7_update
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:569
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:607
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
ffurl_read
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.
Definition: avio.c:398
buffer
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
Definition: filter_design.txt:49
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:392
url_resetbuf
static int url_resetbuf(AVIOContext *s, int flags)
Definition: aviobuf.c:1063
AVIO_DATA_MARKER_HEADER
@ AVIO_DATA_MARKER_HEADER
Header data; this needs to be present for the stream to be decodeable.
Definition: avio.h:115
ffurl_write
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:412
ff_crcA001_update
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:581
DynBuffer::size
int size
Definition: aviobuf.c:1271
AVSEEK_FORCE
#define AVSEEK_FORCE
Passing this flag as the "whence" parameter to a seek function causes it to seek by any means (like r...
Definition: avio.h:539
AVIO_FLAG_DIRECT
#define AVIO_FLAG_DIRECT
Use direct mode.
Definition: avio.h:701
AV_CRC_32_IEEE_LE
@ AV_CRC_32_IEEE_LE
Definition: crc.h:54
AVIO_FLAG_READ
#define AVIO_FLAG_READ
read-only
Definition: avio.h:674
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:259
avio_alloc_context
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.
Definition: aviobuf.c:128
ffio_fdopen
int ffio_fdopen(AVIOContext **s, URLContext *h)
Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h.
Definition: aviobuf.c:904
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1362
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:451
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
ffurl_handshake
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
Definition: avio.c:234
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
DynBuffer::allocated_size
int allocated_size
Definition: aviobuf.c:1271
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:764
d
d
Definition: ffmpeg_filter.c:156
convert_header.str
string str
Definition: convert_header.py:20
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ffio_close_null_buf
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
Definition: aviobuf.c:1470
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
avio_handshake
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
Definition: aviobuf.c:1262
writeout
static void writeout(AVIOContext *s, const uint8_t *data, int len)
Definition: aviobuf.c:150
child_class_iterate
static const AVClass * child_class_iterate(void **iter)
Definition: aviobuf.c:51
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:332
avio_read_partial
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:687
int
int
Definition: ffmpeg_filter.c:156
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:433
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:327
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:885
avio_closep
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition: aviobuf.c:1175
AVIO_DATA_MARKER_FLUSH_POINT
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
Definition: avio.h:146