Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
abc4689a
Commit
abc4689a
authored
Sep 24, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No functionnal changes.
It is mostly clock fields renaming.
parent
da5a30e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
61 deletions
+75
-61
src/input/clock.c
src/input/clock.c
+71
-57
src/input/es_out.c
src/input/es_out.c
+3
-3
src/input/input_internal.h
src/input/input_internal.h
+1
-1
No files found.
src/input/clock.c
View file @
abc4689a
/*****************************************************************************
/*****************************************************************************
* input_clock.c: Clock/System date convertions, stream management
* input_clock.c: Clock/System date convertions, stream management
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-200
4
the VideoLAN team
* Copyright (C) 1999-200
8
the VideoLAN team
* $Id$
* $Id$
*
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar < fenrir _AT_ videolan _DOT_ org >
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
@@ -75,65 +76,77 @@
...
@@ -75,65 +76,77 @@
/* Latency introduced on DVDs with CR == 0 on chapter change - this is from
/* Latency introduced on DVDs with CR == 0 on chapter change - this is from
* my dice --Meuuh */
* my dice --Meuuh */
#define CR_MEAN_PTS_GAP
300000
#define CR_MEAN_PTS_GAP
(300000)
/*****************************************************************************
/*****************************************************************************
* Structures
* Structures
*****************************************************************************/
*****************************************************************************/
struct
input_clock_t
struct
input_clock_t
{
{
/* Synchronization information */
/* Reference point */
mtime_t
delta_cr
;
mtime_t
cr_ref
,
sysdate_ref
;
mtime_t
last_sysdate
;
mtime_t
last_cr
;
/* reference to detect unexpected stream
* discontinuities */
mtime_t
last_pts
;
mtime_t
last_update
;
bool
b_has_reference
;
bool
b_has_reference
;
struct
{
mtime_t
i_clock
;
mtime_t
i_system
;
}
ref
;
bool
b_master
;
/* Last point
* It is used to detect unexpected stream discontinuities */
struct
{
mtime_t
i_clock
;
mtime_t
i_system
;
}
last
;
mtime_t
last_pts
;
/* Clock drift */
mtime_t
i_delta_update
;
/* System time to wait for drift update */
mtime_t
i_delta
;
int
i_delta_residue
;
/* Current modifiers */
bool
b_master
;
int
i_rate
;
int
i_rate
;
/*
Config
*/
/*
Static configuration
*/
int
i_cr_average
;
int
i_cr_average
;
int
i_delta_cr_residue
;
};
};
/*****************************************************************************
/*****************************************************************************
* Clock
ToSysdate
: converts a movie clock to system date
* Clock
StreamToSystem
: converts a movie clock to system date
*****************************************************************************/
*****************************************************************************/
static
mtime_t
Clock
ToSysdate
(
input_clock_t
*
cl
,
mtime_t
i_clock
)
static
mtime_t
Clock
StreamToSystem
(
input_clock_t
*
cl
,
mtime_t
i_clock
)
{
{
if
(
!
cl
->
b_has_reference
)
if
(
!
cl
->
b_has_reference
)
return
0
;
return
0
;
return
(
i_clock
-
cl
->
cr_ref
)
*
cl
->
i_rate
/
INPUT_RATE_DEFAULT
+
return
(
i_clock
-
cl
->
ref
.
i_clock
)
*
cl
->
i_rate
/
INPUT_RATE_DEFAULT
+
cl
->
sysdate_ref
;
cl
->
ref
.
i_system
;
}
}
/*****************************************************************************
/*****************************************************************************
* Clock
FromSysdate
: converts a system date to movie clock
* Clock
SystemToStream
: converts a system date to movie clock
*****************************************************************************
*****************************************************************************
* Caution : a valid reference point is needed for this to operate.
* Caution : a valid reference point is needed for this to operate.
*****************************************************************************/
*****************************************************************************/
static
mtime_t
Clock
FromSysdate
(
input_clock_t
*
cl
,
mtime_t
i_ck_system
)
static
mtime_t
Clock
SystemToStream
(
input_clock_t
*
cl
,
mtime_t
i_ck_system
)
{
{
assert
(
cl
->
b_has_reference
);
assert
(
cl
->
b_has_reference
);
return
(
i_ck_system
-
cl
->
sysdate_ref
)
*
INPUT_RATE_DEFAULT
/
cl
->
i_rate
+
return
(
i_ck_system
-
cl
->
ref
.
i_system
)
*
INPUT_RATE_DEFAULT
/
cl
->
i_rate
+
cl
->
cr_ref
;
cl
->
ref
.
i_clock
;
}
}
/*****************************************************************************
/*****************************************************************************
* Clock
NewRef
: writes a new clock reference
* Clock
SetReference
: writes a new clock reference
*****************************************************************************/
*****************************************************************************/
static
void
Clock
NewRef
(
input_clock_t
*
cl
,
static
void
Clock
SetReference
(
input_clock_t
*
cl
,
mtime_t
i_clock
,
mtime_t
i_sysdate
)
mtime_t
i_clock
,
mtime_t
i_sysdate
)
{
{
cl
->
b_has_reference
=
true
;
cl
->
b_has_reference
=
true
;
cl
->
cr_ref
=
i_clock
;
cl
->
ref
.
i_clock
=
i_clock
;
cl
->
sysdate_ref
=
i_sysdate
;
cl
->
ref
.
i_system
=
i_sysdate
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -146,19 +159,20 @@ input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
...
@@ -146,19 +159,20 @@ input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
return
NULL
;
return
NULL
;
cl
->
b_has_reference
=
false
;
cl
->
b_has_reference
=
false
;
cl
->
ref
.
i_clock
=
0
;
cl
->
ref
.
i_system
=
0
;
cl
->
last_cr
=
0
;
cl
->
last
.
i_clock
=
0
;
cl
->
last
.
i_system
=
0
;
cl
->
last_pts
=
0
;
cl
->
last_pts
=
0
;
cl
->
last_sysdate
=
0
;
cl
->
cr_ref
=
0
;
cl
->
sysdate_ref
=
0
;
cl
->
delta_cr
=
0
;
cl
->
i_delta_cr_residue
=
0
;
cl
->
i_rate
=
i_rate
;
cl
->
i_cr_average
=
i_cr_average
;
cl
->
i_delta
=
0
;
cl
->
i_delta_residue
=
0
;
cl
->
b_master
=
b_master
;
cl
->
b_master
=
b_master
;
cl
->
i_rate
=
i_rate
;
cl
->
i_cr_average
=
i_cr_average
;
return
cl
;
return
cl
;
}
}
...
@@ -185,16 +199,16 @@ void input_clock_SetPCR( input_clock_t *cl,
...
@@ -185,16 +199,16 @@ void input_clock_SetPCR( input_clock_t *cl,
bool
b_reset_reference
=
false
;
bool
b_reset_reference
=
false
;
if
(
(
!
cl
->
b_has_reference
)
||
if
(
(
!
cl
->
b_has_reference
)
||
(
i_ck_stream
==
0
&&
cl
->
last
_cr
!=
0
)
)
(
i_ck_stream
==
0
&&
cl
->
last
.
i_clock
!=
0
)
)
{
{
cl
->
last
_update
=
0
;
cl
->
i_delta
_update
=
0
;
/* */
/* */
b_reset_reference
=
true
;
b_reset_reference
=
true
;
}
}
else
if
(
cl
->
last
_cr
!=
0
&&
else
if
(
cl
->
last
.
i_clock
!=
0
&&
(
(
cl
->
last
_cr
-
i_ck_stream
)
>
CR_MAX_GAP
||
(
(
cl
->
last
.
i_clock
-
i_ck_stream
)
>
CR_MAX_GAP
||
(
cl
->
last
_cr
-
i_ck_stream
)
<
-
CR_MAX_GAP
)
)
(
cl
->
last
.
i_clock
-
i_ck_stream
)
<
-
CR_MAX_GAP
)
)
{
{
/* Stream discontinuity, for which we haven't received a
/* Stream discontinuity, for which we haven't received a
* warning from the stream control facilities (dd-edited
* warning from the stream control facilities (dd-edited
...
@@ -208,30 +222,30 @@ void input_clock_SetPCR( input_clock_t *cl,
...
@@ -208,30 +222,30 @@ void input_clock_SetPCR( input_clock_t *cl,
}
}
if
(
b_reset_reference
)
if
(
b_reset_reference
)
{
{
cl
->
delta_cr
=
0
;
cl
->
i_delta
=
0
;
cl
->
i_delta_
cr_
residue
=
0
;
cl
->
i_delta_residue
=
0
;
/* Feed synchro with a new reference point. */
/* Feed synchro with a new reference point. */
Clock
NewRef
(
cl
,
i_ck_stream
,
Clock
SetReference
(
cl
,
i_ck_stream
,
__MAX
(
cl
->
last_pts
+
CR_MEAN_PTS_GAP
,
i_ck_system
)
);
__MAX
(
cl
->
last_pts
+
CR_MEAN_PTS_GAP
,
i_ck_system
)
);
}
}
cl
->
last
_cr
=
i_ck_stream
;
cl
->
last
.
i_clock
=
i_ck_stream
;
cl
->
last
_sysdate
=
i_ck_system
;
cl
->
last
.
i_system
=
i_ck_system
;
if
(
!
b_synchronize
&&
i_ck_system
-
cl
->
last
_update
>
200000
)
if
(
!
b_synchronize
&&
i_ck_system
-
cl
->
i_delta
_update
>
200000
)
{
{
/* Smooth clock reference variations. */
/* Smooth clock reference variations. */
const
mtime_t
i_extrapoled_clock
=
Clock
FromSysdate
(
cl
,
i_ck_system
);
const
mtime_t
i_extrapoled_clock
=
Clock
SystemToStream
(
cl
,
i_ck_system
);
/* Bresenham algorithm to smooth variations. */
/* Bresenham algorithm to smooth variations. */
const
mtime_t
i_tmp
=
cl
->
delta_cr
*
(
cl
->
i_cr_average
-
1
)
+
const
mtime_t
i_tmp
=
cl
->
i_delta
*
(
cl
->
i_cr_average
-
1
)
+
(
i_extrapoled_clock
-
i_ck_stream
)
*
1
+
(
i_extrapoled_clock
-
i_ck_stream
)
*
1
+
cl
->
i_delta_
cr_
residue
;
cl
->
i_delta_residue
;
cl
->
i_delta_
cr_
residue
=
i_tmp
%
cl
->
i_cr_average
;
cl
->
i_delta_residue
=
i_tmp
%
cl
->
i_cr_average
;
cl
->
delta_cr
=
i_tmp
/
cl
->
i_cr_average
;
cl
->
i_delta
=
i_tmp
/
cl
->
i_cr_average
;
cl
->
last
_update
=
i_ck_system
;
cl
->
i_delta
_update
=
i_ck_system
;
}
}
}
}
...
@@ -248,13 +262,13 @@ void input_clock_ResetPCR( input_clock_t *cl )
...
@@ -248,13 +262,13 @@ void input_clock_ResetPCR( input_clock_t *cl )
* input_clock_GetTS: manages a PTS or DTS
* input_clock_GetTS: manages a PTS or DTS
*****************************************************************************/
*****************************************************************************/
mtime_t
input_clock_GetTS
(
input_clock_t
*
cl
,
mtime_t
input_clock_GetTS
(
input_clock_t
*
cl
,
input_thread_t
*
p_input
,
mtime_t
i_ts
)
mtime_t
i_pts_delay
,
mtime_t
i_ts
)
{
{
if
(
!
cl
->
b_has_reference
)
if
(
!
cl
->
b_has_reference
)
return
0
;
return
0
;
cl
->
last_pts
=
Clock
ToSysdate
(
cl
,
i_ts
+
cl
->
delta_cr
);
cl
->
last_pts
=
Clock
StreamToSystem
(
cl
,
i_ts
+
cl
->
i_delta
);
return
cl
->
last_pts
+
p_input
->
i_pts_delay
;
return
cl
->
last_pts
+
i_pts_delay
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -264,7 +278,7 @@ void input_clock_SetRate( input_clock_t *cl, int i_rate )
...
@@ -264,7 +278,7 @@ void input_clock_SetRate( input_clock_t *cl, int i_rate )
{
{
/* Move the reference point */
/* Move the reference point */
if
(
cl
->
b_has_reference
)
if
(
cl
->
b_has_reference
)
Clock
NewRef
(
cl
,
cl
->
last_cr
,
cl
->
last_sysdate
);
Clock
SetReference
(
cl
,
cl
->
last
.
i_clock
,
cl
->
last
.
i_system
);
cl
->
i_rate
=
i_rate
;
cl
->
i_rate
=
i_rate
;
}
}
...
@@ -293,6 +307,6 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl, input_thread_t *p_input )
...
@@ -293,6 +307,6 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl, input_thread_t *p_input )
return
0
;
return
0
;
/* */
/* */
return
Clock
ToSysdate
(
cl
,
cl
->
last_cr
);
return
Clock
StreamToSystem
(
cl
,
cl
->
last
.
i_clock
);
}
}
src/input/es_out.c
View file @
abc4689a
...
@@ -1546,7 +1546,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
...
@@ -1546,7 +1546,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
else
if
(
p_block
->
i_dts
>
0
)
else
if
(
p_block
->
i_dts
>
0
)
{
{
p_block
->
i_dts
=
p_block
->
i_dts
=
input_clock_GetTS
(
p_pgrm
->
p_clock
,
p_input
,
p_block
->
i_dts
)
+
i_delay
;
input_clock_GetTS
(
p_pgrm
->
p_clock
,
p_input
->
i_pts_delay
,
p_block
->
i_dts
)
+
i_delay
;
}
}
if
(
p_block
->
i_pts
>
0
&&
(
p_block
->
i_flags
&
BLOCK_FLAG_PREROLL
)
)
if
(
p_block
->
i_pts
>
0
&&
(
p_block
->
i_flags
&
BLOCK_FLAG_PREROLL
)
)
{
{
...
@@ -1555,7 +1555,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
...
@@ -1555,7 +1555,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
else
if
(
p_block
->
i_pts
>
0
)
else
if
(
p_block
->
i_pts
>
0
)
{
{
p_block
->
i_pts
=
p_block
->
i_pts
=
input_clock_GetTS
(
p_pgrm
->
p_clock
,
p_input
,
p_block
->
i_pts
)
+
i_delay
;
input_clock_GetTS
(
p_pgrm
->
p_clock
,
p_input
->
i_pts_delay
,
p_block
->
i_pts
)
+
i_delay
;
}
}
if
(
p_block
->
i_rate
==
INPUT_RATE_DEFAULT
&&
if
(
p_block
->
i_rate
==
INPUT_RATE_DEFAULT
&&
es
->
fmt
.
i_codec
==
VLC_FOURCC
(
't'
,
'e'
,
'l'
,
'x'
)
)
es
->
fmt
.
i_codec
==
VLC_FOURCC
(
't'
,
'e'
,
'l'
,
'x'
)
)
...
@@ -1925,7 +1925,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
...
@@ -1925,7 +1925,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
int64_t
i_ts
=
(
int64_t
)
va_arg
(
args
,
int64_t
);
int64_t
i_ts
=
(
int64_t
)
va_arg
(
args
,
int64_t
);
int64_t
*
pi_ts
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
int64_t
*
pi_ts
=
(
int64_t
*
)
va_arg
(
args
,
int64_t
*
);
*
pi_ts
=
input_clock_GetTS
(
p_sys
->
p_pgrm
->
p_clock
,
*
pi_ts
=
input_clock_GetTS
(
p_sys
->
p_pgrm
->
p_clock
,
p_sys
->
p_input
,
i_ts
);
p_sys
->
p_input
->
i_pts_delay
,
i_ts
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
...
src/input/input_internal.h
View file @
abc4689a
...
@@ -363,7 +363,7 @@ void input_clock_Delete( input_clock_t * );
...
@@ -363,7 +363,7 @@ void input_clock_Delete( input_clock_t * );
void
input_clock_SetPCR
(
input_clock_t
*
,
input_thread_t
*
,
mtime_t
i_clock
,
mtime_t
i_system
);
void
input_clock_SetPCR
(
input_clock_t
*
,
input_thread_t
*
,
mtime_t
i_clock
,
mtime_t
i_system
);
void
input_clock_ResetPCR
(
input_clock_t
*
);
void
input_clock_ResetPCR
(
input_clock_t
*
);
mtime_t
input_clock_GetTS
(
input_clock_t
*
,
input_thread_t
*
,
mtime_t
);
mtime_t
input_clock_GetTS
(
input_clock_t
*
,
mtime_t
i_pts_delay
,
mtime_t
);
void
input_clock_SetRate
(
input_clock_t
*
cl
,
int
i_rate
);
void
input_clock_SetRate
(
input_clock_t
*
cl
,
int
i_rate
);
void
input_clock_SetMaster
(
input_clock_t
*
cl
,
bool
b_master
);
void
input_clock_SetMaster
(
input_clock_t
*
cl
,
bool
b_master
);
mtime_t
input_clock_GetWakeup
(
input_clock_t
*
cl
,
input_thread_t
*
);
mtime_t
input_clock_GetWakeup
(
input_clock_t
*
cl
,
input_thread_t
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment