Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
8f05427a
Commit
8f05427a
authored
Jan 21, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce locking and mdate count in input clock.
parent
e92f2914
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
30 deletions
+53
-30
src/input/clock.c
src/input/clock.c
+29
-14
src/input/clock.h
src/input/clock.h
+11
-5
src/input/decoder.c
src/input/decoder.c
+13
-11
No files found.
src/input/clock.c
View file @
8f05427a
...
@@ -136,7 +136,7 @@ struct input_clock_t
...
@@ -136,7 +136,7 @@ struct input_clock_t
* It is used to detect unexpected stream discontinuities */
* It is used to detect unexpected stream discontinuities */
clock_point_t
last
;
clock_point_t
last
;
/* Maximal timestamp returned by input_clock_
Ge
tTS (in system unit) */
/* Maximal timestamp returned by input_clock_
Conver
tTS (in system unit) */
mtime_t
i_ts_max
;
mtime_t
i_ts_max
;
/* Clock drift */
/* Clock drift */
...
@@ -325,13 +325,15 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
...
@@ -325,13 +325,15 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
}
}
/*****************************************************************************
/*****************************************************************************
* input_clock_
GetTS: manages a PTS or D
TS
* input_clock_
Convert
TS
*****************************************************************************/
*****************************************************************************/
mtime_t
input_clock_GetTS
(
input_clock_t
*
cl
,
int
*
pi_rate
,
int
input_clock_ConvertTS
(
input_clock_t
*
cl
,
mtime_t
i_ts
,
mtime_t
i_ts_bound
)
int
*
pi_rate
,
mtime_t
*
pi_ts0
,
mtime_t
*
pi_ts1
,
mtime_t
i_ts_bound
)
{
{
mtime_t
i_
converted_ts
;
mtime_t
i_
pts_delay
;
assert
(
pi_ts0
);
vlc_mutex_lock
(
&
cl
->
lock
);
vlc_mutex_lock
(
&
cl
->
lock
);
if
(
pi_rate
)
if
(
pi_rate
)
...
@@ -340,24 +342,37 @@ mtime_t input_clock_GetTS( input_clock_t *cl, int *pi_rate,
...
@@ -340,24 +342,37 @@ mtime_t input_clock_GetTS( input_clock_t *cl, int *pi_rate,
if
(
!
cl
->
b_has_reference
)
if
(
!
cl
->
b_has_reference
)
{
{
vlc_mutex_unlock
(
&
cl
->
lock
);
vlc_mutex_unlock
(
&
cl
->
lock
);
return
0
;
*
pi_ts0
=
0
;
if
(
pi_ts1
)
*
pi_ts1
=
0
;
return
VLC_EGENERIC
;
}
}
/* */
/* */
i_converted_ts
=
ClockStreamToSystem
(
cl
,
i_ts
+
AvgGet
(
&
cl
->
drift
)
);
if
(
*
pi_ts0
>
0
)
if
(
i_converted_ts
>
cl
->
i_ts_max
)
{
cl
->
i_ts_max
=
i_converted_ts
;
*
pi_ts0
=
ClockStreamToSystem
(
cl
,
*
pi_ts0
+
AvgGet
(
&
cl
->
drift
)
);
if
(
*
pi_ts0
>
cl
->
i_ts_max
)
cl
->
i_ts_max
=
*
pi_ts0
;
*
pi_ts0
+=
cl
->
i_pts_delay
;
}
vlc_mutex_unlock
(
&
cl
->
lock
);
/* XXX we do not ipdate i_ts_max on purpose */
if
(
pi_ts1
&&
*
pi_ts1
>
0
)
{
*
pi_ts1
=
ClockStreamToSystem
(
cl
,
*
pi_ts1
+
AvgGet
(
&
cl
->
drift
)
)
+
cl
->
i_pts_delay
;
}
i_converted_ts
+=
cl
->
i_pts_delay
;
i_pts_delay
=
cl
->
i_pts_delay
;
vlc_mutex_unlock
(
&
cl
->
lock
);
/* Check ts validity */
/* Check ts validity */
if
(
i_ts_bound
!=
INT64_MAX
&&
if
(
i_ts_bound
!=
INT64_MAX
&&
i_converted_ts
>=
mdate
()
+
cl
->
i_pts_delay
+
i_ts_bound
)
*
pi_ts0
>
0
&&
*
pi_ts0
>=
mdate
()
+
cl
->
i_pts_delay
+
i_ts_bound
)
return
0
;
return
VLC_EGENERIC
;
return
i_converted_ts
;
return
VLC_SUCCESS
;
}
}
/*****************************************************************************
/*****************************************************************************
* input_clock_GetRate: Return current rate
* input_clock_GetRate: Return current rate
...
...
src/input/clock.h
View file @
8f05427a
...
@@ -85,14 +85,20 @@ void input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date
...
@@ -85,14 +85,20 @@ void input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date
void
input_clock_ChangeSystemOrigin
(
input_clock_t
*
,
mtime_t
i_system
);
void
input_clock_ChangeSystemOrigin
(
input_clock_t
*
,
mtime_t
i_system
);
/**
/**
* This function converts a timestamp from stream clock to system clock.
* This function converts a
pair of
timestamp from stream clock to system clock.
*
*
* If pi_rate is provided it will be fi
el
d with the rate value used for
* If pi_rate is provided it will be fi
lle
d with the rate value used for
* the conversion.
* the conversion.
* If i_ts_bound is not INT64_MAX, the value will be invalidated if not
* p_ts0 is a pointer to a timestamp to be converted (in place) and must be non NULL.
* before mdate() + i_pts_delay + i_ts_bound.
* p_ts1 is a pointer to a timestamp to be converted (in place) and can be NULL.
*
* It will return VLC_EGENERIC if i_ts_bound is not INT64_MAX and if the value *p_ts0
* after conversion is not before the deadline mdate() + i_pts_delay + i_ts_bound.
* It will also return VLC_EGENERIC if the conversion cannot be done successfully. In
* this case, *p_ts0 and *p_ts1 will hold an invalid timestamp.
* Otherwise it will return VLC_SUCCESS.
*/
*/
mtime_t
input_clock_GetTS
(
input_clock_t
*
,
int
*
pi_rate
,
mtime_t
i_ts
,
mtime_t
i_ts_bound
);
int
input_clock_ConvertTS
(
input_clock_t
*
,
int
*
pi_rate
,
mtime_t
*
pi_ts0
,
mtime_t
*
pi_ts1
,
mtime_t
i_ts_bound
);
/**
/**
* This function returns the current rate.
* This function returns the current rate.
...
...
src/input/decoder.c
View file @
8f05427a
...
@@ -652,7 +652,10 @@ static mtime_t DecoderGetDisplayDate( decoder_t *p_dec, mtime_t i_ts )
...
@@ -652,7 +652,10 @@ static mtime_t DecoderGetDisplayDate( decoder_t *p_dec, mtime_t i_ts )
if
(
!
p_owner
->
p_clock
||
!
i_ts
)
if
(
!
p_owner
->
p_clock
||
!
i_ts
)
return
i_ts
;
return
i_ts
;
return
input_clock_GetTS
(
p_owner
->
p_clock
,
NULL
,
i_ts
,
INT64_MAX
);
if
(
input_clock_ConvertTS
(
p_owner
->
p_clock
,
NULL
,
&
i_ts
,
NULL
,
INT64_MAX
)
)
return
0
;
return
i_ts
;
}
}
static
int
DecoderGetDisplayRate
(
decoder_t
*
p_dec
)
static
int
DecoderGetDisplayRate
(
decoder_t
*
p_dec
)
{
{
...
@@ -1039,7 +1042,6 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
...
@@ -1039,7 +1042,6 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
{
{
decoder_owner_sys_t
*
p_owner
=
p_dec
->
p_owner
;
decoder_owner_sys_t
*
p_owner
=
p_dec
->
p_owner
;
input_clock_t
*
p_clock
=
p_owner
->
p_clock
;
input_clock_t
*
p_clock
=
p_owner
->
p_clock
;
int
i_rate
=
0
;
vlc_assert_locked
(
&
p_owner
->
lock
);
vlc_assert_locked
(
&
p_owner
->
lock
);
...
@@ -1048,24 +1050,24 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
...
@@ -1048,24 +1050,24 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
if
(
p_clock
)
if
(
p_clock
)
{
{
const
bool
b_ephemere
=
pi_ts1
&&
*
pi_ts0
==
*
pi_ts1
;
const
bool
b_ephemere
=
pi_ts1
&&
*
pi_ts0
==
*
pi_ts1
;
int
i_rate
;
if
(
*
pi_ts0
>
0
)
if
(
*
pi_ts0
>
0
)
*
pi_ts0
=
input_clock_GetTS
(
p_clock
,
&
i_rate
,
*
pi_ts0
+
i_es_delay
,
i_ts_bound
);
if
(
pi_ts1
&&
*
pi_ts1
>
0
)
{
{
if
(
*
pi_ts0
>
0
)
*
pi_ts0
+=
i_es_delay
;
*
pi_ts1
=
input_clock_GetTS
(
p_clock
,
&
i_rate
,
*
pi_ts1
+
i_es_delay
,
INT64_MAX
);
if
(
pi_ts1
&&
*
pi_ts1
>
0
)
else
*
pi_ts1
+=
i_es_delay
;
*
pi_ts1
=
0
;
input_clock_ConvertTS
(
p_clock
,
&
i_rate
,
pi_ts0
,
pi_ts1
,
i_ts_bound
);
}
else
{
i_rate
=
input_clock_GetRate
(
p_clock
);
}
}
/* Do not create ephemere data because of rounding errors */
/* Do not create ephemere data because of rounding errors */
if
(
!
b_ephemere
&&
pi_ts1
&&
*
pi_ts0
==
*
pi_ts1
)
if
(
!
b_ephemere
&&
pi_ts1
&&
*
pi_ts0
==
*
pi_ts1
)
*
pi_ts1
+=
1
;
*
pi_ts1
+=
1
;
if
(
i_rate
<=
0
)
i_rate
=
input_clock_GetRate
(
p_clock
);
if
(
pi_duration
)
if
(
pi_duration
)
*
pi_duration
=
(
*
pi_duration
*
i_rate
+
*
pi_duration
=
(
*
pi_duration
*
i_rate
+
INPUT_RATE_DEFAULT
-
1
)
/
INPUT_RATE_DEFAULT
;
INPUT_RATE_DEFAULT
-
1
)
/
INPUT_RATE_DEFAULT
;
...
...
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