44 {117504, 138453, 13954, 34903},
45 {117504, 138453, 13954, 34903},
46 {104597, 132201, 25675, 53279},
47 {104597, 132201, 25675, 53279},
48 {104448, 132798, 24759, 53109},
49 {104597, 132201, 25675, 53279},
50 {104597, 132201, 25675, 53279},
51 {117579, 136230, 16907, 35559}
56 if (colorspace > 7 || colorspace < 0)
61 #define LOADCHROMA(i) \
64 r = (void *)c->table_rV[V]; \
65 g = (void *)(c->table_gU[U] + c->table_gV[V]); \
66 b = (void *)c->table_bU[U];
68 #define PUTRGB(dst,src,i) \
70 dst[2*i ] = r[Y] + g[Y] + b[Y]; \
72 dst[2*i+1] = r[Y] + g[Y] + b[Y];
74 #define PUTRGB24(dst,src,i) \
76 dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \
78 dst[6*i+3] = r[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = b[Y];
80 #define PUTBGR24(dst,src,i) \
82 dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \
84 dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y];
86 #define PUTRGBA(dst,ysrc,asrc,i,s) \
88 dst[2*i ] = r[Y] + g[Y] + b[Y] + (asrc[2*i ]<<s); \
90 dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s);
92 #define PUTRGB48(dst,src,i) \
94 dst[12*i+ 0] = dst[12*i+ 1] = r[Y]; \
95 dst[12*i+ 2] = dst[12*i+ 3] = g[Y]; \
96 dst[12*i+ 4] = dst[12*i+ 5] = b[Y]; \
98 dst[12*i+ 6] = dst[12*i+ 7] = r[Y]; \
99 dst[12*i+ 8] = dst[12*i+ 9] = g[Y]; \
100 dst[12*i+10] = dst[12*i+11] = b[Y];
102 #define PUTBGR48(dst,src,i) \
104 dst[12*i+ 0] = dst[12*i+ 1] = b[Y]; \
105 dst[12*i+ 2] = dst[12*i+ 3] = g[Y]; \
106 dst[12*i+ 4] = dst[12*i+ 5] = r[Y]; \
108 dst[12*i+ 6] = dst[12*i+ 7] = b[Y]; \
109 dst[12*i+ 8] = dst[12*i+ 9] = g[Y]; \
110 dst[12*i+10] = dst[12*i+11] = r[Y];
112 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
113 static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, \
114 int srcSliceH, uint8_t* dst[], int dstStride[]) \
118 if (!alpha && c->srcFormat == PIX_FMT_YUV422P) {\
122 for (y=0; y<srcSliceH; y+=2) {\
123 dst_type *dst_1 = (dst_type*)(dst[0] + (y+srcSliceY )*dstStride[0]);\
124 dst_type *dst_2 = (dst_type*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);\
125 dst_type av_unused *r, *b;\
127 const uint8_t *py_1 = src[0] + y*srcStride[0];\
128 const uint8_t *py_2 = py_1 + srcStride[0];\
129 const uint8_t *pu = src[1] + (y>>1)*srcStride[1];\
130 const uint8_t *pv = src[2] + (y>>1)*srcStride[2];\
131 const uint8_t av_unused *pa_1, *pa_2;\
132 unsigned int h_size = c->dstW>>3;\
134 pa_1 = src[3] + y*srcStride[3];\
135 pa_2 = pa_1 + srcStride[3];\
141 #define ENDYUV2RGBLINE(dst_delta)\
150 int av_unused Y, U, V;\
152 #define ENDYUV2RGBFUNC()\
158 #define CLOSEYUV2RGBFUNC(dst_delta)\
159 ENDYUV2RGBLINE(dst_delta)\
370 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
372 #define PUTRGB12(dst,src,i,o) \
374 dst[2*i] = r[Y+d16[0+o]] + g[Y+d16[0+o]] + b[Y+d16[0+o]]; \
376 dst[2*i+1] = r[Y+d16[1+o]] + g[Y+d16[1+o]] + b[Y+d16[1+o]];
396 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
399 #define PUTRGB8(dst,src,i,o) \
401 dst[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \
403 dst[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]];
422 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
427 #define PUTRGB4D(dst,src,i,o) \
429 acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
431 acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4; \
451 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
455 #define PUTRGB4DB(dst,src,i,o) \
457 dst[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
459 dst[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
478 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
483 #define PUTRGB1(out,src,i,o) \
485 out+= out + g[Y+d128[0+o]]; \
487 out+= out + g[Y+d128[1+o]];
526 switch (c->dstFormat) {
556 static void fill_table(uint8_t* table[256],
const int elemsize,
const int inc,
void *y_tab)
560 uint8_t *y_table = y_tab;
562 y_table -= elemsize * (inc >> 9);
564 for (i = 0; i < 256; i++) {
565 table[i] = y_table + elemsize * (cb >> 16);
570 static void fill_gv_table(
int table[256],
const int elemsize,
const int inc)
574 int off = -(inc >> 9);
576 for (i = 0; i < 256; i++) {
577 table[i] = elemsize * (off + (cb >> 16));
584 int r= (f + (1<<15))>>16;
585 if (r<-0x7FFF)
return 0x8000;
586 else if (r> 0x7FFF)
return 0x7FFF;
616 int i, base, rbase, gbase, bbase, abase, needAlpha;
617 const int yoffs = fullRange ? 384 : 326;
619 int64_t crv = inv_table[0];
620 int64_t cbu = inv_table[1];
621 int64_t cgu = -inv_table[2];
622 int64_t cgv = -inv_table[3];
632 crv = (crv*224) / 255;
633 cbu = (cbu*224) / 255;
634 cgu = (cgu*224) / 255;
635 cgv = (cgv*224) / 255;
645 c->
uOffset= 0x0400040004000400LL;
646 c->
vOffset= 0x0400040004000400LL;
662 crv = ((crv << 16) + 0x8000) / cy;
663 cbu = ((cbu << 16) + 0x8000) / cy;
664 cgu = ((cgu << 16) + 0x8000) / cy;
665 cgv = ((cgv << 16) + 0x8000) / cy;
673 yb = -(384<<16) - oy;
674 for (i = 0; i < 1024-110; i++) {
675 y_table[i+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
683 rbase = isRgb ? 3 : 0;
685 bbase = isRgb ? 0 : 3;
688 yb = -(384<<16) - oy;
689 for (i = 0; i < 1024-110; i++) {
690 int yval = av_clip_uint8((yb + 0x8000) >> 16);
691 y_table[i+110 ] = (yval >> 7) << rbase;
692 y_table[i+ 37+1024] = ((yval + 43) / 85) << gbase;
693 y_table[i+110+2048] = (yval >> 7) << bbase;
702 rbase = isRgb ? 5 : 0;
703 gbase = isRgb ? 2 : 3;
704 bbase = isRgb ? 0 : 6;
707 yb = -(384<<16) - oy;
708 for (i = 0; i < 1024-38; i++) {
709 int yval = av_clip_uint8((yb + 0x8000) >> 16);
710 y_table[i+16 ] = ((yval + 18) / 36) << rbase;
711 y_table[i+16+1024] = ((yval + 18) / 36) << gbase;
712 y_table[i+37+2048] = ((yval + 43) / 85) << bbase;
721 rbase = isRgb ? 8 : 0;
723 bbase = isRgb ? 0 : 8;
726 yb = -(384<<16) - oy;
727 for (i = 0; i < 1024; i++) {
728 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
729 y_table16[i ] = (yval >> 4) << rbase;
730 y_table16[i+1024] = (yval >> 4) << gbase;
731 y_table16[i+2048] = (yval >> 4) << bbase;
735 for (i = 0; i < 1024*3; i++)
744 rbase = isRgb ? bpp - 5 : 0;
746 bbase = isRgb ? 0 : (bpp - 5);
749 yb = -(384<<16) - oy;
750 for (i = 0; i < 1024; i++) {
751 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
752 y_table16[i ] = (yval >> 3) << rbase;
753 y_table16[i+1024] = (yval >> (18 - bpp)) << gbase;
754 y_table16[i+2048] = (yval >> 3) << bbase;
758 for (i = 0; i < 1024*3; i++)
769 yb = -(384<<16) - oy;
770 for (i = 0; i < 1024; i++) {
771 y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
781 rbase = base + (isRgb ? 16 : 0);
783 bbase = base + (isRgb ? 0 : 16);
786 abase = (base + 24) & 31;
789 yb = -(384<<16) - oy;
790 for (i = 0; i < 1024; i++) {
791 unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
792 y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255u << abase));
793 y_table32[i+1024] = yval << gbase;
794 y_table32[i+2048] = yval << bbase;
const int32_t ff_yuv2rgb_coeffs[8][4]
#define PIX_FMT_NE(be, le)
#define AV_LOG_WARNING
Something somehow does not look correct.
static void fill_table(uint8_t *table[256], const int elemsize, const int inc, void *y_tab)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define PUTBGR24(dst, src, i)
const uint8_t dither_8x8_32[8][8]
enum PixelFormat srcFormat
Source pixel format.
SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c)
#define PUTRGB(dst, src, i)
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
external api for the swscale stuff
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
const uint8_t dither_8x8_73[8][8]
#define PUTRGBA(dst, ysrc, asrc, i, s)
SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define PUTBGR48(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 big...
void av_log(void *avcl, int level, const char *fmt,...)
const char * sws_format_name(enum PixelFormat format)
#define YUV2RGBFUNC(func_name, dst_type, alpha)
static uint16_t roundToInt16(int64_t f)
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
const uint8_t dither_8x8_220[8][8]
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
#define PUTRGB4D(dst, src, i, o)
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
#define CLOSEYUV2RGBFUNC(dst_delta)
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
#define PUTRGB12(dst, src, i, o)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
packed RGB 8:8:8, 24bpp, BGRBGR...
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
const uint8_t dither_4x4_16[4][8]
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
#define PUTRGB48(dst, src, i)
#define PUTRGB4DB(dst, src, i, o)
#define PUTRGB8(dst, src, i, o)
#define PUTRGB1(out, src, i, o)
static void fill_gv_table(int table[256], const int elemsize, const int inc)
packed RGB 8:8:8, 24bpp, RGBRGB...
SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
enum AVColorSpace colorspace
enum PixelFormat dstFormat
Destination pixel format.
#define ENDYUV2RGBLINE(dst_delta)
#define PUTRGB24(dst, src, i)
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)