diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-10-06 15:29:37 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-10-12 14:45:39 +0400 |
commit | 22c8cbc0da8be2ba80190d42d381f63da389734f (patch) | |
tree | fd8c450a95415b35ebc9a3f7bbb1a1e6979fa886 /libavutil | |
parent | 59ee9f78b0cc4fb84ae606fa317d8102ad32a627 (diff) |
lavu,lavd: do not use av_pix_fmt_descriptors directly.
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/imgutils.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index fdc07f87a7..e661e1bf8d 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -47,11 +47,14 @@ void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], 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 */ int s; + if (!desc) + return AVERROR(EINVAL); + if (desc->flags & PIX_FMT_BITSTREAM) return (width * (desc->comp[0].step_minus1+1) + 7) >> 3; @@ -63,13 +66,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; - 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); if (desc->flags & PIX_FMT_BITSTREAM) { @@ -96,10 +99,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; @@ -176,9 +179,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, w)) < 0) @@ -196,8 +203,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; @@ -239,9 +245,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 || |