int run_hsl(int c, char* src, char* dst, float hh, float ss, float ll) { BMP* bmp = bmp_read(src); if(bmp==0) { return -1;} // open error if(ss>1) ss=1; else if(ss<-1) ss=-1; if(ll>1) ll=1; else if(ll<-1) ll=-1; uint8_t* data = bmp_get_data(bmp); uint32_t h = *(bmp_get_h(bmp)); uint32_t w = *(bmp_get_w(bmp)); if(w%4!=0) { return -1;} // do not support padding uint8_t* dataC = 0; if(*(bmp_get_bitcount(bmp)) == 24) { dataC = malloc(sizeof(uint8_t)*4*h*w); to32(w,h,data,dataC); } else { dataC = data; } if(c==0) C_hsl(w,h,dataC,hh,ss,ll); else if(c==1) ASM_hsl1(w,h,dataC,hh,ss,ll); else if(c==2) ASM_hsl2(w,h,dataC,hh,ss,ll); else {return -1;} if(*(bmp_get_bitcount(bmp)) == 24) { to24(w,h,dataC,data); free(dataC); } bmp_save(dst,bmp); bmp_delete(bmp); return 0; }
int run_hsl(int c, char* src, char* dst, float hh, float ss, float ll, int times) { BMP* bmp = bmp_read(src); if(bmp==0) { return -1;} // open error if(ss>1) ss=1; else if(ss<-1) ss=-1; if(ll>1) ll=1; else if(ll<-1) ll=-1; uint8_t* data = bmp_get_data(bmp); uint32_t h = *(bmp_get_h(bmp)); uint32_t w = *(bmp_get_w(bmp)); if(w%4!=0) { return -1;} // do not support padding uint8_t* dataC = 0; if(*(bmp_get_bitcount(bmp)) == 24) { dataC = malloc(sizeof(uint8_t)*4*h*w); to32(w,h,data,dataC); } else { dataC = data; } unsigned long start, end; switch(c){ case 0: RDTSC_START(start); C_hsl(w,h,dataC,hh,ss,ll); RDTSC_STOP(end); break; case 1: RDTSC_START(start); ASM_hsl1(w,h,dataC,hh,ss,ll); RDTSC_STOP(end); break; case 2: RDTSC_START(start); ASM_hsl2(w,h,dataC,hh,ss,ll); RDTSC_STOP(end); break; default: return -1; break; } unsigned long delta = end - start; printf("%lu", delta); if(*(bmp_get_bitcount(bmp)) == 24) { to24(w,h,dataC,data); free(dataC); } bmp_delete(bmp); return 0; }