diff tta.c @ 2041:b377fc84b6f9 libavformat

Support for seeking in TTA files.
author conrad
date Wed, 25 Apr 2007 23:22:05 +0000
parents d3c1ef5b9a2f
children 06083249909c
line wrap: on
line diff
--- a/tta.c	Wed Apr 25 15:58:05 2007 +0000
+++ b/tta.c	Wed Apr 25 23:22:05 2007 +0000
@@ -120,6 +120,20 @@
     return av_get_packet(&s->pb, pkt, size);
 }
 
+static int tta_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+    TTAContext *c = s->priv_data;
+    AVStream *st = s->streams[stream_index];
+    int index = av_index_search_timestamp(st, timestamp, flags);
+    if (index < 0)
+        return -1;
+
+    c->currentframe = index;
+    url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET);
+
+    return 0;
+}
+
 AVInputFormat tta_demuxer = {
     "tta",
     "true-audio",
@@ -128,5 +142,6 @@
     tta_read_header,
     tta_read_packet,
     NULL,
+    tta_read_seek,
     .extensions = "tta",
 };