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
ea9367e9
Commit
ea9367e9
authored
Apr 15, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: don't pass input/output streams to some functions.
They are globals, no point in pretending they are not.
parent
3892e784
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
36 deletions
+25
-36
avconv.c
avconv.c
+25
-36
No files found.
avconv.c
View file @
ea9367e9
...
@@ -1485,9 +1485,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost,
...
@@ -1485,9 +1485,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost,
}
}
}
}
static
void
print_report
(
OutputFile
*
output_files
,
static
void
print_report
(
int
is_last_report
,
int64_t
timer_start
)
OutputStream
*
ost_table
,
int
nb_ostreams
,
int
is_last_report
,
int64_t
timer_start
)
{
{
char
buf
[
1024
];
char
buf
[
1024
];
OutputStream
*
ost
;
OutputStream
*
ost
;
...
@@ -1525,9 +1523,9 @@ static void print_report(OutputFile *output_files,
...
@@ -1525,9 +1523,9 @@ static void print_report(OutputFile *output_files,
buf
[
0
]
=
'\0'
;
buf
[
0
]
=
'\0'
;
ti1
=
1e10
;
ti1
=
1e10
;
vid
=
0
;
vid
=
0
;
for
(
i
=
0
;
i
<
nb_ostreams
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_o
utput_
streams
;
i
++
)
{
float
q
=
-
1
;
float
q
=
-
1
;
ost
=
&
o
st_table
[
i
];
ost
=
&
o
utput_streams
[
i
];
enc
=
ost
->
st
->
codec
;
enc
=
ost
->
st
->
codec
;
if
(
!
ost
->
stream_copy
&&
enc
->
coded_frame
)
if
(
!
ost
->
stream_copy
&&
enc
->
coded_frame
)
q
=
enc
->
coded_frame
->
quality
/
(
float
)
FF_QP2LAMBDA
;
q
=
enc
->
coded_frame
->
quality
/
(
float
)
FF_QP2LAMBDA
;
...
@@ -1608,12 +1606,12 @@ static void print_report(OutputFile *output_files,
...
@@ -1608,12 +1606,12 @@ static void print_report(OutputFile *output_files,
}
}
}
}
static
void
flush_encoders
(
OutputStream
*
ost_table
,
int
nb_ostreams
)
static
void
flush_encoders
(
void
)
{
{
int
i
,
ret
;
int
i
,
ret
;
for
(
i
=
0
;
i
<
nb_ostreams
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_o
utput_
streams
;
i
++
)
{
OutputStream
*
ost
=
&
o
st_table
[
i
];
OutputStream
*
ost
=
&
o
utput_streams
[
i
];
AVCodecContext
*
enc
=
ost
->
st
->
codec
;
AVCodecContext
*
enc
=
ost
->
st
->
codec
;
AVFormatContext
*
os
=
output_files
[
ost
->
file_index
].
ctx
;
AVFormatContext
*
os
=
output_files
[
ost
->
file_index
].
ctx
;
int
stop_encoding
=
0
;
int
stop_encoding
=
0
;
...
@@ -2020,9 +2018,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
...
@@ -2020,9 +2018,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
}
}
/* pkt = NULL means EOF (needed to flush decoder buffers) */
/* pkt = NULL means EOF (needed to flush decoder buffers) */
static
int
output_packet
(
InputStream
*
ist
,
static
int
output_packet
(
InputStream
*
ist
,
const
AVPacket
*
pkt
)
OutputStream
*
ost_table
,
int
nb_ostreams
,
const
AVPacket
*
pkt
)
{
{
int
i
;
int
i
;
int
got_output
;
int
got_output
;
...
@@ -2116,8 +2112,8 @@ static int output_packet(InputStream *ist,
...
@@ -2116,8 +2112,8 @@ static int output_packet(InputStream *ist,
break
;
break
;
}
}
}
}
for
(
i
=
0
;
pkt
&&
i
<
nb_ostreams
;
i
++
)
{
for
(
i
=
0
;
pkt
&&
i
<
nb_o
utput_
streams
;
i
++
)
{
OutputStream
*
ost
=
&
o
st_table
[
i
];
OutputStream
*
ost
=
&
o
utput_streams
[
i
];
if
(
!
check_output_constraints
(
ist
,
ost
)
||
ost
->
encoding_needed
)
if
(
!
check_output_constraints
(
ist
,
ost
)
||
ost
->
encoding_needed
)
continue
;
continue
;
...
@@ -2128,18 +2124,18 @@ static int output_packet(InputStream *ist,
...
@@ -2128,18 +2124,18 @@ static int output_packet(InputStream *ist,
return
0
;
return
0
;
}
}
static
void
print_sdp
(
OutputFile
*
output_files
,
int
n
)
static
void
print_sdp
(
void
)
{
{
char
sdp
[
2048
];
char
sdp
[
2048
];
int
i
;
int
i
;
AVFormatContext
**
avc
=
av_malloc
(
sizeof
(
*
avc
)
*
n
);
AVFormatContext
**
avc
=
av_malloc
(
sizeof
(
*
avc
)
*
n
b_output_files
);
if
(
!
avc
)
if
(
!
avc
)
exit_program
(
1
);
exit_program
(
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
i
=
0
;
i
<
n
b_output_files
;
i
++
)
avc
[
i
]
=
output_files
[
i
].
ctx
;
avc
[
i
]
=
output_files
[
i
].
ctx
;
av_sdp_create
(
avc
,
n
,
sdp
,
sizeof
(
sdp
));
av_sdp_create
(
avc
,
n
b_output_files
,
sdp
,
sizeof
(
sdp
));
printf
(
"SDP:
\n
%s
\n
"
,
sdp
);
printf
(
"SDP:
\n
%s
\n
"
,
sdp
);
fflush
(
stdout
);
fflush
(
stdout
);
av_freep
(
&
avc
);
av_freep
(
&
avc
);
...
@@ -2190,8 +2186,7 @@ static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
...
@@ -2190,8 +2186,7 @@ static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
}
}
static
int
init_input_stream
(
int
ist_index
,
OutputStream
*
output_streams
,
int
nb_output_streams
,
static
int
init_input_stream
(
int
ist_index
,
char
*
error
,
int
error_len
)
char
*
error
,
int
error_len
)
{
{
int
i
;
int
i
;
InputStream
*
ist
=
&
input_streams
[
ist_index
];
InputStream
*
ist
=
&
input_streams
[
ist_index
];
...
@@ -2249,10 +2244,7 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb
...
@@ -2249,10 +2244,7 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb
return
0
;
return
0
;
}
}
static
int
transcode_init
(
OutputFile
*
output_files
,
static
int
transcode_init
(
void
)
int
nb_output_files
,
InputFile
*
input_files
,
int
nb_input_files
)
{
{
int
ret
=
0
,
i
,
j
,
k
;
int
ret
=
0
,
i
,
j
,
k
;
AVFormatContext
*
oc
;
AVFormatContext
*
oc
;
...
@@ -2544,7 +2536,7 @@ static int transcode_init(OutputFile *output_files,
...
@@ -2544,7 +2536,7 @@ static int transcode_init(OutputFile *output_files,
/* init input streams */
/* init input streams */
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
if
((
ret
=
init_input_stream
(
i
,
output_streams
,
nb_output_streams
,
error
,
sizeof
(
error
)))
<
0
)
if
((
ret
=
init_input_stream
(
i
,
error
,
sizeof
(
error
)))
<
0
)
goto
dump_format
;
goto
dump_format
;
/* discard unused programs */
/* discard unused programs */
...
@@ -2620,7 +2612,7 @@ static int transcode_init(OutputFile *output_files,
...
@@ -2620,7 +2612,7 @@ static int transcode_init(OutputFile *output_files,
}
}
if
(
want_sdp
)
{
if
(
want_sdp
)
{
print_sdp
(
output_files
,
nb_output_files
);
print_sdp
();
}
}
return
0
;
return
0
;
...
@@ -2629,10 +2621,7 @@ static int transcode_init(OutputFile *output_files,
...
@@ -2629,10 +2621,7 @@ static int transcode_init(OutputFile *output_files,
/*
/*
* The following code is the main loop of the file converter
* The following code is the main loop of the file converter
*/
*/
static
int
transcode
(
OutputFile
*
output_files
,
static
int
transcode
(
void
)
int
nb_output_files
,
InputFile
*
input_files
,
int
nb_input_files
)
{
{
int
ret
,
i
;
int
ret
,
i
;
AVFormatContext
*
is
,
*
os
;
AVFormatContext
*
is
,
*
os
;
...
@@ -2645,7 +2634,7 @@ static int transcode(OutputFile *output_files,
...
@@ -2645,7 +2634,7 @@ static int transcode(OutputFile *output_files,
if
(
!
(
no_packet
=
av_mallocz
(
nb_input_files
)))
if
(
!
(
no_packet
=
av_mallocz
(
nb_input_files
)))
exit_program
(
1
);
exit_program
(
1
);
ret
=
transcode_init
(
output_files
,
nb_output_files
,
input_files
,
nb_input_files
);
ret
=
transcode_init
();
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
fail
;
goto
fail
;
...
@@ -2770,7 +2759,7 @@ static int transcode(OutputFile *output_files,
...
@@ -2770,7 +2759,7 @@ static int transcode(OutputFile *output_files,
}
}
// fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
// fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
if
(
output_packet
(
ist
,
output_streams
,
nb_output_streams
,
&
pkt
)
<
0
)
{
if
(
output_packet
(
ist
,
&
pkt
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while decoding stream #%d:%d
\n
"
,
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error while decoding stream #%d:%d
\n
"
,
ist
->
file_index
,
ist
->
st
->
index
);
ist
->
file_index
,
ist
->
st
->
index
);
...
@@ -2784,17 +2773,17 @@ static int transcode(OutputFile *output_files,
...
@@ -2784,17 +2773,17 @@ static int transcode(OutputFile *output_files,
av_free_packet
(
&
pkt
);
av_free_packet
(
&
pkt
);
/* dump report by using the output first video and audio streams */
/* dump report by using the output first video and audio streams */
print_report
(
output_files
,
output_streams
,
nb_output_streams
,
0
,
timer_start
);
print_report
(
0
,
timer_start
);
}
}
/* at the end of stream, we must flush the decoder buffers */
/* at the end of stream, we must flush the decoder buffers */
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_input_streams
;
i
++
)
{
ist
=
&
input_streams
[
i
];
ist
=
&
input_streams
[
i
];
if
(
ist
->
decoding_needed
)
{
if
(
ist
->
decoding_needed
)
{
output_packet
(
ist
,
output_streams
,
nb_output_streams
,
NULL
);
output_packet
(
ist
,
NULL
);
}
}
}
}
flush_encoders
(
output_streams
,
nb_output_streams
);
flush_encoders
();
term_exit
();
term_exit
();
...
@@ -2805,7 +2794,7 @@ static int transcode(OutputFile *output_files,
...
@@ -2805,7 +2794,7 @@ static int transcode(OutputFile *output_files,
}
}
/* dump report by using the first video and audio streams */
/* dump report by using the first video and audio streams */
print_report
(
output_files
,
output_streams
,
nb_output_streams
,
1
,
timer_start
);
print_report
(
1
,
timer_start
);
/* close each encoder */
/* close each encoder */
for
(
i
=
0
;
i
<
nb_output_streams
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_output_streams
;
i
++
)
{
...
@@ -4622,7 +4611,7 @@ int main(int argc, char **argv)
...
@@ -4622,7 +4611,7 @@ int main(int argc, char **argv)
}
}
ti
=
getutime
();
ti
=
getutime
();
if
(
transcode
(
output_files
,
nb_output_files
,
input_files
,
nb_input_files
)
<
0
)
if
(
transcode
()
<
0
)
exit_program
(
1
);
exit_program
(
1
);
ti
=
getutime
()
-
ti
;
ti
=
getutime
()
-
ti
;
if
(
do_benchmark
)
{
if
(
do_benchmark
)
{
...
...
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