mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
16-bit grayscale support
Originally committed as revision 6778 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
a163ed1aaa
commit
34380af0e1
@ -193,6 +193,20 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* gray / mono formats */
|
/* 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] = {
|
[PIX_FMT_GRAY8] = {
|
||||||
.name = "gray",
|
.name = "gray",
|
||||||
.nb_channels = 1,
|
.nb_channels = 1,
|
||||||
@ -427,6 +441,8 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
|
|||||||
picture->data[2] = NULL;
|
picture->data[2] = NULL;
|
||||||
picture->linesize[0] = width * 4;
|
picture->linesize[0] = width * 4;
|
||||||
return size * 4;
|
return size * 4;
|
||||||
|
case PIX_FMT_GRAY16BE:
|
||||||
|
case PIX_FMT_GRAY16LE:
|
||||||
case PIX_FMT_BGR555:
|
case PIX_FMT_BGR555:
|
||||||
case PIX_FMT_BGR565:
|
case PIX_FMT_BGR565:
|
||||||
case PIX_FMT_RGB555:
|
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);
|
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; y<height; y++){
|
||||||
|
for(x=0; x<width; x++){
|
||||||
|
*d++ = *s;
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
s += src_wrap;
|
||||||
|
d += dst_wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gray16_to_gray(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 * 2;
|
||||||
|
d = dst->data[0];
|
||||||
|
dst_wrap = dst->linesize[0] - width;
|
||||||
|
for(y=0; y<height; y++){
|
||||||
|
for(x=0; x<width; x++){
|
||||||
|
*d++ = *s;
|
||||||
|
s += 2;
|
||||||
|
}
|
||||||
|
s += src_wrap;
|
||||||
|
d += dst_wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gray16be_to_gray(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
gray16_to_gray(dst, src, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gray16le_to_gray(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
gray16_to_gray(dst, src + 1, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gray16_to_gray16(AVPicture *dst, const AVPicture *src,
|
||||||
|
int width, int height)
|
||||||
|
{
|
||||||
|
int x, y, src_wrap, dst_wrap;
|
||||||
|
uint16_t *s, *d;
|
||||||
|
s = src->data[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<height; y++){
|
||||||
|
for(x=0; x<width; x++){
|
||||||
|
*d++ = bswap_16(*s++);
|
||||||
|
}
|
||||||
|
s += src_wrap;
|
||||||
|
d += dst_wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct ConvertEntry {
|
typedef struct ConvertEntry {
|
||||||
void (*convert)(AVPicture *dst,
|
void (*convert)(AVPicture *dst,
|
||||||
const AVPicture *src, int width, int height);
|
const AVPicture *src, int width, int height);
|
||||||
@ -2024,6 +2109,22 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
|
|||||||
.convert = rgb565_to_gray
|
.convert = rgb565_to_gray
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
[PIX_FMT_GRAY16BE] = {
|
||||||
|
[PIX_FMT_GRAY8] = {
|
||||||
|
.convert = gray16be_to_gray
|
||||||
|
},
|
||||||
|
[PIX_FMT_GRAY16LE] = {
|
||||||
|
.convert = gray16_to_gray16
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[PIX_FMT_GRAY16LE] = {
|
||||||
|
[PIX_FMT_GRAY8] = {
|
||||||
|
.convert = gray16le_to_gray
|
||||||
|
},
|
||||||
|
[PIX_FMT_GRAY16BE] = {
|
||||||
|
.convert = gray16_to_gray16
|
||||||
|
},
|
||||||
|
},
|
||||||
[PIX_FMT_GRAY8] = {
|
[PIX_FMT_GRAY8] = {
|
||||||
[PIX_FMT_RGB555] = {
|
[PIX_FMT_RGB555] = {
|
||||||
.convert = gray_to_rgb555
|
.convert = gray_to_rgb555
|
||||||
@ -2046,6 +2147,12 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
|
|||||||
[PIX_FMT_MONOBLACK] = {
|
[PIX_FMT_MONOBLACK] = {
|
||||||
.convert = gray_to_monoblack
|
.convert = gray_to_monoblack
|
||||||
},
|
},
|
||||||
|
[PIX_FMT_GRAY16LE] = {
|
||||||
|
.convert = gray_to_gray16
|
||||||
|
},
|
||||||
|
[PIX_FMT_GRAY16BE] = {
|
||||||
|
.convert = gray_to_gray16
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[PIX_FMT_MONOWHITE] = {
|
[PIX_FMT_MONOWHITE] = {
|
||||||
[PIX_FMT_GRAY8] = {
|
[PIX_FMT_GRAY8] = {
|
||||||
|
@ -177,6 +177,8 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
|
|||||||
case PIX_FMT_YUV422P:
|
case PIX_FMT_YUV422P:
|
||||||
case PIX_FMT_YUV444P:
|
case PIX_FMT_YUV444P:
|
||||||
case PIX_FMT_GRAY8:
|
case PIX_FMT_GRAY8:
|
||||||
|
case PIX_FMT_GRAY16BE:
|
||||||
|
case PIX_FMT_GRAY16LE:
|
||||||
case PIX_FMT_YUVJ420P:
|
case PIX_FMT_YUVJ420P:
|
||||||
case PIX_FMT_YUVJ422P:
|
case PIX_FMT_YUVJ422P:
|
||||||
case PIX_FMT_YUVJ444P:
|
case PIX_FMT_YUVJ444P:
|
||||||
|
@ -34,8 +34,8 @@ extern "C" {
|
|||||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||||
#define AV_TOSTRING(s) #s
|
#define AV_TOSTRING(s) #s
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+1)
|
#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+2)
|
||||||
#define LIBAVUTIL_VERSION 49.0.1
|
#define LIBAVUTIL_VERSION 49.0.2
|
||||||
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
||||||
|
|
||||||
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
||||||
@ -105,6 +105,8 @@ enum PixelFormat {
|
|||||||
PIX_FMT_RGB32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in cpu endianness
|
PIX_FMT_RGB32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in cpu endianness
|
||||||
PIX_FMT_BGR32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in cpu endianness
|
PIX_FMT_BGR32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in cpu endianness
|
||||||
|
|
||||||
|
PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
|
||||||
|
PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
|
||||||
PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,11 +115,13 @@ enum PixelFormat {
|
|||||||
#define PIX_FMT_BGRA PIX_FMT_BGR32_1
|
#define PIX_FMT_BGRA PIX_FMT_BGR32_1
|
||||||
#define PIX_FMT_ARGB PIX_FMT_RGB32
|
#define PIX_FMT_ARGB PIX_FMT_RGB32
|
||||||
#define PIX_FMT_ABGR PIX_FMT_BGR32
|
#define PIX_FMT_ABGR PIX_FMT_BGR32
|
||||||
|
#define PIX_FMT_GRAY16 PIX_FMT_GRAY16BE
|
||||||
#else
|
#else
|
||||||
#define PIX_FMT_RGBA PIX_FMT_BGR32
|
#define PIX_FMT_RGBA PIX_FMT_BGR32
|
||||||
#define PIX_FMT_BGRA PIX_FMT_RGB32
|
#define PIX_FMT_BGRA PIX_FMT_RGB32
|
||||||
#define PIX_FMT_ARGB PIX_FMT_BGR32_1
|
#define PIX_FMT_ARGB PIX_FMT_BGR32_1
|
||||||
#define PIX_FMT_ABGR PIX_FMT_RGB32_1
|
#define PIX_FMT_ABGR PIX_FMT_RGB32_1
|
||||||
|
#define PIX_FMT_GRAY16 PIX_FMT_GRAY16LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LIBAVUTIL_VERSION_INT < (50<<16)
|
#if LIBAVUTIL_VERSION_INT < (50<<16)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user