summaryrefslogtreecommitdiff
path: root/libavformat/avio_internal.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-04 16:52:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-25 23:01:54 +0200
commit45bfe8b838275235412777dd430206d9a24eb3ee (patch)
treed35a1ee7436b0259fd26d32bc80482c0a9f2927e /libavformat/avio_internal.h
parent530ac6aa305aeda631c77f8a17e96c14c7ab1a1c (diff)
avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/avio_internal.h')
-rw-r--r--libavformat/avio_internal.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index de95b43bdb..8b9e048f73 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -26,7 +26,54 @@
extern const AVClass ff_avio_class;
-int ffio_init_context(AVIOContext *s,
+typedef struct FFIOContext {
+ AVIOContext pub;
+ /**
+ * A callback that is used instead of short_seek_threshold.
+ */
+ int (*short_seek_get)(void *opaque);
+
+ /**
+ * Threshold to favor readahead over seek.
+ */
+ int short_seek_threshold;
+
+ enum AVIODataMarkerType current_type;
+ int64_t last_time;
+
+ /**
+ * max filesize, used to limit allocations
+ */
+ int64_t maxsize;
+
+ /**
+ * Bytes read statistic
+ */
+ int64_t bytes_read;
+
+ /**
+ * seek statistic
+ */
+ int seek_count;
+
+ /**
+ * writeout statistic
+ */
+ int writeout_count;
+
+ /**
+ * Original buffer size
+ * used after probing to ensure seekback and to reset the buffer size
+ */
+ int orig_buffer_size;
+} FFIOContext;
+
+static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx)
+{
+ return (FFIOContext*)ctx;
+}
+
+void ffio_init_context(FFIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,