diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-12 17:21:01 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-12 17:21:01 +0200 |
commit | 27ccc82e1bb1b97a85e5fb33b92082267078b4d1 (patch) | |
tree | 6dbdea647635c92e397cf37407540070453340c5 /libavutil/imgutils.c | |
parent | 13afee951a49964abb6d3e2d11644ac9d5ded2c7 (diff) | |
parent | 22c8cbc0da8be2ba80190d42d381f63da389734f (diff) | |
download | ffmpeg-streaming-27ccc82e1bb1b97a85e5fb33b92082267078b4d1.zip ffmpeg-streaming-27ccc82e1bb1b97a85e5fb33b92082267078b4d1.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
lavu,lavd: do not use av_pix_fmt_descriptors directly.
Conflicts:
libavutil/imgutils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/imgutils.c')
-rw-r--r-- | libavutil/imgutils.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 6174a60..7c7ae5c 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -53,6 +53,9 @@ int image_get_linesize(int width, int plane, { int s, shifted_w, linesize; + if (!desc) + return AVERROR(EINVAL); + if (width < 0) return AVERROR(EINVAL); s = (max_step_comp == 1 || max_step_comp == 2) ? desc->log2_chroma_w : 0; @@ -60,6 +63,7 @@ int image_get_linesize(int width, int plane, if (shifted_w && max_step > INT_MAX / shifted_w) return AVERROR(EINVAL); linesize = max_step * shifted_w; + if (desc->flags & PIX_FMT_BITSTREAM) linesize = (linesize + 7) >> 3; return linesize; @@ -67,7 +71,7 @@ int image_get_linesize(int width, int plane, int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane) { - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int max_step [4]; /* max pixel step for each plane */ int max_step_comp[4]; /* the component for each plane which has the max pixel step */ @@ -81,13 +85,13 @@ int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane) int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width) { int i, ret; - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int max_step [4]; /* max pixel step for each plane */ int max_step_comp[4]; /* the component for each plane which has the max pixel step */ memset(linesizes, 0, 4*sizeof(linesizes[0])); - if ((unsigned)pix_fmt >= AV_PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) + if (!desc || desc->flags & PIX_FMT_HWACCEL) return AVERROR(EINVAL); av_image_fill_max_pixsteps(max_step, max_step_comp, desc); @@ -105,10 +109,10 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei { int i, total_size, size[4] = { 0 }, has_plane[4] = { 0 }; - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); memset(data , 0, sizeof(data[0])*4); - if ((unsigned)pix_fmt >= AV_PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) + if (!desc || desc->flags & PIX_FMT_HWACCEL) return AVERROR(EINVAL); data[0] = ptr; @@ -185,9 +189,13 @@ int ff_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt) int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int i, ret; uint8_t *buf; + if (!desc) + return AVERROR(EINVAL); + if ((ret = av_image_check_size(w, h, 0, NULL)) < 0) return ret; if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0) @@ -205,8 +213,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], av_free(buf); return ret; } - if (av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PAL || - av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_PSEUDOPAL) + if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL) ff_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt); return ret; @@ -248,9 +255,9 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height) { - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - if (desc->flags & PIX_FMT_HWACCEL) + if (!desc || desc->flags & PIX_FMT_HWACCEL) return; if (desc->flags & PIX_FMT_PAL || @@ -317,7 +324,7 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size, enum AVPixelFormat pix_fmt, int width, int height, int align) { int i, j, nb_planes = 0, linesize[4]; - const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int size = av_image_get_buffer_size(pix_fmt, width, height, align); if (size > dst_size || size < 0) |