mirror of https://github.com/mpv-player/mpv
New member in demuxer_t: reference_clock.
If it's != MP_NOPTS_VALUE ds_fill_buffer() will keep on demuxing until the pts of the next_pts is <= reference_clock. It guarantees the compliance with the buffering model indicated by the transmitter of the multiplex and a long-time stability of playback (at least for me). In any case up to a maximum of 64 packets are accumulated to prevent memory hogging and leaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26069 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
5f2b3c6c67
commit
8f0095af65
|
@ -206,6 +206,7 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id,char
|
|||
memset(d,0,sizeof(demuxer_t));
|
||||
d->stream=stream;
|
||||
d->stream_pts = MP_NOPTS_VALUE;
|
||||
d->reference_clock = MP_NOPTS_VALUE;
|
||||
d->movi_start=stream->start_pos;
|
||||
d->movi_end=stream->end_pos;
|
||||
d->seekable=1;
|
||||
|
@ -405,6 +406,7 @@ int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
|
|||
// return value:
|
||||
// 0 = EOF
|
||||
// 1 = successful
|
||||
#define MAX_ACUMULATED_PACKETS 64
|
||||
int ds_fill_buffer(demux_stream_t *ds){
|
||||
demuxer_t *demux=ds->demuxer;
|
||||
if(ds->current) free_demux_packet(ds->current);
|
||||
|
@ -418,6 +420,13 @@ int ds_fill_buffer(demux_stream_t *ds){
|
|||
while(1){
|
||||
if(ds->packs){
|
||||
demux_packet_t *p=ds->first;
|
||||
if(demux->reference_clock != MP_NOPTS_VALUE) {
|
||||
if((p->pts != MP_NOPTS_VALUE) && (p->pts > demux->reference_clock)
|
||||
&& (ds->packs < MAX_ACUMULATED_PACKETS)) {
|
||||
if(demux_fill_buffer(demux,ds))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// copy useful data:
|
||||
ds->buffer=p->buffer;
|
||||
ds->buffer_pos=0;
|
||||
|
|
|
@ -194,6 +194,7 @@ typedef struct demuxer_st {
|
|||
off_t movi_end;
|
||||
stream_t *stream;
|
||||
double stream_pts; // current stream pts, if applicable (e.g. dvd)
|
||||
double reference_clock;
|
||||
char *filename; ///< Needed by avs_check_file
|
||||
int synced; // stream synced (used by mpeg)
|
||||
int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
|
||||
|
|
Loading…
Reference in New Issue