Revision e28630fc libswscale/swscale_template.c

View differences:

libswscale/swscale_template.c
2279 2279
	}
2280 2280
}
2281 2281

  
2282
static inline void RENAME(palToY)(uint8_t *dst, uint8_t *src, int width, uint32_t *pal)
2283
{
2284
	int i;
2285
	for(i=0; i<width; i++)
2286
	{
2287
		int d= src[i];
2288
		int b= pal[d]     &0xFF;
2289
		int g=(pal[d]>>8 )&0xFF;
2290
		int r= pal[d]>>16;
2291

  
2292
		dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
2293
	}
2294
}
2295

  
2296
static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)
2297
{
2298
	int i;
2299
        assert(src1 == src2);
2300
	for(i=0; i<width; i++)
2301
	{
2302
		int d0= src1[2*i  ];
2303
		int d1= src1[2*i+1];
2304
                int p = (pal[d0]&0xFF00FF) + (pal[d1]&0xFF00FF);
2305
                int g = (pal[d0]+pal[d1]-p)>>8;
2306
                int b= p&0x1FF;
2307
                int r= p>>16;
2308

  
2309
		dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128;
2310
		dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128;
2311
	}
2312
}
2313

  
2282 2314
// Bilinear / Bicubic scaling
2283 2315
static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
2284 2316
				  int16_t *filter, int16_t *filterPos, long filterSize)
......
2467 2499
				   int flags, int canMMX2BeUsed, int16_t *hLumFilter,
2468 2500
				   int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode, 
2469 2501
				   int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
2470
				   int32_t *mmx2FilterPos)
2502
				   int32_t *mmx2FilterPos, uint8_t *pal)
2471 2503
{
2472 2504
    if(srcFormat==PIX_FMT_YUYV422 || srcFormat==PIX_FMT_GRAY16BE)
2473 2505
    {
......
2519 2551
	RENAME(rgb15ToY)(formatConvBuffer, src, srcW);
2520 2552
	src= formatConvBuffer;
2521 2553
    }
2554
    else if(srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8)
2555
    {
2556
	RENAME(palToY)(formatConvBuffer, src, srcW, pal);
2557
	src= formatConvBuffer;
2558
    }
2522 2559

  
2523 2560
#ifdef HAVE_MMX
2524 2561
	// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
......
2664 2701
				   int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
2665 2702
				   int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
2666 2703
				   int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
2667
				   int32_t *mmx2FilterPos)
2704
				   int32_t *mmx2FilterPos, uint8_t *pal)
2668 2705
{
2669 2706
    if(srcFormat==PIX_FMT_YUYV422)
2670 2707
    {
......
2730 2767
    {
2731 2768
    	return;
2732 2769
    }
2770
    else if(srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8)
2771
    {
2772
	RENAME(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);
2773
	src1= formatConvBuffer;
2774
	src2= formatConvBuffer+2048;
2775
    }
2733 2776

  
2734 2777
#ifdef HAVE_MMX
2735 2778
	// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
......
2932 2975
	const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
2933 2976
	const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
2934 2977
	int lastDstY;
2978
        uint8_t *pal=NULL;
2935 2979

  
2936 2980
	/* vars whch will change and which we need to storw back in the context */
2937 2981
	int dstY= c->dstY;
......
2941 2985
	int lastInChrBuf= c->lastInChrBuf;
2942 2986
	
2943 2987
	if(isPacked(c->srcFormat)){
2988
                pal= src[1];
2944 2989
		src[0]=
2945 2990
		src[1]=
2946 2991
		src[2]= src[0];
......
3026 3071
				RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
3027 3072
						flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
3028 3073
						funnyYCode, c->srcFormat, formatConvBuffer, 
3029
						c->lumMmx2Filter, c->lumMmx2FilterPos);
3074
						c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
3030 3075
				lastInLumBuf++;
3031 3076
			}
3032 3077
			while(lastInChrBuf < lastChrSrcY)
......
3043 3088
					RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
3044 3089
						flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
3045 3090
						funnyUVCode, c->srcFormat, formatConvBuffer, 
3046
						c->chrMmx2Filter, c->chrMmx2FilterPos);
3091
						c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
3047 3092
				lastInChrBuf++;
3048 3093
			}
3049 3094
			//wrap buf index around to stay inside the ring buffer
......
3068 3113
				RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
3069 3114
						flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
3070 3115
						funnyYCode, c->srcFormat, formatConvBuffer, 
3071
						c->lumMmx2Filter, c->lumMmx2FilterPos);
3116
						c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
3072 3117
				lastInLumBuf++;
3073 3118
			}
3074 3119
			while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
......
3084 3129
					RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
3085 3130
						flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
3086 3131
						funnyUVCode, c->srcFormat, formatConvBuffer, 
3087
						c->chrMmx2Filter, c->chrMmx2FilterPos);
3132
						c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
3088 3133
				lastInChrBuf++;
3089 3134
			}
3090 3135
			//wrap buf index around to stay inside the ring buffer

Also available in: Unified diff