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
cdc78058
Commit
cdc78058
authored
Jan 30, 2018
by
Josh de Kock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmdutils: make use of new iteration APIs
parent
0fd47570
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
79 deletions
+43
-79
cmdutils.c
fftools/cmdutils.c
+43
-79
No files found.
fftools/cmdutils.c
View file @
cdc78058
...
@@ -1250,19 +1250,11 @@ int show_license(void *optctx, const char *opt, const char *arg)
...
@@ -1250,19 +1250,11 @@ int show_license(void *optctx, const char *opt, const char *arg)
return
0
;
return
0
;
}
}
static
int
is_device
(
const
AVClass
*
avclass
)
{
if
(
!
avclass
)
return
0
;
return
AV_IS_INPUT_DEVICE
(
avclass
->
category
)
||
AV_IS_OUTPUT_DEVICE
(
avclass
->
category
);
}
static
int
show_formats_devices
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
,
int
device_only
,
int
muxdemuxers
)
static
int
show_formats_devices
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
,
int
device_only
,
int
muxdemuxers
)
{
{
AVInputFormat
*
ifmt
=
NULL
;
const
AVInputFormat
*
ifmt
=
NULL
;
AVOutputFormat
*
ofmt
=
NULL
;
const
AVOutputFormat
*
ofmt
=
NULL
;
const
char
*
last_name
;
const
char
*
last_name
;
int
is_dev
;
printf
(
"%s
\n
"
printf
(
"%s
\n
"
" D. = Demuxing supported
\n
"
" D. = Demuxing supported
\n
"
...
@@ -1275,34 +1267,24 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
...
@@ -1275,34 +1267,24 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
const
char
*
name
=
NULL
;
const
char
*
name
=
NULL
;
const
char
*
long_name
=
NULL
;
const
char
*
long_name
=
NULL
;
if
(
muxdemuxers
!=
SHOW_DEMUXERS
)
{
#define x(func, type, condition) do { \
while
((
ofmt
=
av_oformat_next
(
ofmt
)))
{
void *i = 0; \
is_dev
=
is_device
(
ofmt
->
priv_class
);
if (condition) { \
if
(
!
is_dev
&&
device_only
)
while ((type = func(&i))) { \
continue
;
if ((!name || strcmp(type->name, name) < 0) && \
if
((
!
name
||
strcmp
(
ofmt
->
name
,
name
)
<
0
)
&&
strcmp(type->name, last_name) > 0) { \
strcmp
(
ofmt
->
name
,
last_name
)
>
0
)
{
name = type->name; \
name
=
ofmt
->
name
;
long_name = type->long_name; \
long_name
=
ofmt
->
long_name
;
encode = 1; \
encode
=
1
;
} \
}
} \
}
} } while(0)
}
if
(
muxdemuxers
!=
SHOW_MUXERS
)
{
x
(
av_muxer_iterate
,
ofmt
,
muxdemuxers
!=
SHOW_DEMUXERS
&&
!
device_only
);
while
((
ifmt
=
av_iformat_next
(
ifmt
)))
{
x
(
av_outdev_iterate
,
ofmt
,
muxdemuxers
!=
SHOW_DEMUXERS
);
is_dev
=
is_device
(
ifmt
->
priv_class
);
x
(
av_demuxer_iterate
,
ifmt
,
muxdemuxers
!=
SHOW_MUXERS
&&
!
device_only
);
if
(
!
is_dev
&&
device_only
)
x
(
av_indev_iterate
,
ifmt
,
muxdemuxers
!=
SHOW_MUXERS
);
continue
;
#undef x
if
((
!
name
||
strcmp
(
ifmt
->
name
,
name
)
<
0
)
&&
strcmp
(
ifmt
->
name
,
last_name
)
>
0
)
{
name
=
ifmt
->
name
;
long_name
=
ifmt
->
long_name
;
encode
=
0
;
}
if
(
name
&&
strcmp
(
ifmt
->
name
,
name
)
==
0
)
decode
=
1
;
}
}
if
(
!
name
)
if
(
!
name
)
break
;
break
;
last_name
=
name
;
last_name
=
name
;
...
@@ -1442,7 +1424,8 @@ static char get_media_type_char(enum AVMediaType type)
...
@@ -1442,7 +1424,8 @@ static char get_media_type_char(enum AVMediaType type)
static
const
AVCodec
*
next_codec_for_id
(
enum
AVCodecID
id
,
const
AVCodec
*
prev
,
static
const
AVCodec
*
next_codec_for_id
(
enum
AVCodecID
id
,
const
AVCodec
*
prev
,
int
encoder
)
int
encoder
)
{
{
while
((
prev
=
av_codec_next
(
prev
)))
{
void
*
i
=
0
;
while
((
prev
=
av_codec_iterate
(
&
i
)))
{
if
(
prev
->
id
==
id
&&
if
(
prev
->
id
==
id
&&
(
encoder
?
av_codec_is_encoder
(
prev
)
:
av_codec_is_decoder
(
prev
)))
(
encoder
?
av_codec_is_encoder
(
prev
)
:
av_codec_is_decoder
(
prev
)))
return
prev
;
return
prev
;
...
@@ -2116,7 +2099,7 @@ double get_rotation(AVStream *st)
...
@@ -2116,7 +2099,7 @@ double get_rotation(AVStream *st)
}
}
#if CONFIG_AVDEVICE
#if CONFIG_AVDEVICE
static
int
print_device_sources
(
AVInputFormat
*
fmt
,
AVDictionary
*
opts
)
static
int
print_device_sources
(
const
AVInputFormat
*
fmt
,
AVDictionary
*
opts
)
{
{
int
ret
,
i
;
int
ret
,
i
;
AVDeviceInfoList
*
device_list
=
NULL
;
AVDeviceInfoList
*
device_list
=
NULL
;
...
@@ -2131,7 +2114,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
...
@@ -2131,7 +2114,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
goto
fail
;
goto
fail
;
}
}
if
((
ret
=
avdevice_list_input_sources
(
fmt
,
NULL
,
opts
,
&
device_list
))
<
0
)
{
if
((
ret
=
avdevice_list_input_sources
(
(
AVInputFormat
*
)
fmt
,
NULL
,
opts
,
&
device_list
))
<
0
)
{
printf
(
"Cannot list sources.
\n
"
);
printf
(
"Cannot list sources.
\n
"
);
goto
fail
;
goto
fail
;
}
}
...
@@ -2146,7 +2129,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
...
@@ -2146,7 +2129,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
return
ret
;
return
ret
;
}
}
static
int
print_device_sinks
(
AVOutputFormat
*
fmt
,
AVDictionary
*
opts
)
static
int
print_device_sinks
(
const
AVOutputFormat
*
fmt
,
AVDictionary
*
opts
)
{
{
int
ret
,
i
;
int
ret
,
i
;
AVDeviceInfoList
*
device_list
=
NULL
;
AVDeviceInfoList
*
device_list
=
NULL
;
...
@@ -2161,7 +2144,7 @@ static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
...
@@ -2161,7 +2144,7 @@ static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
goto
fail
;
goto
fail
;
}
}
if
((
ret
=
avdevice_list_output_sinks
(
fmt
,
NULL
,
opts
,
&
device_list
))
<
0
)
{
if
((
ret
=
avdevice_list_output_sinks
(
(
AVOutputFormat
*
)
fmt
,
NULL
,
opts
,
&
device_list
))
<
0
)
{
printf
(
"Cannot list sinks.
\n
"
);
printf
(
"Cannot list sinks.
\n
"
);
goto
fail
;
goto
fail
;
}
}
...
@@ -2200,7 +2183,8 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
...
@@ -2200,7 +2183,8 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
int
show_sources
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
)
int
show_sources
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
)
{
{
AVInputFormat
*
fmt
=
NULL
;
const
AVInputFormat
*
fmt
=
NULL
;
void
*
i
=
0
;
char
*
dev
=
NULL
;
char
*
dev
=
NULL
;
AVDictionary
*
opts
=
NULL
;
AVDictionary
*
opts
=
NULL
;
int
ret
=
0
;
int
ret
=
0
;
...
@@ -2211,24 +2195,14 @@ int show_sources(void *optctx, const char *opt, const char *arg)
...
@@ -2211,24 +2195,14 @@ int show_sources(void *optctx, const char *opt, const char *arg)
if
((
ret
=
show_sinks_sources_parse_arg
(
arg
,
&
dev
,
&
opts
))
<
0
)
if
((
ret
=
show_sinks_sources_parse_arg
(
arg
,
&
dev
,
&
opts
))
<
0
)
goto
fail
;
goto
fail
;
do
{
while
((
fmt
=
av_indev_iterate
(
&
i
)))
{
fmt
=
av_input_audio_device_next
(
fmt
);
if
(
!
strcmp
(
fmt
->
name
,
"lavfi"
))
if
(
fmt
)
{
continue
;
//it's pointless to probe lavfi
if
(
!
strcmp
(
fmt
->
name
,
"lavfi"
))
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
continue
;
//it's pointless to probe lavfi
continue
;
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
print_device_sources
(
fmt
,
opts
);
continue
;
}
print_device_sources
(
fmt
,
opts
);
}
}
while
(
fmt
);
do
{
fmt
=
av_input_video_device_next
(
fmt
);
if
(
fmt
)
{
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
continue
;
print_device_sources
(
fmt
,
opts
);
}
}
while
(
fmt
);
fail:
fail:
av_dict_free
(
&
opts
);
av_dict_free
(
&
opts
);
av_free
(
dev
);
av_free
(
dev
);
...
@@ -2238,7 +2212,8 @@ int show_sources(void *optctx, const char *opt, const char *arg)
...
@@ -2238,7 +2212,8 @@ int show_sources(void *optctx, const char *opt, const char *arg)
int
show_sinks
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
)
int
show_sinks
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
)
{
{
AVOutputFormat
*
fmt
=
NULL
;
const
AVOutputFormat
*
fmt
=
NULL
;
void
*
i
=
0
;
char
*
dev
=
NULL
;
char
*
dev
=
NULL
;
AVDictionary
*
opts
=
NULL
;
AVDictionary
*
opts
=
NULL
;
int
ret
=
0
;
int
ret
=
0
;
...
@@ -2249,22 +2224,11 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
...
@@ -2249,22 +2224,11 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
if
((
ret
=
show_sinks_sources_parse_arg
(
arg
,
&
dev
,
&
opts
))
<
0
)
if
((
ret
=
show_sinks_sources_parse_arg
(
arg
,
&
dev
,
&
opts
))
<
0
)
goto
fail
;
goto
fail
;
do
{
while
((
fmt
=
av_outdev_iterate
(
&
i
)))
{
fmt
=
av_output_audio_device_next
(
fmt
);
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
if
(
fmt
)
{
continue
;
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
print_device_sinks
(
fmt
,
opts
);
continue
;
}
print_device_sinks
(
fmt
,
opts
);
}
}
while
(
fmt
);
do
{
fmt
=
av_output_video_device_next
(
fmt
);
if
(
fmt
)
{
if
(
dev
&&
!
av_match_name
(
dev
,
fmt
->
name
))
continue
;
print_device_sinks
(
fmt
,
opts
);
}
}
while
(
fmt
);
fail:
fail:
av_dict_free
(
&
opts
);
av_dict_free
(
&
opts
);
av_free
(
dev
);
av_free
(
dev
);
...
...
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