[vlc-commits] v4l2: limit PTS delay
Rémi Denis-Courmont
git at videolan.org
Mon Mar 15 17:10:44 UTC 2021
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 15 18:59:25 2021 +0200| [9e15fb2864a5f74062b793a2718d194df96d3a43] | committer: Rémi Denis-Courmont
v4l2: limit PTS delay
There really is no point having the PTS delay over the frame interval;
it just adds unnecessary latency. This should probably be even lower to
improve streaming responsiveness.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9e15fb2864a5f74062b793a2718d194df96d3a43
---
modules/access/v4l2/demux.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index 00f02ee76e..5ae1989f5a 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -58,6 +58,7 @@ typedef struct
es_out_id_t *es;
vlc_v4l2_ctrl_t *controls;
vlc_tick_t start;
+ vlc_tick_t interval;
#ifdef ZVBI_COMPILED
vlc_v4l2_vbi_t *vbi;
@@ -406,6 +407,10 @@ static int InitVideo (demux_t *demux, int fd, uint32_t caps)
es_fmt.video.i_frame_rate_base = parm.parm.capture.timeperframe.numerator;
GetAR (fd, &es_fmt.video.i_sar_num, &es_fmt.video.i_sar_den);
+ sys->interval = vlc_tick_from_samples(
+ parm.parm.capture.timeperframe.numerator,
+ parm.parm.capture.timeperframe.denominator);
+
msg_Dbg (demux, "color primaries: %u", fmt.fmt.pix.colorspace);
switch (fmt.fmt.pix.colorspace)
{
@@ -848,9 +853,14 @@ static int DemuxControl( demux_t *demux, int query, va_list args )
return VLC_SUCCESS;
case DEMUX_GET_PTS_DELAY:
- *va_arg(args,vlc_tick_t *) = VLC_TICK_FROM_MS(
- var_InheritInteger( demux, "live-caching" ) );
+ {
+ vlc_tick_t *pd = va_arg(args, vlc_tick_t *);
+
+ *pd = VLC_TICK_FROM_MS(var_InheritInteger(demux, "live-caching"));
+ if (*pd > sys->interval)
+ *pd = sys->interval; /* cap at one frame, more than enough */
return VLC_SUCCESS;
+ }
case DEMUX_GET_TIME:
*va_arg (args, vlc_tick_t *) = vlc_tick_now() - sys->start;
More information about the vlc-commits
mailing list