diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2011-10-24 19:58:48 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2011-10-28 02:06:50 +0200 |
commit | 8dc90371b1d0dac0a9417890d1a3dfcd9f31559b (patch) | |
tree | 87a610369c2a490147dbdfc7a3d5944e58e781c4 /libavfilter | |
parent | b76bc010343b0cff8717cc7ee81e47273272336c (diff) | |
download | ffmpeg-8dc90371b1d0dac0a9417890d1a3dfcd9f31559b.tar.gz |
lavfi: add internal function ff_fill_rgba_map()
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/drawutils.c | 27 | ||||
-rw-r--r-- | libavfilter/drawutils.h | 2 |
2 files changed, 18 insertions, 11 deletions
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c index dd9ceff117..bf308a1c5c 100644 --- a/libavfilter/drawutils.c +++ b/libavfilter/drawutils.c @@ -23,16 +23,8 @@ enum { RED = 0, GREEN, BLUE, ALPHA }; -int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], - enum PixelFormat pix_fmt, uint8_t rgba_color[4], - int *is_packed_rgba, uint8_t rgba_map_ptr[4]) +int ff_fill_rgba_map(uint8_t *rgba_map, enum PixelFormat pix_fmt) { - uint8_t rgba_map[4] = {0}; - int i; - const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; - int hsub = pix_desc->log2_chroma_w; - - *is_packed_rgba = 1; switch (pix_fmt) { case PIX_FMT_ARGB: rgba_map[ALPHA] = 0; rgba_map[RED ] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE ] = 3; break; case PIX_FMT_ABGR: rgba_map[ALPHA] = 0; rgba_map[BLUE ] = 1; rgba_map[GREEN] = 2; rgba_map[RED ] = 3; break; @@ -40,9 +32,22 @@ int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t case PIX_FMT_RGB24: rgba_map[RED ] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE ] = 2; rgba_map[ALPHA] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: rgba_map[BLUE ] = 0; rgba_map[GREEN] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break; - default: - *is_packed_rgba = 0; + default: /* unsupported */ + return AVERROR(EINVAL); } + return 0; +} + +int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], + enum PixelFormat pix_fmt, uint8_t rgba_color[4], + int *is_packed_rgba, uint8_t rgba_map_ptr[4]) +{ + uint8_t rgba_map[4] = {0}; + int i; + const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; + int hsub = pix_desc->log2_chroma_w; + + *is_packed_rgba = ff_fill_rgba_map(rgba_map, pix_fmt) >= 0; if (*is_packed_rgba) { pixel_step[0] = (av_get_bits_per_pixel(pix_desc))>>3; diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h index e838660579..330b1cb0aa 100644 --- a/libavfilter/drawutils.h +++ b/libavfilter/drawutils.h @@ -27,6 +27,8 @@ #include <stdint.h> #include "libavutil/pixfmt.h" +int ff_fill_rgba_map(uint8_t *rgba_map, enum PixelFormat pix_fmt); + int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], enum PixelFormat pix_fmt, uint8_t rgba_color[4], |