@@ -15,6 +15,7 @@ static int GpuId;
1515static int TotalJobsProc = 0 ;
1616static int NumThreads = 1 ;
1717static int TaskId = 1 ;
18+ static int WebpQuality = 90 ;
1819
1920bool IsDebug = false ;
2021
@@ -49,7 +50,7 @@ int waifu2x_getData(void*& out, unsigned long& outSize, double& tick, int& callB
4950 outSize = v.outSize ;
5051
5152 v.out = NULL ;
52- strcpy (format, v.file .c_str ());
53+ strcpy (format, v.save_format .c_str ());
5354 tick = v.allTick ;
5455 return v.id ;
5556}
@@ -141,7 +142,7 @@ void* waifu2x_proc(void* args)
141142 name = " cpu" ;
142143
143144 waifu2x_printf (stdout, " [waifu2x] start encode imageId :%d, gpu:%s, format:%s, model:%s, noise:%d, scale:%d, tta:%d, tileSize:%d\n " ,
144- v.callBack , name, v.file .c_str (), waifu2x->mode_name .c_str (), waifu2x->noise , waifu2x->scale , waifu2x->tta_mode , v.tileSize );
145+ v.callBack , name, v.save_format .c_str (), waifu2x->mode_name .c_str (), waifu2x->noise , waifu2x->scale , waifu2x->tta_mode , v.tileSize );
145146 int scale_run_count = 1 ;
146147 int frame = 0 ;
147148 for (std::list<ncnn::Mat *>::iterator in = v.inImage .begin (); in != v.inImage .end (); in++)
@@ -590,6 +591,7 @@ int waifu2x_addData(const unsigned char* data, unsigned int size, int callBack,
590591 v.toW = toW;
591592 v.scale = scale;
592593 v.tileSize = tileSize;
594+ v.webp_quality = WebpQuality;
593595 if ((toH <= 0 || toW <= 0 ) && scale <= 0 )
594596 {
595597 waifu2x_set_error (" invalid scale params" );
@@ -601,10 +603,10 @@ int waifu2x_addData(const unsigned char* data, unsigned int size, int callBack,
601603 waifu2x_set_error (" invalid model index" );
602604 return sts;
603605 }
604- if (format) v.file = format;
606+ if (format) v.save_format = format;
605607
606- transform (v.file .begin (), v.file .end (), v.file .begin (), ::tolower);
607- if (v.file .length () == 0 || !v.file .compare (" jpg" ) || !v.file .compare (" jpeg" ) || !v.file .compare (" png" ) || !v.file .compare (" webp" ) || !v.file .compare (" jpg" ) || !v.file .compare (" bmp" ) || !v.file .compare (" apng" ))
608+ transform (v.save_format .begin (), v.save_format .end (), v.save_format .begin (), ::tolower);
609+ if (v.save_format .length () == 0 || !v.save_format .compare (" jpg" ) || !v.save_format .compare (" jpeg" ) || !v.save_format .compare (" png" ) || !v.save_format .compare (" webp" ) || !v.save_format .compare (" jpg" ) || !v.save_format .compare (" bmp" ) || !v.save_format .compare (" apng" ))
608610 {
609611 Todecode.put (v);
610612 return TaskId;
@@ -650,6 +652,12 @@ int waifu2x_set_debug(bool isdebug)
650652 return 0 ;
651653}
652654
655+ int waifu2x_set_webp_quality (int webp_quality)
656+ {
657+ WebpQuality = webp_quality;
658+ return 0 ;
659+ }
660+
653661int waifu2x_remove_wait (std::set<int >& taskIds)
654662{
655663 Todecode.remove (taskIds);
0 commit comments