[vlc-devel] [PATCH] AVFormat Demux : Reset PCR for streams initialized later on.

Laurent Aimar fenrir at elivagar.org
Sat Jul 24 22:29:33 CEST 2010


Hi,

On Sun, Jul 25, 2010 at 01:28:19AM +0530, Jai Menon wrote:
> On Sat, Jul 24, 2010 at 10:36 AM, Jai Menon <jmenon86 at gmail.com> wrote:
> > On Sat, Jul 24, 2010 at 9:50 AM, Jai Menon <jmenon86 at gmail.com> wrote:
> >> A situation where this is desirable is when the video stream is
> >> initialized after the audio stream. In this case the PCR must be
> >> reset based on the video stream packet timestamp to avoid dropping
> >> frames.
> >> ---
> >>  modules/demux/avformat/demux.c |    3 ++-
> >>  1 files changed, 2 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
> >> index a8042b8..86aeb5d 100644
> >> --- a/modules/demux/avformat/demux.c
> >> +++ b/modules/demux/avformat/demux.c
> >> @@ -588,7 +588,8 @@ static int Demux( demux_t *p_demux )
> >>  #endif
> >>
> >>     if( p_frame->i_dts > VLC_TS_INVALID  &&
> >> -        ( pkt.stream_index == p_sys->i_pcr_tk || p_sys->i_pcr_tk < 0 ) )
> >> +        ( pkt.stream_index == p_sys->i_pcr_tk || p_sys->i_pcr_tk < 0 ||
> >> +          p_frame->i_dts < p_sys->i_pcr ) )
> >>     {
> >>         p_sys->i_pcr_tk = pkt.stream_index;
> >>         p_sys->i_pcr = p_frame->i_dts;
> >> --
> >> 1.7.1.1
> >
> > I'm still considering if there's a better solution to this, so please
> > disregard for now.
> 
> After thinking some more, I think maybe something like attached would
> be worth considering. Essentially, the reference is set after we get
> atleast a few video and audio packets.
 I may have misunderstood  your patch, but you must call ES_OUT_SET_PCR
before sending the first packets. Otherwise they will be rejected.

-- 
fenrir



More information about the vlc-devel mailing list