//=================== DEMUXER v2.5 =========================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "../m_config.h"
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
#include "mf.h"
#include "../libvo/fastmemcpy.h"
void free_demuxer_stream(demux_stream_t *ds){
ds_free_packs(ds);
free(ds);
}
demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
demux_stream_t* ds=malloc(sizeof(demux_stream_t));
ds->buffer_pos=ds->buffer_size=0;
ds->buffer=NULL;
ds->pts=0;
ds->pts_bytes=0;
ds->eof=0;
ds->pos=0;
ds->dpos=0;
ds->pack_no=0;
//---------------
ds->packs=0;
ds->bytes=0;
ds->first=ds->last=ds->current=NULL;
ds->id=id;
ds->demuxer=demuxer;
//----------------
ds->asf_seq=-1;
ds->asf_packet=NULL;
//----------------
ds->ss_mul=ds->ss_div=0;
//----------------
ds->sh=NULL;
return ds;
}
demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){
demuxer_t *d=malloc(sizeof(demuxer_t));
memset(d,0,sizeof(demuxer_t));
d->stream=stream;
d->movi_start=stream->start_pos;
d->movi_end=stream->end_pos;
d->seekable=1;
d->synced=0;
d->filepos=0;
d->audio=new_demuxer_stream(d,a_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;
}
sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
if(id > MAX_A_STREAMS-1 || id < 0)
{
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n",
id, MAX_A_STREAMS);
return NULL;
}
if(demuxer->a_streams[id]){
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id);
} else {
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundAudioStream,id);
demuxer->a_streams[id]=malloc(sizeof(sh_audio_t));
memset(demuxer->a_streams[id],0,sizeof(sh_audio_t));
}
return demuxer->a_streams[id];
}
void free_sh_audio(sh_audio_t* sh){
mp_msg(MSGT_DEMUXER,MSGL_V,"DEMUXER: freeing sh_audio at %p \n",sh);
if(sh->wf) free(sh->wf);
free(sh);
}
sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
if(id > MAX_V_STREAMS-1 || id < 0)
{
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n",
id, MAX_V_STREAMS);
return NULL;
}
if(demuxer->v_streams[id]){
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
} else {
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id);
demuxer->v_streams[id]=malloc(sizeof(sh_video_t));
memset(demuxer->v_streams[id],0,sizeof(sh_video_t));
}
return demuxer->v_streams[id];
}
void free_sh_video(sh_video_t* s
|