mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 04:51:52 +00:00
seek.c moved to demuxer.c, stream_reset in new_demuxer()
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1498 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
935bc73d6b
commit
255aedeb1a
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ PRG_CFG = codec-cfg
|
||||
#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)
|
||||
|
@ -341,7 +341,7 @@ do{
|
||||
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 @@ void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){
|
||||
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
|
||||
|
59
demuxer.c
59
demuxer.c
@ -57,6 +57,8 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){
|
||||
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_packets101;
|
||||
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 @@ sh_video_t *sh_video=NULL;
|
||||
|
||||
//=============== 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 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AVI){
|
||||
}
|
||||
//=============== 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_ASF){
|
||||
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 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
|
||||
}
|
||||
//=============== 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 @@ if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!
|
||||
//=============== 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 @@ switch(file_format){
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -593,7 +593,7 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
|
||||
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) {
|
||||
|
76
seek.c
76
seek.c
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user