comparison postproc/postprocess.c @ 7963:0a5d69e6f2a2

cleanup
author michael
date Tue, 29 Oct 2002 20:12:24 +0000
parents 78e0f2776da7
children 2648f13b1709
comparison
equal deleted inserted replaced
7962:1d2d47aa8717 7963:0a5d69e6f2a2
45 c = checked against the other implementations (-vo md5) 45 c = checked against the other implementations (-vo md5)
46 */ 46 */
47 47
48 /* 48 /*
49 TODO: 49 TODO:
50 remove global/static vars
51 reduce the time wasted on the mem transfer 50 reduce the time wasted on the mem transfer
52 unroll stuff if instructions depend too much on the prior one 51 unroll stuff if instructions depend too much on the prior one
53 we use 8x8 blocks for the horizontal filters, opendivx seems to use 8x4?
54 move YScale thing to the end instead of fixing QP 52 move YScale thing to the end instead of fixing QP
55 write a faster and higher quality deblocking filter :) 53 write a faster and higher quality deblocking filter :)
56 make the mainloop more flexible (variable number of blocks at once 54 make the mainloop more flexible (variable number of blocks at once
57 (the if/else stuff per block is slowing things down) 55 (the if/else stuff per block is slowing things down)
58 compare the quality & speed of all filters 56 compare the quality & speed of all filters
67 #include "../config.h" 65 #include "../config.h"
68 #include <inttypes.h> 66 #include <inttypes.h>
69 #include <stdio.h> 67 #include <stdio.h>
70 #include <stdlib.h> 68 #include <stdlib.h>
71 #include <string.h> 69 #include <string.h>
72 #include <errno.h>
73 #ifdef HAVE_MALLOC_H 70 #ifdef HAVE_MALLOC_H
74 #include <malloc.h> 71 #include <malloc.h>
75 #endif 72 #endif
76 //#undef HAVE_MMX2 73 //#undef HAVE_MMX2
77 //#define HAVE_3DNOW 74 //#define HAVE_3DNOW
102 static uint64_t __attribute__((aligned(8))) b02= 0x0202020202020202LL; 99 static uint64_t __attribute__((aligned(8))) b02= 0x0202020202020202LL;
103 static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL; 100 static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL;
104 static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL; 101 static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL;
105 #endif 102 #endif
106 103
107 extern int divx_quality; 104 static int verbose= 0;
108 static int firstTime2 = 0; 105
109 106 static const int deringThreshold= 20;
110 extern int verbose;
111
112 int deringThreshold= 20;
113
114 //amount of "black" u r willing to loose to get a brightness corrected picture
115 double maxClippedThreshold= 0.01;
116 107
117 struct PPFilter{ 108 struct PPFilter{
118 char *shortName; 109 char *shortName;
119 char *longName; 110 char *longName;
120 int chromDefault; // is chrominance filtering on by default if this filter is manually activated 111 int chromDefault; // is chrominance filtering on by default if this filter is manually activated
591 { 582 {
592 char temp[GET_MODE_BUFFER_SIZE]; 583 char temp[GET_MODE_BUFFER_SIZE];
593 char *p= temp; 584 char *p= temp;
594 char *filterDelimiters= ",/"; 585 char *filterDelimiters= ",/";
595 char *optionDelimiters= ":"; 586 char *optionDelimiters= ":";
596 struct PPMode ppMode= {0,0,0,0,0,{150,200,400}}; 587 struct PPMode ppMode;
597 char *filterToken; 588 char *filterToken;
598 589
590 ppMode.lumMode= 0;
591 ppMode.chromMode= 0;
592 ppMode.maxTmpNoise[0]= 700;
593 ppMode.maxTmpNoise[1]= 1500;
594 ppMode.maxTmpNoise[2]= 3000;
595 ppMode.maxAllowedY= 234;
596 ppMode.minAllowedY= 16;
597 ppMode.baseDcDiff= 256/4;
598 ppMode.flatnessThreshold=40;
599 ppMode.flatnessThreshold= 56-16; 599 ppMode.flatnessThreshold= 56-16;
600 600 ppMode.maxClippedThreshold= 0.01;
601
601 strncpy(temp, name, GET_MODE_BUFFER_SIZE); 602 strncpy(temp, name, GET_MODE_BUFFER_SIZE);
602 603
603 if(verbose>1) printf("pp: %s\n", name); 604 if(verbose>1) printf("pp: %s\n", name);
604 605
605 for(;;){ 606 for(;;){
703 } 704 }
704 else if(filters[i].mask == TEMP_NOISE_FILTER) 705 else if(filters[i].mask == TEMP_NOISE_FILTER)
705 { 706 {
706 int o; 707 int o;
707 int numOfNoises=0; 708 int numOfNoises=0;
708 ppMode.maxTmpNoise[0]= 150;
709 ppMode.maxTmpNoise[1]= 200;
710 ppMode.maxTmpNoise[2]= 400;
711 709
712 for(o=0; options[o]!=NULL; o++) 710 for(o=0; options[o]!=NULL; o++)
713 { 711 {
714 char *tail; 712 char *tail;
715 ppMode.maxTmpNoise[numOfNoises]= 713 ppMode.maxTmpNoise[numOfNoises]=
723 } 721 }
724 } 722 }
725 else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK) 723 else if(filters[i].mask == V_DEBLOCK || filters[i].mask == H_DEBLOCK)
726 { 724 {
727 int o; 725 int o;
728 ppMode.baseDcDiff=256/4;
729 // hFlatnessThreshold= 40;
730 // vFlatnessThreshold= 40;
731 726
732 for(o=0; options[o]!=NULL && o<2; o++) 727 for(o=0; options[o]!=NULL && o<2; o++)
733 { 728 {
734 char *tail; 729 char *tail;
735 int val= strtol(options[o], &tail, 0); 730 int val= strtol(options[o], &tail, 0);
816 free(c->nonBQPTable); 811 free(c->nonBQPTable);
817 812
818 free(c); 813 free(c);
819 } 814 }
820 815
821 //FIXME move this shit away from here
822 int readPPOpt(void *conf, char *arg)
823 {
824 int val;
825
826 if(arg == NULL)
827 return -2; // ERR_MISSING_PARAM
828 errno = 0;
829 val = (int)strtol(arg,NULL,0);
830 if(errno != 0)
831 return -4; // What about include cfgparser.h and use ERR_* defines */
832 if(val < 0)
833 return -3; // ERR_OUT_OF_RANGE
834
835 divx_quality = val;
836 firstTime2 = 1;
837
838 return 1;
839 }
840
841 void revertPPOpt(void *conf, char* opt)
842 {
843 divx_quality=0;
844 }
845
846
847 void pp_postprocess(uint8_t * src[3], int srcStride[3], 816 void pp_postprocess(uint8_t * src[3], int srcStride[3],
848 uint8_t * dst[3], int dstStride[3], 817 uint8_t * dst[3], int dstStride[3],
849 int width, int height, 818 int width, int height,
850 QP_STORE_T *QP_store, int QPStride, 819 QP_STORE_T *QP_store, int QPStride,
851 PPMode *mode, void *vc, int pict_type) 820 PPMode *mode, void *vc, int pict_type)
887 c->nonBQPTable[y*mbWidth + x]= qscale; 856 c->nonBQPTable[y*mbWidth + x]= qscale;
888 } 857 }
889 } 858 }
890 } 859 }
891 860
892 if(firstTime2 && verbose) 861 if(verbose>2)
893 { 862 {
894 printf("using npp filters 0x%X/0x%X\n", mode->lumMode, mode->chromMode); 863 printf("using npp filters 0x%X/0x%X\n", mode->lumMode, mode->chromMode);
895 firstTime2=0;
896 } 864 }
897 865
898 postProcess(src[0], srcStride[0], dst[0], dstStride[0], 866 postProcess(src[0], srcStride[0], dst[0], dstStride[0],
899 width, height, QP_store, QPStride, 0, mode, c); 867 width, height, QP_store, QPStride, 0, mode, c);
900 868