summaryrefslogtreecommitdiff
path: root/ffmpeg/libswscale/yuv2rgb.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg/libswscale/yuv2rgb.c')
-rw-r--r--ffmpeg/libswscale/yuv2rgb.c87
1 files changed, 40 insertions, 47 deletions
diff --git a/ffmpeg/libswscale/yuv2rgb.c b/ffmpeg/libswscale/yuv2rgb.c
index d12abda..77c56a9 100644
--- a/ffmpeg/libswscale/yuv2rgb.c
+++ b/ffmpeg/libswscale/yuv2rgb.c
@@ -35,13 +35,6 @@
#include "swscale_internal.h"
#include "libavutil/pixdesc.h"
-extern const uint8_t dither_2x2_4[3][8];
-extern const uint8_t dither_2x2_8[3][8];
-extern const uint8_t dither_4x4_16[5][8];
-extern const uint8_t dither_8x8_32[9][8];
-extern const uint8_t dither_8x8_73[9][8];
-extern const uint8_t dither_8x8_220[9][8];
-
const int32_t ff_yuv2rgb_coeffs[8][4] = {
{ 117504, 138453, 13954, 34903 }, /* no sequence_display_extension */
{ 117504, 138453, 13954, 34903 }, /* ITU-R Rec. 709 (1990) */
@@ -266,28 +259,28 @@ YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
PUTRGBA(dst_2, py_2, pa_2, 0, 24);
LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_1, 1, 24);
- PUTRGBA(dst_1, py_1, pa_2, 1, 24);
+ PUTRGBA(dst_2, py_2, pa_2, 1, 24);
+ PUTRGBA(dst_1, py_1, pa_1, 1, 24);
LOADCHROMA(2);
PUTRGBA(dst_1, py_1, pa_1, 2, 24);
PUTRGBA(dst_2, py_2, pa_2, 2, 24);
LOADCHROMA(3);
- PUTRGBA(dst_2, py_2, pa_1, 3, 24);
- PUTRGBA(dst_1, py_1, pa_2, 3, 24);
- pa_1 += 8; \
- pa_2 += 8; \
+ PUTRGBA(dst_2, py_2, pa_2, 3, 24);
+ PUTRGBA(dst_1, py_1, pa_1, 3, 24);
+ pa_1 += 8;
+ pa_2 += 8;
ENDYUV2RGBLINE(8, 0)
LOADCHROMA(0);
PUTRGBA(dst_1, py_1, pa_1, 0, 24);
PUTRGBA(dst_2, py_2, pa_2, 0, 24);
LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_1, 1, 24);
- PUTRGBA(dst_1, py_1, pa_2, 1, 24);
- pa_1 += 4; \
- pa_2 += 4; \
+ PUTRGBA(dst_2, py_2, pa_2, 1, 24);
+ PUTRGBA(dst_1, py_1, pa_1, 1, 24);
+ pa_1 += 4;
+ pa_2 += 4;
ENDYUV2RGBLINE(8, 1)
LOADCHROMA(0);
PUTRGBA(dst_1, py_1, pa_1, 0, 24);
@@ -310,8 +303,8 @@ YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
LOADCHROMA(3);
PUTRGBA(dst_2, py_2, pa_2, 3, 0);
PUTRGBA(dst_1, py_1, pa_1, 3, 0);
- pa_1 += 8; \
- pa_2 += 8; \
+ pa_1 += 8;
+ pa_2 += 8;
ENDYUV2RGBLINE(8, 0)
LOADCHROMA(0);
PUTRGBA(dst_1, py_1, pa_1, 0, 0);
@@ -320,8 +313,8 @@ ENDYUV2RGBLINE(8, 0)
LOADCHROMA(1);
PUTRGBA(dst_2, py_2, pa_2, 1, 0);
PUTRGBA(dst_1, py_1, pa_1, 1, 0);
- pa_1 += 4; \
- pa_2 += 4; \
+ pa_1 += 4;
+ pa_2 += 4;
ENDYUV2RGBLINE(8, 1)
LOADCHROMA(0);
PUTRGBA(dst_1, py_1, pa_1, 0, 0);
@@ -390,9 +383,9 @@ ENDYUV2RGBLINE(24, 1)
ENDYUV2RGBFUNC()
YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_2x2_8[y & 1];
- const uint8_t *e16 = dither_2x2_4[y & 1];
- const uint8_t *f16 = dither_2x2_8[(y & 1)^1];
+ const uint8_t *d16 = ff_dither_2x2_8[y & 1];
+ const uint8_t *e16 = ff_dither_2x2_4[y & 1];
+ const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1];
#define PUTRGB16(dst, src, i, o) \
Y = src[2 * i]; \
@@ -421,8 +414,8 @@ YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
CLOSEYUV2RGBFUNC(8)
YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_2x2_8[y & 1];
- const uint8_t *e16 = dither_2x2_8[(y & 1)^1];
+ const uint8_t *d16 = ff_dither_2x2_8[y & 1];
+ const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1];
#define PUTRGB15(dst, src, i, o) \
Y = src[2 * i]; \
@@ -452,7 +445,7 @@ CLOSEYUV2RGBFUNC(8)
// r, g, b, dst_1, dst_2
YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_4x4_16[y & 3];
+ const uint8_t *d16 = ff_dither_4x4_16[y & 3];
#define PUTRGB12(dst, src, i, o) \
Y = src[2 * i]; \
@@ -483,8 +476,8 @@ CLOSEYUV2RGBFUNC(8)
// r, g, b, dst_1, dst_2
YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
- const uint8_t *d32 = dither_8x8_32[y & 7];
- const uint8_t *d64 = dither_8x8_73[y & 7];
+ const uint8_t *d32 = ff_dither_8x8_32[y & 7];
+ const uint8_t *d64 = ff_dither_8x8_73[y & 7];
#define PUTRGB8(dst, src, i, o) \
Y = src[2 * i]; \
@@ -514,8 +507,8 @@ YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
CLOSEYUV2RGBFUNC(8)
YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
- const uint8_t * d64 = dither_8x8_73[y & 7];
- const uint8_t *d128 = dither_8x8_220[y & 7];
+ const uint8_t * d64 = ff_dither_8x8_73[y & 7];
+ const uint8_t *d128 = ff_dither_8x8_220[y & 7];
int acc;
#define PUTRGB4D(dst, src, i, o) \
@@ -547,8 +540,8 @@ YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
CLOSEYUV2RGBFUNC(4)
YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
- const uint8_t *d64 = dither_8x8_73[y & 7];
- const uint8_t *d128 = dither_8x8_220[y & 7];
+ const uint8_t *d64 = ff_dither_8x8_73[y & 7];
+ const uint8_t *d128 = ff_dither_8x8_220[y & 7];
#define PUTRGB4DB(dst, src, i, o) \
Y = src[2 * i]; \
@@ -578,7 +571,7 @@ YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
CLOSEYUV2RGBFUNC(8)
YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
- const uint8_t *d128 = dither_8x8_220[y & 7];
+ const uint8_t *d128 = ff_dither_8x8_220[y & 7];
char out_1 = 0, out_2 = 0;
g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
@@ -608,14 +601,14 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
{
SwsFunc t = NULL;
- if (HAVE_MMX)
- t = ff_yuv2rgb_init_mmx(c);
- else if (HAVE_VIS)
+ if (ARCH_BFIN)
+ t = ff_yuv2rgb_init_bfin(c);
+ if (ARCH_PPC)
+ t = ff_yuv2rgb_init_ppc(c);
+ if (HAVE_VIS)
t = ff_yuv2rgb_init_vis(c);
- else if (HAVE_ALTIVEC)
- t = ff_yuv2rgb_init_altivec(c);
- else if (ARCH_BFIN)
- t = ff_yuv2rgb_get_func_ptr_bfin(c);
+ if (ARCH_X86)
+ t = ff_yuv2rgb_init_x86(c);
if (t)
return t;
@@ -775,12 +768,12 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
//scale coefficients by cy
- crv = ((crv << 16) + 0x8000) / cy;
- cbu = ((cbu << 16) + 0x8000) / cy;
- cgu = ((cgu << 16) + 0x8000) / cy;
- cgv = ((cgv << 16) + 0x8000) / cy;
+ crv = ((crv << 16) + 0x8000) / FFMAX(cy, 1);
+ cbu = ((cbu << 16) + 0x8000) / FFMAX(cy, 1);
+ cgu = ((cgu << 16) + 0x8000) / FFMAX(cy, 1);
+ cgv = ((cgv << 16) + 0x8000) / FFMAX(cy, 1);
- av_free(c->yuvTable);
+ av_freep(&c->yuvTable);
switch (bpp) {
case 1:
@@ -893,6 +886,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
fill_gv_table(c->table_gV, 1, cgv);
break;
case 32:
+ case 64:
base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
rbase = base + (isRgb ? 16 : 0);
@@ -918,7 +912,6 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
fill_gv_table(c->table_gV, 4, cgv);
break;
default:
- c->yuvTable = NULL;
if(!isPlanar(c->dstFormat) || bpp <= 24)
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;