⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_blit_n.c

📁 MPEG-4编解码的实现(包括MPEG4视音频编解码)
💻 C
📖 第 1 页 / 共 4 页
字号:
		0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000,
		0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000,
		0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000,
		0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000,
		0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000,
		0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000,
		0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000,
		0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000,
		0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000,
		0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000,
		0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000,
		0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000,
		0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000,
		0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000,
		0x001000ff, 0x83000000, 0x001008ff, 0x83200000,
		0x001010ff, 0x83400000, 0x001018ff, 0x83610000,
		0x001020ff, 0x83810000, 0x001029ff, 0x83a10000,
		0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000,
		0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000,
		0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000,
		0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000,
		0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000,
		0x001083ff, 0x94000000, 0x00108bff, 0x94200000,
		0x001094ff, 0x94400000, 0x00109cff, 0x94610000,
		0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000,
		0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000,
		0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000,
		0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000,
		0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000,
		0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000,
		0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000,
		0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000,
		0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000,
		0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000,
		0x001441ff, 0xac000000, 0x00144aff, 0xac200000,
		0x001452ff, 0xac400000, 0x00145aff, 0xac610000,
		0x001462ff, 0xac810000, 0x00146aff, 0xaca10000,
		0x001473ff, 0xacc20000, 0x00147bff, 0xace20000,
		0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000,
		0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000,
		0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000,
		0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000,
		0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000,
		0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000,
		0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000,
		0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000,
		0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000,
		0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000,
		0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000,
		0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000,
		0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000,
		0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000,
		0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000,
		0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000,
		0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000,
		0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000,
		0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000,
		0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000,
		0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000,
		0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000,
		0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000,
		0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000,
		0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000,
		0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000,
		0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000,
		0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000,
		0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000,
		0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000,
		0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000,
		0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000,
		0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000,
		0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000,
		0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000,
		0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000,
		0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000,
		0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000,
		0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
		0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000,
};
static void Blit_RGB565_RGBA8888(SDL_BlitInfo *info)
{
    Blit_RGB565_32(info, RGB565_RGBA8888_LUT);
}

/* Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 */
static const Uint32 RGB565_BGRA8888_LUT[512] = {
		0x00000000, 0x000000ff, 0x08000000, 0x002000ff,
		0x10000000, 0x004000ff, 0x18000000, 0x006100ff,
		0x20000000, 0x008100ff, 0x29000000, 0x00a100ff,
		0x31000000, 0x00c200ff, 0x39000000, 0x00e200ff,
		0x41000000, 0x000008ff, 0x4a000000, 0x002008ff,
		0x52000000, 0x004008ff, 0x5a000000, 0x006108ff,
		0x62000000, 0x008108ff, 0x6a000000, 0x00a108ff,
		0x73000000, 0x00c208ff, 0x7b000000, 0x00e208ff,
		0x83000000, 0x000010ff, 0x8b000000, 0x002010ff,
		0x94000000, 0x004010ff, 0x9c000000, 0x006110ff,
		0xa4000000, 0x008110ff, 0xac000000, 0x00a110ff,
		0xb4000000, 0x00c210ff, 0xbd000000, 0x00e210ff,
		0xc5000000, 0x000018ff, 0xcd000000, 0x002018ff,
		0xd5000000, 0x004018ff, 0xde000000, 0x006118ff,
		0xe6000000, 0x008118ff, 0xee000000, 0x00a118ff,
		0xf6000000, 0x00c218ff, 0xff000000, 0x00e218ff,
		0x00040000, 0x000020ff, 0x08040000, 0x002020ff,
		0x10040000, 0x004020ff, 0x18040000, 0x006120ff,
		0x20040000, 0x008120ff, 0x29040000, 0x00a120ff,
		0x31040000, 0x00c220ff, 0x39040000, 0x00e220ff,
		0x41040000, 0x000029ff, 0x4a040000, 0x002029ff,
		0x52040000, 0x004029ff, 0x5a040000, 0x006129ff,
		0x62040000, 0x008129ff, 0x6a040000, 0x00a129ff,
		0x73040000, 0x00c229ff, 0x7b040000, 0x00e229ff,
		0x83040000, 0x000031ff, 0x8b040000, 0x002031ff,
		0x94040000, 0x004031ff, 0x9c040000, 0x006131ff,
		0xa4040000, 0x008131ff, 0xac040000, 0x00a131ff,
		0xb4040000, 0x00c231ff, 0xbd040000, 0x00e231ff,
		0xc5040000, 0x000039ff, 0xcd040000, 0x002039ff,
		0xd5040000, 0x004039ff, 0xde040000, 0x006139ff,
		0xe6040000, 0x008139ff, 0xee040000, 0x00a139ff,
		0xf6040000, 0x00c239ff, 0xff040000, 0x00e239ff,
		0x00080000, 0x000041ff, 0x08080000, 0x002041ff,
		0x10080000, 0x004041ff, 0x18080000, 0x006141ff,
		0x20080000, 0x008141ff, 0x29080000, 0x00a141ff,
		0x31080000, 0x00c241ff, 0x39080000, 0x00e241ff,
		0x41080000, 0x00004aff, 0x4a080000, 0x00204aff,
		0x52080000, 0x00404aff, 0x5a080000, 0x00614aff,
		0x62080000, 0x00814aff, 0x6a080000, 0x00a14aff,
		0x73080000, 0x00c24aff, 0x7b080000, 0x00e24aff,
		0x83080000, 0x000052ff, 0x8b080000, 0x002052ff,
		0x94080000, 0x004052ff, 0x9c080000, 0x006152ff,
		0xa4080000, 0x008152ff, 0xac080000, 0x00a152ff,
		0xb4080000, 0x00c252ff, 0xbd080000, 0x00e252ff,
		0xc5080000, 0x00005aff, 0xcd080000, 0x00205aff,
		0xd5080000, 0x00405aff, 0xde080000, 0x00615aff,
		0xe6080000, 0x00815aff, 0xee080000, 0x00a15aff,
		0xf6080000, 0x00c25aff, 0xff080000, 0x00e25aff,
		0x000c0000, 0x000062ff, 0x080c0000, 0x002062ff,
		0x100c0000, 0x004062ff, 0x180c0000, 0x006162ff,
		0x200c0000, 0x008162ff, 0x290c0000, 0x00a162ff,
		0x310c0000, 0x00c262ff, 0x390c0000, 0x00e262ff,
		0x410c0000, 0x00006aff, 0x4a0c0000, 0x00206aff,
		0x520c0000, 0x00406aff, 0x5a0c0000, 0x00616aff,
		0x620c0000, 0x00816aff, 0x6a0c0000, 0x00a16aff,
		0x730c0000, 0x00c26aff, 0x7b0c0000, 0x00e26aff,
		0x830c0000, 0x000073ff, 0x8b0c0000, 0x002073ff,
		0x940c0000, 0x004073ff, 0x9c0c0000, 0x006173ff,
		0xa40c0000, 0x008173ff, 0xac0c0000, 0x00a173ff,
		0xb40c0000, 0x00c273ff, 0xbd0c0000, 0x00e273ff,
		0xc50c0000, 0x00007bff, 0xcd0c0000, 0x00207bff,
		0xd50c0000, 0x00407bff, 0xde0c0000, 0x00617bff,
		0xe60c0000, 0x00817bff, 0xee0c0000, 0x00a17bff,
		0xf60c0000, 0x00c27bff, 0xff0c0000, 0x00e27bff,
		0x00100000, 0x000083ff, 0x08100000, 0x002083ff,
		0x10100000, 0x004083ff, 0x18100000, 0x006183ff,
		0x20100000, 0x008183ff, 0x29100000, 0x00a183ff,
		0x31100000, 0x00c283ff, 0x39100000, 0x00e283ff,
		0x41100000, 0x00008bff, 0x4a100000, 0x00208bff,
		0x52100000, 0x00408bff, 0x5a100000, 0x00618bff,
		0x62100000, 0x00818bff, 0x6a100000, 0x00a18bff,
		0x73100000, 0x00c28bff, 0x7b100000, 0x00e28bff,
		0x83100000, 0x000094ff, 0x8b100000, 0x002094ff,
		0x94100000, 0x004094ff, 0x9c100000, 0x006194ff,
		0xa4100000, 0x008194ff, 0xac100000, 0x00a194ff,
		0xb4100000, 0x00c294ff, 0xbd100000, 0x00e294ff,
		0xc5100000, 0x00009cff, 0xcd100000, 0x00209cff,
		0xd5100000, 0x00409cff, 0xde100000, 0x00619cff,
		0xe6100000, 0x00819cff, 0xee100000, 0x00a19cff,
		0xf6100000, 0x00c29cff, 0xff100000, 0x00e29cff,
		0x00140000, 0x0000a4ff, 0x08140000, 0x0020a4ff,
		0x10140000, 0x0040a4ff, 0x18140000, 0x0061a4ff,
		0x20140000, 0x0081a4ff, 0x29140000, 0x00a1a4ff,
		0x31140000, 0x00c2a4ff, 0x39140000, 0x00e2a4ff,
		0x41140000, 0x0000acff, 0x4a140000, 0x0020acff,
		0x52140000, 0x0040acff, 0x5a140000, 0x0061acff,
		0x62140000, 0x0081acff, 0x6a140000, 0x00a1acff,
		0x73140000, 0x00c2acff, 0x7b140000, 0x00e2acff,
		0x83140000, 0x0000b4ff, 0x8b140000, 0x0020b4ff,
		0x94140000, 0x0040b4ff, 0x9c140000, 0x0061b4ff,
		0xa4140000, 0x0081b4ff, 0xac140000, 0x00a1b4ff,
		0xb4140000, 0x00c2b4ff, 0xbd140000, 0x00e2b4ff,
		0xc5140000, 0x0000bdff, 0xcd140000, 0x0020bdff,
		0xd5140000, 0x0040bdff, 0xde140000, 0x0061bdff,
		0xe6140000, 0x0081bdff, 0xee140000, 0x00a1bdff,
		0xf6140000, 0x00c2bdff, 0xff140000, 0x00e2bdff,
		0x00180000, 0x0000c5ff, 0x08180000, 0x0020c5ff,
		0x10180000, 0x0040c5ff, 0x18180000, 0x0061c5ff,
		0x20180000, 0x0081c5ff, 0x29180000, 0x00a1c5ff,
		0x31180000, 0x00c2c5ff, 0x39180000, 0x00e2c5ff,
		0x41180000, 0x0000cdff, 0x4a180000, 0x0020cdff,
		0x52180000, 0x0040cdff, 0x5a180000, 0x0061cdff,
		0x62180000, 0x0081cdff, 0x6a180000, 0x00a1cdff,
		0x73180000, 0x00c2cdff, 0x7b180000, 0x00e2cdff,
		0x83180000, 0x0000d5ff, 0x8b180000, 0x0020d5ff,
		0x94180000, 0x0040d5ff, 0x9c180000, 0x0061d5ff,
		0xa4180000, 0x0081d5ff, 0xac180000, 0x00a1d5ff,
		0xb4180000, 0x00c2d5ff, 0xbd180000, 0x00e2d5ff,
		0xc5180000, 0x0000deff, 0xcd180000, 0x0020deff,
		0xd5180000, 0x0040deff, 0xde180000, 0x0061deff,
		0xe6180000, 0x0081deff, 0xee180000, 0x00a1deff,
		0xf6180000, 0x00c2deff, 0xff180000, 0x00e2deff,
		0x001c0000, 0x0000e6ff, 0x081c0000, 0x0020e6ff,
		0x101c0000, 0x0040e6ff, 0x181c0000, 0x0061e6ff,
		0x201c0000, 0x0081e6ff, 0x291c0000, 0x00a1e6ff,
		0x311c0000, 0x00c2e6ff, 0x391c0000, 0x00e2e6ff,
		0x411c0000, 0x0000eeff, 0x4a1c0000, 0x0020eeff,
		0x521c0000, 0x0040eeff, 0x5a1c0000, 0x0061eeff,
		0x621c0000, 0x0081eeff, 0x6a1c0000, 0x00a1eeff,
		0x731c0000, 0x00c2eeff, 0x7b1c0000, 0x00e2eeff,
		0x831c0000, 0x0000f6ff, 0x8b1c0000, 0x0020f6ff,
		0x941c0000, 0x0040f6ff, 0x9c1c0000, 0x0061f6ff,
		0xa41c0000, 0x0081f6ff, 0xac1c0000, 0x00a1f6ff,
		0xb41c0000, 0x00c2f6ff, 0xbd1c0000, 0x00e2f6ff,
		0xc51c0000, 0x0000ffff, 0xcd1c0000, 0x0020ffff,
		0xd51c0000, 0x0040ffff, 0xde1c0000, 0x0061ffff,
		0xe61c0000, 0x0081ffff, 0xee1c0000, 0x00a1ffff,
		0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff
};
static void Blit_RGB565_BGRA8888(SDL_BlitInfo *info)
{
    Blit_RGB565_32(info, RGB565_BGRA8888_LUT);
}

/* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
#ifndef RGB888_RGB332
#define RGB888_RGB332(dst, src) { \
	dst = (((src)&0x00E00000)>>16)| \
	      (((src)&0x0000E000)>>11)| \
	      (((src)&0x000000C0)>>6); \
}
#endif
static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
{
#ifndef USE_DUFFS_LOOP
	int c;
#endif
	int pixel;
	int width, height;
	Uint32 *src;
	const Uint8 *map;
	Uint8 *dst;
	int srcskip, dstskip;

	/* Set up some basic variables */
	width = info->d_width;
	height = info->d_height;
	src = (Uint32 *)info->s_pixels;
	srcskip = info->s_skip/4;
	dst = info->d_pixels;
	dstskip = info->d_skip;
	map = info->table;

#ifdef USE_DUFFS_LOOP
	while ( height-- ) {
		DUFFS_LOOP(
			RGB888_RGB332(pixel, *src);
			*dst++ = map[pixel];
			++src;
		, width);
		src += srcskip;
		dst += dstskip;
	}
#else
	while ( height-- ) {
		for ( c=width/4; c; --c ) {
			/* Pack RGB into 8bit pixel */
			RGB888_RGB332(pixel, *src);
			*dst++ = map[pixel];
			++src;
			RGB888_RGB332(pixel, *src);
			*dst++ = map[pixel];
			++src;
			RGB888_RGB332(pixel, *src);
			*dst++ = map[pixel];
			++src;
			RGB888_RGB332(pixel, *src);
			*dst++ = map[pixel];
			++src;
		}
		switch ( width & 3 ) {
			case 3:
				RGB888_RGB332(pixel, *src);
				*dst++ = map[pixel];
				++src;
			case 2:
				RGB888_RGB332(pixel, *src);
				*dst++ = map[pixel];
				++src;
			case 1:
				RGB888_RGB332(pixel, *src);
				*dst++ = map[pixel];
				++src;
		}
		src += srcskip;
		dst += dstskip;
	}
#endif /* USE_DUFFS_LOOP */
}
static void BlitNto1(SDL_BlitInfo *info)
{
#ifndef USE_DUFFS_LOOP
	int c;
#endif
	int width, height;
	Uint8 *src;
	const Uint8 *map;
	Uint8 *dst;
	int srcskip, dstskip;
	int srcbpp;
	Uint32 pixel;
	int  sR, sG, sB;
	SDL_PixelFormat *srcfmt;

	/* Set up some basic variables */
	width = info->d_width;
	height = info->d_height;
	src = info->s_pixels;
	srcskip = info->s_skip;
	dst = info->d_pixels;
	dstskip = info->d_skip;
	map = info->table;
	srcfmt = info->src;
	srcbpp = srcfmt->BytesPerPixel;

	if ( map == NULL ) {
		while ( height-- ) {
#ifdef USE_DUFFS_LOOP
			DUFFS_LOOP(
				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
								sR, sG, sB);
				if ( 1 ) {
				  	/* Pack RGB into 8bit pixel */
				  	*dst = ((sR>>5)<<(3+2))|
					        ((sG>>5)<<(2)) |
					        ((sB>>6)<<(0)) ;
				}
				dst++;
				src += srcbpp;
			, width);
#else
			for ( c=width; c; --c ) {
				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
								sR, sG, sB);
				if ( 1 ) {
				  	/* Pack RGB into 8bit pixel */
				  	*dst = ((sR>>5)<<(3+2))|
					        ((sG>>5)<<(2)) |
					        ((sB>>6)<<(0)) ;
				}
				dst++;
				src += srcbpp;
			}
#endif
			src += srcskip;
			dst += dstskip;
		}
	} else {
		while ( height-- ) {
#ifdef USE_DUFFS_LOOP
			DUFFS_LOOP(
				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
								sR, sG, sB);
				if ( 1 ) {
				  	/* Pack RGB into 8bit pixel */
				  	*dst = map[((sR>>5)<<(3+2))|
						   ((sG>>5)<<(2))  |
						   ((sB>>6)<<(0))  ];
				}
				dst++;
				src += srcbpp;
			, width);
#else
			for ( c=width; c; --c ) {
				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
								sR, sG, sB);
				if ( 1 ) {
				  	/* Pack RGB into 8bit pixel */
				  	*dst = map[((sR>>5)<<(3+2))|
						   ((sG>>5)<<(2))  |
						   ((sB>>6)<<(0))  ];
				}
				dst++;
				src += srcbpp;
			}
#endif /* USE_DUFFS_LOOP */
			src += srcskip;
			dst += dstskip;
		}
	}
}
static void BlitNtoN(SDL_BlitInfo *info)
{
	int width = info->d_width;
	int height = info->d_height;
	Uint8 *src = info->s_pixels;
	int srcskip = info->s_skip;
	Uint8 *dst = info->d_pixels;
	int dstskip = info->d_skip;
	SDL_PixelFormat *srcfmt = info->src;
	int srcbpp = srcfmt->BytesPerPixel;
	SDL_PixelFormat *dstfmt = info->dst;
	int dstbpp = dstfmt->BytesPerPixel;
	unsigned alpha = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;

	while ( height-- ) {
		DUFFS_LOOP(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -