Commit 07f8991b authored by Michael Niedermayer's avatar Michael Niedermayer

minor brightness/contrast bugfix / moved some global vars into ppMode

non mmx compilation bugfix

Originally committed as revision 3833 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc
parent 43d52f76
...@@ -47,6 +47,7 @@ c = checked against the other implementations (-vo md5) ...@@ -47,6 +47,7 @@ c = checked against the other implementations (-vo md5)
/* /*
TODO: TODO:
remove global/static vars
reduce the time wasted on the mem transfer reduce the time wasted on the mem transfer
implement everything in C at least (done at the moment but ...) implement everything in C at least (done at the moment but ...)
unroll stuff if instructions depend too much on the prior one unroll stuff if instructions depend too much on the prior one
...@@ -153,15 +154,12 @@ int hFlatnessThreshold= 56 - 16; ...@@ -153,15 +154,12 @@ int hFlatnessThreshold= 56 - 16;
int vFlatnessThreshold= 56 - 16; int vFlatnessThreshold= 56 - 16;
int deringThreshold= 20; int deringThreshold= 20;
static int dcOffset= 1; static int dcOffset;
static int dcThreshold= 3; static int dcThreshold;
//amount of "black" u r willing to loose to get a brightness corrected picture //amount of "black" u r willing to loose to get a brightness corrected picture
double maxClippedThreshold= 0.01; double maxClippedThreshold= 0.01;
int maxAllowedY=234;
int minAllowedY=16;
static struct PPFilter filters[]= static struct PPFilter filters[]=
{ {
{"hb", "hdeblock", 1, 1, 3, H_DEBLOCK}, {"hb", "hdeblock", 1, 1, 3, H_DEBLOCK},
...@@ -672,6 +670,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality) ...@@ -672,6 +670,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality)
ppMode.minAllowedY= 16; ppMode.minAllowedY= 16;
ppMode.maxAllowedY= 234; ppMode.maxAllowedY= 234;
for(o=0; options[o]!=NULL; o++) for(o=0; options[o]!=NULL; o++)
{
if( !strcmp(options[o],"fullyrange") if( !strcmp(options[o],"fullyrange")
||!strcmp(options[o],"f")) ||!strcmp(options[o],"f"))
{ {
...@@ -679,6 +678,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality) ...@@ -679,6 +678,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality)
ppMode.maxAllowedY= 255; ppMode.maxAllowedY= 255;
numOfUnknownOptions--; numOfUnknownOptions--;
} }
}
} }
else if(filters[i].mask == TEMP_NOISE_FILTER) else if(filters[i].mask == TEMP_NOISE_FILTER)
{ {
...@@ -704,6 +704,9 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality) ...@@ -704,6 +704,9 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality)
else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK) else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK)
{ {
int o; int o;
ppMode.maxDcDiff=1;
// hFlatnessThreshold= 40;
// vFlatnessThreshold= 40;
for(o=0; options[o]!=NULL && o<2; o++) for(o=0; options[o]!=NULL && o<2; o++)
{ {
...@@ -712,16 +715,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality) ...@@ -712,16 +715,7 @@ struct PPMode getPPModeByNameAndQuality(char *name, int quality)
if(tail==options[o]) break; if(tail==options[o]) break;
numOfUnknownOptions--; numOfUnknownOptions--;
if(o==0) if(o==0) ppMode.maxDcDiff= val;
{
dcOffset= val;
dcThreshold= 2*val+1;
mmxDCOffset= 0x7F - val;
mmxDCThreshold= 0x7F - 2*val - 1;
mmxDCOffset*= 0x0101010101010101LL;
mmxDCThreshold*= 0x0101010101010101LL;
}
else hFlatnessThreshold= else hFlatnessThreshold=
vFlatnessThreshold= val; vFlatnessThreshold= val;
} }
...@@ -800,6 +794,9 @@ void postprocess(unsigned char * src[], int src_stride, ...@@ -800,6 +794,9 @@ void postprocess(unsigned char * src[], int src_stride,
ppMode.maxTmpNoise[0]= 700; ppMode.maxTmpNoise[0]= 700;
ppMode.maxTmpNoise[1]= 1500; ppMode.maxTmpNoise[1]= 1500;
ppMode.maxTmpNoise[2]= 3000; ppMode.maxTmpNoise[2]= 3000;
ppMode.maxAllowedY= 234;
ppMode.minAllowedY= 16;
ppMode.maxDcDiff= 1;
#ifdef HAVE_ODIVX_POSTPROCESS #ifdef HAVE_ODIVX_POSTPROCESS
// Note: I could make this shit outside of this file, but it would mean one // Note: I could make this shit outside of this file, but it would mean one
......
...@@ -85,6 +85,8 @@ struct PPMode{ ...@@ -85,6 +85,8 @@ struct PPMode{
int maxAllowedY; // for brihtness correction int maxAllowedY; // for brihtness correction
int maxTmpNoise[3]; // for Temporal Noise Reducing filter (Maximal sum of abs differences) int maxTmpNoise[3]; // for Temporal Noise Reducing filter (Maximal sum of abs differences)
int maxDcDiff; // max abs diff between pixels to be considered flat
}; };
struct PPFilter{ struct PPFilter{
......
...@@ -2615,11 +2615,20 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int ...@@ -2615,11 +2615,20 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
long long memcpyTime=0, vertTime=0, horizTime=0, sumTime; long long memcpyTime=0, vertTime=0, horizTime=0, sumTime;
sumTime= rdtsc(); sumTime= rdtsc();
#endif #endif
//mode= 0x7F;
dcOffset= ppMode->maxDcDiff;
dcThreshold= ppMode->maxDcDiff*2 + 1;
#ifdef HAVE_MMX #ifdef HAVE_MMX
maxTmpNoise[0]= ppMode->maxTmpNoise[0]; maxTmpNoise[0]= ppMode->maxTmpNoise[0];
maxTmpNoise[1]= ppMode->maxTmpNoise[1]; maxTmpNoise[1]= ppMode->maxTmpNoise[1];
maxTmpNoise[2]= ppMode->maxTmpNoise[2]; maxTmpNoise[2]= ppMode->maxTmpNoise[2];
mmxDCOffset= 0x7F - dcOffset;
mmxDCThreshold= 0x7F - dcThreshold;
mmxDCOffset*= 0x0101010101010101LL;
mmxDCThreshold*= 0x0101010101010101LL;
#endif #endif
if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16; if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;
...@@ -2662,8 +2671,8 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int ...@@ -2662,8 +2671,8 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
if(mode & FULL_Y_RANGE) if(mode & FULL_Y_RANGE)
{ {
maxAllowedY=255; ppMode->maxAllowedY=255;
minAllowedY=0; ppMode->minAllowedY=0;
} }
} }
...@@ -2703,14 +2712,14 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int ...@@ -2703,14 +2712,14 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
clipped-= yHistogram[white]; clipped-= yHistogram[white];
} }
scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black); scale= (double)(ppMode->maxAllowedY - ppMode->minAllowedY) / (double)(white-black);
#ifdef HAVE_MMX2 #ifdef HAVE_MMX2
packedYScale= (uint16_t)(scale*256.0 + 0.5); packedYScale= (uint16_t)(scale*256.0 + 0.5);
packedYOffset= (((black*packedYScale)>>8) - minAllowedY) & 0xFFFF; packedYOffset= (((black*packedYScale)>>8) - ppMode->minAllowedY) & 0xFFFF;
#else #else
packedYScale= (uint16_t)(scale*1024.0 + 0.5); packedYScale= (uint16_t)(scale*1024.0 + 0.5);
packedYOffset= (black - minAllowedY) & 0xFFFF; packedYOffset= (black - ppMode->minAllowedY) & 0xFFFF;
#endif #endif
packedYOffset|= packedYOffset<<32; packedYOffset|= packedYOffset<<32;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment