[vlc-devel] How to write a encoder/decoder plugin for VLC?

Rémi Denis-Courmont remi at remlab.net
Mon Mar 16 15:58:16 CET 2009


On Mon, 16 Mar 2009 21:59:11 +0800, Alex Lee <alex.q.lee at gmail.com> wrote:
> "Presentation Time Stamps located in the system layer of the
> stream are passed to the decoders, and all resulting samples are
> dated accordingly. The output layers are supposed to play them at
> the right time. Dates are converted to microseconds ; an absolute
> date is the number of microseconds since Epoch (Jan 1st, 1970).
> The mtime_t type is a signed 64-bit integer. "

That's not true, and it's not surprising because the Wiki is
_full_of_crap_. It has a lot of outdated or just plain wrong infos.

The presentation time stamp (PTS) represent the ideal time at which a block
of data (audio, video or spu) should be performed. The origin is arbitrary.
Namely, the demultiplexer chooses the origin (the zero) as it sees fit. The
time stamp frequency is one million hertz multiplied by the playback rate.
Hence at a nominal playback rate (1.0), the PTS is expressed in microsecond
units.

The demuxer is responsible for passing consistent PTS for each elementary
stream. Decoders are responsible for maintaining the PTS while decoding so
that decoded audio, video and SPU outputs are synchronized.

> Do you know how to comute PTS value? I see this modules/codec/theora.c :
> 
>     p_sys->i_pts += ( INT64_C(1000000) * p_sys->ti.fps_denominator /
>                       p_sys->ti.fps_numerator ); /* 1 frame per packet */
> 
> But what PTS should be for variable frame rate stream?

A video codec must provide timestamps to the video output. The video output
_needs_ to know when to display the picture, otherwise the picture is
useless. Either the demux knows the timestamps, feeds them to the codec,
and the codec preserves timestamps, or the codec knows the frame rate and
sets the timestamps by itself.

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list