Mercurial > mplayer.hg
comparison libswscale/swscale_template.c @ 27158:65b8334df960
spelling/grammar/wording overhaul
author | diego |
---|---|
date | Fri, 04 Jul 2008 13:49:45 +0000 |
parents | f910db69b343 |
children | f7b6d1014b6b |
comparison
equal
deleted
inserted
replaced
27157:e2797c291ba9 | 27158:65b8334df960 |
---|---|
15 * | 15 * |
16 * You should have received a copy of the GNU General Public License | 16 * You should have received a copy of the GNU General Public License |
17 * along with FFmpeg; if not, write to the Free Software | 17 * along with FFmpeg; if not, write to the Free Software |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 * | 19 * |
20 * the C code (not assembly, mmx, ...) of this file can be used | 20 * The C code (not assembly, MMX, ...) of this file can be used |
21 * under the LGPL license too | 21 * under the LGPL license. |
22 */ | 22 */ |
23 | 23 |
24 #undef REAL_MOVNTQ | 24 #undef REAL_MOVNTQ |
25 #undef MOVNTQ | 25 #undef MOVNTQ |
26 #undef PAVGB | 26 #undef PAVGB |
28 #undef PREFETCHW | 28 #undef PREFETCHW |
29 #undef EMMS | 29 #undef EMMS |
30 #undef SFENCE | 30 #undef SFENCE |
31 | 31 |
32 #ifdef HAVE_3DNOW | 32 #ifdef HAVE_3DNOW |
33 /* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */ | 33 /* On K6 femms is faster than emms. On K7 femms is directly mapped on emms. */ |
34 #define EMMS "femms" | 34 #define EMMS "femms" |
35 #else | 35 #else |
36 #define EMMS "emms" | 36 #define EMMS "emms" |
37 #endif | 37 #endif |
38 | 38 |
1501 uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y) | 1501 uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y) |
1502 { | 1502 { |
1503 const int yalpha1=0; | 1503 const int yalpha1=0; |
1504 int i; | 1504 int i; |
1505 | 1505 |
1506 uint16_t *buf1= buf0; //FIXME needed for the rgb1/bgr1 | 1506 uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 |
1507 const int yalpha= 4096; //FIXME ... | 1507 const int yalpha= 4096; //FIXME ... |
1508 | 1508 |
1509 if (flags&SWS_FULL_CHR_H_INT) | 1509 if (flags&SWS_FULL_CHR_H_INT) |
1510 { | 1510 { |
1511 RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y); | 1511 RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y); |
1698 }else{ | 1698 }else{ |
1699 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) | 1699 YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) |
1700 } | 1700 } |
1701 } | 1701 } |
1702 | 1702 |
1703 //FIXME yuy2* can read upto 7 samples to much | 1703 //FIXME yuy2* can read up to 7 samples too much |
1704 | 1704 |
1705 static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width) | 1705 static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width) |
1706 { | 1706 { |
1707 #ifdef HAVE_MMX | 1707 #ifdef HAVE_MMX |
1708 asm volatile( | 1708 asm volatile( |
2295 dstU[i]= p>>8; | 2295 dstU[i]= p>>8; |
2296 dstV[i]= p>>16; | 2296 dstV[i]= p>>16; |
2297 } | 2297 } |
2298 } | 2298 } |
2299 | 2299 |
2300 // Bilinear / Bicubic scaling | 2300 // bilinear / bicubic scaling |
2301 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, | 2301 static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, |
2302 int16_t *filter, int16_t *filterPos, long filterSize) | 2302 int16_t *filter, int16_t *filterPos, long filterSize) |
2303 { | 2303 { |
2304 #ifdef HAVE_MMX | 2304 #ifdef HAVE_MMX |
2305 assert(filterSize % 4 == 0 && filterSize>0); | 2305 assert(filterSize % 4 == 0 && filterSize>0); |
2542 RENAME(palToY)(formatConvBuffer, src, srcW, (uint32_t*)pal); | 2542 RENAME(palToY)(formatConvBuffer, src, srcW, (uint32_t*)pal); |
2543 src= formatConvBuffer; | 2543 src= formatConvBuffer; |
2544 } | 2544 } |
2545 | 2545 |
2546 #ifdef HAVE_MMX | 2546 #ifdef HAVE_MMX |
2547 // use the new MMX scaler if the mmx2 can't be used (it is faster than the x86 ASM one) | 2547 // Use the new MMX scaler if the MMX2 one can't be used (it is faster than the x86 ASM one). |
2548 if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) | 2548 if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
2549 #else | 2549 #else |
2550 if (!(flags&SWS_FAST_BILINEAR)) | 2550 if (!(flags&SWS_FAST_BILINEAR)) |
2551 #endif | 2551 #endif |
2552 { | 2552 { |
2553 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); | 2553 RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); |
2554 } | 2554 } |
2555 else // Fast Bilinear upscale / crap downscale | 2555 else // fast bilinear upscale / crap downscale |
2556 { | 2556 { |
2557 #if defined(ARCH_X86) | 2557 #if defined(ARCH_X86) |
2558 #ifdef HAVE_MMX2 | 2558 #ifdef HAVE_MMX2 |
2559 int i; | 2559 int i; |
2560 #if defined(PIC) | 2560 #if defined(PIC) |
2759 src1= formatConvBuffer; | 2759 src1= formatConvBuffer; |
2760 src2= formatConvBuffer+VOFW; | 2760 src2= formatConvBuffer+VOFW; |
2761 } | 2761 } |
2762 | 2762 |
2763 #ifdef HAVE_MMX | 2763 #ifdef HAVE_MMX |
2764 // use the new MMX scaler if the mmx2 can't be used (it is faster than the x86 ASM one) | 2764 // Use the new MMX scaler if the MMX2 one can't be used (it is faster than the x86 ASM one). |
2765 if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) | 2765 if (!(flags&SWS_FAST_BILINEAR) || (!canMMX2BeUsed)) |
2766 #else | 2766 #else |
2767 if (!(flags&SWS_FAST_BILINEAR)) | 2767 if (!(flags&SWS_FAST_BILINEAR)) |
2768 #endif | 2768 #endif |
2769 { | 2769 { |
2770 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | 2770 RENAME(hScale)(dst , dstWidth, src1, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); |
2771 RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); | 2771 RENAME(hScale)(dst+VOFW, dstWidth, src2, srcW, xInc, hChrFilter, hChrFilterPos, hChrFilterSize); |
2772 } | 2772 } |
2773 else // Fast Bilinear upscale / crap downscale | 2773 else // fast bilinear upscale / crap downscale |
2774 { | 2774 { |
2775 #if defined(ARCH_X86) | 2775 #if defined(ARCH_X86) |
2776 #ifdef HAVE_MMX2 | 2776 #ifdef HAVE_MMX2 |
2777 int i; | 2777 int i; |
2778 #if defined(PIC) | 2778 #if defined(PIC) |
2888 "adc %3, %%"REG_d" \n\t" //xx+= xInc>>8 + carry | 2888 "adc %3, %%"REG_d" \n\t" //xx+= xInc>>8 + carry |
2889 "add $1, %%"REG_a" \n\t" | 2889 "add $1, %%"REG_a" \n\t" |
2890 "cmp %2, %%"REG_a" \n\t" | 2890 "cmp %2, %%"REG_a" \n\t" |
2891 " jb 1b \n\t" | 2891 " jb 1b \n\t" |
2892 | 2892 |
2893 /* GCC-3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, | 2893 /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, |
2894 which is needed to support GCC-4.0 */ | 2894 which is needed to support GCC 4.0. */ |
2895 #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) | 2895 #if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) |
2896 :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), | 2896 :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), |
2897 #else | 2897 #else |
2898 :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), | 2898 :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), |
2899 #endif | 2899 #endif |
2961 const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; | 2961 const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample; |
2962 const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); | 2962 const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); |
2963 int lastDstY; | 2963 int lastDstY; |
2964 uint8_t *pal=NULL; | 2964 uint8_t *pal=NULL; |
2965 | 2965 |
2966 /* vars whch will change and which we need to storw back in the context */ | 2966 /* vars which will change and which we need to store back in the context */ |
2967 int dstY= c->dstY; | 2967 int dstY= c->dstY; |
2968 int lumBufIndex= c->lumBufIndex; | 2968 int lumBufIndex= c->lumBufIndex; |
2969 int chrBufIndex= c->chrBufIndex; | 2969 int chrBufIndex= c->chrBufIndex; |
2970 int lastInLumBuf= c->lastInLumBuf; | 2970 int lastInLumBuf= c->lastInLumBuf; |
2971 int lastInChrBuf= c->lastInChrBuf; | 2971 int lastInChrBuf= c->lastInChrBuf; |
3002 { | 3002 { |
3003 static int firstTime=1; //FIXME move this into the context perhaps | 3003 static int firstTime=1; //FIXME move this into the context perhaps |
3004 if (flags & SWS_PRINT_INFO && firstTime) | 3004 if (flags & SWS_PRINT_INFO && firstTime) |
3005 { | 3005 { |
3006 av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" | 3006 av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" |
3007 " ->cannot do aligned memory acesses anymore\n"); | 3007 " ->cannot do aligned memory accesses anymore\n"); |
3008 firstTime=0; | 3008 firstTime=0; |
3009 } | 3009 } |
3010 } | 3010 } |
3011 | 3011 |
3012 /* Note the user might start scaling the picture in the middle so this will not get executed | 3012 /* Note the user might start scaling the picture in the middle so this |
3013 this is not really intended but works currently, so ppl might do it */ | 3013 will not get executed. This is not really intended but works |
3014 currently, so people might do it. */ | |
3014 if (srcSliceY ==0){ | 3015 if (srcSliceY ==0){ |
3015 lumBufIndex=0; | 3016 lumBufIndex=0; |
3016 chrBufIndex=0; | 3017 chrBufIndex=0; |
3017 dstY=0; | 3018 dstY=0; |
3018 lastInLumBuf= -1; | 3019 lastInLumBuf= -1; |
3180 } | 3181 } |
3181 else if (isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like | 3182 else if (isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like |
3182 { | 3183 { |
3183 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; | 3184 const int chrSkipMask= (1<<c->chrDstVSubSample)-1; |
3184 if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi | 3185 if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi |
3185 if (vLumFilterSize == 1 && vChrFilterSize == 1) // Unscaled YV12 | 3186 if (vLumFilterSize == 1 && vChrFilterSize == 1) // unscaled YV12 |
3186 { | 3187 { |
3187 int16_t *lumBuf = lumPixBuf[0]; | 3188 int16_t *lumBuf = lumPixBuf[0]; |
3188 int16_t *chrBuf= chrPixBuf[0]; | 3189 int16_t *chrBuf= chrPixBuf[0]; |
3189 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW); | 3190 RENAME(yuv2yuv1)(lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW); |
3190 } | 3191 } |
3198 } | 3199 } |
3199 else | 3200 else |
3200 { | 3201 { |
3201 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); | 3202 ASSERT(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); |
3202 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); | 3203 ASSERT(chrSrcPtr + vChrFilterSize - 1 < chrPixBuf + vChrBufSize*2); |
3203 if (vLumFilterSize == 1 && vChrFilterSize == 2) //Unscaled RGB | 3204 if (vLumFilterSize == 1 && vChrFilterSize == 2) //unscaled RGB |
3204 { | 3205 { |
3205 int chrAlpha= vChrFilter[2*dstY+1]; | 3206 int chrAlpha= vChrFilter[2*dstY+1]; |
3206 RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), | 3207 RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1), |
3207 dest, dstW, chrAlpha, dstFormat, flags, dstY); | 3208 dest, dstW, chrAlpha, dstFormat, flags, dstY); |
3208 } | 3209 } |
3209 else if (vLumFilterSize == 2 && vChrFilterSize == 2) //BiLinear Upscale RGB | 3210 else if (vLumFilterSize == 2 && vChrFilterSize == 2) //bilinear upscale RGB |
3210 { | 3211 { |
3211 int lumAlpha= vLumFilter[2*dstY+1]; | 3212 int lumAlpha= vLumFilter[2*dstY+1]; |
3212 int chrAlpha= vChrFilter[2*dstY+1]; | 3213 int chrAlpha= vChrFilter[2*dstY+1]; |
3213 lumMmxFilter[2]= | 3214 lumMmxFilter[2]= |
3214 lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; | 3215 lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; |
3215 chrMmxFilter[2]= | 3216 chrMmxFilter[2]= |
3216 chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; | 3217 chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; |
3217 RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), | 3218 RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1), |
3218 dest, dstW, lumAlpha, chrAlpha, dstY); | 3219 dest, dstW, lumAlpha, chrAlpha, dstY); |
3219 } | 3220 } |
3220 else //General RGB | 3221 else //general RGB |
3221 { | 3222 { |
3222 RENAME(yuv2packedX)(c, | 3223 RENAME(yuv2packedX)(c, |
3223 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, | 3224 vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, |
3224 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, | 3225 vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, |
3225 dest, dstW, dstY); | 3226 dest, dstW, dstY); |