mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
ffmpegcolorspace: Add conversions from all ARGB formats to AYUV and back
This commit is contained in:
parent
b5fd5953d1
commit
8b1e42f272
2 changed files with 162 additions and 0 deletions
|
@ -2804,6 +2804,7 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_ABGR32, PIX_FMT_GRAY8, abgr32_to_gray},
|
||||
{PIX_FMT_ABGR32, PIX_FMT_GRAY16_L, abgr32_to_gray16_l},
|
||||
{PIX_FMT_ABGR32, PIX_FMT_GRAY16_B, abgr32_to_gray16_b},
|
||||
{PIX_FMT_ABGR32, PIX_FMT_AYUV4444, abgr32_to_ayuv4444},
|
||||
|
||||
{PIX_FMT_ARGB32, PIX_FMT_RGB24, argb32_to_rgb24},
|
||||
{PIX_FMT_ARGB32, PIX_FMT_RGBA32, argb32_to_rgba32},
|
||||
|
@ -2813,6 +2814,7 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_ARGB32, PIX_FMT_GRAY8, argb32_to_gray},
|
||||
{PIX_FMT_ARGB32, PIX_FMT_GRAY16_L, argb32_to_gray16_l},
|
||||
{PIX_FMT_ARGB32, PIX_FMT_GRAY16_B, argb32_to_gray16_b},
|
||||
{PIX_FMT_ARGB32, PIX_FMT_AYUV4444, argb32_to_ayuv4444},
|
||||
|
||||
{PIX_FMT_RGB555, PIX_FMT_RGB24, rgb555_to_rgb24},
|
||||
{PIX_FMT_RGB555, PIX_FMT_RGB32, rgb555_to_rgba32},
|
||||
|
@ -2901,6 +2903,9 @@ static ConvertEntry convert_table[] = {
|
|||
{PIX_FMT_V308, PIX_FMT_RGB24, v308_to_rgb24},
|
||||
|
||||
{PIX_FMT_AYUV4444, PIX_FMT_RGBA32, ayuv4444_to_rgba32},
|
||||
{PIX_FMT_AYUV4444, PIX_FMT_ARGB32, ayuv4444_to_argb32},
|
||||
{PIX_FMT_AYUV4444, PIX_FMT_BGRA32, ayuv4444_to_bgra32},
|
||||
{PIX_FMT_AYUV4444, PIX_FMT_ABGR32, ayuv4444_to_abgr32},
|
||||
{PIX_FMT_AYUV4444, PIX_FMT_RGB24, ayuv4444_to_rgb24},
|
||||
};
|
||||
|
||||
|
|
|
@ -1083,10 +1083,167 @@ bgra32_to_ayuv4444 (AVPicture * dst, const AVPicture * src,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ayuv4444_to_bgra32 (AVPicture * dst, const AVPicture * src,
|
||||
int width, int height)
|
||||
{
|
||||
uint8_t *s, *d, *d1, *s1;
|
||||
int w, y, cb, cr, r_add, g_add, b_add;
|
||||
uint8_t *cm = cropTbl + MAX_NEG_CROP;
|
||||
unsigned int r, g, b, a;
|
||||
|
||||
d = dst->data[0];
|
||||
s = src->data[0];
|
||||
for (; height > 0; height--) {
|
||||
d1 = d;
|
||||
s1 = s;
|
||||
for (w = width; w > 0; w--) {
|
||||
a = s1[0];
|
||||
YUV_TO_RGB1_CCIR (s1[2], s1[3]);
|
||||
|
||||
YUV_TO_RGB2_CCIR (r, g, b, s1[1]);
|
||||
RGBA_OUT (d1, r, g, b, a);
|
||||
d1 += BPP;
|
||||
s1 += 4;
|
||||
}
|
||||
d += dst->linesize[0];
|
||||
s += src->linesize[0];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !defined(bgra32_fcts_done) */
|
||||
|
||||
#endif /* defined(FMT_BGRA32) */
|
||||
|
||||
#if defined(FMT_ARGB32)
|
||||
|
||||
#if !defined(argb32_fcts_done)
|
||||
#define argb32_fcts_done
|
||||
|
||||
static void
|
||||
ayuv4444_to_argb32 (AVPicture * dst, const AVPicture * src,
|
||||
int width, int height)
|
||||
{
|
||||
uint8_t *s, *d, *d1, *s1;
|
||||
int w, y, cb, cr, r_add, g_add, b_add;
|
||||
uint8_t *cm = cropTbl + MAX_NEG_CROP;
|
||||
unsigned int r, g, b, a;
|
||||
|
||||
d = dst->data[0];
|
||||
s = src->data[0];
|
||||
for (; height > 0; height--) {
|
||||
d1 = d;
|
||||
s1 = s;
|
||||
for (w = width; w > 0; w--) {
|
||||
a = s1[0];
|
||||
YUV_TO_RGB1_CCIR (s1[2], s1[3]);
|
||||
|
||||
YUV_TO_RGB2_CCIR (r, g, b, s1[1]);
|
||||
RGBA_OUT (d1, r, g, b, a);
|
||||
d1 += BPP;
|
||||
s1 += 4;
|
||||
}
|
||||
d += dst->linesize[0];
|
||||
s += src->linesize[0];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
argb32_to_ayuv4444 (AVPicture * dst, const AVPicture * src,
|
||||
int width, int height)
|
||||
{
|
||||
int src_wrap, dst_wrap, x, y;
|
||||
int r, g, b, a;
|
||||
uint8_t *d;
|
||||
const uint8_t *p;
|
||||
|
||||
src_wrap = src->linesize[0] - width * BPP;
|
||||
dst_wrap = dst->linesize[0] - width * 4;
|
||||
d = dst->data[0];
|
||||
p = src->data[0];
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
RGBA_IN (r, g, b, a, p);
|
||||
d[0] = a;
|
||||
d[1] = RGB_TO_Y_CCIR (r, g, b);
|
||||
d[2] = RGB_TO_U_CCIR (r, g, b, 0);
|
||||
d[3] = RGB_TO_V_CCIR (r, g, b, 0);
|
||||
p += BPP;
|
||||
d += 4;
|
||||
}
|
||||
p += src_wrap;
|
||||
d += dst_wrap;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !defined(argb32_fcts_done) */
|
||||
|
||||
#endif /* defined(FMT_ARGB32) */
|
||||
|
||||
#if defined(FMT_ABGR32)
|
||||
#if !defined(abgr32_fcts_done)
|
||||
#define abgr32_fcts_done
|
||||
|
||||
static void
|
||||
abgr32_to_ayuv4444 (AVPicture * dst, const AVPicture * src,
|
||||
int width, int height)
|
||||
{
|
||||
int src_wrap, dst_wrap, x, y;
|
||||
int r, g, b, a;
|
||||
uint8_t *d;
|
||||
const uint8_t *p;
|
||||
|
||||
src_wrap = src->linesize[0] - width * BPP;
|
||||
dst_wrap = dst->linesize[0] - width * 4;
|
||||
d = dst->data[0];
|
||||
p = src->data[0];
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
RGBA_IN (r, g, b, a, p);
|
||||
d[0] = a;
|
||||
d[1] = RGB_TO_Y_CCIR (r, g, b);
|
||||
d[2] = RGB_TO_U_CCIR (r, g, b, 0);
|
||||
d[3] = RGB_TO_V_CCIR (r, g, b, 0);
|
||||
p += BPP;
|
||||
d += 4;
|
||||
}
|
||||
p += src_wrap;
|
||||
d += dst_wrap;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ayuv4444_to_abgr32 (AVPicture * dst, const AVPicture * src,
|
||||
int width, int height)
|
||||
{
|
||||
uint8_t *s, *d, *d1, *s1;
|
||||
int w, y, cb, cr, r_add, g_add, b_add;
|
||||
uint8_t *cm = cropTbl + MAX_NEG_CROP;
|
||||
unsigned int r, g, b, a;
|
||||
|
||||
d = dst->data[0];
|
||||
s = src->data[0];
|
||||
for (; height > 0; height--) {
|
||||
d1 = d;
|
||||
s1 = s;
|
||||
for (w = width; w > 0; w--) {
|
||||
a = s1[0];
|
||||
YUV_TO_RGB1_CCIR (s1[2], s1[3]);
|
||||
|
||||
YUV_TO_RGB2_CCIR (r, g, b, s1[1]);
|
||||
RGBA_OUT (d1, r, g, b, a);
|
||||
d1 += BPP;
|
||||
s1 += 4;
|
||||
}
|
||||
d += dst->linesize[0];
|
||||
s += src->linesize[0];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !defined(abgr32_fcts_done) */
|
||||
|
||||
#endif /* defined(FMT_ABGR32) */
|
||||
|
||||
#ifndef FMT_RGB24
|
||||
|
||||
static void glue (rgb24_to_, RGB_NAME) (AVPicture * dst, const AVPicture * src,
|
||||
|
|
Loading…
Reference in a new issue