changeset 558:89bd76208427 libavformat

100l (forgoten seeking functions)
author michael
date Mon, 11 Oct 2004 23:53:53 +0000
parents 084de726b4d0
children f5f85a07fafe
files avformat.h avidec.c ffm.c mov.c raw.c rtsp.c wav.c
diffstat 7 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/avformat.h	Mon Oct 11 19:42:18 2004 +0000
+++ b/avformat.h	Mon Oct 11 23:53:53 2004 +0000
@@ -441,7 +441,7 @@
 
 /* raw.c */
 int pcm_read_seek(AVFormatContext *s, 
-                  int stream_index, int64_t timestamp);
+                  int stream_index, int64_t timestamp, int flags);
 int raw_init(void);
 
 /* mp3.c */
--- a/avidec.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/avidec.c	Mon Oct 11 23:53:53 2004 +0000
@@ -649,7 +649,7 @@
     return m;
 }
 
-static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp)
+static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 {
     AVIContext *avi = s->priv_data;
     AVStream *st;
--- a/ffm.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/ffm.c	Mon Oct 11 23:53:53 2004 +0000
@@ -627,7 +627,7 @@
 /* seek to a given time in the file. The file read pointer is
    positionned at or before pts. XXX: the following code is quite
    approximative */
-static int ffm_seek(AVFormatContext *s, int64_t wanted_pts)
+static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
 {
     FFMContext *ffm = s->priv_data;
     offset_t pos_min, pos_max, pos;
@@ -662,7 +662,7 @@
             pos_min = pos + FFM_PACKET_SIZE;
         }
     }
-    pos = pos_min;
+    pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
     if (pos > 0)
         pos -= FFM_PACKET_SIZE;
  found:
--- a/mov.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/mov.c	Mon Oct 11 23:53:53 2004 +0000
@@ -1846,7 +1846,7 @@
 /**
  * Seek method based on the one described in the Appendix C of QTFileFormat.pdf
  */
-static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp)
+static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 {
     MOVContext* mov = (MOVContext *) s->priv_data;
     MOVStreamContext* sc;
--- a/raw.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/raw.c	Mon Oct 11 23:53:53 2004 +0000
@@ -126,7 +126,7 @@
 }
 
 int pcm_read_seek(AVFormatContext *s, 
-                  int stream_index, int64_t timestamp)
+                  int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st;
     int block_align, byte_rate;
@@ -158,8 +158,11 @@
         return -1;
 
     /* compute the position by aligning it to block_align */
-    pos = av_rescale(timestamp * byte_rate, st->time_base.num, st->time_base.den);
-    pos = (pos / block_align) * block_align;
+    pos = av_rescale_rnd(timestamp * byte_rate, 
+                         st->time_base.num, 
+                         st->time_base.den * (int64_t)block_align,
+                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
+    pos *= block_align;
 
     /* recompute exact position */
     st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
--- a/rtsp.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/rtsp.c	Mon Oct 11 23:53:53 2004 +0000
@@ -1111,7 +1111,7 @@
 }
 
 static int rtsp_read_seek(AVFormatContext *s, int stream_index, 
-                          int64_t timestamp)
+                          int64_t timestamp, int flags)
 {
     RTSPState *rt = s->priv_data;
     
--- a/wav.c	Mon Oct 11 19:42:18 2004 +0000
+++ b/wav.c	Mon Oct 11 23:53:53 2004 +0000
@@ -344,7 +344,7 @@
 }
 
 static int wav_read_seek(AVFormatContext *s, 
-                         int stream_index, int64_t timestamp)
+                         int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st;
 
@@ -359,7 +359,7 @@
     default:
         break;
     }
-    return pcm_read_seek(s, stream_index, timestamp);
+    return pcm_read_seek(s, stream_index, timestamp, flags);
 }