Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
54e40b9c
Commit
54e40b9c
authored
Dec 01, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffmpeg: factorize duration calculation in transcode_video()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
6e96ad82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
ffmpeg.c
ffmpeg.c
+11
-14
No files found.
ffmpeg.c
View file @
54e40b9c
...
...
@@ -1834,6 +1834,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
#if CONFIG_AVFILTER
int
frame_available
=
1
;
#endif
int
duration
=
0
;
if
(
!
(
decoded_frame
=
avcodec_alloc_frame
()))
return
AVERROR
(
ENOMEM
);
...
...
@@ -1841,13 +1842,17 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
pkt
->
dts
=
*
pkt_dts
;
*
pkt_pts
=
AV_NOPTS_VALUE
;
if
(
*
pkt_dts
!=
AV_NOPTS_VALUE
&&
pkt
->
duration
)
{
*
pkt_dts
+
=
av_rescale_q
(
pkt
->
duration
,
ist
->
st
->
time_base
,
AV_TIME_BASE_Q
);
}
else
if
(
*
pkt_dts
!=
AV_NOPTS_VALUE
&&
ist
->
st
->
codec
->
time_base
.
num
!=
0
)
{
if
(
pkt
->
duration
)
{
duration
=
av_rescale_q
(
pkt
->
duration
,
ist
->
st
->
time_base
,
AV_TIME_BASE_Q
);
}
else
if
(
ist
->
st
->
codec
->
time_base
.
num
!=
0
)
{
int
ticks
=
ist
->
st
->
parser
?
ist
->
st
->
parser
->
repeat_pict
+
1
:
ist
->
st
->
codec
->
ticks_per_frame
;
*
pkt_dts
+
=
((
int64_t
)
AV_TIME_BASE
*
duration
=
((
int64_t
)
AV_TIME_BASE
*
ist
->
st
->
codec
->
time_base
.
num
*
ticks
)
/
ist
->
st
->
codec
->
time_base
.
den
;
ist
->
st
->
codec
->
time_base
.
den
;
}
if
(
*
pkt_dts
!=
AV_NOPTS_VALUE
&&
duration
)
{
*
pkt_dts
+=
duration
;
}
else
*
pkt_dts
=
AV_NOPTS_VALUE
;
...
...
@@ -1866,15 +1871,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
if
(
decoded_frame
->
best_effort_timestamp
!=
AV_NOPTS_VALUE
)
ist
->
next_pts
=
ist
->
pts
=
decoded_frame
->
best_effort_timestamp
;
if
(
pkt
->
duration
)
ist
->
next_pts
+=
av_rescale_q
(
pkt
->
duration
,
ist
->
st
->
time_base
,
AV_TIME_BASE_Q
);
else
if
(
ist
->
st
->
codec
->
time_base
.
num
!=
0
)
{
int
ticks
=
ist
->
st
->
parser
?
ist
->
st
->
parser
->
repeat_pict
+
1
:
ist
->
st
->
codec
->
ticks_per_frame
;
ist
->
next_pts
+=
((
int64_t
)
AV_TIME_BASE
*
ist
->
st
->
codec
->
time_base
.
num
*
ticks
)
/
ist
->
st
->
codec
->
time_base
.
den
;
}
ist
->
next_pts
+=
duration
;
pkt
->
size
=
0
;
pre_process_video_frame
(
ist
,
(
AVPicture
*
)
decoded_frame
,
&
buffer_to_free
);
...
...
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