///////////////////////////////////////////////////////////////////////////// // Rev 11/12/2003 // // // TESTJPG.C // --------- // // // Sylvain MARECHAL - sylvain.marechal1@libertysurf.fr ///////////////////////////////////////////////////////////////////////////// // // show how to use dcpjpeg.c, the wrapper to the jpeg6b lib // should be linked with : // -the jpeglib-6b (http://www.ijg.org/) // -dcpjpeg.c // // Usage : // testjpg // // [quality(default to 50, 1 =poor, 100=good)] // [fOnePass](default to 0) // [nbtimes(default to 1] // ///////////////////////////////////////////////////////////////////////////// #ifdef _WIN32 #include #include #include #else #include #include #include #endif #include #include "dcpjpeg.h" ///////////////////////////////////////////////////////////////////////////// // // GETCLOCKCOUNT ///////////////////////////////////////////////////////////////////////////// // // DESCRIPTION // --GetClockCount-- // // Return a relative current time in milliseconds // // ARGUMENTS // Argument1: void // RETOUR/RESULTAT // long // REMARQUE // Rev 11/12/2003 ////////////////////////////////////////////////////////////////////////////// static long GetClockCount(void) { #ifdef _WIN32 return clock () ; #else static struct timeval ClockCount; struct timeval Now; static long diff; if( ClockCount.tv_sec != 0 ) { gettimeofday(&Now, NULL); diff += (Now.tv_sec - ClockCount.tv_sec) * 1000L; diff += (Now.tv_usec - ClockCount.tv_usec) / 1000L; ClockCount.tv_sec = Now.tv_sec ; ClockCount.tv_usec = Now.tv_usec ; return diff; } else { gettimeofday(&ClockCount, NULL); diff = 0 ; return 0; } #endif } ///////////////////////////////////////////////////////////////////////////// // // MAIN ///////////////////////////////////////////////////////////////////////////// // // DESCRIPTION // --main-- // ARGUMENTS // Argument1: int argc // Argument2: char * argv[] // RETOUR/RESULTAT // void // REMARQUE // Rev 11/12/2003 ////////////////////////////////////////////////////////////////////////////// void main( int argc, char * argv[] ) { char szSource[1024]; char szDest[1024]; int nQuality = 50; BOOL fOnePass = 0; int nbTimes = 1; int i; long tick; if( argc < 3 ) { printf( "Usage : %s \n", argv[0] ); exit(1); } // Source file strcpy( szSource, argv[1] ); // Destination file strcpy( szDest, argv[2] ); // Quality if( argc >= 4 ) nQuality = atoi(argv[3]); // Do it in one pass (obsolete) if( argc >= 5 ) fOnePass = atoi(argv[4]); // Do it n times to count the time if( argc >= 6 ) nbTimes = atoi(argv[5]); tick = GetClockCount(); for( i = 0; i < nbTimes; i ++ ) TestJpeg( szSource, szDest, nQuality, fOnePass ); printf( "Time : %d ms\n", GetClockCount() - tick ); }