Mercurial > mplayer.hg
comparison postproc/swscale.c @ 9416:83fe90af3e16
brightness / saturation / contrast / different yuv colorspace support for some yuv2rgb converters (many converters still ignore it)
author | michael |
---|---|
date | Thu, 13 Feb 2003 19:27:17 +0000 |
parents | 0d86fe21b281 |
children | aab93879d8f8 |
comparison
equal
deleted
inserted
replaced
9415:d6cf3c7c6a4f | 9416:83fe90af3e16 |
---|---|
130 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) | 130 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) |
131 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | 131 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) |
132 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) | 132 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) |
133 | 133 |
134 extern int verbose; // defined in mplayer.c | 134 extern int verbose; // defined in mplayer.c |
135 extern const int32_t Inverse_Table_6_9[8][4]; | |
136 | |
135 /* | 137 /* |
136 NOTES | 138 NOTES |
137 Special versions: fast Y 1:1 scaling (no interpolation in y direction) | 139 Special versions: fast Y 1:1 scaling (no interpolation in y direction) |
138 | 140 |
139 TODO | 141 TODO |
1958 *v=0; | 1960 *v=0; |
1959 break; | 1961 break; |
1960 } | 1962 } |
1961 } | 1963 } |
1962 | 1964 |
1965 static uint16_t roundToInt16(float f){ | |
1966 if(f<-0x7FFF) f= -0x7FFF; | |
1967 else if(f> 0x7FFF) f= 0x7FFF; | |
1968 | |
1969 return (int)floor(f + 0.5); | |
1970 } | |
1971 | |
1972 /** | |
1973 * @param colorspace colorspace | |
1974 * @param fullRange if 1 then the luma range is 0..255 if 0 its 16..235 | |
1975 */ | |
1976 void setInputColorspaceDetails(SwsContext *c, int colorspace, int fullRange, float brightness, float contrast, float saturation){ | |
1977 | |
1978 float crv = Inverse_Table_6_9[colorspace][0]/65536.0; | |
1979 float cbu = Inverse_Table_6_9[colorspace][1]/65536.0; | |
1980 float cgu = -Inverse_Table_6_9[colorspace][2]/65536.0; | |
1981 float cgv = -Inverse_Table_6_9[colorspace][3]/65536.0; | |
1982 float cy = 1.0; | |
1983 float oy = 0; | |
1984 | |
1985 c->uOffset= 0x0400040004000400LL; | |
1986 c->vOffset= 0x0400040004000400LL; | |
1987 | |
1988 if(!fullRange){ | |
1989 cy= (cy*255.0) / 219.0; | |
1990 oy= 16.0; | |
1991 } | |
1992 | |
1993 cy *= contrast; | |
1994 crv*= contrast * saturation; | |
1995 cbu*= contrast * saturation; | |
1996 cgu*= contrast * saturation; | |
1997 cgv*= contrast * saturation; | |
1998 | |
1999 oy -= 256.0*brightness; | |
2000 | |
2001 c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL; | |
2002 c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL; | |
2003 c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL; | |
2004 c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL; | |
2005 c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL; | |
2006 c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL; | |
2007 } | |
2008 | |
1963 SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, | 2009 SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, |
1964 SwsFilter *srcFilter, SwsFilter *dstFilter){ | 2010 SwsFilter *srcFilter, SwsFilter *dstFilter){ |
1965 | 2011 |
1966 SwsContext *c; | 2012 SwsContext *c; |
1967 int i; | 2013 int i; |
2017 c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; | 2063 c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; |
2018 c->flags= flags; | 2064 c->flags= flags; |
2019 c->dstFormat= dstFormat; | 2065 c->dstFormat= dstFormat; |
2020 c->srcFormat= srcFormat; | 2066 c->srcFormat= srcFormat; |
2021 | 2067 |
2022 c->yCoeff= 0x2568256825682568LL; | 2068 setInputColorspaceDetails(c, SWS_CS_DEFAULT, 0, 0.0, 1.0, 1.0); |
2023 c->vrCoeff= 0x3343334333433343LL; | 2069 |
2024 c->ubCoeff= 0x40cf40cf40cf40cfLL; | |
2025 c->vgCoeff= 0xE5E2E5E2E5E2E5E2LL; | |
2026 c->ugCoeff= 0xF36EF36EF36EF36ELL; | |
2027 c->yOffset= 0x0080008000800080LL; | |
2028 c->uOffset= 0x0400040004000400LL; | |
2029 c->vOffset= 0x0400040004000400LL; | |
2030 | |
2031 usesFilter=0; | 2070 usesFilter=0; |
2032 if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1; | 2071 if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1; |
2033 if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesFilter=1; | 2072 if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesFilter=1; |
2034 if(dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesFilter=1; | 2073 if(dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesFilter=1; |
2035 if(dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesFilter=1; | 2074 if(dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesFilter=1; |
2676 c->yuvTable=NULL; | 2715 c->yuvTable=NULL; |
2677 | 2716 |
2678 free(c); | 2717 free(c); |
2679 } | 2718 } |
2680 | 2719 |
2681 |