comparison libpostproc/postprocess.c @ 179:02b2b7ffe324 libavcodec

new -pp options stuff (-npp ...) see line527@postproc/postprocess.c ;) for the documentation of the format
author michael
date Wed, 26 Dec 2001 19:45:49 +0000
parents fa9734559c98
children fc656a23b35a
comparison
equal deleted inserted replaced
178:374f80a78f0d 179:02b2b7ffe324
141 #else 141 #else
142 static uint64_t packedYOffset= 0x0000000000000000LL; 142 static uint64_t packedYOffset= 0x0000000000000000LL;
143 static uint64_t packedYScale= 0x0100010001000100LL; 143 static uint64_t packedYScale= 0x0100010001000100LL;
144 #endif 144 #endif
145 145
146 extern int divx_quality;
147 int newPPFlag=0; //is set if -npp is used
148 struct PPMode gPPMode[GET_PP_QUALITY_MAX+1];
149
150 extern int verbose;
151
146 int hFlatnessThreshold= 56 - 16; 152 int hFlatnessThreshold= 56 - 16;
147 int vFlatnessThreshold= 56 - 16; 153 int vFlatnessThreshold= 56 - 16;
148 int deringThreshold= 20; 154 int deringThreshold= 20;
149 155
150 //amount of "black" u r willing to loose to get a brightness corrected picture 156 //amount of "black" u r willing to loose to get a brightness corrected picture
563 struct PPMode ppMode= {0,0,0,0,0,0,{150,200,400}}; 569 struct PPMode ppMode= {0,0,0,0,0,0,{150,200,400}};
564 char *filterToken; 570 char *filterToken;
565 571
566 strncpy(temp, name, GET_MODE_BUFFER_SIZE); 572 strncpy(temp, name, GET_MODE_BUFFER_SIZE);
567 573
568 printf("%s\n", name); 574 if(verbose) printf("%s\n", name);
569 575
570 for(;;){ 576 for(;;){
571 char *filterName; 577 char *filterName;
572 int q= 1000000; //GET_PP_QUALITY_MAX; 578 int q= 1000000; //GET_PP_QUALITY_MAX;
573 int chrom=-1; 579 int chrom=-1;
580 586
581 filterToken= strtok(p, filterDelimiters); 587 filterToken= strtok(p, filterDelimiters);
582 if(filterToken == NULL) break; 588 if(filterToken == NULL) break;
583 p+= strlen(filterToken) + 1; // p points to next filterToken 589 p+= strlen(filterToken) + 1; // p points to next filterToken
584 filterName= strtok(filterToken, optionDelimiters); 590 filterName= strtok(filterToken, optionDelimiters);
585 printf("%s::%s\n", filterToken, filterName); 591 if(verbose) printf("%s::%s\n", filterToken, filterName);
586 592
587 if(*filterName == '-') 593 if(*filterName == '-')
588 { 594 {
589 enable=0; 595 enable=0;
590 filterName++; 596 filterName++;
592 598
593 for(;;){ //for all options 599 for(;;){ //for all options
594 option= strtok(NULL, optionDelimiters); 600 option= strtok(NULL, optionDelimiters);
595 if(option == NULL) break; 601 if(option == NULL) break;
596 602
597 printf("%s\n", option); 603 if(verbose) printf(" option: %s\n", option);
598 if(!strcmp("autoq", option) || !strcmp("a", option)) q= quality; 604 if(!strcmp("autoq", option) || !strcmp("a", option)) q= quality;
599 else if(!strcmp("nochrom", option) || !strcmp("y", option)) chrom=0; 605 else if(!strcmp("nochrom", option) || !strcmp("y", option)) chrom=0;
600 else if(!strcmp("chrom", option) || !strcmp("c", option)) chrom=1; 606 else if(!strcmp("chrom", option) || !strcmp("c", option)) chrom=1;
601 else 607 else
602 { 608 {
698 if(ppMode.chromMode & V_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_C_V; 704 if(ppMode.chromMode & V_DEBLOCK) ppMode.oldMode |= PP_DEBLOCK_C_V;
699 if(ppMode.lumMode & DERING) ppMode.oldMode |= PP_DERING_Y; 705 if(ppMode.lumMode & DERING) ppMode.oldMode |= PP_DERING_Y;
700 if(ppMode.chromMode & DERING) ppMode.oldMode |= PP_DERING_C; 706 if(ppMode.chromMode & DERING) ppMode.oldMode |= PP_DERING_C;
701 #endif 707 #endif
702 708
709 if(verbose) printf("lumMode=%X, chromMode=%X\n", ppMode.lumMode, ppMode.chromMode);
703 return ppMode; 710 return ppMode;
711 }
712
713 /**
714 * Check and load the -npp part of the cmd line
715 */
716 int readPPOpt(void *conf, char *arg)
717 {
718 int quality;
719 for(quality=0; quality<GET_PP_QUALITY_MAX+1; quality++)
720 {
721 gPPMode[quality]= getPPModeByNameAndQuality(arg, quality);
722
723 if(gPPMode[quality].error) return -1;
724 }
725 newPPFlag=1;
726
727 // it shouldnt matter what we set divx_quality to as long as its not 0
728 // (we dont use it if newPPFlag is set)
729 divx_quality=1;
730 return 1;
704 } 731 }
705 732
706 /** 733 /**
707 * Obsolete, dont use it, use postprocess2() instead 734 * Obsolete, dont use it, use postprocess2() instead
735 * this will check newPPFlag automatically and use postprocess2 if it is set
736 * mode = quality if newPPFlag
708 */ 737 */
709 void postprocess(unsigned char * src[], int src_stride, 738 void postprocess(unsigned char * src[], int src_stride,
710 unsigned char * dst[], int dst_stride, 739 unsigned char * dst[], int dst_stride,
711 int horizontal_size, int vertical_size, 740 int horizontal_size, int vertical_size,
712 QP_STORE_T *QP_store, int QP_stride, 741 QP_STORE_T *QP_store, int QP_stride,
713 int mode) 742 int mode)
714 { 743 {
715 struct PPMode ppMode; 744 struct PPMode ppMode;
716 static QP_STORE_T zeroArray[2048/8]; 745 static QP_STORE_T zeroArray[2048/8];
717 /* 746
718 static int qual=0; 747 if(newPPFlag)
719 748 {
720 ppMode= getPPModeByNameAndQuality("fast,default,-hdeblock,-vdeblock,tmpnoise:150:200:300", qual); 749 ppMode= gPPMode[mode];
721 printf("OK\n"); 750
722 qual++; 751 postprocess2(src, src_stride, dst, dst_stride,
723 qual%=7; 752 horizontal_size, vertical_size, QP_store, QP_stride, &ppMode);
724 printf("\n%X %X %X %X :%d: %d %d %d\n", ppMode.lumMode, ppMode.chromMode, ppMode.oldMode, ppMode.error, 753
725 qual, ppMode.maxTmpNoise[0], ppMode.maxTmpNoise[1], ppMode.maxTmpNoise[2]); 754 return;
726 postprocess2(src, src_stride, dst, dst_stride, 755 }
727 horizontal_size, vertical_size, QP_store, QP_stride, &ppMode); 756
728
729 return;
730 */
731 if(QP_store==NULL) 757 if(QP_store==NULL)
732 { 758 {
733 QP_store= zeroArray; 759 QP_store= zeroArray;
734 QP_stride= 0; 760 QP_stride= 0;
735 } 761 }
842 } 868 }
843 869
844 870
845 /** 871 /**
846 * gets the mode flags for a given quality (larger values mean slower but better postprocessing) 872 * gets the mode flags for a given quality (larger values mean slower but better postprocessing)
873 * with -npp it simply returns quality
847 * 0 <= quality <= 6 874 * 0 <= quality <= 6
848 */ 875 */
849 int getPpModeForQuality(int quality){ 876 int getPpModeForQuality(int quality){
850 int modes[1+GET_PP_QUALITY_MAX]= { 877 int modes[1+GET_PP_QUALITY_MAX]= {
851 0, 878 0,
878 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y, 905 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y,
879 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y|PP_DERING_C 906 PP_DEBLOCK_Y_H|PP_DEBLOCK_Y_V|PP_DEBLOCK_C_H|PP_DEBLOCK_C_V|PP_DERING_Y|PP_DERING_C
880 }; 907 };
881 if(use_old_pp) return odivx_modes[quality]; 908 if(use_old_pp) return odivx_modes[quality];
882 #endif 909 #endif
883 return modes[quality]; 910 if(newPPFlag) return quality;
884 } 911 else return modes[quality];
885 912 }
886 913
914