mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
Merge commit '9e500efdbe'
* commit '9e500efdbe':
Add av_image_check_sar() and use it to validate SAR
Conflicts:
libavcodec/dpx.c
libavcodec/dvdec.c
libavcodec/ffv1dec.c
libavcodec/utils.c
libavutil/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
0dceefc5fa
19 changed files with 120 additions and 11 deletions
|
|
@ -27,7 +27,9 @@
|
|||
#include "internal.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "log.h"
|
||||
#include "mathematics.h"
|
||||
#include "pixdesc.h"
|
||||
#include "rational.h"
|
||||
|
||||
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
|
||||
const AVPixFmtDescriptor *pixdesc)
|
||||
|
|
@ -239,6 +241,27 @@ int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *lo
|
|||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
|
||||
{
|
||||
int64_t scaled_dim;
|
||||
|
||||
if (!sar.den)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (!sar.num || sar.num == sar.den)
|
||||
return 0;
|
||||
|
||||
if (sar.num < sar.den)
|
||||
scaled_dim = av_rescale_rnd(w, sar.num, sar.den, AV_ROUND_ZERO);
|
||||
else
|
||||
scaled_dim = av_rescale_rnd(h, sar.den, sar.num, AV_ROUND_ZERO);
|
||||
|
||||
if (scaled_dim > 0)
|
||||
return 0;
|
||||
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
|
||||
const uint8_t *src, int src_linesize,
|
||||
int bytewidth, int height)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue