summaryrefslogtreecommitdiffstats
path: root/demux/ebml.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-05 16:36:18 +0100
committerwm4 <wm4@nowhere>2017-11-05 18:13:34 +0100
commit9e1fbffc37779c8f491d3aa8e319ab233e5ab0da (patch)
tree894c25cc6443805d3453c3a4788ed4ab1ee0bedc /demux/ebml.h
parent8aa1db3b175d29201f55648849b4f2ddc15f8ea1 (diff)
downloadmpv-9e1fbffc37779c8f491d3aa8e319ab233e5ab0da.tar.bz2
mpv-9e1fbffc37779c8f491d3aa8e319ab233e5ab0da.tar.xz
demux_mkv: rewrite packet reading to avoid 1 memcpy()
This directly reads individual mkv sub-packets (block laces) into a dedicated AVBufferRefs, which can be directly used for creating packets without a additional copy of the packet data. This also means we switch parsing of block header fields and lacing metadata to read directly from the stream, instead of a memory buffer. This could have been much easier if libavcodec didn't require padding the packet data with zero bytes. We could just have each packet reference a slice of the block data. But as it is, the only way to get padding without a copy is to read the laces into individually allocated (and padded) memory block, which required a larger rewrite. This probably makes recovering from broken mkv files slightly worse if the transport is unseekable. We just read, and then check if we've overread. But I think that shouldn't be a real concern. No actual measureable performance change. Potential for some regressions, as this is quite intrusive, and touches weird obscure shit like mkv lacing. Still keeping it because I like how it removes some redundant EBML parsing functions.
Diffstat (limited to 'demux/ebml.h')
-rw-r--r--demux/ebml.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/demux/ebml.h b/demux/ebml.h
index 8b67ea7071..86a40092b6 100644
--- a/demux/ebml.h
+++ b/demux/ebml.h
@@ -80,9 +80,8 @@ struct ebml_parse_ctx {
bool ebml_is_mkv_level1_id(uint32_t id);
uint32_t ebml_read_id (stream_t *s);
-uint64_t ebml_read_vlen_uint (bstr *buffer);
-int64_t ebml_read_vlen_int (bstr *buffer);
uint64_t ebml_read_length (stream_t *s);
+int64_t ebml_read_signed_length(stream_t *s);
uint64_t ebml_read_uint (stream_t *s);
int64_t ebml_read_int (stream_t *s);
int ebml_read_skip(struct mp_log *log, int64_t end, stream_t *s);