From 34380af0e1c837e116d12e57155a7057bf3b872b Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 24 Oct 2006 04:57:43 +0000 Subject: [PATCH] 16-bit grayscale support Originally committed as revision 6778 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/imgconvert.c | 107 ++++++++++++++++++++++++++++++++++++++++ libavcodec/utils.c | 2 + libavutil/avutil.h | 8 ++- 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 7293e58a16..575d47ec01 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -193,6 +193,20 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { }, /* gray / mono formats */ + [PIX_FMT_GRAY16BE] = { + .name = "gray16be", + .nb_channels = 1, + .color_type = FF_COLOR_GRAY, + .pixel_type = FF_PIXEL_PLANAR, + .depth = 16, + }, + [PIX_FMT_GRAY16LE] = { + .name = "gray16le", + .nb_channels = 1, + .color_type = FF_COLOR_GRAY, + .pixel_type = FF_PIXEL_PLANAR, + .depth = 16, + }, [PIX_FMT_GRAY8] = { .name = "gray", .nb_channels = 1, @@ -427,6 +441,8 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr, picture->data[2] = NULL; picture->linesize[0] = width * 4; return size * 4; + case PIX_FMT_GRAY16BE: + case PIX_FMT_GRAY16LE: case PIX_FMT_BGR555: case PIX_FMT_BGR565: case PIX_FMT_RGB555: @@ -1842,6 +1858,75 @@ static void gray_to_monoblack(AVPicture *dst, const AVPicture *src, gray_to_mono(dst, src, width, height, 0x00); } +static void gray_to_gray16(AVPicture *dst, const AVPicture *src, + int width, int height) +{ + int x, y, src_wrap, dst_wrap; + uint8_t *s, *d; + s = src->data[0]; + src_wrap = src->linesize[0] - width; + d = dst->data[0]; + dst_wrap = dst->linesize[0] - width * 2; + for(y=0; ydata[0]; + src_wrap = src->linesize[0] - width * 2; + d = dst->data[0]; + dst_wrap = dst->linesize[0] - width; + for(y=0; ydata[0]; + src_wrap = (src->linesize[0] - width * 2)/2; + d = dst->data[0]; + dst_wrap = (dst->linesize[0] - width * 2)/2; + for(y=0; y