mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
swscale/yuv2rgb: add yuv42{0,2}p -> gbrp unscaled colorspace converters
This commit is contained in:
parent
af5adf57e3
commit
4545205a26
@ -124,6 +124,16 @@ const int *sws_getCoefficients(int colorspace)
|
||||
dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \
|
||||
dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];
|
||||
|
||||
#define PUTGBRP(l, i, abase) \
|
||||
Y = py_##l[2 * i]; \
|
||||
dst_##l [2 * i + 0] = g[Y]; \
|
||||
dst1_##l[2 * i + 0] = b[Y]; \
|
||||
dst2_##l[2 * i + 0] = r[Y]; \
|
||||
Y = py_##l[2 * i + 1]; \
|
||||
dst_##l [2 * i + 1] = g[Y]; \
|
||||
dst1_##l[2 * i + 1] = b[Y]; \
|
||||
dst2_##l[2 * i + 1] = r[Y];
|
||||
|
||||
#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \
|
||||
static int func_name(SwsContext *c, const uint8_t *src[], \
|
||||
int srcStride[], int srcSliceY, int srcSliceH, \
|
||||
@ -519,6 +529,7 @@ YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
|
||||
#endif
|
||||
YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1)
|
||||
YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1)
|
||||
YUV420FUNC(yuv420p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
|
||||
YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8)
|
||||
YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8)
|
||||
YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8)
|
||||
@ -539,6 +550,7 @@ YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
|
||||
#endif
|
||||
YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1)
|
||||
YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1)
|
||||
YUV422FUNC(yuv422p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
|
||||
YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8)
|
||||
YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8)
|
||||
YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8)
|
||||
@ -604,6 +616,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
|
||||
return yuv422p_bgr4_byte;
|
||||
case AV_PIX_FMT_MONOBLACK:
|
||||
return yuv2rgb_c_1_ordered_dither;
|
||||
case AV_PIX_FMT_GBRP:
|
||||
return yuv422p_gbrp_c;
|
||||
}
|
||||
} else {
|
||||
switch (c->dstFormat) {
|
||||
@ -644,6 +658,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
|
||||
return yuv2rgb_c_4b_ordered_dither;
|
||||
case AV_PIX_FMT_MONOBLACK:
|
||||
return yuv2rgb_c_1_ordered_dither;
|
||||
case AV_PIX_FMT_GBRP:
|
||||
return yuv420p_gbrp_c;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -58,6 +58,7 @@ static const int dst_fmts[] = {
|
||||
// AV_PIX_FMT_RGB4_BYTE,
|
||||
// AV_PIX_FMT_BGR4_BYTE,
|
||||
// AV_PIX_FMT_MONOBLACK,
|
||||
AV_PIX_FMT_GBRP,
|
||||
};
|
||||
|
||||
static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy)
|
||||
@ -116,13 +117,25 @@ static void check_yuv2rgb(int src_pix_fmt)
|
||||
LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]);
|
||||
const uint8_t *src[4] = { src_y, src_u, src_v, src_a };
|
||||
|
||||
LOCAL_ALIGNED_8(uint8_t, dst0_, [2 * MAX_LINE_SIZE * 6]);
|
||||
uint8_t *dst0[4] = { dst0_ };
|
||||
uint8_t *lines0[2] = { dst0_, dst0_ + MAX_LINE_SIZE * 6 };
|
||||
LOCAL_ALIGNED_8(uint8_t, dst0_0, [2 * MAX_LINE_SIZE * 6]);
|
||||
LOCAL_ALIGNED_8(uint8_t, dst0_1, [2 * MAX_LINE_SIZE]);
|
||||
LOCAL_ALIGNED_8(uint8_t, dst0_2, [2 * MAX_LINE_SIZE]);
|
||||
uint8_t *dst0[4] = { dst0_0, dst0_1, dst0_2 };
|
||||
uint8_t *lines0[4][2] = {
|
||||
{ dst0_0, dst0_0 + MAX_LINE_SIZE * 6 },
|
||||
{ dst0_1, dst0_1 + MAX_LINE_SIZE },
|
||||
{ dst0_2, dst0_2 + MAX_LINE_SIZE }
|
||||
};
|
||||
|
||||
LOCAL_ALIGNED_8(uint8_t, dst1_, [2 * MAX_LINE_SIZE * 6]);
|
||||
uint8_t *dst1[4] = { dst1_ };
|
||||
uint8_t *lines1[2] = { dst1_, dst1_ + MAX_LINE_SIZE * 6 };
|
||||
LOCAL_ALIGNED_8(uint8_t, dst1_0, [2 * MAX_LINE_SIZE * 6]);
|
||||
LOCAL_ALIGNED_8(uint8_t, dst1_1, [2 * MAX_LINE_SIZE]);
|
||||
LOCAL_ALIGNED_8(uint8_t, dst1_2, [2 * MAX_LINE_SIZE]);
|
||||
uint8_t *dst1[4] = { dst1_0, dst1_1, dst1_2 };
|
||||
uint8_t *lines1[4][2] = {
|
||||
{ dst1_0, dst1_0 + MAX_LINE_SIZE * 6 },
|
||||
{ dst1_1, dst1_1 + MAX_LINE_SIZE },
|
||||
{ dst1_2, dst1_2 + MAX_LINE_SIZE }
|
||||
};
|
||||
|
||||
randomize_buffers(src_y, MAX_LINE_SIZE * 2);
|
||||
randomize_buffers(src_u, MAX_LINE_SIZE);
|
||||
@ -145,7 +158,11 @@ static void check_yuv2rgb(int src_pix_fmt)
|
||||
width >> src_desc->log2_chroma_w,
|
||||
width,
|
||||
};
|
||||
int dstStride[4] = { MAX_LINE_SIZE * 6 };
|
||||
int dstStride[4] = {
|
||||
MAX_LINE_SIZE * 6,
|
||||
MAX_LINE_SIZE,
|
||||
MAX_LINE_SIZE,
|
||||
};
|
||||
|
||||
// override log level to prevent spamming of the message
|
||||
// "No accelerated colorspace conversion found from %s to %s"
|
||||
@ -159,8 +176,14 @@ static void check_yuv2rgb(int src_pix_fmt)
|
||||
fail();
|
||||
|
||||
if (check_func(ctx->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) {
|
||||
memset(dst0_, 0xFF, 2 * MAX_LINE_SIZE * 6);
|
||||
memset(dst1_, 0xFF, 2 * MAX_LINE_SIZE * 6);
|
||||
memset(dst0_0, 0xFF, 2 * MAX_LINE_SIZE * 6);
|
||||
memset(dst1_0, 0xFF, 2 * MAX_LINE_SIZE * 6);
|
||||
if (dst_pix_fmt == AV_PIX_FMT_GBRP) {
|
||||
memset(dst0_1, 0xFF, MAX_LINE_SIZE);
|
||||
memset(dst0_2, 0xFF, MAX_LINE_SIZE);
|
||||
memset(dst1_1, 0xFF, MAX_LINE_SIZE);
|
||||
memset(dst1_2, 0xFF, MAX_LINE_SIZE);
|
||||
}
|
||||
|
||||
call_ref(ctx, src, srcStride, srcSliceY,
|
||||
srcSliceH, dst0, dstStride);
|
||||
@ -173,19 +196,24 @@ static void check_yuv2rgb(int src_pix_fmt)
|
||||
dst_pix_fmt == AV_PIX_FMT_BGRA ||
|
||||
dst_pix_fmt == AV_PIX_FMT_RGB24 ||
|
||||
dst_pix_fmt == AV_PIX_FMT_BGR24) {
|
||||
if (cmp_off_by_n(lines0[0], lines1[0], width * sample_size, 3) ||
|
||||
cmp_off_by_n(lines0[1], lines1[1], width * sample_size, 3))
|
||||
if (cmp_off_by_n(lines0[0][0], lines1[0][0], width * sample_size, 3) ||
|
||||
cmp_off_by_n(lines0[0][1], lines1[0][1], width * sample_size, 3))
|
||||
fail();
|
||||
} else if (dst_pix_fmt == AV_PIX_FMT_RGB565 ||
|
||||
dst_pix_fmt == AV_PIX_FMT_BGR565) {
|
||||
if (cmp_565_by_n(lines0[0], lines1[0], width, 2) ||
|
||||
cmp_565_by_n(lines0[1], lines1[1], width, 2))
|
||||
if (cmp_565_by_n(lines0[0][0], lines1[0][0], width, 2) ||
|
||||
cmp_565_by_n(lines0[0][1], lines1[0][1], width, 2))
|
||||
fail();
|
||||
} else if (dst_pix_fmt == AV_PIX_FMT_RGB555 ||
|
||||
dst_pix_fmt == AV_PIX_FMT_BGR555) {
|
||||
if (cmp_555_by_n(lines0[0], lines1[0], width, 2) ||
|
||||
cmp_555_by_n(lines0[1], lines1[1], width, 2))
|
||||
if (cmp_555_by_n(lines0[0][0], lines1[0][0], width, 2) ||
|
||||
cmp_555_by_n(lines0[0][1], lines1[0][1], width, 2))
|
||||
fail();
|
||||
} else if (dst_pix_fmt == AV_PIX_FMT_GBRP) {
|
||||
for (int p = 0; p < 3; p++)
|
||||
for (int l = 0; l < 2; l++)
|
||||
if (cmp_off_by_n(lines0[p][l], lines1[p][l], width, 3))
|
||||
fail();
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user