I am using the UIC samples to decode JPEG images and it seems to be too slow. It takes about 3 sec to decode my test image and I can decode it in about 0.8 sec using FreeImage ( http://freeimage.sourceforge.net/ -- which itself is using libjpeg I believe).
Here is the output of the test program for uic. Note that I changed the code a bit to get the 'real' user timing (in bold below). The low-level routine pretends to decode in 209 msec but from the high level call in the demo program, it really takes 3 sec :
Could you try your operation in a single-thread mode (i.e. use "-n 1" option)?
As far as I remember there was an issue on Linux with measuring time by using standard "time.h" functions. These functions return so called "process time", which is sum of all thread times. For example, if the piece of the code is executed in 2 parallel threads and each of them takes 0.5 sec - i.e. the whole piece finishes in 0.5 sec by wall clock - the Linux's time measuring functions will return the value of 1 sec.
If my assumption is correct, then when you use "-n 1" you will get both times (returned by uic_transcoder and by your measurements) about the same. If not, we'll be investigating the issue. Hope, you use multi-core CPU )).
I tried -n 1 and it idoes not change anything. The time reported is still ~240 msec but the real time is ~3 sec.
The real time is 3 sec as confirmed with the external call to ftime() before and after the high level decode routine.
The computer under which I run this has 8 cpus and I compiled the sampled with the script build_intel64.sh .
Can I do something to speed it up? FreeImage can decode the image in about 0.8 sec (real user time). So I expect that I should be able to get at lest that with UIC. Being almost 4 times slower, I must be doing something wrong but I cannot find it.
I just found the the CTimer object at the beginning of the DecodeImage() routine takes a long time to create. I have removed it and now the DecodeImage routine is blazing fast as expected, about 4 times faster then FreeImage.
I am not familiar with CTimer and I dont know whether it is a known problem or not but I can certainly live without it (ftime() works great with no overhead).
So, if like me you want to wrap the UIC library into your own project and use the DecodeImage() and EncodeImage() high level functions, you should remove the CTimer object from these routines (unless this problem is specific to my installation).
It is not a "known problem", but specifics we had to notify. On Linux, CTimer::Init calls 'ippGetCpuFreqMhz' (you can see from timer.cpp source file). This - ippGetCpuFreqMhz - function directly measures CPU frequency by counting CPU clocks and this measurement takes about 3 seconds. On Windows there is no problem like this, because Init function reads frequency from system performance counters.
I will speak with information development team to add notification about this to ippGetCpuFreqMhz description, will add notification to uic_transcoder_con description (and its console output) and, probably, will modify uic_transcoder_con source code to avoid operations with timer if no timing is asked in command line options.
In my own code, I always used ftime() directly to get the real user time. It has no overhead. This is what i use now in my copy of ipp samples now. I am not usre about the advantage of Ctimer, is it better at measuring the CPU time in a specific thread ?
Ftime() must be ok, since it shows astronomical (absolute, wallclock) time, though it may be not precise enough. In our measurements we try to use CPU clocks, because a) the time intervals we need to measure are usually shorter and b) these values to some extent are frequency-invariants (mostly depending on CPU architecture).
There's another Linux function - clock() - which returns total process time, including all childs of process (i.e. parallel threads). This function must be used carefully.
If you are hoping to support CMYK images using UIC with no effort on your part then get ready for a (not so pleasant) surprise. In order to correctly display colors from CMYK JPEG you will have to use color management which UIC does not provide meaning that you must use external library (such as LittleCMS) which will significantly slow down your decoding.