Mercurial > libavcodec.hg
comparison libpostproc/postprocess.c @ 181:edc5f6cf1855 libavcodec
customizeable deblocking (2 thresholds)
chrominance & luminance filtering is the default now if -npp ...:y isnt specified (lumi only was only used for the deinterlacers and that was wrong anyway)
| author | michael |
|---|---|
| date | Fri, 28 Dec 2001 00:09:55 +0000 |
| parents | fc656a23b35a |
| children | 3ccd74a91074 |
comparison
equal
deleted
inserted
replaced
| 180:fc656a23b35a | 181:edc5f6cf1855 |
|---|---|
| 123 static uint64_t __attribute__((aligned(8))) b04= 0x0404040404040404LL; | 123 static uint64_t __attribute__((aligned(8))) b04= 0x0404040404040404LL; |
| 124 static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL; | 124 static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL; |
| 125 static uint64_t __attribute__((aligned(8))) bFF= 0xFFFFFFFFFFFFFFFFLL; | 125 static uint64_t __attribute__((aligned(8))) bFF= 0xFFFFFFFFFFFFFFFFLL; |
| 126 static uint64_t __attribute__((aligned(8))) b20= 0x2020202020202020LL; | 126 static uint64_t __attribute__((aligned(8))) b20= 0x2020202020202020LL; |
| 127 static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL; | 127 static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL; |
| 128 static uint64_t __attribute__((aligned(8))) b7E= 0x7E7E7E7E7E7E7E7ELL; | 128 static uint64_t __attribute__((aligned(8))) mmxDCOffset= 0x7E7E7E7E7E7E7E7ELL; |
| 129 static uint64_t __attribute__((aligned(8))) b7C= 0x7C7C7C7C7C7C7C7CLL; | 129 static uint64_t __attribute__((aligned(8))) mmxDCThreshold= 0x7C7C7C7C7C7C7C7CLL; |
| 130 static uint64_t __attribute__((aligned(8))) b3F= 0x3F3F3F3F3F3F3F3FLL; | 130 static uint64_t __attribute__((aligned(8))) b3F= 0x3F3F3F3F3F3F3F3FLL; |
| 131 static uint64_t __attribute__((aligned(8))) temp0=0; | 131 static uint64_t __attribute__((aligned(8))) temp0=0; |
| 132 static uint64_t __attribute__((aligned(8))) temp1=0; | 132 static uint64_t __attribute__((aligned(8))) temp1=0; |
| 133 static uint64_t __attribute__((aligned(8))) temp2=0; | 133 static uint64_t __attribute__((aligned(8))) temp2=0; |
| 134 static uint64_t __attribute__((aligned(8))) temp3=0; | 134 static uint64_t __attribute__((aligned(8))) temp3=0; |
| 151 | 151 |
| 152 int hFlatnessThreshold= 56 - 16; | 152 int hFlatnessThreshold= 56 - 16; |
| 153 int vFlatnessThreshold= 56 - 16; | 153 int vFlatnessThreshold= 56 - 16; |
| 154 int deringThreshold= 20; | 154 int deringThreshold= 20; |
| 155 | 155 |
| 156 static int dcOffset= 1; | |
| 157 static int dcThreshold= 3; | |
| 158 | |
| 156 //amount of "black" u r willing to loose to get a brightness corrected picture | 159 //amount of "black" u r willing to loose to get a brightness corrected picture |
| 157 double maxClippedThreshold= 0.01; | 160 double maxClippedThreshold= 0.01; |
| 158 | 161 |
| 159 int maxAllowedY=234; | 162 int maxAllowedY=234; |
| 160 int minAllowedY=16; | 163 int minAllowedY=16; |
| 167 {"vr", "rkvdeblock", 1, 2, 4, V_RK1_FILTER}, | 170 {"vr", "rkvdeblock", 1, 2, 4, V_RK1_FILTER}, |
| 168 {"h1", "x1hdeblock", 1, 1, 3, H_X1_FILTER}, | 171 {"h1", "x1hdeblock", 1, 1, 3, H_X1_FILTER}, |
| 169 {"v1", "x1vdeblock", 1, 2, 4, V_X1_FILTER}, | 172 {"v1", "x1vdeblock", 1, 2, 4, V_X1_FILTER}, |
| 170 {"dr", "dering", 1, 5, 6, DERING}, | 173 {"dr", "dering", 1, 5, 6, DERING}, |
| 171 {"al", "autolevels", 0, 1, 2, LEVEL_FIX}, | 174 {"al", "autolevels", 0, 1, 2, LEVEL_FIX}, |
| 172 {"lb", "linblenddeint", 0, 1, 6, LINEAR_BLEND_DEINT_FILTER}, | 175 {"lb", "linblenddeint", 1, 1, 4, LINEAR_BLEND_DEINT_FILTER}, |
| 173 {"li", "linipoldeint", 0, 1, 6, LINEAR_IPOL_DEINT_FILTER}, | 176 {"li", "linipoldeint", 1, 1, 4, LINEAR_IPOL_DEINT_FILTER}, |
| 174 {"ci", "cubicipoldeint", 0, 1, 6, CUBIC_IPOL_DEINT_FILTER}, | 177 {"ci", "cubicipoldeint", 1, 1, 4, CUBIC_IPOL_DEINT_FILTER}, |
| 175 {"md", "mediandeint", 0, 1, 6, MEDIAN_DEINT_FILTER}, | 178 {"md", "mediandeint", 1, 1, 4, MEDIAN_DEINT_FILTER}, |
| 176 {"tn", "tmpnoise", 1, 7, 8, TEMP_NOISE_FILTER}, | 179 {"tn", "tmpnoise", 1, 7, 8, TEMP_NOISE_FILTER}, |
| 177 {NULL, NULL,0,0,0,0} //End Marker | 180 {NULL, NULL,0,0,0,0} //End Marker |
| 178 }; | 181 }; |
| 179 | 182 |
| 180 static char *replaceTable[]= | 183 static char *replaceTable[]= |
| 191 { | 194 { |
| 192 if( | 195 if( |
| 193 packedYOffset + packedYScale + w05 + w20 + w1400 + bm00000001 + bm00010000 | 196 packedYOffset + packedYScale + w05 + w20 + w1400 + bm00000001 + bm00010000 |
| 194 + bm00001000 + bm10000000 + bm10000001 + bm11000011 + bm00000011 + bm11111110 | 197 + bm00001000 + bm10000000 + bm10000001 + bm11000011 + bm00000011 + bm11111110 |
| 195 + bm11000000 + bm00011000 + bm00110011 + bm11001100 + b00 + b01 + b02 + b0F | 198 + bm11000000 + bm00011000 + bm00110011 + bm11001100 + b00 + b01 + b02 + b0F |
| 196 + bFF + b20 + b04+ b08 + pQPb2 + b80 + b7E + b7C + b3F + temp0 + temp1 + temp2 + temp3 + temp4 | 199 + bFF + b20 + b04+ b08 + pQPb2 + b80 + mmxDCOffset + mmxDCThreshold + b3F + temp0 + temp1 + temp2 + temp3 + temp4 |
| 197 + temp5 + pQPb== 0) b00=0; | 200 + temp5 + pQPb== 0) b00=0; |
| 198 } | 201 } |
| 199 #endif | 202 #endif |
| 200 | 203 |
| 201 #ifdef TIMING | 204 #ifdef TIMING |
| 249 { | 252 { |
| 250 int numEq= 0; | 253 int numEq= 0; |
| 251 int y; | 254 int y; |
| 252 for(y=0; y<BLOCK_SIZE; y++) | 255 for(y=0; y<BLOCK_SIZE; y++) |
| 253 { | 256 { |
| 254 if(((src[0] - src[1] + 1) & 0xFFFF) < 3) numEq++; | 257 if(((src[0] - src[1] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 255 if(((src[1] - src[2] + 1) & 0xFFFF) < 3) numEq++; | 258 if(((src[1] - src[2] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 256 if(((src[2] - src[3] + 1) & 0xFFFF) < 3) numEq++; | 259 if(((src[2] - src[3] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 257 if(((src[3] - src[4] + 1) & 0xFFFF) < 3) numEq++; | 260 if(((src[3] - src[4] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 258 if(((src[4] - src[5] + 1) & 0xFFFF) < 3) numEq++; | 261 if(((src[4] - src[5] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 259 if(((src[5] - src[6] + 1) & 0xFFFF) < 3) numEq++; | 262 if(((src[5] - src[6] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 260 if(((src[6] - src[7] + 1) & 0xFFFF) < 3) numEq++; | 263 if(((src[6] - src[7] + dcOffset) & 0xFFFF) < dcThreshold) numEq++; |
| 261 src+= stride; | 264 src+= stride; |
| 262 } | 265 } |
| 263 return numEq > hFlatnessThreshold; | 266 return numEq > hFlatnessThreshold; |
| 264 } | 267 } |
| 265 | 268 |
| 537 Filters Options | 540 Filters Options |
| 538 short long name short long option Description | 541 short long name short long option Description |
| 539 * * a autoq cpu power dependant enabler | 542 * * a autoq cpu power dependant enabler |
| 540 c chrom chrominance filtring enabled | 543 c chrom chrominance filtring enabled |
| 541 y nochrom chrominance filtring disabled | 544 y nochrom chrominance filtring disabled |
| 542 hb hdeblock horizontal deblocking filter | 545 hb hdeblock (2 Threshold) horizontal deblocking filter |
| 543 vb vdeblock vertical deblocking filter | 546 1. Threshold: default is 1, higher means stronger deblocking |
| 547 2. Threshold: default is 40, lower means stronger deblocking | |
| 548 the horizontal & vertical deblocking filters share these | |
| 549 so u cant set different thresholds for h / v | |
| 550 vb vdeblock (2 Threshold) vertical deblocking filter | |
| 544 hr rkhdeblock | 551 hr rkhdeblock |
| 545 vr rkvdeblock | 552 vr rkvdeblock |
| 546 h1 x1hdeblock Experimental horizontal deblock filter 1 | 553 h1 x1hdeblock Experimental horizontal deblock filter 1 |
| 547 v1 x1vdeblock Experimental vertical deblock filter 1 | 554 v1 x1vdeblock Experimental vertical deblock filter 1 |
| 548 dr dering not implemented yet | 555 dr dering not implemented yet |
| 553 ci cubicipoldeint cubic interpolating deinterlacer | 560 ci cubicipoldeint cubic interpolating deinterlacer |
| 554 md mediandeint median deinterlacer | 561 md mediandeint median deinterlacer |
| 555 de default hdeblock:a,vdeblock:a,dering:a,autolevels | 562 de default hdeblock:a,vdeblock:a,dering:a,autolevels |
| 556 fa fast x1hdeblock:a,x1vdeblock:a,dering:a,autolevels | 563 fa fast x1hdeblock:a,x1vdeblock:a,dering:a,autolevels |
| 557 tn tmpnoise (3 Thresholds) Temporal Noise Reducer | 564 tn tmpnoise (3 Thresholds) Temporal Noise Reducer |
| 565 1. <= 2. <= 3. Threshold, larger means stronger filtering | |
| 558 */ | 566 */ |
| 559 | 567 |
| 560 /** | 568 /** |
| 561 * returns a PPMode struct which will have a non 0 error variable if an error occured | 569 * returns a PPMode struct which will have a non 0 error variable if an error occured |
| 562 * name is the string after "-pp" on the command line | 570 * name is the string after "-pp" on the command line |
| 689 { | 697 { |
| 690 numOfNoises++; | 698 numOfNoises++; |
| 691 numOfUnknownOptions--; | 699 numOfUnknownOptions--; |
| 692 if(numOfNoises >= 3) break; | 700 if(numOfNoises >= 3) break; |
| 693 } | 701 } |
| 702 } | |
| 703 } | |
| 704 else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK) | |
| 705 { | |
| 706 int o; | |
| 707 | |
| 708 for(o=0; options[o]!=NULL && o<2; o++) | |
| 709 { | |
| 710 char *tail; | |
| 711 int val= strtol(options[o], &tail, 0); | |
| 712 if(tail==options[o]) break; | |
| 713 | |
| 714 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 } | |
| 725 else hFlatnessThreshold= | |
| 726 vFlatnessThreshold= val; | |
| 694 } | 727 } |
| 695 } | 728 } |
| 696 } | 729 } |
| 697 } | 730 } |
| 698 if(!filterNameOk) ppMode.error++; | 731 if(!filterNameOk) ppMode.error++; |
