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
e53901ba
Commit
e53901ba
authored
Dec 02, 2018
by
Martin Vignali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/utils : add ff_int_from_list_or_default func
to check valid value, or return default_value
parent
aae7e009
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
internal.h
libavcodec/internal.h
+12
-0
utils.c
libavcodec/utils.c
+19
-0
No files found.
libavcodec/internal.h
View file @
e53901ba
...
...
@@ -404,6 +404,18 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
*/
int64_t
ff_guess_coded_bitrate
(
AVCodecContext
*
avctx
);
/**
* Check if a value is in the list. If not, return the default value
*
* @param ctx Context for the log msg
* @param val_name Name of the checked value, for log msg
* @param array_valid_values Array of valid int, ended with INT_MAX
* @param default_value Value return if checked value is not in the array
* @return Value or default_value.
*/
int
ff_int_from_list_or_default
(
void
*
ctx
,
const
char
*
val_name
,
int
val
,
const
int
*
array_valid_values
,
int
default_value
);
#if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec)
# define av_export_avcodec __declspec(dllimport)
#else
...
...
libavcodec/utils.c
View file @
e53901ba
...
...
@@ -2209,3 +2209,22 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
return
bitrate
;
}
int
ff_int_from_list_or_default
(
void
*
ctx
,
const
char
*
val_name
,
int
val
,
const
int
*
array_valid_values
,
int
default_value
)
{
int
i
=
0
,
ref_val
;
while
(
1
)
{
ref_val
=
array_valid_values
[
i
];
if
(
ref_val
==
INT_MAX
)
break
;
if
(
val
==
ref_val
)
return
val
;
i
++
;
}
/* val is not a valid value */
av_log
(
ctx
,
AV_LOG_DEBUG
,
"%s %d are not supported. Set to default value : %d
\n
"
,
val_name
,
val
,
default_value
);
return
default_value
;
}
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