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
1575a96b
Commit
1575a96b
authored
Dec 16, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavu/opt: factorize setting of format values from string
Simplify incoming patch.
parent
e2b54464
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
32 deletions
+38
-32
opt.c
libavutil/opt.c
+38
-32
No files found.
libavutil/opt.c
View file @
1575a96b
...
...
@@ -295,6 +295,42 @@ static int set_string_color(void *obj, const AVOption *o, const char *val, uint8
return
0
;
}
static
int
set_string_fmt
(
void
*
obj
,
const
AVOption
*
o
,
const
char
*
val
,
uint8_t
*
dst
,
int
fmt_nb
,
int
((
*
get_fmt
)(
const
char
*
)),
const
char
*
desc
)
{
int
fmt
;
if
(
!
val
||
!
strcmp
(
val
,
"none"
))
{
fmt
=
-
1
;
}
else
{
fmt
=
get_fmt
(
val
);
if
(
fmt
==
-
1
)
{
char
*
tail
;
fmt
=
strtol
(
val
,
&
tail
,
0
);
if
(
*
tail
||
(
unsigned
)
fmt
>=
fmt_nb
)
{
av_log
(
obj
,
AV_LOG_ERROR
,
"Unable to parse option value
\"
%s
\"
as %s
\n
"
,
val
,
desc
);
return
AVERROR
(
EINVAL
);
}
}
}
*
(
int
*
)
dst
=
fmt
;
return
0
;
}
static
int
set_string_pixel_fmt
(
void
*
obj
,
const
AVOption
*
o
,
const
char
*
val
,
uint8_t
*
dst
)
{
return
set_string_fmt
(
obj
,
o
,
val
,
dst
,
AV_PIX_FMT_NB
,
av_get_pix_fmt
,
"pixel format"
);
}
static
int
set_string_sample_fmt
(
void
*
obj
,
const
AVOption
*
o
,
const
char
*
val
,
uint8_t
*
dst
)
{
return
set_string_fmt
(
obj
,
o
,
val
,
dst
,
AV_SAMPLE_FMT_NB
,
av_get_sample_fmt
,
"sample format"
);
}
#if FF_API_OLD_AVOPTIONS
int
av_set_string3
(
void
*
obj
,
const
char
*
name
,
const
char
*
val
,
int
alloc
,
const
AVOption
**
o_out
)
{
...
...
@@ -331,38 +367,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
case
AV_OPT_TYPE_RATIONAL
:
return
set_string_number
(
obj
,
target_obj
,
o
,
val
,
dst
);
case
AV_OPT_TYPE_IMAGE_SIZE
:
return
set_string_image_size
(
obj
,
o
,
val
,
dst
);
case
AV_OPT_TYPE_VIDEO_RATE
:
return
set_string_video_rate
(
obj
,
o
,
val
,
dst
);
case
AV_OPT_TYPE_PIXEL_FMT
:
if
(
!
val
||
!
strcmp
(
val
,
"none"
))
{
ret
=
AV_PIX_FMT_NONE
;
}
else
{
ret
=
av_get_pix_fmt
(
val
);
if
(
ret
==
AV_PIX_FMT_NONE
)
{
char
*
tail
;
ret
=
strtol
(
val
,
&
tail
,
0
);
if
(
*
tail
||
(
unsigned
)
ret
>=
AV_PIX_FMT_NB
)
{
av_log
(
obj
,
AV_LOG_ERROR
,
"Unable to parse option value
\"
%s
\"
as pixel format
\n
"
,
val
);
return
AVERROR
(
EINVAL
);
}
}
}
*
(
enum
AVPixelFormat
*
)
dst
=
ret
;
return
0
;
case
AV_OPT_TYPE_SAMPLE_FMT
:
if
(
!
val
||
!
strcmp
(
val
,
"none"
))
{
ret
=
AV_SAMPLE_FMT_NONE
;
}
else
{
ret
=
av_get_sample_fmt
(
val
);
if
(
ret
==
AV_SAMPLE_FMT_NONE
)
{
char
*
tail
;
ret
=
strtol
(
val
,
&
tail
,
0
);
if
(
*
tail
||
(
unsigned
)
ret
>=
AV_SAMPLE_FMT_NB
)
{
av_log
(
obj
,
AV_LOG_ERROR
,
"Unable to parse option value
\"
%s
\"
as sample format
\n
"
,
val
);
return
AVERROR
(
EINVAL
);
}
}
}
*
(
enum
AVSampleFormat
*
)
dst
=
ret
;
return
0
;
case
AV_OPT_TYPE_PIXEL_FMT
:
return
set_string_pixel_fmt
(
obj
,
o
,
val
,
dst
);
case
AV_OPT_TYPE_SAMPLE_FMT
:
return
set_string_sample_fmt
(
obj
,
o
,
val
,
dst
);
case
AV_OPT_TYPE_DURATION
:
if
(
!
val
)
{
*
(
int64_t
*
)
dst
=
0
;
...
...
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