comparison postprocess.c @ 16:ac05bfe3da66 libpostproc

make postproc use avutil
author lu_zero
date Mon, 02 Oct 2006 10:49:27 +0000
parents e718a1049f9e
children 2cd017ec54f3
comparison
equal deleted inserted replaced
15:ac99241b61c3 16:ac05bfe3da66
70 */ 70 */
71 71
72 //Changelog: use the Subversion log 72 //Changelog: use the Subversion log
73 73
74 #include "config.h" 74 #include "config.h"
75 #include "avutil.h"
75 #include <inttypes.h> 76 #include <inttypes.h>
76 #include <stdio.h> 77 #include <stdio.h>
77 #include <stdlib.h> 78 #include <stdlib.h>
78 #include <string.h> 79 #include <string.h>
79 #ifdef HAVE_MALLOC_H 80 #ifdef HAVE_MALLOC_H
92 93
93 #include "mangle.h" //FIXME should be supressed 94 #include "mangle.h" //FIXME should be supressed
94 95
95 #ifdef HAVE_ALTIVEC_H 96 #ifdef HAVE_ALTIVEC_H
96 #include <altivec.h> 97 #include <altivec.h>
97 #endif
98
99 #ifndef HAVE_MEMALIGN
100 #define memalign(a,b) malloc(b)
101 #endif 98 #endif
102 99
103 #define MIN(a,b) ((a) > (b) ? (b) : (a)) 100 #define MIN(a,b) ((a) > (b) ? (b) : (a))
104 #define MAX(a,b) ((a) < (b) ? (b) : (a)) 101 #define MAX(a,b) ((a) < (b) ? (b) : (a))
105 #define ABS(a) ((a) > 0 ? (a) : (-(a))) 102 #define ABS(a) ((a) > 0 ? (a) : (-(a)))
426 int y; 423 int y;
427 static uint64_t *lut= NULL; 424 static uint64_t *lut= NULL;
428 if(lut==NULL) 425 if(lut==NULL)
429 { 426 {
430 int i; 427 int i;
431 lut= (uint64_t*)memalign(8, 256*8); 428 lut = av_malloc(256*8);
432 for(i=0; i<256; i++) 429 for(i=0; i<256; i++)
433 { 430 {
434 int v= i < 128 ? 2*i : 2*(i-256); 431 int v= i < 128 ? 2*i : 2*(i-256);
435 /* 432 /*
436 //Simulate 112242211 9-Tap filter 433 //Simulate 112242211 9-Tap filter
769 const char *filterDelimiters= ",/"; 766 const char *filterDelimiters= ",/";
770 const char *optionDelimiters= ":"; 767 const char *optionDelimiters= ":";
771 struct PPMode *ppMode; 768 struct PPMode *ppMode;
772 char *filterToken; 769 char *filterToken;
773 770
774 ppMode= memalign(8, sizeof(PPMode)); 771 ppMode= av_malloc(sizeof(PPMode));
775 772
776 ppMode->lumMode= 0; 773 ppMode->lumMode= 0;
777 ppMode->chromMode= 0; 774 ppMode->chromMode= 0;
778 ppMode->maxTmpNoise[0]= 700; 775 ppMode->maxTmpNoise[0]= 700;
779 ppMode->maxTmpNoise[1]= 1500; 776 ppMode->maxTmpNoise[1]= 1500;
947 944
948 if(verbose>1) printf("pp: lumMode=%X, chromMode=%X\n", ppMode->lumMode, ppMode->chromMode); 945 if(verbose>1) printf("pp: lumMode=%X, chromMode=%X\n", ppMode->lumMode, ppMode->chromMode);
949 if(ppMode->error) 946 if(ppMode->error)
950 { 947 {
951 fprintf(stderr, "%d errors in postprocess string \"%s\"\n", ppMode->error, name); 948 fprintf(stderr, "%d errors in postprocess string \"%s\"\n", ppMode->error, name);
952 free(ppMode); 949 av_free(ppMode);
953 return NULL; 950 return NULL;
954 } 951 }
955 return ppMode; 952 return ppMode;
956 } 953 }
957 954
958 void pp_free_mode(pp_mode_t *mode){ 955 void pp_free_mode(pp_mode_t *mode){
959 if(mode) free(mode); 956 av_free(mode);
960 } 957 }
961 958
962 static void reallocAlign(void **p, int alignment, int size){ 959 static void reallocAlign(void **p, int alignment, int size){
963 if(*p) free(*p); 960 av_free(p);
964 *p= memalign(alignment, size); 961 *p= av_mallocz(size);
965 memset(*p, 0, size);
966 } 962 }
967 963
968 static void reallocBuffers(PPContext *c, int width, int height, int stride, int qpStride){ 964 static void reallocBuffers(PPContext *c, int width, int height, int stride, int qpStride){
969 int mbWidth = (width+15)>>4; 965 int mbWidth = (width+15)>>4;
970 int mbHeight= (height+15)>>4; 966 int mbHeight= (height+15)>>4;
1000 clip_table[i]= i; 996 clip_table[i]= i;
1001 memset(clip_table+512, 0, 256); 997 memset(clip_table+512, 0, 256);
1002 } 998 }
1003 999
1004 pp_context_t *pp_get_context(int width, int height, int cpuCaps){ 1000 pp_context_t *pp_get_context(int width, int height, int cpuCaps){
1005 PPContext *c= memalign(32, sizeof(PPContext)); 1001 PPContext *c= av_malloc(sizeof(PPContext));
1006 int stride= (width+15)&(~15); //assumed / will realloc if needed 1002 int stride= (width+15)&(~15); //assumed / will realloc if needed
1007 int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed 1003 int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed
1008 1004
1009 global_init(); 1005 global_init();
1010 1006
1027 1023
1028 void pp_free_context(void *vc){ 1024 void pp_free_context(void *vc){
1029 PPContext *c = (PPContext*)vc; 1025 PPContext *c = (PPContext*)vc;
1030 int i; 1026 int i;
1031 1027
1032 for(i=0; i<3; i++) free(c->tempBlured[i]); 1028 for(i=0; i<3; i++) av_free(c->tempBlured[i]);
1033 for(i=0; i<3; i++) free(c->tempBluredPast[i]); 1029 for(i=0; i<3; i++) av_free(c->tempBluredPast[i]);
1034 1030
1035 free(c->tempBlocks); 1031 av_free(c->tempBlocks);
1036 free(c->yHistogram); 1032 av_free(c->yHistogram);
1037 free(c->tempDst); 1033 av_free(c->tempDst);
1038 free(c->tempSrc); 1034 av_free(c->tempSrc);
1039 free(c->deintTemp); 1035 av_free(c->deintTemp);
1040 free(c->stdQPTable); 1036 av_free(c->stdQPTable);
1041 free(c->nonBQPTable); 1037 av_free(c->nonBQPTable);
1042 free(c->forcedQPTable); 1038 av_free(c->forcedQPTable);
1043 1039
1044 memset(c, 0, sizeof(PPContext)); 1040 memset(c, 0, sizeof(PPContext));
1045 1041
1046 free(c); 1042 av_free(c);
1047 } 1043 }
1048 1044
1049 void pp_postprocess(uint8_t * src[3], int srcStride[3], 1045 void pp_postprocess(uint8_t * src[3], int srcStride[3],
1050 uint8_t * dst[3], int dstStride[3], 1046 uint8_t * dst[3], int dstStride[3],
1051 int width, int height, 1047 int width, int height,