39 { 117504, 138453, 13954, 34903 },
40 { 117504, 138453, 13954, 34903 },
41 { 104597, 132201, 25675, 53279 },
42 { 104597, 132201, 25675, 53279 },
43 { 104448, 132798, 24759, 53109 },
44 { 104597, 132201, 25675, 53279 },
45 { 104597, 132201, 25675, 53279 },
46 { 117579, 136230, 16907, 35559 }
51 if (colorspace > 7 || colorspace < 0)
56 #define LOADCHROMA(i) \
59 r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \
60 g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \
61 b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM];
63 #define PUTRGB(dst, src, i) \
65 dst[2 * i] = r[Y] + g[Y] + b[Y]; \
67 dst[2 * i + 1] = r[Y] + g[Y] + b[Y];
69 #define PUTRGB24(dst, src, i) \
71 dst[6 * i + 0] = r[Y]; \
72 dst[6 * i + 1] = g[Y]; \
73 dst[6 * i + 2] = b[Y]; \
75 dst[6 * i + 3] = r[Y]; \
76 dst[6 * i + 4] = g[Y]; \
77 dst[6 * i + 5] = b[Y];
79 #define PUTBGR24(dst, src, i) \
81 dst[6 * i + 0] = b[Y]; \
82 dst[6 * i + 1] = g[Y]; \
83 dst[6 * i + 2] = r[Y]; \
85 dst[6 * i + 3] = b[Y]; \
86 dst[6 * i + 4] = g[Y]; \
87 dst[6 * i + 5] = r[Y];
89 #define PUTRGBA(dst, ysrc, asrc, i, s) \
91 dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \
92 Y = ysrc[2 * i + 1]; \
93 dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s);
95 #define PUTRGB48(dst, src, i) \
97 dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \
98 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
99 dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \
100 Y = src[ 2 * i + 1]; \
101 dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \
102 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
103 dst[12 * i + 10] = dst[12 * i + 11] = b[Y];
105 #define PUTBGR48(dst, src, i) \
107 dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \
108 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
109 dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \
110 Y = src[2 * i + 1]; \
111 dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \
112 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
113 dst[12 * i + 10] = dst[12 * i + 11] = r[Y];
115 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
116 static int func_name(SwsContext *c, const uint8_t *src[], \
117 int srcStride[], int srcSliceY, int srcSliceH, \
118 uint8_t *dst[], int dstStride[]) \
122 if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \
126 for (y = 0; y < srcSliceH; y += 2) { \
128 (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \
130 (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \
131 dst_type av_unused *r, *g, *b; \
132 const uint8_t *py_1 = src[0] + y * srcStride[0]; \
133 const uint8_t *py_2 = py_1 + srcStride[0]; \
134 const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \
135 const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \
136 const uint8_t av_unused *pa_1, *pa_2; \
137 unsigned int h_size = c->dstW >> 3; \
139 pa_1 = src[3] + y * srcStride[3]; \
140 pa_2 = pa_1 + srcStride[3]; \
143 int av_unused U, V, Y; \
145 #define ENDYUV2RGBLINE(dst_delta, ss) \
150 dst_1 += dst_delta >> ss; \
151 dst_2 += dst_delta >> ss; \
153 if (c->dstW & (4 >> ss)) { \
154 int av_unused Y, U, V; \
156 #define ENDYUV2RGBFUNC() \
162 #define CLOSEYUV2RGBFUNC(dst_delta) \
163 ENDYUV2RGBLINE(dst_delta, 0) \
262 PUTRGBA(dst_2, py_2, pa_2, 1, 24);
263 PUTRGBA(dst_1, py_1, pa_1, 1, 24);
266 PUTRGBA(dst_1, py_1, pa_1, 2, 24);
267 PUTRGBA(dst_2, py_2, pa_2, 2, 24);
270 PUTRGBA(dst_2, py_2, pa_2, 3, 24);
271 PUTRGBA(dst_1, py_1, pa_1, 3, 24);
276 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
277 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
280 PUTRGBA(dst_2, py_2, pa_2, 1, 24);
281 PUTRGBA(dst_1, py_1, pa_1, 1, 24);
286 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
287 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
292 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
293 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
296 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
297 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
300 PUTRGBA(dst_1, py_1, pa_1, 2, 0);
301 PUTRGBA(dst_2, py_2, pa_2, 2, 0);
304 PUTRGBA(dst_2, py_2, pa_2, 3, 0);
305 PUTRGBA(dst_1, py_1, pa_1, 3, 0);
310 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
311 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
314 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
315 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
320 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
321 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
385 YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
390 #define PUTRGB16(dst, src, i, o) \
392 dst[2 * i] = r[Y + d16[0 + o]] + \
393 g[Y + e16[0 + o]] + \
395 Y = src[2 * i + 1]; \
396 dst[2 * i + 1] = r[Y + d16[1 + o]] + \
397 g[Y + e16[1 + o]] + \
416 YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
420 #define PUTRGB15(dst, src, i, o) \
422 dst[2 * i] = r[Y + d16[0 + o]] + \
423 g[Y + d16[1 + o]] + \
425 Y = src[2 * i + 1]; \
426 dst[2 * i + 1] = r[Y + d16[1 + o]] + \
427 g[Y + d16[0 + o]] + \
447 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
450 #define PUTRGB12(dst, src, i, o) \
452 dst[2 * i] = r[Y + d16[0 + o]] + \
453 g[Y + d16[0 + o]] + \
455 Y = src[2 * i + 1]; \
456 dst[2 * i + 1] = r[Y + d16[1 + o]] + \
457 g[Y + d16[1 + o]] + \
478 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
482 #define PUTRGB8(dst, src, i, o) \
484 dst[2 * i] = r[Y + d32[0 + o]] + \
485 g[Y + d32[0 + o]] + \
487 Y = src[2 * i + 1]; \
488 dst[2 * i + 1] = r[Y + d32[1 + o]] + \
489 g[Y + d32[1 + o]] + \
494 PUTRGB8(dst_2, py_2, 0, 0 + 8);
497 PUTRGB8(dst_2, py_2, 1, 2 + 8);
502 PUTRGB8(dst_2, py_2, 2, 4 + 8);
505 PUTRGB8(dst_2, py_2, 3, 6 + 8);
513 PUTRGB8(dst_2, py_2, 0, 0 + 8);
516 PUTRGB8(dst_2, py_2, 1, 2 + 8);
524 PUTRGB8(dst_2, py_2, 0, 0 + 8);
529 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
534 #define PUTRGB4D(dst, src, i, o) \
536 acc = r[Y + d128[0 + o]] + \
537 g[Y + d64[0 + o]] + \
538 b[Y + d128[0 + o]]; \
539 Y = src[2 * i + 1]; \
540 acc |= (r[Y + d128[1 + o]] + \
541 g[Y + d64[1 + o]] + \
542 b[Y + d128[1 + o]]) << 4; \
582 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
586 #define PUTRGB4DB(dst, src, i, o) \
588 dst[2 * i] = r[Y + d128[0 + o]] + \
589 g[Y + d64[0 + o]] + \
590 b[Y + d128[0 + o]]; \
591 Y = src[2 * i + 1]; \
592 dst[2 * i + 1] = r[Y + d128[1 + o]] + \
593 g[Y + d64[1 + o]] + \
629 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
634 #define PUTRGB1(out, src, i, o) \
636 out += out + g[Y + d128[0 + o]]; \
637 Y = src[2 * i + 1]; \
638 out += out + g[Y + d128[1 + o]];
641 PUTRGB1(out_2, py_2, 0, 0 + 8);
643 PUTRGB1(out_2, py_2, 1, 2 + 8);
647 PUTRGB1(out_2, py_2, 2, 4 + 8);
649 PUTRGB1(out_2, py_2, 3, 6 + 8);
669 "No accelerated colorspace conversion found from %s to %s.\n",
672 switch (c->dstFormat) {
675 return yuv2rgb_c_bgr48;
681 if (CONFIG_SWSCALE_ALPHA &&
isALPHA(c->srcFormat))
685 return (CONFIG_SWSCALE_ALPHA &&
isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32;
687 return yuv2rgb_c_24_rgb;
689 return yuv2rgb_c_24_bgr;
692 return yuv2rgb_c_16_ordered_dither;
695 return yuv2rgb_c_15_ordered_dither;
698 return yuv2rgb_c_12_ordered_dither;
701 return yuv2rgb_c_8_ordered_dither;
704 return yuv2rgb_c_4_ordered_dither;
707 return yuv2rgb_c_4b_ordered_dither;
709 return yuv2rgb_c_1_ordered_dither;
714 static void fill_table(uint8_t*
table[256 + 2*YUVRGB_TABLE_HEADROOM],
const int elemsize,
715 const int64_t inc,
void *y_tab)
718 uint8_t *y_table = y_tab;
720 y_table -= elemsize * (inc >> 9);
723 int64_t
cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc;
724 table[i] = y_table + elemsize * (cb >> 16);
728 static void fill_gv_table(
int table[256 + 2*YUVRGB_TABLE_HEADROOM],
const int elemsize,
const int64_t inc)
731 int off = -(inc >> 9);
734 int64_t
cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc;
735 table[i] = elemsize * (off + (cb >> 16));
741 int r = (f + (1 << 15)) >> 16;
752 int fullRange,
int brightness,
753 int contrast,
int saturation)
778 int i, base, rbase, gbase, bbase,
av_uninit(abase), needAlpha;
779 const int yoffs = fullRange ? 384 : 326;
781 int64_t crv = inv_table[0];
782 int64_t cbu = inv_table[1];
783 int64_t cgu = -inv_table[2];
784 int64_t cgv = -inv_table[3];
785 int64_t cy = 1 << 16;
790 cy = (cy * 255) / 219;
793 crv = (crv * 224) / 255;
794 cbu = (cbu * 224) / 255;
795 cgu = (cgu * 224) / 255;
796 cgv = (cgv * 224) / 255;
799 cy = (cy * contrast) >> 16;
800 crv = (crv * contrast * saturation) >> 32;
801 cbu = (cbu * contrast * saturation) >> 32;
802 cgu = (cgu * contrast * saturation) >> 32;
803 cgv = (cgv * contrast * saturation) >> 32;
804 oy -= 256 * brightness;
806 c->
uOffset = 0x0400040004000400LL;
807 c->
vOffset = 0x0400040004000400LL;
823 crv = ((crv << 16) + 0x8000) /
FFMAX(cy, 1);
824 cbu = ((cbu << 16) + 0x8000) /
FFMAX(cy, 1);
825 cgu = ((cgu << 16) + 0x8000) /
FFMAX(cy, 1);
826 cgv = ((cgv << 16) + 0x8000) /
FFMAX(cy, 1);
830 #define ALLOC_YUV_TABLE(x) \
831 c->yuvTable = av_malloc(x); \
833 return AVERROR(ENOMEM);
838 yb = -(384 << 16) - oy;
839 for (i = 0; i < 1024 - 110; i++) {
840 y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
848 rbase = isRgb ? 3 : 0;
850 bbase = isRgb ? 0 : 3;
853 yb = -(384 << 16) - oy;
854 for (i = 0; i < 1024 - 110; i++) {
855 int yval = av_clip_uint8((yb + 0x8000) >> 16);
856 y_table[i + 110] = (yval >> 7) << rbase;
857 y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
858 y_table[i + 110 + 2048] = (yval >> 7) << bbase;
867 rbase = isRgb ? 5 : 0;
868 gbase = isRgb ? 2 : 3;
869 bbase = isRgb ? 0 : 6;
872 yb = -(384 << 16) - oy;
873 for (i = 0; i < 1024 - 38; i++) {
874 int yval = av_clip_uint8((yb + 0x8000) >> 16);
875 y_table[i + 16] = ((yval + 18) / 36) << rbase;
876 y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
877 y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
886 rbase = isRgb ? 8 : 0;
888 bbase = isRgb ? 0 : 8;
891 yb = -(384 << 16) - oy;
892 for (i = 0; i < 1024; i++) {
893 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
894 y_table16[i] = (yval >> 4) << rbase;
895 y_table16[i + 1024] = (yval >> 4) << gbase;
896 y_table16[i + 2048] = (yval >> 4) << bbase;
900 for (i = 0; i < 1024 * 3; i++)
909 rbase = isRgb ? bpp - 5 : 0;
911 bbase = isRgb ? 0 : (bpp - 5);
914 yb = -(384 << 16) - oy;
915 for (i = 0; i < 1024; i++) {
916 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
917 y_table16[i] = (yval >> 3) << rbase;
918 y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
919 y_table16[i + 2048] = (yval >> 3) << bbase;
923 for (i = 0; i < 1024 * 3; i++)
934 yb = -(384 << 16) - oy;
935 for (i = 0; i < 1024; i++) {
936 y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
948 rbase = base + (isRgb ? 16 : 0);
950 bbase = base + (isRgb ? 0 : 16);
953 abase = (base + 24) & 31;
956 yb = -(384 << 16) - oy;
957 for (i = 0; i < 1024; i++) {
958 unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
959 y_table32[i] = (yval << rbase) +
960 (needAlpha ? 0 : (255
u << abase));
961 y_table32[i + 1024] = yval << gbase;
962 y_table32[i + 2048] = yval << bbase;
const int32_t ff_yuv2rgb_coeffs[8][4]
#define YUVRGB_TABLE_HEADROOM
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
const uint8_t ff_dither_2x2_8[][8]
av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
uint8_t * table_bU[256+2 *YUVRGB_TABLE_HEADROOM]
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define ALLOC_YUV_TABLE(x)
#define PUTRGB15(dst, src, i, o)
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
#define PUTBGR24(dst, src, i)
#define AV_PIX_FMT_RGB444
const uint8_t ff_dither_8x8_220[][8]
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
static void fill_table(uint8_t *table[256+2 *YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc, void *y_tab)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
const uint8_t ff_dither_8x8_32[][8]
#define PUTRGB(dst, src, i)
static double cb(void *priv, double x, double y)
const uint8_t ff_dither_2x2_4[][8]
const uint8_t ff_dither_4x4_16[][8]
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
static void fill_gv_table(int table[256+2 *YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc)
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined ...
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
#define PUTRGB16(dst, src, i, o)
enum AVPixelFormat dstFormat
Destination pixel format.
uint8_t * table_gU[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGBA(dst, ysrc, asrc, i, s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_BGR32_1
#define AV_PIX_FMT_NE(be, le)
#define PUTBGR48(dst, src, i)
static const struct endianess table[]
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define YUV2RGBFUNC(func_name, dst_type, alpha)
static uint16_t roundToInt16(int64_t f)
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
int table_gV[256+2 *YUVRGB_TABLE_HEADROOM]
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t * table_rV[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGB4D(dst, src, i, o)
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
#define AV_PIX_FMT_BGR555
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
#define CLOSEYUV2RGBFUNC(dst_delta)
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
#define PUTRGB12(dst, src, i, o)
const uint8_t ff_dither_8x8_73[][8]
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define ENDYUV2RGBLINE(dst_delta, ss)
#define AV_PIX_FMT_BGR565
av_cold SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
#define PUTRGB48(dst, src, i)
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
#define PUTRGB4DB(dst, src, i, o)
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define PUTRGB8(dst, src, i, o)
#define AV_PIX_FMT_BGR444
enum AVPixelFormat srcFormat
Source pixel format.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
#define AV_PIX_FMT_RGB555
#define PUTRGB1(out, src, i, o)
#define AV_PIX_FMT_RGB32_1
#define AV_PIX_FMT_RGB565
enum AVColorSpace colorspace
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
#define PUTRGB24(dst, src, i)