Revision 07f8991b

View differences:

postproc/postprocess.c
47 47

  
48 48
/*
49 49
TODO:
50
remove global/static vars
50 51
reduce the time wasted on the mem transfer
51 52
implement everything in C at least (done at the moment but ...)
52 53
unroll stuff if instructions depend too much on the prior one
......
153 154
int vFlatnessThreshold= 56 - 16;
154 155
int deringThreshold= 20;
155 156

  
156
static int dcOffset= 1;
157
static int dcThreshold= 3;
157
static int dcOffset;
158
static int dcThreshold;
158 159

  
159 160
//amount of "black" u r willing to loose to get a brightness corrected picture
160 161
double maxClippedThreshold= 0.01;
161 162

  
162
int maxAllowedY=234;
163
int minAllowedY=16;
164

  
165 163
static struct PPFilter filters[]=
166 164
{
167 165
	{"hb", "hdeblock", 		1, 1, 3, H_DEBLOCK},
......
672 670
					ppMode.minAllowedY= 16;
673 671
					ppMode.maxAllowedY= 234;
674 672
					for(o=0; options[o]!=NULL; o++)
673
					{
675 674
						if(  !strcmp(options[o],"fullyrange")
676 675
						   ||!strcmp(options[o],"f"))
677 676
						{
......
679 678
							ppMode.maxAllowedY= 255;
680 679
							numOfUnknownOptions--;
681 680
						}
681
					}
682 682
				}
683 683
				else if(filters[i].mask == TEMP_NOISE_FILTER)
684 684
				{
......
704 704
				else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK)
705 705
				{
706 706
					int o;
707
					ppMode.maxDcDiff=1;
708
//					hFlatnessThreshold= 40;
709
//					vFlatnessThreshold= 40;
707 710

  
708 711
					for(o=0; options[o]!=NULL && o<2; o++)
709 712
					{
......
712 715
						if(tail==options[o]) break;
713 716

  
714 717
						numOfUnknownOptions--;
715
						if(o==0)
716
						{
717
							dcOffset= val;
718
							dcThreshold= 2*val+1;
719
							mmxDCOffset= 0x7F - val;
720
							mmxDCThreshold= 0x7F - 2*val - 1;
721
							
722
							mmxDCOffset*= 0x0101010101010101LL;
723
							mmxDCThreshold*= 0x0101010101010101LL;
724
						}  
718
						if(o==0) ppMode.maxDcDiff= val;
725 719
						else hFlatnessThreshold=
726 720
						     vFlatnessThreshold= val;
727 721
					}
......
800 794
	ppMode.maxTmpNoise[0]= 700;
801 795
	ppMode.maxTmpNoise[1]= 1500;
802 796
	ppMode.maxTmpNoise[2]= 3000;
797
	ppMode.maxAllowedY= 234;
798
	ppMode.minAllowedY= 16;
799
	ppMode.maxDcDiff= 1;
803 800

  
804 801
#ifdef HAVE_ODIVX_POSTPROCESS
805 802
// Note: I could make this shit outside of this file, but it would mean one
postproc/postprocess.h
85 85
	int maxAllowedY; // for brihtness correction
86 86

  
87 87
	int maxTmpNoise[3]; // for Temporal Noise Reducing filter (Maximal sum of abs differences)
88
	
89
	int maxDcDiff; // max abs diff between pixels to be considered flat
88 90
};
89 91

  
90 92
struct PPFilter{
postproc/postprocess_template.c
2615 2615
	long long memcpyTime=0, vertTime=0, horizTime=0, sumTime;
2616 2616
	sumTime= rdtsc();
2617 2617
#endif
2618
//mode= 0x7F;
2618

  
2619
	dcOffset= ppMode->maxDcDiff;
2620
	dcThreshold= ppMode->maxDcDiff*2 + 1;
2621

  
2619 2622
#ifdef HAVE_MMX
2620 2623
	maxTmpNoise[0]= ppMode->maxTmpNoise[0];
2621 2624
	maxTmpNoise[1]= ppMode->maxTmpNoise[1];
2622 2625
	maxTmpNoise[2]= ppMode->maxTmpNoise[2];
2626
	
2627
	mmxDCOffset= 0x7F - dcOffset;
2628
	mmxDCThreshold= 0x7F - dcThreshold;
2629

  
2630
	mmxDCOffset*= 0x0101010101010101LL;
2631
	mmxDCThreshold*= 0x0101010101010101LL;
2623 2632
#endif
2624 2633

  
2625 2634
	if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;
......
2662 2671

  
2663 2672
		if(mode & FULL_Y_RANGE)
2664 2673
		{
2665
			maxAllowedY=255;
2666
			minAllowedY=0;
2674
			ppMode->maxAllowedY=255;
2675
			ppMode->minAllowedY=0;
2667 2676
		}
2668 2677
	}
2669 2678

  
......
2703 2712
			clipped-= yHistogram[white];
2704 2713
		}
2705 2714

  
2706
		scale= (double)(maxAllowedY - minAllowedY) / (double)(white-black);
2715
		scale= (double)(ppMode->maxAllowedY - ppMode->minAllowedY) / (double)(white-black);
2707 2716

  
2708 2717
#ifdef HAVE_MMX2
2709 2718
		packedYScale= (uint16_t)(scale*256.0 + 0.5);
2710
		packedYOffset= (((black*packedYScale)>>8) - minAllowedY) & 0xFFFF;
2719
		packedYOffset= (((black*packedYScale)>>8) - ppMode->minAllowedY) & 0xFFFF;
2711 2720
#else
2712 2721
		packedYScale= (uint16_t)(scale*1024.0 + 0.5);
2713
		packedYOffset= (black - minAllowedY) & 0xFFFF;
2722
		packedYOffset= (black - ppMode->minAllowedY) & 0xFFFF;
2714 2723
#endif
2715 2724

  
2716 2725
		packedYOffset|= packedYOffset<<32;

Also available in: Unified diff