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
83916029
Commit
83916029
authored
Aug 04, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: simplify transcode().
Operate with a pointer to InputFile instead of its index in input_files.
parent
c0fbf971
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
avconv.c
avconv.c
+21
-19
No files found.
avconv.c
View file @
83916029
...
...
@@ -1954,10 +1954,11 @@ static int need_output(void)
return
0
;
}
static
int
select_input_file
(
void
)
static
InputFile
*
select_input_file
(
void
)
{
InputFile
*
ifile
=
NULL
;
int64_t
ipts_min
=
INT64_MAX
;
int
i
,
file_index
=
-
1
;
int
i
;
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
{
InputStream
*
ist
=
input_streams
[
i
];
...
...
@@ -1968,12 +1969,12 @@ static int select_input_file(void)
if
(
!
input_files
[
ist
->
file_index
]
->
eof_reached
)
{
if
(
ipts
<
ipts_min
)
{
ipts_min
=
ipts
;
file_index
=
ist
->
file_index
;
ifile
=
input_files
[
ist
->
file_index
]
;
}
}
}
return
file_index
;
return
ifile
;
}
#if HAVE_PTHREADS
...
...
@@ -2137,7 +2138,8 @@ static int transcode(void)
#endif
while
(
!
received_sigterm
)
{
int
file_index
,
ist_index
;
InputFile
*
ifile
;
int
ist_index
;
AVPacket
pkt
;
/* check if there's any stream where output is still needed */
...
...
@@ -2147,9 +2149,9 @@ static int transcode(void)
}
/* select the stream that we must read now */
file_index
=
select_input_file
();
ifile
=
select_input_file
();
/* if none, if is finished */
if
(
file_index
<
0
)
{
if
(
!
ifile
)
{
if
(
got_eagain
())
{
reset_eagain
();
av_usleep
(
10000
);
...
...
@@ -2159,11 +2161,11 @@ static int transcode(void)
break
;
}
is
=
i
nput_files
[
file_index
]
->
ctx
;
ret
=
get_input_packet
(
i
nput_files
[
file_index
]
,
&
pkt
);
is
=
i
file
->
ctx
;
ret
=
get_input_packet
(
i
file
,
&
pkt
);
if
(
ret
==
AVERROR
(
EAGAIN
))
{
i
nput_files
[
file_index
]
->
eagain
=
1
;
i
file
->
eagain
=
1
;
continue
;
}
if
(
ret
<
0
)
{
...
...
@@ -2172,10 +2174,10 @@ static int transcode(void)
if
(
exit_on_error
)
exit_program
(
1
);
}
i
nput_files
[
file_index
]
->
eof_reached
=
1
;
i
file
->
eof_reached
=
1
;
for
(
i
=
0
;
i
<
i
nput_files
[
file_index
]
->
nb_streams
;
i
++
)
{
ist
=
input_streams
[
i
nput_files
[
file_index
]
->
ist_index
+
i
];
for
(
i
=
0
;
i
<
i
file
->
nb_streams
;
i
++
)
{
ist
=
input_streams
[
i
file
->
ist_index
+
i
];
if
(
ist
->
decoding_needed
)
output_packet
(
ist
,
NULL
);
}
...
...
@@ -2194,17 +2196,17 @@ static int transcode(void)
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
if
(
pkt
.
stream_index
>=
i
nput_files
[
file_index
]
->
nb_streams
)
if
(
pkt
.
stream_index
>=
i
file
->
nb_streams
)
goto
discard_packet
;
ist_index
=
i
nput_files
[
file_index
]
->
ist_index
+
pkt
.
stream_index
;
ist_index
=
i
file
->
ist_index
+
pkt
.
stream_index
;
ist
=
input_streams
[
ist_index
];
if
(
ist
->
discard
)
goto
discard_packet
;
if
(
pkt
.
dts
!=
AV_NOPTS_VALUE
)
pkt
.
dts
+=
av_rescale_q
(
i
nput_files
[
ist
->
file_index
]
->
ts_offset
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
pkt
.
dts
+=
av_rescale_q
(
i
file
->
ts_offset
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
if
(
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
+=
av_rescale_q
(
i
nput_files
[
ist
->
file_index
]
->
ts_offset
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
pkt
.
pts
+=
av_rescale_q
(
i
file
->
ts_offset
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
if
(
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
*=
ist
->
ts_scale
;
...
...
@@ -2216,10 +2218,10 @@ static int transcode(void)
int64_t
pkt_dts
=
av_rescale_q
(
pkt
.
dts
,
ist
->
st
->
time_base
,
AV_TIME_BASE_Q
);
int64_t
delta
=
pkt_dts
-
ist
->
next_dts
;
if
((
FFABS
(
delta
)
>
1LL
*
dts_delta_threshold
*
AV_TIME_BASE
||
pkt_dts
+
1
<
ist
->
last_dts
)
&&
!
copy_ts
)
{
i
nput_files
[
ist
->
file_index
]
->
ts_offset
-=
delta
;
i
file
->
ts_offset
-=
delta
;
av_log
(
NULL
,
AV_LOG_DEBUG
,
"timestamp discontinuity %"
PRId64
", new offset= %"
PRId64
"
\n
"
,
delta
,
i
nput_files
[
ist
->
file_index
]
->
ts_offset
);
delta
,
i
file
->
ts_offset
);
pkt
.
dts
-=
av_rescale_q
(
delta
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
if
(
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pkt
.
pts
-=
av_rescale_q
(
delta
,
AV_TIME_BASE_Q
,
ist
->
st
->
time_base
);
...
...
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