comparison postproc/postprocess.c @ 4257:ab189f1f876f

Added reverting support for -pp and -npp options
author albeu
date Sat, 19 Jan 2002 17:01:03 +0000
parents 3cdb86beebce
children aee9c32349a9
comparison
equal deleted inserted replaced
4256:bbaa26821fdf 4257:ab189f1f876f
73 #include "../config.h" 73 #include "../config.h"
74 #include <inttypes.h> 74 #include <inttypes.h>
75 #include <stdio.h> 75 #include <stdio.h>
76 #include <stdlib.h> 76 #include <stdlib.h>
77 #include <string.h> 77 #include <string.h>
78 #include <errno.h>
78 #ifdef HAVE_MALLOC_H 79 #ifdef HAVE_MALLOC_H
79 #include <malloc.h> 80 #include <malloc.h>
80 #endif 81 #endif
81 //#undef HAVE_MMX2 82 //#undef HAVE_MMX2
82 //#define HAVE_3DNOW 83 //#define HAVE_3DNOW
146 #endif 147 #endif
147 148
148 extern int divx_quality; 149 extern int divx_quality;
149 int newPPFlag=0; //is set if -npp is used 150 int newPPFlag=0; //is set if -npp is used
150 struct PPMode gPPMode[GET_PP_QUALITY_MAX+1]; 151 struct PPMode gPPMode[GET_PP_QUALITY_MAX+1];
152 static int firstTime = 0, firstTime2 = 0;
151 153
152 extern int verbose; 154 extern int verbose;
153 155
154 int hFlatnessThreshold= 56 - 16; 156 int hFlatnessThreshold= 56 - 16;
155 int vFlatnessThreshold= 56 - 16; 157 int vFlatnessThreshold= 56 - 16;
757 } 759 }
758 760
759 /** 761 /**
760 * Check and load the -npp part of the cmd line 762 * Check and load the -npp part of the cmd line
761 */ 763 */
762 int readPPOpt(void *conf, char *arg) 764 int readNPPOpt(void *conf, char *arg)
763 { 765 {
764 int quality; 766 int quality;
765 767
766 if(!strcmp("help", arg)) 768 if(!strcmp("help", arg))
767 { 769 {
776 if(gPPMode[quality].error) return -1; 778 if(gPPMode[quality].error) return -1;
777 } 779 }
778 newPPFlag=1; 780 newPPFlag=1;
779 781
780 //divx_quality is passed to postprocess if autoq if off 782 //divx_quality is passed to postprocess if autoq if off
781 divx_quality= GET_PP_QUALITY_MAX; 783 divx_quality= GET_PP_QUALITY_MAX;
784 firstTime = firstTime2 = 1;
782 return 1; 785 return 1;
783 } 786 }
787
788 int readPPOpt(void *conf, char *arg)
789 {
790 int val;
791
792 if(arg == NULL)
793 return -2; // ERR_MISSING_PARAM
794 errno = 0;
795 val = (int)strtol(arg,NULL,0);
796 if(errno != 0)
797 return -4; // What about include cfgparser.h and use ERR_* defines */
798 if(val < 0)
799 return -3; // ERR_OUT_OF_RANGE
800
801 divx_quality = val;
802 firstTime = firstTime2 = 1;
803
804 return 1;
805 }
806
807 void revertPPOpt(void *conf, char* opt)
808 {
809 newPPFlag=0;
810 divx_quality=0;
811 }
812
784 813
785 /** 814 /**
786 * Obsolete, dont use it, use postprocess2() instead 815 * Obsolete, dont use it, use postprocess2() instead
787 * this will check newPPFlag automatically and use postprocess2 if it is set 816 * this will check newPPFlag automatically and use postprocess2 if it is set
788 * mode = quality if newPPFlag 817 * mode = quality if newPPFlag
793 QP_STORE_T *QP_store, int QP_stride, 822 QP_STORE_T *QP_store, int QP_stride,
794 int mode) 823 int mode)
795 { 824 {
796 struct PPMode ppMode; 825 struct PPMode ppMode;
797 static QP_STORE_T zeroArray[2048/8]; 826 static QP_STORE_T zeroArray[2048/8];
798 static int firstTime=1;
799 827
800 if(newPPFlag) 828 if(newPPFlag)
801 { 829 {
802 ppMode= gPPMode[mode]; 830 ppMode= gPPMode[mode];
803 // printf("%d \n",QP_store[5]); 831 // printf("%d \n",QP_store[5]);
880 QP_STORE_T *QP_store, int QP_stride, 908 QP_STORE_T *QP_store, int QP_stride,
881 struct PPMode *mode) 909 struct PPMode *mode)
882 { 910 {
883 911
884 QP_STORE_T quantArray[2048/8]; 912 QP_STORE_T quantArray[2048/8];
885 static int firstTime=1;
886 913
887 if(QP_store==NULL || (mode->lumMode & FORCE_QUANT)) 914 if(QP_store==NULL || (mode->lumMode & FORCE_QUANT))
888 { 915 {
889 int i; 916 int i;
890 QP_store= quantArray; 917 QP_store= quantArray;
893 for(i=0; i<2048/8; i++) quantArray[i]= mode->forcedQuant; 920 for(i=0; i<2048/8; i++) quantArray[i]= mode->forcedQuant;
894 else 921 else
895 for(i=0; i<2048/8; i++) quantArray[i]= 1; 922 for(i=0; i<2048/8; i++) quantArray[i]= 1;
896 } 923 }
897 924
898 if(firstTime && verbose) 925 if(firstTime2 && verbose)
899 { 926 {
900 printf("using npp filters 0x%X/0x%X\n", mode->lumMode, mode->chromMode); 927 printf("using npp filters 0x%X/0x%X\n", mode->lumMode, mode->chromMode);
901 firstTime=0; 928 firstTime2=0;
902 } 929 }
903 930
904 #ifdef HAVE_ODIVX_POSTPROCESS 931 #ifdef HAVE_ODIVX_POSTPROCESS
905 // Note: I could make this shit outside of this file, but it would mean one 932 // Note: I could make this shit outside of this file, but it would mean one
906 // more function call... 933 // more function call...