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
dc59ec5e
Commit
dc59ec5e
authored
May 22, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AVOptions: add av_opt_find() as a replacement for av_find_opt.
parent
7e83e1c5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
9 deletions
+70
-9
cmdutils.c
cmdutils.c
+3
-3
ffserver.c
ffserver.c
+1
-1
avutil.h
libavutil/avutil.h
+3
-0
log.h
libavutil/log.h
+7
-0
opt.c
libavutil/opt.c
+25
-5
opt.h
libavutil/opt.h
+31
-0
No files found.
cmdutils.c
View file @
dc59ec5e
...
...
@@ -299,7 +299,7 @@ int opt_default(const char *opt, const char *arg){
int
opt_types
[]
=
{
AV_OPT_FLAG_VIDEO_PARAM
,
AV_OPT_FLAG_AUDIO_PARAM
,
0
,
AV_OPT_FLAG_SUBTITLE_PARAM
,
0
};
for
(
type
=
0
;
*
avcodec_opts
&&
type
<
AVMEDIA_TYPE_NB
&&
ret
>=
0
;
type
++
){
const
AVOption
*
o2
=
av_
find_opt
(
avcodec_opts
[
0
],
opt
,
NULL
,
opt_types
[
type
],
opt_types
[
type
]
);
const
AVOption
*
o2
=
av_
opt_find
(
avcodec_opts
[
0
],
opt
,
NULL
,
opt_types
[
type
],
0
);
if
(
o2
)
ret
=
av_set_string3
(
avcodec_opts
[
type
],
opt
,
arg
,
1
,
&
o
);
}
...
...
@@ -324,13 +324,13 @@ int opt_default(const char *opt, const char *arg){
AVOutputFormat
*
oformat
=
NULL
;
while
((
p
=
av_codec_next
(
p
))){
const
AVClass
*
c
=
p
->
priv_class
;
if
(
c
&&
av_
find_opt
(
&
c
,
opt
,
NULL
,
0
,
0
))
if
(
c
&&
av_
opt_find
(
&
c
,
opt
,
NULL
,
0
,
0
))
break
;
}
if
(
!
p
)
{
while
((
oformat
=
av_oformat_next
(
oformat
)))
{
const
AVClass
*
c
=
oformat
->
priv_class
;
if
(
c
&&
av_
find_opt
(
&
c
,
opt
,
NULL
,
0
,
0
))
if
(
c
&&
av_
opt_find
(
&
c
,
opt
,
NULL
,
0
,
0
))
break
;
}
}
...
...
ffserver.c
View file @
dc59ec5e
...
...
@@ -3944,7 +3944,7 @@ static int ffserver_opt_default(const char *opt, const char *arg,
AVCodecContext
*
avctx
,
int
type
)
{
int
ret
=
0
;
const
AVOption
*
o
=
av_
find_opt
(
avctx
,
opt
,
NULL
,
type
,
type
);
const
AVOption
*
o
=
av_
opt_find
(
avctx
,
opt
,
NULL
,
type
,
0
);
if
(
o
)
ret
=
av_set_string3
(
avctx
,
opt
,
arg
,
1
,
NULL
);
return
ret
;
...
...
libavutil/avutil.h
View file @
dc59ec5e
...
...
@@ -60,6 +60,9 @@
#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
#endif
#ifndef FF_API_FIND_OPT
#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52)
#endif
/**
* Return the LIBAVUTIL_VERSION_INT constant.
...
...
libavutil/log.h
View file @
dc59ec5e
...
...
@@ -70,6 +70,13 @@ typedef struct {
* can be NULL of course
*/
int
parent_log_context_offset
;
/**
* A function for extended searching, e.g. in possible
* children objects.
*/
const
struct
AVOption
*
(
*
opt_find
)(
void
*
obj
,
const
char
*
name
,
const
char
*
unit
,
int
opt_flags
,
int
search_flags
);
}
AVClass
;
/* av_log API */
...
...
libavutil/opt.c
View file @
dc59ec5e
...
...
@@ -31,6 +31,7 @@
#include "eval.h"
#include "dict.h"
#if FF_API_FIND_OPT
//FIXME order them and do a bin search
const
AVOption
*
av_find_opt
(
void
*
v
,
const
char
*
name
,
const
char
*
unit
,
int
mask
,
int
flags
)
{
...
...
@@ -43,6 +44,7 @@ const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mas
}
return
NULL
;
}
#endif
const
AVOption
*
av_next_option
(
void
*
obj
,
const
AVOption
*
last
)
{
...
...
@@ -53,7 +55,7 @@ const AVOption *av_next_option(void *obj, const AVOption *last)
static
int
av_set_number2
(
void
*
obj
,
const
char
*
name
,
double
num
,
int
den
,
int64_t
intnum
,
const
AVOption
**
o_out
)
{
const
AVOption
*
o
=
av_find_opt
(
obj
,
name
,
NULL
,
0
,
0
);
const
AVOption
*
o
=
av_opt_find
(
obj
,
name
,
NULL
,
0
,
0
);
void
*
dst
;
if
(
o_out
)
*
o_out
=
o
;
...
...
@@ -116,7 +118,7 @@ static int hexchar2int(char c) {
int
av_set_string3
(
void
*
obj
,
const
char
*
name
,
const
char
*
val
,
int
alloc
,
const
AVOption
**
o_out
)
{
int
ret
;
const
AVOption
*
o
=
av_find_opt
(
obj
,
name
,
NULL
,
0
,
0
);
const
AVOption
*
o
=
av_opt_find
(
obj
,
name
,
NULL
,
0
,
0
);
if
(
o_out
)
*
o_out
=
o
;
if
(
!
o
)
...
...
@@ -163,7 +165,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
buf
[
i
]
=
0
;
{
const
AVOption
*
o_named
=
av_find_opt
(
obj
,
buf
,
o
->
unit
,
0
,
0
);
const
AVOption
*
o_named
=
av_opt_find
(
obj
,
buf
,
o
->
unit
,
0
,
0
);
if
(
o_named
&&
o_named
->
type
==
FF_OPT_TYPE_CONST
)
d
=
o_named
->
default_val
.
dbl
;
else
if
(
!
strcmp
(
buf
,
"default"
))
d
=
o
->
default_val
.
dbl
;
...
...
@@ -228,7 +230,7 @@ const AVOption *av_set_int(void *obj, const char *name, int64_t n)
*/
const
char
*
av_get_string
(
void
*
obj
,
const
char
*
name
,
const
AVOption
**
o_out
,
char
*
buf
,
int
buf_len
)
{
const
AVOption
*
o
=
av_find_opt
(
obj
,
name
,
NULL
,
0
,
0
);
const
AVOption
*
o
=
av_opt_find
(
obj
,
name
,
NULL
,
0
,
0
);
void
*
dst
;
uint8_t
*
bin
;
int
len
,
i
;
...
...
@@ -261,7 +263,7 @@ const char *av_get_string(void *obj, const char *name, const AVOption **o_out, c
static
int
av_get_number
(
void
*
obj
,
const
char
*
name
,
const
AVOption
**
o_out
,
double
*
num
,
int
*
den
,
int64_t
*
intnum
)
{
const
AVOption
*
o
=
av_find_opt
(
obj
,
name
,
NULL
,
0
,
0
);
const
AVOption
*
o
=
av_opt_find
(
obj
,
name
,
NULL
,
0
,
0
);
void
*
dst
;
if
(
!
o
||
o
->
offset
<=
0
)
goto
error
;
...
...
@@ -560,6 +562,24 @@ int av_opt_set_dict(void *obj, AVDictionary **options)
return
ret
;
}
const
AVOption
*
av_opt_find
(
void
*
obj
,
const
char
*
name
,
const
char
*
unit
,
int
opt_flags
,
int
search_flags
)
{
AVClass
*
c
=
*
(
AVClass
**
)
obj
;
const
AVOption
*
o
=
NULL
;
if
(
c
->
opt_find
&&
search_flags
&
AV_OPT_SEARCH_CHILDREN
&&
(
o
=
c
->
opt_find
(
obj
,
name
,
unit
,
opt_flags
,
search_flags
)))
return
o
;
while
(
o
=
av_next_option
(
obj
,
o
))
{
if
(
!
strcmp
(
o
->
name
,
name
)
&&
(
!
unit
||
(
o
->
unit
&&
!
strcmp
(
o
->
unit
,
unit
)))
&&
(
o
->
flags
&
opt_flags
)
==
opt_flags
)
return
o
;
}
return
NULL
;
}
#ifdef TEST
#undef printf
...
...
libavutil/opt.h
View file @
dc59ec5e
...
...
@@ -92,6 +92,7 @@ typedef struct AVOption {
const
char
*
unit
;
}
AVOption
;
#if FF_API_FIND_OPT
/**
* Look for an option in obj. Look only for the options which
* have the flags set as specified in mask and flags (that is,
...
...
@@ -103,8 +104,12 @@ typedef struct AVOption {
* @param[in] unit the unit of the option to look for, or any if NULL
* @return a pointer to the option found, or NULL if no option
* has been found
*
* @deprecated use av_opt_find.
*/
attribute_deprecated
const
AVOption
*
av_find_opt
(
void
*
obj
,
const
char
*
name
,
const
char
*
unit
,
int
mask
,
int
flags
);
#endif
/**
* Set the field of obj with the given name to value.
...
...
@@ -208,4 +213,30 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
*/
int
av_opt_set_dict
(
void
*
obj
,
struct
AVDictionary
**
options
);
#define AV_OPT_SEARCH_CHILDREN 0x0001
/**< Search in possible children of the
given object first. */
/**
* Look for an option in an object. Consider only options which
* have all the specified flags set.
*
* @param[in] obj A pointer to a struct whose first element is a
* pointer to an AVClass.
* @param[in] name The name of the option to look for.
* @param[in] unit When searching for named constants, name of the unit
* it belongs to.
* @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
* @param search_flags A combination of AV_OPT_SEARCH_*.
*
* @return A pointer to the option found, or NULL if no option
* was found.
*
* @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
* directly with av_set_string3(). Use special calls which take an options
* AVDictionary (e.g. avformat_open_input()) to set options found with this
* flag.
*/
const
AVOption
*
av_opt_find
(
void
*
obj
,
const
char
*
name
,
const
char
*
unit
,
int
opt_flags
,
int
search_flags
);
#endif
/* AVUTIL_OPT_H */
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