Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
libvpx
Commits
545c3249
Commit
545c3249
authored
10 years ago
by
Dmitry Kovalev
Browse files
Options
Download
Patches
Plain Diff
Adding ticks <-> timebase units conversion functions.
Change-Id: I75abd57367a7974a9fab8a727b2bbc54dea428c3
parent
ff40d9ec
v1.14.0-linphone
1.4.X
feature/update_to_v1.9.0-linphone
feature/uwp_nuget
highbitdepth
indianrunnerduck
javanwhistlingduck
khakicampbell
linphone
linphone-android
linphone-old
longtailedduck
m49-2623
m52-2743
m54-2840
m56-2924
m66-3359
m68-3440
mandarinduck
nextgen
nextgenv2
sandbox/Jingning/experimental
sandbox/Jingning/vpx
sandbox/aconverse@google.com/ansbench
sandbox/hkuang@google.com/decode
sandbox/jimbankoski@google.com/proposed-aom
sandbox/jingning@google.com/decoder_test_suite
sandbox/jingning@google.com/experimental
sandbox/jzern@google.com/test
sandbox/wangch@google.com/vp9
sandbox/yaowu@google.com/mergeaom
v1.12.0-linphone
v1.6.1_linphone
v1.7.0-linphone
v1.9.0-linphone
v1.9.0
v1.9.0-rc1
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.0
v1.4.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vp9/vp9_cx_iface.c
+25
-20
vp9/vp9_cx_iface.c
with
25 additions
and
20 deletions
vp9/vp9_cx_iface.c
+
25
−
20
View file @
545c3249
...
...
@@ -803,6 +803,20 @@ static int write_superframe_index(vpx_codec_alg_priv_t *ctx) {
return
index_sz
;
}
// vp9 uses 10,000,000 ticks/second as time stamp
#define TICKS_PER_SEC 10000000
static
int64_t
timebase_units_to_ticks
(
const
vpx_rational_t
*
timebase
,
int64_t
n
)
{
return
n
*
TICKS_PER_SEC
*
timebase
->
num
/
timebase
->
den
;
}
static
int64_t
ticks_to_timebase_units
(
const
vpx_rational_t
*
timebase
,
int64_t
n
)
{
const
int64_t
round
=
TICKS_PER_SEC
*
timebase
->
num
/
2
-
1
;
return
(
n
*
timebase
->
den
+
round
)
/
timebase
->
num
/
TICKS_PER_SEC
;
}
static
vpx_codec_err_t
encoder_encode
(
vpx_codec_alg_priv_t
*
ctx
,
const
vpx_image_t
*
img
,
vpx_codec_pts_t
pts
,
...
...
@@ -810,6 +824,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
vpx_enc_frame_flags_t
flags
,
unsigned
long
deadline
)
{
vpx_codec_err_t
res
=
VPX_CODEC_OK
;
const
vpx_rational_t
*
const
timebase
=
&
ctx
->
cfg
.
g_timebase
;
if
(
img
!=
NULL
)
{
res
=
validate_img
(
ctx
,
img
);
...
...
@@ -855,7 +870,9 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
if
(
res
==
VPX_CODEC_OK
&&
ctx
->
cpi
!=
NULL
)
{
unsigned
int
lib_flags
=
0
;
YV12_BUFFER_CONFIG
sd
;
int64_t
dst_time_stamp
,
dst_end_time_stamp
;
int64_t
dst_time_stamp
=
timebase_units_to_ticks
(
timebase
,
pts
);
int64_t
dst_end_time_stamp
=
timebase_units_to_ticks
(
timebase
,
pts
+
duration
);
size_t
size
,
cx_data_sz
;
unsigned
char
*
cx_data
;
...
...
@@ -863,12 +880,6 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
if
(
ctx
->
base
.
init_flags
&
VPX_CODEC_USE_PSNR
)
((
VP9_COMP
*
)
ctx
->
cpi
)
->
b_calculate_psnr
=
1
;
/* vp9 use 10,000,000 ticks/second as time stamp */
dst_time_stamp
=
(
pts
*
10000000
*
ctx
->
cfg
.
g_timebase
.
num
)
/
ctx
->
cfg
.
g_timebase
.
den
;
dst_end_time_stamp
=
(
pts
+
duration
)
*
10000000
*
ctx
->
cfg
.
g_timebase
.
num
/
ctx
->
cfg
.
g_timebase
.
den
;
if
(
img
!=
NULL
)
{
res
=
image2yuvconfig
(
img
,
&
sd
);
...
...
@@ -905,9 +916,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
cx_data
,
&
dst_time_stamp
,
&
dst_end_time_stamp
,
!
img
))
{
if
(
size
)
{
vpx_codec_pts_t
round
,
delta
;
vpx_codec_cx_pkt_t
pkt
;
VP9_COMP
*
const
cpi
=
(
VP9_COMP
*
)
ctx
->
cpi
;
vpx_codec_cx_pkt_t
pkt
;
#if CONFIG_SPATIAL_SVC
if
(
cpi
->
use_svc
&&
cpi
->
svc
.
number_temporal_layers
==
1
)
...
...
@@ -932,15 +942,11 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
}
// Add the frame packet to the list of returned packets.
round
=
(
vpx_codec_pts_t
)
10000000
*
ctx
->
cfg
.
g_timebase
.
num
/
2
-
1
;
delta
=
(
dst_end_time_stamp
-
dst_time_stamp
);
pkt
.
kind
=
VPX_CODEC_CX_FRAME_PKT
;
pkt
.
data
.
frame
.
pts
=
(
dst_time_stamp
*
ctx
->
cfg
.
g_timebase
.
den
+
round
)
/
ctx
->
cfg
.
g_timebase
.
num
/
10000000
;
pkt
.
data
.
frame
.
duration
=
(
unsigned
long
)
((
delta
*
ctx
->
cfg
.
g_timebase
.
den
+
round
)
/
ctx
->
cfg
.
g_timebase
.
num
/
10000000
);
pkt
.
data
.
frame
.
pts
=
ticks_to_timebase_units
(
timebase
,
dst_time_stamp
);
pkt
.
data
.
frame
.
duration
=
(
unsigned
long
)
ticks_to_timebase_units
(
timebase
,
dst_end_time_stamp
-
dst_time_stamp
);
pkt
.
data
.
frame
.
flags
=
lib_flags
<<
16
;
if
(
lib_flags
&
FRAMEFLAGS_KEY
...
...
@@ -958,9 +964,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
// prior PTS so that if a decoder uses pts to schedule when
// to do this, we start right after last frame was decoded.
// Invisible frames have no duration.
pkt
.
data
.
frame
.
pts
=
((
cpi
->
last_time_stamp_seen
*
ctx
->
cfg
.
g_timebase
.
den
+
round
)
/
ctx
->
cfg
.
g_timebase
.
num
/
10000000
)
+
1
;
pkt
.
data
.
frame
.
pts
=
ticks_to_timebase_units
(
timebase
,
cpi
->
last_time_stamp_seen
)
+
1
;
pkt
.
data
.
frame
.
duration
=
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets