46 { 117504, 138453, 13954, 34903 },
47 { 117504, 138453, 13954, 34903 },
48 { 104597, 132201, 25675, 53279 },
49 { 104597, 132201, 25675, 53279 },
50 { 104448, 132798, 24759, 53109 },
51 { 104597, 132201, 25675, 53279 },
52 { 104597, 132201, 25675, 53279 },
53 { 117579, 136230, 16907, 35559 }
58 if (colorspace > 7 || colorspace < 0)
63 #define LOADCHROMA(i) \ 66 r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \ 67 g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \ 68 b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM]; 70 #define PUTRGB(dst, src, i) \ 72 dst[2 * i] = r[Y] + g[Y] + b[Y]; \ 74 dst[2 * i + 1] = r[Y] + g[Y] + b[Y]; 76 #define PUTRGB24(dst, src, i) \ 78 dst[6 * i + 0] = r[Y]; \ 79 dst[6 * i + 1] = g[Y]; \ 80 dst[6 * i + 2] = b[Y]; \ 82 dst[6 * i + 3] = r[Y]; \ 83 dst[6 * i + 4] = g[Y]; \ 84 dst[6 * i + 5] = b[Y]; 86 #define PUTBGR24(dst, src, i) \ 88 dst[6 * i + 0] = b[Y]; \ 89 dst[6 * i + 1] = g[Y]; \ 90 dst[6 * i + 2] = r[Y]; \ 92 dst[6 * i + 3] = b[Y]; \ 93 dst[6 * i + 4] = g[Y]; \ 94 dst[6 * i + 5] = r[Y]; 96 #define PUTRGBA(dst, ysrc, asrc, i, s) \ 98 dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \ 99 Y = ysrc[2 * i + 1]; \ 100 dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s); 102 #define PUTRGB48(dst, src, i) \ 104 dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \ 105 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ 106 dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \ 107 Y = src[ 2 * i + 1]; \ 108 dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \ 109 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ 110 dst[12 * i + 10] = dst[12 * i + 11] = b[Y]; 112 #define PUTBGR48(dst, src, i) \ 114 dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \ 115 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ 116 dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \ 117 Y = src[2 * i + 1]; \ 118 dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \ 119 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ 120 dst[12 * i + 10] = dst[12 * i + 11] = r[Y]; 122 #define YUV2RGBFUNC(func_name, dst_type, alpha) \ 123 static int func_name(SwsContext *c, const uint8_t *src[], \ 124 int srcStride[], int srcSliceY, int srcSliceH, \ 125 uint8_t *dst[], int dstStride[]) \ 129 if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \ 133 for (y = 0; y < srcSliceH; y += 2) { \ 135 (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \ 137 (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \ 138 dst_type av_unused *r, *g, *b; \ 139 const uint8_t *py_1 = src[0] + y * srcStride[0]; \ 140 const uint8_t *py_2 = py_1 + srcStride[0]; \ 141 const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \ 142 const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \ 143 const uint8_t av_unused *pa_1, *pa_2; \ 144 unsigned int h_size = c->dstW >> 3; \ 146 pa_1 = src[3] + y * srcStride[3]; \ 147 pa_2 = pa_1 + srcStride[3]; \ 150 int av_unused U, V, Y; \ 152 #define ENDYUV2RGBLINE(dst_delta, ss) \ 157 dst_1 += dst_delta >> ss; \ 158 dst_2 += dst_delta >> ss; \ 160 if (c->dstW & (4 >> ss)) { \ 161 int av_unused Y, U, V; \ 163 #define ENDYUV2RGBFUNC() \ 169 #define CLOSEYUV2RGBFUNC(dst_delta) \ 170 ENDYUV2RGBLINE(dst_delta, 0) \ 269 PUTRGBA(dst_2, py_2, pa_1, 1, 24);
270 PUTRGBA(dst_1, py_1, pa_2, 1, 24);
273 PUTRGBA(dst_1, py_1, pa_1, 2, 24);
274 PUTRGBA(dst_2, py_2, pa_2, 2, 24);
277 PUTRGBA(dst_2, py_2, pa_1, 3, 24);
278 PUTRGBA(dst_1, py_1, pa_2, 3, 24);
283 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
284 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
287 PUTRGBA(dst_2, py_2, pa_1, 1, 24);
288 PUTRGBA(dst_1, py_1, pa_2, 1, 24);
293 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
294 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
299 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
300 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
303 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
304 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
307 PUTRGBA(dst_1, py_1, pa_1, 2, 0);
308 PUTRGBA(dst_2, py_2, pa_2, 2, 0);
311 PUTRGBA(dst_2, py_2, pa_2, 3, 0);
312 PUTRGBA(dst_1, py_1, pa_1, 3, 0);
317 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
318 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
321 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
322 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
327 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
328 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
392 YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
397 #define PUTRGB16(dst, src, i, o) \ 399 dst[2 * i] = r[Y + d16[0 + o]] + \ 400 g[Y + e16[0 + o]] + \ 402 Y = src[2 * i + 1]; \ 403 dst[2 * i + 1] = r[Y + d16[1 + o]] + \ 404 g[Y + e16[1 + o]] + \ 423 YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
427 #define PUTRGB15(dst, src, i, o) \ 429 dst[2 * i] = r[Y + d16[0 + o]] + \ 430 g[Y + d16[1 + o]] + \ 432 Y = src[2 * i + 1]; \ 433 dst[2 * i + 1] = r[Y + d16[1 + o]] + \ 434 g[Y + d16[0 + o]] + \ 454 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
457 #define PUTRGB12(dst, src, i, o) \ 459 dst[2 * i] = r[Y + d16[0 + o]] + \ 460 g[Y + d16[0 + o]] + \ 462 Y = src[2 * i + 1]; \ 463 dst[2 * i + 1] = r[Y + d16[1 + o]] + \ 464 g[Y + d16[1 + o]] + \ 485 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
489 #define PUTRGB8(dst, src, i, o) \ 491 dst[2 * i] = r[Y + d32[0 + o]] + \ 492 g[Y + d32[0 + o]] + \ 494 Y = src[2 * i + 1]; \ 495 dst[2 * i + 1] = r[Y + d32[1 + o]] + \ 496 g[Y + d32[1 + o]] + \ 501 PUTRGB8(dst_2, py_2, 0, 0 + 8);
504 PUTRGB8(dst_2, py_2, 1, 2 + 8);
509 PUTRGB8(dst_2, py_2, 2, 4 + 8);
512 PUTRGB8(dst_2, py_2, 3, 6 + 8);
516 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
521 #define PUTRGB4D(dst, src, i, o) \ 523 acc = r[Y + d128[0 + o]] + \ 524 g[Y + d64[0 + o]] + \ 525 b[Y + d128[0 + o]]; \ 526 Y = src[2 * i + 1]; \ 527 acc |= (r[Y + d128[1 + o]] + \ 528 g[Y + d64[1 + o]] + \ 529 b[Y + d128[1 + o]]) << 4; \ 549 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
553 #define PUTRGB4DB(dst, src, i, o) \ 555 dst[2 * i] = r[Y + d128[0 + o]] + \ 556 g[Y + d64[0 + o]] + \ 557 b[Y + d128[0 + o]]; \ 558 Y = src[2 * i + 1]; \ 559 dst[2 * i + 1] = r[Y + d128[1 + o]] + \ 560 g[Y + d64[1 + o]] + \ 580 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
585 #define PUTRGB1(out, src, i, o) \ 587 out += out + g[Y + d128[0 + o]]; \ 588 Y = src[2 * i + 1]; \ 589 out += out + g[Y + d128[1 + o]]; 592 PUTRGB1(out_2, py_2, 0, 0 + 8);
594 PUTRGB1(out_2, py_2, 1, 2 + 8);
598 PUTRGB1(out_2, py_2, 2, 4 + 8);
600 PUTRGB1(out_2, py_2, 3, 6 + 8);
624 "No accelerated colorspace conversion found from %s to %s.\n",
627 switch (c->dstFormat) {
630 return yuv2rgb_c_bgr48;
642 return yuv2rgb_c_24_rgb;
644 return yuv2rgb_c_24_bgr;
647 return yuv2rgb_c_16_ordered_dither;
650 return yuv2rgb_c_15_ordered_dither;
653 return yuv2rgb_c_12_ordered_dither;
656 return yuv2rgb_c_8_ordered_dither;
659 return yuv2rgb_c_4_ordered_dither;
662 return yuv2rgb_c_4b_ordered_dither;
664 return yuv2rgb_c_1_ordered_dither;
669 static void fill_table(uint8_t*
table[256 + 2*YUVRGB_TABLE_HEADROOM],
const int elemsize,
670 const int64_t inc,
void *y_tab)
673 uint8_t *y_table = y_tab;
675 y_table -= elemsize * (inc >> 9);
678 int64_t
cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
679 table[
i] = y_table + elemsize * (cb >> 16);
683 static void fill_gv_table(
int table[256 + 2*YUVRGB_TABLE_HEADROOM],
const int elemsize,
const int64_t inc)
686 int off = -(inc >> 9);
689 int64_t
cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
690 table[
i] = elemsize * (off + (cb >> 16));
696 int r = (f + (1 << 15)) >> 16;
707 int fullRange,
int brightness,
708 int contrast,
int saturation)
733 int i, base, rbase, gbase, bbase,
av_uninit(abase), needAlpha;
734 const int yoffs = fullRange ? 384 : 326;
736 int64_t crv = inv_table[0];
737 int64_t cbu = inv_table[1];
738 int64_t cgu = -inv_table[2];
739 int64_t cgv = -inv_table[3];
740 int64_t cy = 1 << 16;
745 cy = (cy * 255) / 219;
748 crv = (crv * 224) / 255;
749 cbu = (cbu * 224) / 255;
750 cgu = (cgu * 224) / 255;
751 cgv = (cgv * 224) / 255;
754 cy = (cy * contrast) >> 16;
755 crv = (crv * contrast * saturation) >> 32;
756 cbu = (cbu * contrast * saturation) >> 32;
757 cgu = (cgu * contrast * saturation) >> 32;
758 cgv = (cgv * contrast * saturation) >> 32;
759 oy -= 256 * brightness;
761 c->uOffset = 0x0400040004000400LL;
762 c->vOffset = 0x0400040004000400LL;
763 c->yCoeff =
roundToInt16(cy * 8192) * 0x0001000100010001ULL;
764 c->vrCoeff =
roundToInt16(crv * 8192) * 0x0001000100010001ULL;
765 c->ubCoeff =
roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
766 c->vgCoeff =
roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
767 c->ugCoeff =
roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
768 c->yOffset =
roundToInt16(oy * 8) * 0x0001000100010001ULL;
778 crv = ((crv << 16) + 0x8000) / cy;
779 cbu = ((cbu << 16) + 0x8000) / cy;
780 cgu = ((cgu << 16) + 0x8000) / cy;
781 cgv = ((cgv << 16) + 0x8000) / cy;
789 yb = -(384 << 16) - oy;
790 for (i = 0; i < 1024 - 110; i++) {
791 y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
799 rbase = isRgb ? 3 : 0;
801 bbase = isRgb ? 0 : 3;
804 yb = -(384 << 16) - oy;
805 for (i = 0; i < 1024 - 110; i++) {
806 int yval = av_clip_uint8((yb + 0x8000) >> 16);
807 y_table[i + 110] = (yval >> 7) << rbase;
808 y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
809 y_table[i + 110 + 2048] = (yval >> 7) << bbase;
818 rbase = isRgb ? 5 : 0;
819 gbase = isRgb ? 2 : 3;
820 bbase = isRgb ? 0 : 6;
823 yb = -(384 << 16) - oy;
824 for (i = 0; i < 1024 - 38; i++) {
825 int yval = av_clip_uint8((yb + 0x8000) >> 16);
826 y_table[i + 16] = ((yval + 18) / 36) << rbase;
827 y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
828 y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
837 rbase = isRgb ? 8 : 0;
839 bbase = isRgb ? 0 : 8;
842 yb = -(384 << 16) - oy;
843 for (i = 0; i < 1024; i++) {
844 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
845 y_table16[
i] = (yval >> 4) << rbase;
846 y_table16[i + 1024] = (yval >> 4) << gbase;
847 y_table16[i + 2048] = (yval >> 4) << bbase;
851 for (i = 0; i < 1024 * 3; i++)
860 rbase = isRgb ? bpp - 5 : 0;
862 bbase = isRgb ? 0 : (bpp - 5);
865 yb = -(384 << 16) - oy;
866 for (i = 0; i < 1024; i++) {
867 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
868 y_table16[
i] = (yval >> 3) << rbase;
869 y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
870 y_table16[i + 2048] = (yval >> 3) << bbase;
874 for (i = 0; i < 1024 * 3; i++)
885 yb = -(384 << 16) - oy;
886 for (i = 0; i < 1024; i++) {
887 y_table[
i] = av_clip_uint8((yb + 0x8000) >> 16);
898 rbase = base + (isRgb ? 16 : 0);
900 bbase = base + (isRgb ? 0 : 16);
903 abase = (base + 24) & 31;
906 yb = -(384 << 16) - oy;
907 for (i = 0; i < 1024; i++) {
908 unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
909 y_table32[
i] = (yval << rbase) +
910 (needAlpha ? 0 : (255
u << abase));
911 y_table32[i + 1024] = yval << gbase;
912 y_table32[i + 2048] = yval << bbase;
const int32_t ff_yuv2rgb_coeffs[8][4]
#define YUVRGB_TABLE_HEADROOM
const uint8_t dither_4x4_16[5][8]
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 ...
av_cold SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
uint8_t * table_bU[256+2 *YUVRGB_TABLE_HEADROOM]
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define PUTRGB15(dst, src, i, o)
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
#define PUTBGR24(dst, src, i)
#define AV_PIX_FMT_RGB444
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)
#define PUTRGB(dst, src, i)
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)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
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)
av_cold SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
enum AVPixelFormat dstFormat
Destination pixel format.
uint8_t * table_gU[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGBA(dst, ysrc, asrc, i, s)
#define AV_PIX_FMT_BGR32_1
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define AV_PIX_FMT_NE(be, le)
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
#define PUTBGR48(dst, src, i)
const uint8_t dither_8x8_73[9][8]
static const struct endianess table[]
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
const uint8_t dither_8x8_32[9][8]
void av_log(void *avcl, int level, const char *fmt,...)
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)
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
int table_gV[256+2 *YUVRGB_TABLE_HEADROOM]
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)
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_BGR555
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
#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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
synthesis window for stochastic i
#define ENDYUV2RGBLINE(dst_delta, ss)
#define AV_PIX_FMT_BGR565
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
#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 CONFIG_SWSCALE_ALPHA
const uint8_t dither_2x2_4[3][8]
#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
const uint8_t dither_8x8_220[9][8]
#define AV_PIX_FMT_RGB565
const uint8_t dither_2x2_8[3][8]
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)