changeset 1497:ad4d402b3d29

seek.c moved to demuxer.c, stream_reset in new_demuxer()
author arpi
date Sun, 12 Aug 2001 17:28:16 +0000
parents 8c3e93ef116d
children 6174b815b5f4
files Makefile demux_mpg.c demuxer.c mplayer.c seek.c
diffstat 5 files changed, 52 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Aug 12 15:46:09 2001 +0000
+++ b/Makefile	Sun Aug 12 17:28:16 2001 +0000
@@ -16,7 +16,7 @@
 #prefix = /usr/local
 BINDIR = ${prefix}/bin
 # BINDIR = /usr/local/bin
-SRCS = open.c seek.c parse_es.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS)
+SRCS = open.c parse_es.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS)
 OBJS = $(SRCS:.c=.o)
 CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) $(EXTRA_INC) # -Wall
 A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3 $(ALSA_LIB) $(ESD_LIB)
--- a/demux_mpg.c	Sun Aug 12 15:46:09 2001 +0000
+++ b/demux_mpg.c	Sun Aug 12 17:28:16 2001 +0000
@@ -341,7 +341,7 @@
   return 1;
 }
 
-extern off_t seek_to_byte;
+//extern off_t seek_to_byte;
 
 void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){
     demux_stream_t *d_audio=demuxer->audio;
@@ -356,7 +356,7 @@
         else
           newpos=demuxer->filepos+(sh_video->i_bps)*rel_seek_secs;
 
-        if(newpos<seek_to_byte) newpos=seek_to_byte; // for VCD
+        if(newpos<demuxer->stream->start_pos) newpos=demuxer->stream->start_pos; // for VCD
 #ifdef _LARGEFILE_SOURCE
         newpos&=~((long long)STREAM_BUFFER_SIZE-1);  /* sector boundary */
 #else
--- a/demuxer.c	Sun Aug 12 15:46:09 2001 +0000
+++ b/demuxer.c	Sun Aug 12 17:28:16 2001 +0000
@@ -57,6 +57,8 @@
   d->video=new_demuxer_stream(d,v_id);
   d->sub=new_demuxer_stream(d,s_id);
   d->type=type;
+  stream_reset(stream);
+  stream_seek(stream,stream->start_pos);
   return d;
 }
 
@@ -293,7 +295,7 @@
 extern int num_elementary_packetsPES;
 
 // commandline options, flags:
-extern int seek_to_byte;
+//extern int seek_to_byte;
 extern int force_ni;
 extern int pts_from_bps;
 
@@ -321,9 +323,7 @@
 
 //=============== Try to open as AVI file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AVI){
-  stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_AVI,audio_id,video_id,dvdsub_id);
-  stream_seek(demuxer->stream,seek_to_byte);
   { //---- RIFF header:
     int id=stream_read_dword_le(demuxer->stream); // "RIFF"
     if(id==mmioFOURCC('R','I','F','F')){
@@ -338,9 +338,7 @@
 }
 //=============== Try to open as ASF file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_ASF){
-  stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_ASF,audio_id,video_id,dvdsub_id);
-  stream_seek(demuxer->stream,seek_to_byte);
   if(asf_check_header(demuxer)){
       printf("Detected ASF file format!\n");
       file_format=DEMUXER_TYPE_ASF;
@@ -350,9 +348,7 @@
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
  int pes=1;
  while(pes>=0){
-  stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
-  stream_seek(demuxer->stream,seek_to_byte);
   if(!pes) demuxer->synced=1; // hack!
   if(ds_fill_buffer(demuxer->video)){
     if(!pes)
@@ -380,9 +376,7 @@
 }
 //=============== Try to open as MPEG-ES file: =================
 if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!
-  stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_ES,audio_id,video_id,dvdsub_id);
-  stream_seek(demuxer->stream,seek_to_byte);
   if(!ds_fill_buffer(demuxer->video)){
     printf("Invalid MPEG-ES stream??? contact the author, it may be a bug :(\n");
     file_format=DEMUXER_TYPE_UNKNOWN;
@@ -393,9 +387,7 @@
 //=============== Try to open as MOV file: =================
 #if 1
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MOV){
-  stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MOV,audio_id,video_id,dvdsub_id);
-  stream_seek(demuxer->stream,seek_to_byte);
   if(mov_check_file(demuxer)){
       printf("Detected QuickTime/MOV file format!\n");
       file_format=DEMUXER_TYPE_MOV;
@@ -489,3 +481,48 @@
 
 return demuxer;
 }
+
+
+
+int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
+int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
+int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
+
+int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
+    demux_stream_t *d_audio=demuxer->audio;
+    demux_stream_t *d_video=demuxer->video;
+    sh_audio_t *sh_audio=d_audio->sh;
+    sh_video_t *sh_video=d_video->sh;
+
+//if(demuxer->file_format==DEMUXER_TYPE_AVI && demuxer->idx_size<=0){
+//    printf("Can't seek in raw .AVI streams! (index required, try with the -idx switch!)  \n");
+//    return 0;
+//}
+
+    // clear demux buffers:
+    if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
+    ds_free_packs(d_video);
+    
+    demuxer->stream->eof=0; // clear eof flag
+
+    if(sh_audio) sh_audio->timer=0;
+    sh_video->timer=0; // !!!!!!
+
+switch(demuxer->file_format){
+
+  case DEMUXER_TYPE_AVI:
+      demux_seek_avi(demuxer,rel_seek_secs,flags);  break;
+
+  case DEMUXER_TYPE_ASF:
+      demux_seek_asf(demuxer,rel_seek_secs,flags);  break;
+  
+  case DEMUXER_TYPE_MPEG_ES:
+  case DEMUXER_TYPE_MPEG_PS:
+      demux_seek_mpg(demuxer,rel_seek_secs,flags);  break;
+
+} // switch(demuxer->file_format)
+
+return 1;
+}
+
+
--- a/mplayer.c	Sun Aug 12 15:46:09 2001 +0000
+++ b/mplayer.c	Sun Aug 12 17:28:16 2001 +0000
@@ -593,7 +593,7 @@
   stream=open_stream(filename,vcd_track,&file_format);
   if(!stream) return 1; // error...
   use_stdin=(!strcmp(filename,"-"));
-  seek_to_byte+=stream->start_pos; // required for VCD
+  stream->start_pos+=seek_to_byte;
 
 #ifdef HAVE_LIBCSS
   if (dvdimportkey) {
--- a/seek.c	Sun Aug 12 15:46:09 2001 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-//extern int verbose; // defined in mplayer.c
-
-#include "config.h"
-
-#include "stream.h"
-#include "demuxer.h"
-#include "parse_es.h"
-
-#include "wine/mmreg.h"
-#include "wine/avifmt.h"
-#include "wine/vfw.h"
-
-#include "codec-cfg.h"
-#include "stheader.h"
-
-//extern void resync_audio_stream(sh_audio_t *sh_audio);
-//extern void skip_audio_frame(sh_audio_t *sh_audio);
-
-//extern int asf_packetsize; // for seeking
-
-//extern char* current_module; // for debugging
-
-// flags:
-//   0x1 - absolute/relative
-//   0x2 - keyframe/hard
-
-int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
-int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
-int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
-
-int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
-    demux_stream_t *d_audio=demuxer->audio;
-    demux_stream_t *d_video=demuxer->video;
-    sh_audio_t *sh_audio=d_audio->sh;
-    sh_video_t *sh_video=d_video->sh;
-//    float skip_audio_secs=0;
-
-//if(demuxer->file_format==DEMUXER_TYPE_AVI && demuxer->idx_size<=0){
-//    printf("Can't seek in raw .AVI streams! (index required, try with the -idx switch!)  \n");
-//    return 0;
-//}
-
-//    current_module="seek";
-
-    // clear demux buffers:
-    if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
-    ds_free_packs(d_video);
-    
-    demuxer->stream->eof=0; // clear eof flag
-
-      if(sh_audio) sh_audio->timer=0;
-      sh_video->timer=0; // !!!!!!
-    
-//    printf("sh_audio->a_buffer_len=%d  \n",sh_audio->a_buffer_len);
-    
-
-switch(demuxer->file_format){
-
-  case DEMUXER_TYPE_AVI:
-      demux_seek_avi(demuxer,rel_seek_secs,flags);  break;
-
-  case DEMUXER_TYPE_ASF:
-      demux_seek_asf(demuxer,rel_seek_secs,flags);  break;
-  
-  case DEMUXER_TYPE_MPEG_ES:
-  case DEMUXER_TYPE_MPEG_PS:
-      demux_seek_mpg(demuxer,rel_seek_secs,flags);  break;
-
-} // switch(demuxer->file_format)
-
-return 1;
-}