|
|
@@ -317,15 +317,17 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], |
|
|
|
} |
|
|
|
|
|
|
|
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], |
|
|
|
const uint8_t *src, |
|
|
|
enum AVPixelFormat pix_fmt, int width, int height, int align) |
|
|
|
const uint8_t *src, enum AVPixelFormat pix_fmt, |
|
|
|
int width, int height, int align) |
|
|
|
{ |
|
|
|
int ret, i; |
|
|
|
|
|
|
|
if ((ret = av_image_check_size(width, height, 0, NULL)) < 0) |
|
|
|
ret = av_image_check_size(width, height, 0, NULL); |
|
|
|
if (ret < 0) |
|
|
|
return ret; |
|
|
|
|
|
|
|
if ((ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width)) < 0) |
|
|
|
ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width); |
|
|
|
if (ret < 0) |
|
|
|
return ret; |
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) |
|
|
@@ -334,35 +336,44 @@ int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], |
|
|
|
return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, dst_linesize); |
|
|
|
} |
|
|
|
|
|
|
|
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align) |
|
|
|
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, |
|
|
|
int width, int height, int align) |
|
|
|
{ |
|
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); |
|
|
|
uint8_t *data[4]; |
|
|
|
int linesize[4]; |
|
|
|
|
|
|
|
int ret; |
|
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); |
|
|
|
if (!desc) |
|
|
|
return AVERROR(EINVAL); |
|
|
|
if (av_image_check_size(width, height, 0, NULL) < 0) |
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
|
|
|
ret = av_image_check_size(width, height, 0, NULL); |
|
|
|
if (ret < 0) |
|
|
|
return ret; |
|
|
|
|
|
|
|
// do not include palette for these pseudo-paletted formats |
|
|
|
if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) |
|
|
|
// do not include palette for these pseudo-paletted formats |
|
|
|
return width * height; |
|
|
|
return av_image_fill_arrays(data, linesize, NULL, pix_fmt, width, height, align); |
|
|
|
|
|
|
|
return av_image_fill_arrays(data, linesize, NULL, pix_fmt, |
|
|
|
width, height, align); |
|
|
|
} |
|
|
|
|
|
|
|
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, |
|
|
|
const uint8_t * const src_data[4], const int src_linesize[4], |
|
|
|
enum AVPixelFormat pix_fmt, int width, int height, int align) |
|
|
|
const uint8_t * const src_data[4], |
|
|
|
const int src_linesize[4], |
|
|
|
enum AVPixelFormat pix_fmt, |
|
|
|
int width, int height, int align) |
|
|
|
{ |
|
|
|
int i, j, nb_planes = 0, linesize[4]; |
|
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); |
|
|
|
int size = av_image_get_buffer_size(pix_fmt, width, height, align); |
|
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); |
|
|
|
|
|
|
|
if (size > dst_size || size < 0) |
|
|
|
if (size > dst_size || size < 0 || !desc) |
|
|
|
return AVERROR(EINVAL); |
|
|
|
|
|
|
|
for (i = 0; i < desc->nb_components; i++) |
|
|
|
nb_planes = FFMAX(desc->comp[i].plane, nb_planes); |
|
|
|
|
|
|
|
nb_planes++; |
|
|
|
|
|
|
|
av_image_fill_linesizes(linesize, pix_fmt, width); |
|
|
|