Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
8c8eab8b
Commit
8c8eab8b
authored
13 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
cmdutils: store all codec options in one dict instead of video/audio/sub
Split them when codec id is known.
parent
a9eb4f08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmdutils.c
+34
-21
34 additions, 21 deletions
cmdutils.c
cmdutils.h
+6
-1
6 additions, 1 deletion
cmdutils.h
with
40 additions
and
22 deletions
cmdutils.c
+
34
−
21
View file @
8c8eab8b
...
...
@@ -55,7 +55,7 @@ static int opt_name_count;
AVCodecContext
*
avcodec_opts
[
AVMEDIA_TYPE_NB
];
AVFormatContext
*
avformat_opts
;
struct
SwsContext
*
sws_opts
;
AVDictionary
*
format_opts
,
*
video_opts
,
*
audio_opts
,
*
sub
_opts
;
AVDictionary
*
format_opts
,
*
codec
_opts
;
static
const
int
this_year
=
2011
;
...
...
@@ -93,9 +93,7 @@ void uninit_opts(void)
av_freep
(
&
opt_values
);
opt_name_count
=
0
;
av_dict_free
(
&
format_opts
);
av_dict_free
(
&
video_opts
);
av_dict_free
(
&
audio_opts
);
av_dict_free
(
&
sub_opts
);
av_dict_free
(
&
codec_opts
);
}
void
log_callback_help
(
void
*
ptr
,
int
level
,
const
char
*
fmt
,
va_list
vl
)
...
...
@@ -299,20 +297,14 @@ unknown_opt:
}
#define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
#define SET_PREFIXED_OPTS(ch, flag, output) \
if (opt[0] == ch && avcodec_opts[0] && (o = av_opt_find(avcodec_opts[0], opt+1, NULL, flag, 0)))\
av_dict_set(&output, opt+1, arg, FLAGS);
static
int
opt_default2
(
const
char
*
opt
,
const
char
*
arg
)
{
const
AVOption
*
o
;
if
((
o
=
av_opt_find
(
avcodec_opts
[
0
],
opt
,
NULL
,
0
,
AV_OPT_SEARCH_CHILDREN
)))
{
if
(
o
->
flags
&
AV_OPT_FLAG_VIDEO_PARAM
)
av_dict_set
(
&
video_opts
,
opt
,
arg
,
FLAGS
);
if
(
o
->
flags
&
AV_OPT_FLAG_AUDIO_PARAM
)
av_dict_set
(
&
audio_opts
,
opt
,
arg
,
FLAGS
);
if
(
o
->
flags
&
AV_OPT_FLAG_SUBTITLE_PARAM
)
av_dict_set
(
&
sub_opts
,
opt
,
arg
,
FLAGS
);
}
else
if
((
o
=
av_opt_find
(
avformat_opts
,
opt
,
NULL
,
0
,
AV_OPT_SEARCH_CHILDREN
)))
if
((
o
=
av_opt_find
(
avcodec_opts
[
0
],
opt
,
NULL
,
0
,
AV_OPT_SEARCH_CHILDREN
))
||
((
opt
[
0
]
==
'v'
||
opt
[
0
]
==
'a'
||
opt
[
0
]
==
's'
)
&&
(
o
=
av_opt_find
(
avcodec_opts
[
0
],
opt
+
1
,
NULL
,
0
,
0
))))
av_dict_set
(
&
codec_opts
,
opt
,
arg
,
FLAGS
);
else
if
((
o
=
av_opt_find
(
avformat_opts
,
opt
,
NULL
,
0
,
AV_OPT_SEARCH_CHILDREN
)))
av_dict_set
(
&
format_opts
,
opt
,
arg
,
FLAGS
);
else
if
((
o
=
av_opt_find
(
sws_opts
,
opt
,
NULL
,
0
,
AV_OPT_SEARCH_CHILDREN
)))
{
// XXX we only support sws_flags, not arbitrary sws options
...
...
@@ -323,12 +315,6 @@ static int opt_default2(const char *opt, const char *arg)
}
}
if
(
!
o
)
{
SET_PREFIXED_OPTS
(
'v'
,
AV_OPT_FLAG_VIDEO_PARAM
,
video_opts
)
SET_PREFIXED_OPTS
(
'a'
,
AV_OPT_FLAG_AUDIO_PARAM
,
audio_opts
)
SET_PREFIXED_OPTS
(
's'
,
AV_OPT_FLAG_SUBTITLE_PARAM
,
sub_opts
)
}
if
(
o
)
return
0
;
fprintf
(
stderr
,
"Unrecognized option '%s'
\n
"
,
opt
);
...
...
@@ -899,6 +885,33 @@ FILE *get_preset_file(char *filename, size_t filename_size,
return
f
;
}
AVDictionary
*
filter_codec_opts
(
AVDictionary
*
opts
,
enum
CodecID
codec_id
,
int
encoder
)
{
AVDictionary
*
ret
=
NULL
;
AVDictionaryEntry
*
t
=
NULL
;
AVCodec
*
codec
=
encoder
?
avcodec_find_encoder
(
codec_id
)
:
avcodec_find_decoder
(
codec_id
);
int
flags
=
encoder
?
AV_OPT_FLAG_ENCODING_PARAM
:
AV_OPT_FLAG_DECODING_PARAM
;
char
prefix
=
0
;
if
(
!
codec
)
return
NULL
;
switch
(
codec
->
type
)
{
case
AVMEDIA_TYPE_VIDEO
:
prefix
=
'v'
;
flags
|=
AV_OPT_FLAG_VIDEO_PARAM
;
break
;
case
AVMEDIA_TYPE_AUDIO
:
prefix
=
'a'
;
flags
|=
AV_OPT_FLAG_AUDIO_PARAM
;
break
;
case
AVMEDIA_TYPE_SUBTITLE
:
prefix
=
's'
;
flags
|=
AV_OPT_FLAG_SUBTITLE_PARAM
;
break
;
}
while
(
t
=
av_dict_get
(
opts
,
""
,
t
,
AV_DICT_IGNORE_SUFFIX
))
{
if
(
av_opt_find
(
avcodec_opts
[
0
],
t
->
key
,
NULL
,
flags
,
0
)
||
(
codec
&&
codec
->
priv_class
&&
av_opt_find
(
&
codec
->
priv_class
,
t
->
key
,
NULL
,
flags
,
0
)))
av_dict_set
(
&
ret
,
t
->
key
,
t
->
value
,
0
);
else
if
(
t
->
key
[
0
]
==
prefix
&&
av_opt_find
(
avcodec_opts
[
0
],
t
->
key
+
1
,
NULL
,
flags
,
0
))
av_dict_set
(
&
ret
,
t
->
key
+
1
,
t
->
value
,
0
);
}
return
ret
;
}
#if CONFIG_AVFILTER
static
int
ffsink_init
(
AVFilterContext
*
ctx
,
const
char
*
args
,
void
*
opaque
)
...
...
This diff is collapsed.
Click to expand it.
cmdutils.h
+
6
−
1
View file @
8c8eab8b
...
...
@@ -43,7 +43,7 @@ extern const char **opt_names;
extern
AVCodecContext
*
avcodec_opts
[
AVMEDIA_TYPE_NB
];
extern
AVFormatContext
*
avformat_opts
;
extern
struct
SwsContext
*
sws_opts
;
extern
AVDictionary
*
format_opts
,
*
video_opts
,
*
audio_opts
,
*
sub
_opts
;
extern
AVDictionary
*
format_opts
,
*
codec
_opts
;
/**
* Initialize the cmdutils option system, in particular
...
...
@@ -151,6 +151,11 @@ void parse_options(int argc, char **argv, const OptionDef *options,
void
set_context_opts
(
void
*
ctx
,
void
*
opts_ctx
,
int
flags
,
AVCodec
*
codec
);
/**
* Filter out options for given codec.
*/
AVDictionary
*
filter_codec_opts
(
AVDictionary
*
opts
,
enum
CodecID
codec_id
,
int
encoder
);
/**
* Print an error message to stderr, indicating filename and a human
* readable description of the error code err.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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