Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
8766ad9e
Commit
8766ad9e
authored
Oct 26, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavu: add av_rescale_delta()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
03e44bcb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
mathematics.c
libavutil/mathematics.c
+23
-0
mathematics.h
libavutil/mathematics.h
+5
-0
No files found.
libavutil/mathematics.c
View file @
8766ad9e
...
@@ -142,3 +142,26 @@ int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
...
@@ -142,3 +142,26 @@ int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
c
-=
mod
;
c
-=
mod
;
return
c
;
return
c
;
}
}
int64_t
av_rescale_delta
(
AVRational
in_tb
,
int64_t
in_ts
,
AVRational
fs_tb
,
int
duration
,
int64_t
*
last
,
AVRational
out_tb
){
int64_t
a
,
b
,
this
;
av_assert0
(
in_ts
!=
AV_NOPTS_VALUE
);
av_assert0
(
duration
>=
0
);
if
(
*
last
==
AV_NOPTS_VALUE
||
!
duration
||
in_tb
.
num
*
(
int64_t
)
out_tb
.
den
<=
out_tb
.
num
*
(
int64_t
)
in_tb
.
den
)
{
simple_round
:
*
last
=
av_rescale_q
(
in_ts
,
in_tb
,
fs_tb
)
+
duration
;
return
av_rescale_q
(
in_ts
,
in_tb
,
out_tb
);
}
a
=
av_rescale_q_rnd
(
2
*
in_ts
-
1
,
in_tb
,
fs_tb
,
AV_ROUND_DOWN
)
>>
1
;
b
=
(
av_rescale_q_rnd
(
2
*
in_ts
+
1
,
in_tb
,
fs_tb
,
AV_ROUND_UP
)
+
1
)
>>
1
;
if
(
*
last
<
2
*
a
-
b
||
*
last
>
2
*
b
-
a
)
goto
simple_round
;
this
=
av_clip64
(
*
last
,
a
,
b
);
*
last
=
this
+
duration
;
return
av_rescale_q
(
this
,
fs_tb
,
out_tb
);
}
libavutil/mathematics.h
View file @
8766ad9e
...
@@ -122,6 +122,11 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
...
@@ -122,6 +122,11 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
*/
*/
int64_t
av_compare_mod
(
uint64_t
a
,
uint64_t
b
,
uint64_t
mod
);
int64_t
av_compare_mod
(
uint64_t
a
,
uint64_t
b
,
uint64_t
mod
);
/**
* Rescale a timestamp while preserving known durations.
*/
int64_t
av_rescale_delta
(
AVRational
in_tb
,
int64_t
in_ts
,
AVRational
fs_tb
,
int
duration
,
int64_t
*
last
,
AVRational
out_tb
);
/**
/**
* @}
* @}
*/
*/
...
...
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