summaryrefslogtreecommitdiffstats
path: root/postproc
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-02-13 19:27:17 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-02-13 19:27:17 +0000
commit0e7b470b4eb969cfa20897ce6a3d95f128210431 (patch)
tree7c7a69f45c3d85f5e02a84da3bff269ebab803c8 /postproc
parent4c6a9664f43ebebaff5cb905c9eb9b33654fe45d (diff)
downloadmpv-0e7b470b4eb969cfa20897ce6a3d95f128210431.tar.bz2
mpv-0e7b470b4eb969cfa20897ce6a3d95f128210431.tar.xz
brightness / saturation / contrast / different yuv colorspace support for some yuv2rgb converters (many converters still ignore it)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9417 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'postproc')
-rw-r--r--postproc/swscale.c58
-rw-r--r--postproc/swscale.h8
2 files changed, 56 insertions, 10 deletions
diff --git a/postproc/swscale.c b/postproc/swscale.c
index 044085b9d1..05655c3ccd 100644
--- a/postproc/swscale.c
+++ b/postproc/swscale.c
@@ -132,6 +132,8 @@ untested special converters
#define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
extern int verbose; // defined in mplayer.c
+extern const int32_t Inverse_Table_6_9[8][4];
+
/*
NOTES
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){
}
}
+static uint16_t roundToInt16(float f){
+ if(f<-0x7FFF) f= -0x7FFF;
+ else if(f> 0x7FFF) f= 0x7FFF;
+
+ return (int)floor(f + 0.5);
+}
+
+/**
+ * @param colorspace colorspace
+ * @param fullRange if 1 then the luma range is 0..255 if 0 its 16..235
+ */
+void setInputColorspaceDetails(SwsContext *c, int colorspace, int fullRange, float brightness, float contrast, float saturation){
+
+ float crv = Inverse_Table_6_9[colorspace][0]/65536.0;
+ float cbu = Inverse_Table_6_9[colorspace][1]/65536.0;
+ float cgu = -Inverse_Table_6_9[colorspace][2]/65536.0;
+ float cgv = -Inverse_Table_6_9[colorspace][3]/65536.0;
+ float cy = 1.0;
+ float oy = 0;
+
+ c->uOffset= 0x0400040004000400LL;
+ c->vOffset= 0x0400040004000400LL;
+
+ if(!fullRange){
+ cy= (cy*255.0) / 219.0;
+ oy= 16.0;
+ }
+
+ cy *= contrast;
+ crv*= contrast * saturation;
+ cbu*= contrast * saturation;
+ cgu*= contrast * saturation;
+ cgv*= contrast * saturation;
+
+ oy -= 256.0*brightness;
+
+ c->yCoeff= roundToInt16(cy *8192) * 0x0001000100010001ULL;
+ c->vrCoeff= roundToInt16(crv*8192) * 0x0001000100010001ULL;
+ c->ubCoeff= roundToInt16(cbu*8192) * 0x0001000100010001ULL;
+ c->vgCoeff= roundToInt16(cgv*8192) * 0x0001000100010001ULL;
+ c->ugCoeff= roundToInt16(cgu*8192) * 0x0001000100010001ULL;
+ c->yOffset= roundToInt16(oy * 8) * 0x0001000100010001ULL;
+}
+
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter){
@@ -2019,15 +2065,8 @@ SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH,
c->dstFormat= dstFormat;
c->srcFormat= srcFormat;
- c->yCoeff= 0x2568256825682568LL;
- c->vrCoeff= 0x3343334333433343LL;
- c->ubCoeff= 0x40cf40cf40cf40cfLL;
- c->vgCoeff= 0xE5E2E5E2E5E2E5E2LL;
- c->ugCoeff= 0xF36EF36EF36EF36ELL;
- c->yOffset= 0x0080008000800080LL;
- c->uOffset= 0x0400040004000400LL;
- c->vOffset= 0x0400040004000400LL;
-
+ setInputColorspaceDetails(c, SWS_CS_DEFAULT, 0, 0.0, 1.0, 1.0);
+
usesFilter=0;
if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1;
if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesFilter=1;
@@ -2678,4 +2717,3 @@ void freeSwsContext(SwsContext *c){
free(c);
}
-
diff --git a/postproc/swscale.h b/postproc/swscale.h
index 1e98919d12..fd1539b1e6 100644
--- a/postproc/swscale.h
+++ b/postproc/swscale.h
@@ -48,6 +48,14 @@
#define SWS_MAX_REDUCE_CUTOFF 0.002
+#define SWS_CS_ITU709 1
+#define SWS_CS_FCC 4
+#define SWS_CS_ITU601 5
+#define SWS_CS_ITU624 5
+#define SWS_CS_SMPTE170M 5
+#define SWS_CS_SMPTE240M 7
+#define SWS_CS_DEFAULT 5
+
/* this struct should be aligned on at least 32-byte boundary */
typedef struct SwsContext{
int srcW, srcH, dstH;