50 { 117504, 138453, 13954, 34903 },
51 { 117504, 138453, 13954, 34903 },
52 { 104597, 132201, 25675, 53279 },
53 { 104597, 132201, 25675, 53279 },
54 { 104448, 132798, 24759, 53109 },
55 { 104597, 132201, 25675, 53279 },
56 { 104597, 132201, 25675, 53279 },
57 { 117579, 136230, 16907, 35559 }
62 if (colorspace > 7 || colorspace < 0)
67 #define LOADCHROMA(i) \ 70 r = (void *)c->table_rV[V]; \ 71 g = (void *)(c->table_gU[U] + c->table_gV[V]); \ 72 b = (void *)c->table_bU[U]; 74 #define PUTRGB(dst, src, i) \ 76 dst[2 * i] = r[Y] + g[Y] + b[Y]; \ 78 dst[2 * i + 1] = r[Y] + g[Y] + b[Y]; 80 #define PUTRGB24(dst, src, i) \ 82 dst[6 * i + 0] = r[Y]; \ 83 dst[6 * i + 1] = g[Y]; \ 84 dst[6 * i + 2] = b[Y]; \ 86 dst[6 * i + 3] = r[Y]; \ 87 dst[6 * i + 4] = g[Y]; \ 88 dst[6 * i + 5] = b[Y]; 90 #define PUTBGR24(dst, src, i) \ 92 dst[6 * i + 0] = b[Y]; \ 93 dst[6 * i + 1] = g[Y]; \ 94 dst[6 * i + 2] = r[Y]; \ 96 dst[6 * i + 3] = b[Y]; \ 97 dst[6 * i + 4] = g[Y]; \ 98 dst[6 * i + 5] = r[Y]; 100 #define PUTRGBA(dst, ysrc, asrc, i, s) \ 102 dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \ 103 Y = ysrc[2 * i + 1]; \ 104 dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s); 106 #define PUTRGB48(dst, src, i) \ 108 dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \ 109 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ 110 dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \ 111 Y = src[ 2 * i + 1]; \ 112 dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \ 113 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ 114 dst[12 * i + 10] = dst[12 * i + 11] = b[Y]; 116 #define PUTBGR48(dst, src, i) \ 118 dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \ 119 dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ 120 dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \ 121 Y = src[2 * i + 1]; \ 122 dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \ 123 dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ 124 dst[12 * i + 10] = dst[12 * i + 11] = r[Y]; 126 #define YUV2RGBFUNC(func_name, dst_type, alpha) \ 127 static int func_name(SwsContext *c, const uint8_t *src[], \ 128 int srcStride[], int srcSliceY, int srcSliceH, \ 129 uint8_t *dst[], int dstStride[]) \ 133 if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \ 137 for (y = 0; y < srcSliceH; y += 2) { \ 139 (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \ 141 (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \ 142 dst_type av_unused *r, *g, *b; \ 143 const uint8_t *py_1 = src[0] + y * srcStride[0]; \ 144 const uint8_t *py_2 = py_1 + srcStride[0]; \ 145 const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \ 146 const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \ 147 const uint8_t av_unused *pa_1, *pa_2; \ 148 unsigned int h_size = c->dstW >> 3; \ 150 pa_1 = src[3] + y * srcStride[3]; \ 151 pa_2 = pa_1 + srcStride[3]; \ 154 int av_unused U, V, Y; \ 156 #define ENDYUV2RGBLINE(dst_delta, ss) \ 161 dst_1 += dst_delta >> ss; \ 162 dst_2 += dst_delta >> ss; \ 164 if (c->dstW & (4 >> ss)) { \ 165 int av_unused Y, U, V; \ 167 #define ENDYUV2RGBFUNC() \ 173 #define CLOSEYUV2RGBFUNC(dst_delta) \ 174 ENDYUV2RGBLINE(dst_delta, 0) \ 273 PUTRGBA(dst_2, py_2, pa_2, 1, 24);
274 PUTRGBA(dst_1, py_1, pa_1, 1, 24);
277 PUTRGBA(dst_1, py_1, pa_1, 2, 24);
278 PUTRGBA(dst_2, py_2, pa_2, 2, 24);
281 PUTRGBA(dst_2, py_2, pa_2, 3, 24);
282 PUTRGBA(dst_1, py_1, pa_1, 3, 24);
287 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
288 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
291 PUTRGBA(dst_2, py_2, pa_2, 1, 24);
292 PUTRGBA(dst_1, py_1, pa_1, 1, 24);
297 PUTRGBA(dst_1, py_1, pa_1, 0, 24);
298 PUTRGBA(dst_2, py_2, pa_2, 0, 24);
303 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
304 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
307 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
308 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
311 PUTRGBA(dst_1, py_1, pa_1, 2, 0);
312 PUTRGBA(dst_2, py_2, pa_2, 2, 0);
315 PUTRGBA(dst_2, py_2, pa_2, 3, 0);
316 PUTRGBA(dst_1, py_1, pa_1, 3, 0);
321 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
322 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
325 PUTRGBA(dst_2, py_2, pa_2, 1, 0);
326 PUTRGBA(dst_1, py_1, pa_1, 1, 0);
331 PUTRGBA(dst_1, py_1, pa_1, 0, 0);
332 PUTRGBA(dst_2, py_2, pa_2, 0, 0);
417 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
420 #define PUTRGB12(dst, src, i, o) \ 422 dst[2 * i] = r[Y + d16[0 + o]] + \ 423 g[Y + d16[0 + o]] + \ 425 Y = src[2 * i + 1]; \ 426 dst[2 * i + 1] = r[Y + d16[1 + o]] + \ 427 g[Y + d16[1 + o]] + \ 448 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
452 #define PUTRGB8(dst, src, i, o) \ 454 dst[2 * i] = r[Y + d32[0 + o]] + \ 455 g[Y + d32[0 + o]] + \ 457 Y = src[2 * i + 1]; \ 458 dst[2 * i + 1] = r[Y + d32[1 + o]] + \ 459 g[Y + d32[1 + o]] + \ 464 PUTRGB8(dst_2, py_2, 0, 0 + 8);
467 PUTRGB8(dst_2, py_2, 1, 2 + 8);
472 PUTRGB8(dst_2, py_2, 2, 4 + 8);
475 PUTRGB8(dst_2, py_2, 3, 6 + 8);
479 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
484 #define PUTRGB4D(dst, src, i, o) \ 486 acc = r[Y + d128[0 + o]] + \ 487 g[Y + d64[0 + o]] + \ 488 b[Y + d128[0 + o]]; \ 489 Y = src[2 * i + 1]; \ 490 acc |= (r[Y + d128[1 + o]] + \ 491 g[Y + d64[1 + o]] + \ 492 b[Y + d128[1 + o]]) << 4; \ 512 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
516 #define PUTRGB4DB(dst, src, i, o) \ 518 dst[2 * i] = r[Y + d128[0 + o]] + \ 519 g[Y + d64[0 + o]] + \ 520 b[Y + d128[0 + o]]; \ 521 Y = src[2 * i + 1]; \ 522 dst[2 * i + 1] = r[Y + d128[1 + o]] + \ 523 g[Y + d64[1 + o]] + \ 543 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
546 g = c->table_gU[128] + c->table_gV[128];
548 #define PUTRGB1(out, src, i, o) \ 550 out += out + g[Y + d128[0 + o]]; \ 551 Y = src[2 * i + 1]; \ 552 out += out + g[Y + d128[1 + o]]; 555 PUTRGB1(out_2, py_2, 0, 0 + 8);
557 PUTRGB1(out_2, py_2, 1, 2 + 8);
561 PUTRGB1(out_2, py_2, 2, 4 + 8);
563 PUTRGB1(out_2, py_2, 3, 6 + 8);
583 "No accelerated colorspace conversion found from %s to %s.\n",
586 switch (c->dstFormat) {
589 return yuv2rgb_c_bgr48;
604 return yuv2rgb_c_24_rgb;
606 return yuv2rgb_c_24_bgr;
614 return yuv2rgb_c_12_ordered_dither;
617 return yuv2rgb_c_8_ordered_dither;
620 return yuv2rgb_c_4_ordered_dither;
623 return yuv2rgb_c_4b_ordered_dither;
625 return yuv2rgb_c_1_ordered_dither;
632 static void fill_table(uint8_t *table[256],
const int elemsize,
633 const int inc,
void *y_tab)
637 uint8_t *y_table = y_tab;
639 y_table -= elemsize * (inc >> 9);
641 for (i = 0; i < 256; i++) {
642 table[i] = y_table + elemsize * (cb >> 16);
647 static void fill_gv_table(
int table[256],
const int elemsize,
const int inc)
651 int off = -(inc >> 9);
653 for (i = 0; i < 256; i++) {
654 table[i] = elemsize * (off + (cb >> 16));
661 int r = (f + (1 << 15)) >> 16;
672 int fullRange,
int brightness,
673 int contrast,
int saturation)
698 int i, base, rbase, gbase, bbase, abase, needAlpha;
699 const int yoffs = fullRange ? 384 : 326;
701 int64_t crv = inv_table[0];
702 int64_t cbu = inv_table[1];
703 int64_t cgu = -inv_table[2];
704 int64_t cgv = -inv_table[3];
705 int64_t cy = 1 << 16;
710 cy = (cy * 255) / 219;
713 crv = (crv * 224) / 255;
714 cbu = (cbu * 224) / 255;
715 cgu = (cgu * 224) / 255;
716 cgv = (cgv * 224) / 255;
719 cy = (cy * contrast) >> 16;
720 crv = (crv * contrast * saturation) >> 32;
721 cbu = (cbu * contrast * saturation) >> 32;
722 cgu = (cgu * contrast * saturation) >> 32;
723 cgv = (cgv * contrast * saturation) >> 32;
724 oy -= 256 * brightness;
726 c->
uOffset = 0x0400040004000400LL;
727 c->
vOffset = 0x0400040004000400LL;
743 crv = ((crv << 16) + 0x8000) / cy;
744 cbu = ((cbu << 16) + 0x8000) / cy;
745 cgu = ((cgu << 16) + 0x8000) / cy;
746 cgv = ((cgv << 16) + 0x8000) / cy;
750 #define ALLOC_YUV_TABLE(x) \ 751 c->yuvTable = av_malloc(x); \ 753 return AVERROR(ENOMEM); 758 yb = -(384 << 16) - oy;
759 for (i = 0; i < 1024 - 110; i++) {
760 y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
768 rbase = isRgb ? 3 : 0;
770 bbase = isRgb ? 0 : 3;
773 yb = -(384 << 16) - oy;
774 for (i = 0; i < 1024 - 110; i++) {
775 int yval = av_clip_uint8((yb + 0x8000) >> 16);
776 y_table[i + 110] = (yval >> 7) << rbase;
777 y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
778 y_table[i + 110 + 2048] = (yval >> 7) << bbase;
787 rbase = isRgb ? 5 : 0;
788 gbase = isRgb ? 2 : 3;
789 bbase = isRgb ? 0 : 6;
792 yb = -(384 << 16) - oy;
793 for (i = 0; i < 1024 - 38; i++) {
794 int yval = av_clip_uint8((yb + 0x8000) >> 16);
795 y_table[i + 16] = ((yval + 18) / 36) << rbase;
796 y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
797 y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
806 rbase = isRgb ? 8 : 0;
808 bbase = isRgb ? 0 : 8;
811 yb = -(384 << 16) - oy;
812 for (i = 0; i < 1024; i++) {
813 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
814 y_table16[i] = (yval >> 4) << rbase;
815 y_table16[i + 1024] = (yval >> 4) << gbase;
816 y_table16[i + 2048] = (yval >> 4) << bbase;
820 for (i = 0; i < 1024 * 3; i++)
829 rbase = isRgb ? bpp - 5 : 0;
831 bbase = isRgb ? 0 : (bpp - 5);
834 yb = -(384 << 16) - oy;
835 for (i = 0; i < 1024; i++) {
836 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
837 y_table16[i] = (yval >> 3) << rbase;
838 y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
839 y_table16[i + 2048] = (yval >> 3) << bbase;
843 for (i = 0; i < 1024 * 3; i++)
854 yb = -(384 << 16) - oy;
855 for (i = 0; i < 1024; i++) {
856 y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
867 rbase = base + (isRgb ? 16 : 0);
869 bbase = base + (isRgb ? 0 : 16);
872 abase = (base + 24) & 31;
875 yb = -(384 << 16) - oy;
876 for (i = 0; i < 1024; i++) {
877 unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
878 y_table32[i] = (yval << rbase) +
879 (needAlpha ? 0 : (255
u << abase));
880 y_table32[i + 1024] = yval << gbase;
881 y_table32[i + 2048] = yval << bbase;
const char * sws_format_name(enum AVPixelFormat format)
const int32_t ff_yuv2rgb_coeffs[8][4]
#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 ...
static void fill_table(uint8_t *table[256], const int elemsize, const int inc, void *y_tab)
av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define ALLOC_YUV_TABLE(x)
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 ...
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)
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
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...
external api for the swscale stuff
enum AVPixelFormat dstFormat
Destination pixel format.
#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
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)
#define PUTBGR48(dst, src, i)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
const uint8_t ff_dither_8x8_32[8][8]
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)
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...
const uint8_t ff_dither_4x4_16[4][8]
#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)
#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_220[8][8]
#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)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
const uint8_t ff_dither_8x8_73[8][8]
#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
#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)
static void fill_gv_table(int table[256], const int elemsize, const int inc)
#define AV_PIX_FMT_RGB32_1
#define AV_PIX_FMT_RGB565
#define PUTRGB24(dst, src, i)