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
f542b152
Commit
f542b152
authored
Dec 10, 2016
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil: Add av_image_check_size2()
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
1b39a302
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
5 deletions
+41
-5
APIchanges
doc/APIchanges
+3
-0
imgutils.c
libavutil/imgutils.c
+23
-4
imgutils.h
libavutil/imgutils.h
+14
-0
version.h
libavutil/version.h
+1
-1
No files found.
doc/APIchanges
View file @
f542b152
...
...
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
2016-12-10 - xxxxxxx - lavu xx.xx.100- imgutils.h
Add av_image_check_size2()
2016-xx-xx - xxxxxxx - lavc 57.67.100 / 57.29.0 - avcodec.h
Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
information from containers.
...
...
libavutil/imgutils.c
View file @
f542b152
...
...
@@ -248,19 +248,38 @@ static const AVClass imgutils_class = {
.
parent_log_context_offset
=
offsetof
(
ImgUtils
,
log_ctx
),
};
int
av_image_check_size
(
unsigned
int
w
,
unsigned
int
h
,
int
log_offset
,
void
*
log_ctx
)
int
av_image_check_size
2
(
unsigned
int
w
,
unsigned
int
h
,
int64_t
max_pixels
,
enum
AVPixelFormat
pix_fmt
,
int
log_offset
,
void
*
log_ctx
)
{
ImgUtils
imgutils
=
{
.
class
=
&
imgutils_class
,
.
log_offset
=
log_offset
,
.
log_ctx
=
log_ctx
,
};
int64_t
stride
=
av_image_get_linesize
(
pix_fmt
,
w
,
0
);
if
(
stride
<=
0
)
stride
=
8LL
*
w
;
stride
+=
128
*
8
;
if
((
int
)
w
>
0
&&
(
int
)
h
>
0
&&
(
w
+
128
)
*
(
uint64_t
)(
h
+
128
)
<
INT_MAX
/
8
)
return
0
;
if
((
int
)
w
<=
0
||
(
int
)
h
<=
0
||
stride
>=
INT_MAX
||
stride
*
(
uint64_t
)(
h
+
128
)
>=
INT_MAX
)
{
av_log
(
&
imgutils
,
AV_LOG_ERROR
,
"Picture size %ux%u is invalid
\n
"
,
w
,
h
);
return
AVERROR
(
EINVAL
);
}
if
(
max_pixels
<
INT64_MAX
)
{
if
(
w
*
(
int64_t
)
h
>
max_pixels
)
{
av_log
(
&
imgutils
,
AV_LOG_ERROR
,
"Picture size %ux%u exceeds specified max pixel count %"
PRId64
", see the documentation if you wish to increase it
\n
"
,
w
,
h
,
max_pixels
);
return
AVERROR
(
EINVAL
);
}
}
return
0
;
}
int
av_image_check_size
(
unsigned
int
w
,
unsigned
int
h
,
int
log_offset
,
void
*
log_ctx
)
{
return
av_image_check_size2
(
w
,
h
,
INT64_MAX
,
AV_PIX_FMT_NONE
,
log_offset
,
log_ctx
);
}
int
av_image_check_sar
(
unsigned
int
w
,
unsigned
int
h
,
AVRational
sar
)
...
...
libavutil/imgutils.h
View file @
f542b152
...
...
@@ -191,6 +191,20 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
*/
int
av_image_check_size
(
unsigned
int
w
,
unsigned
int
h
,
int
log_offset
,
void
*
log_ctx
);
/**
* Check if the given dimension of an image is valid, meaning that all
* bytes of the image can be addressed with a signed int.
*
* @param w the width of the picture
* @param h the height of the picture
* @param max_pixels the maximum number of pixels the user wants to accept
* @param pix_fmt the pixel format, can be AV_PIX_FMT_NONE if unknown.
* @param log_offset the offset to sum to the log level for logging with log_ctx
* @param log_ctx the parent logging context, it may be NULL
* @return >= 0 if valid, a negative error code otherwise
*/
int
av_image_check_size2
(
unsigned
int
w
,
unsigned
int
h
,
int64_t
max_pixels
,
enum
AVPixelFormat
pix_fmt
,
int
log_offset
,
void
*
log_ctx
);
/**
* Check if the given sample aspect ratio of an image is valid.
*
...
...
libavutil/version.h
View file @
f542b152
...
...
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 4
2
#define LIBAVUTIL_VERSION_MINOR 4
3
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
...
...
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