[FFmpeg-devel,18/37] avformat/matroskadec: Add function to reset status

Submitted by Andreas Rheinhardt on May 16, 2019, 10:30 p.m.

Details

Message ID 20190516223018.30827-19-andreas.rheinhardt@gmail.com
State Accepted
Commit 310f326b4354d7353850e00393aeecada3c3c2c0
Headers show

Commit Message

Andreas Rheinhardt May 16, 2019, 10:30 p.m.
This function will be useful later to reset the status (e.g. current
level and the already parsed id).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
This function is not used yet, so compilation will likely result in a
warning because of an unused function. This will be fixed with the next
commit. Splitting this into two commits is a suggestion by Steve.
 libavformat/matroskadec.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b14f168c2c..4e81108dbe 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -739,6 +739,25 @@  static const char *const matroska_doctypes[] = { "matroska", "webm" };
 
 static int matroska_read_close(AVFormatContext *s);
 
+/*
+ * This function prepares the status for parsing of level 1 elements.
+ */
+static int matroska_reset_status(MatroskaDemuxContext *matroska,
+                                 uint32_t id, int64_t position)
+{
+    if (position >= 0) {
+        int err = avio_seek(matroska->ctx->pb, position, SEEK_SET);
+        if (err < 0)
+            return err;
+    }
+
+    matroska->current_id = id;
+    matroska->num_levels = 1;
+    matroska->current_cluster.pos = 0;
+
+    return 0;
+}
+
 static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
 {
     AVIOContext *pb = matroska->ctx->pb;