diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-09 22:22:36 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-09 22:22:36 +0000 |
commit | ed5d30d91ca226fce0ff47a284df5e724cd0adcc (patch) | |
tree | 7e8351a89a0ee383f90bed00bc3b3f63ac77ced2 /libavcore/imgutils.c | |
parent | a29039aef39f16c28649c39025765b10bda0b74a (diff) | |
download | ffmpeg-streaming-ed5d30d91ca226fce0ff47a284df5e724cd0adcc.zip ffmpeg-streaming-ed5d30d91ca226fce0ff47a284df5e724cd0adcc.tar.gz |
Move internal function ff_set_systematic_pal() to libavcore, and
rename it ff_set_systematic_pal2().
Originally committed as revision 25712 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcore/imgutils.c')
-rw-r--r-- | libavcore/imgutils.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libavcore/imgutils.c b/libavcore/imgutils.c index 0a21f6d..554639f 100644 --- a/libavcore/imgutils.c +++ b/libavcore/imgutils.c @@ -22,6 +22,7 @@ */ #include "imgutils.h" +#include "internal.h" #include "libavutil/pixdesc.h" void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], @@ -120,6 +121,46 @@ int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh return total_size; } +int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt) +{ + int i; + + for (i = 0; i < 256; i++) { + int r, g, b; + + switch (pix_fmt) { + case PIX_FMT_RGB8: + r = (i>>5 )*36; + g = ((i>>2)&7)*36; + b = (i&3 )*85; + break; + case PIX_FMT_BGR8: + b = (i>>6 )*85; + g = ((i>>3)&7)*36; + r = (i&7 )*36; + break; + case PIX_FMT_RGB4_BYTE: + r = (i>>3 )*255; + g = ((i>>1)&3)*85; + b = (i&1 )*255; + break; + case PIX_FMT_BGR4_BYTE: + b = (i>>3 )*255; + g = ((i>>1)&3)*85; + r = (i&1 )*255; + break; + case PIX_FMT_GRAY8: + r = b = g = i; + break; + default: + return AVERROR(EINVAL); + } + pal[i] = b + (g<<8) + (r<<16); + } + + return 0; +} + typedef struct ImgUtils { const AVClass *class; int log_offset; |