Originally committed as revision 9417 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
Michael Niedermayer authored on 2003/02/14 04:27:17... | ... |
@@ -132,6 +132,8 @@ untested special converters |
132 | 132 |
#define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) |
133 | 133 |
|
134 | 134 |
extern int verbose; // defined in mplayer.c |
135 |
+extern const int32_t Inverse_Table_6_9[8][4]; |
|
136 |
+ |
|
135 | 137 |
/* |
136 | 138 |
NOTES |
137 | 139 |
Special versions: fast Y 1:1 scaling (no interpolation in y direction) |
... | ... |
@@ -1960,6 +1962,50 @@ static void getSubSampleFactors(int *h, int *v, int format){ |
1960 | 1960 |
} |
1961 | 1961 |
} |
1962 | 1962 |
|
1963 |
+static uint16_t roundToInt16(float f){ |
|
1964 |
+ if(f<-0x7FFF) f= -0x7FFF; |
|
1965 |
+ else if(f> 0x7FFF) f= 0x7FFF; |
|
1966 |
+ |
|
1967 |
+ return (int)floor(f + 0.5); |
|
1968 |
+} |
|
1969 |
+ |
|
1970 |
+/** |
|
1971 |
+ * @param colorspace colorspace |
|
1972 |
+ * @param fullRange if 1 then the luma range is 0..255 if 0 its 16..235 |
|
1973 |
+ */ |
|
1974 |
+void setInputColorspaceDetails(SwsContext *c, int colorspace, int fullRange, float brightness, float contrast, float saturation){ |
|
1975 |
+ |
|
1976 |
+ float crv = Inverse_Table_6_9[colorspace][0]/65536.0; |
|
1977 |
+ float cbu = Inverse_Table_6_9[colorspace][1]/65536.0; |
|
1978 |
+ float cgu = -Inverse_Table_6_9[colorspace][2]/65536.0; |
|
1979 |
+ float cgv = -Inverse_Table_6_9[colorspace][3]/65536.0; |
|
1980 |
+ float cy = 1.0; |
|
1981 |
+ float oy = 0; |
|
1982 |
+ |
|
1983 |
+ c->uOffset= 0x0400040004000400LL; |
|
1984 |
+ c->vOffset= 0x0400040004000400LL; |
|
1985 |
+ |
|
1986 |
+ if(!fullRange){ |
|
1987 |
+ cy= (cy*255.0) / 219.0; |
|
1988 |
+ oy= 16.0; |
|
1989 |
+ } |
|
1990 |
+ |
|
1991 |
+ cy *= contrast; |
|
1992 |
+ crv*= contrast * saturation; |
|
1993 |
+ cbu*= contrast * saturation; |
|
1994 |
+ cgu*= contrast * saturation; |
|
1995 |
+ cgv*= contrast * saturation; |
|
1996 |
+ |
|
1997 |
+ oy -= 256.0*brightness; |
|
1998 |
+ |
|
1999 |
+ c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL; |
|
2000 |
+ c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL; |
|
2001 |
+ c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL; |
|
2002 |
+ c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL; |
|
2003 |
+ c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL; |
|
2004 |
+ c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL; |
|
2005 |
+} |
|
2006 |
+ |
|
1963 | 2007 |
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, |
1964 | 2008 |
SwsFilter *srcFilter, SwsFilter *dstFilter){ |
1965 | 2009 |
|
... | ... |
@@ -2019,15 +2065,8 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, |
2019 | 2019 |
c->dstFormat= dstFormat; |
2020 | 2020 |
c->srcFormat= srcFormat; |
2021 | 2021 |
|
2022 |
- c->yCoeff= 0x2568256825682568LL; |
|
2023 |
- c->vrCoeff= 0x3343334333433343LL; |
|
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 |
- |
|
2022 |
+ setInputColorspaceDetails(c, SWS_CS_DEFAULT, 0, 0.0, 1.0, 1.0); |
|
2023 |
+ |
|
2031 | 2024 |
usesFilter=0; |
2032 | 2025 |
if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1; |
2033 | 2026 |
if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesFilter=1; |
... | ... |
@@ -2678,4 +2717,3 @@ void freeSwsContext(SwsContext *c){ |
2678 | 2678 |
free(c); |
2679 | 2679 |
} |
2680 | 2680 |
|
2681 |
- |
... | ... |
@@ -48,6 +48,14 @@ |
48 | 48 |
|
49 | 49 |
#define SWS_MAX_REDUCE_CUTOFF 0.002 |
50 | 50 |
|
51 |
+#define SWS_CS_ITU709 1 |
|
52 |
+#define SWS_CS_FCC 4 |
|
53 |
+#define SWS_CS_ITU601 5 |
|
54 |
+#define SWS_CS_ITU624 5 |
|
55 |
+#define SWS_CS_SMPTE170M 5 |
|
56 |
+#define SWS_CS_SMPTE240M 7 |
|
57 |
+#define SWS_CS_DEFAULT 5 |
|
58 |
+ |
|
51 | 59 |
/* this struct should be aligned on at least 32-byte boundary */ |
52 | 60 |
typedef struct SwsContext{ |
53 | 61 |
int srcW, srcH, dstH; |