ZM 1.25.0 Performance Patch - Completed

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
elusive
Posts: 14
Joined: Wed Oct 22, 2008 4:53 am

Re: ZM 1.24.4 Peformance Patch - Completed

Post by elusive »

Hello,

First, congratulations for that impressive work !

I just tried your patch on an Ubuntu 11.04 64 bits distribution but the compilation failed :

Code: Select all

zm_local_camera.cpp: In member function âvirtual int LocalCamera::Capture(Image&)â:
zm_local_camera.cpp:1819:18: warning: unused variable âdirectbufferâ
zm_local_camera.cpp: At global scope:
zm_local_camera.cpp:1906:2: error: expected unqualified-id before âifâ
zm_local_camera.cpp: In member function âvirtual int LocalCamera::Capture(Image&)â:
zm_local_camera.cpp:1904:5: warning: control reaches end of non-void function
make[2]: *** [zm_local_camera.o] Error 1
make[2]: Leaving directory `/usr/src/ZoneMinder-1.24.4/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/ZoneMinder-1.24.4'
make: *** [all] Error 2
Any idea on what could be wrong ?

Thanks in advance.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

Hi, I think i found the syntax error. Here is a corrected zm_local_camera.cpp file, tell me if it works (choose one of the links):
http://pastebin.com/Mcg3wxJX
http://www.megaupload.com/?d=T7MI4VVZ


I have also updated the patch link in the original post to include this fix.

mastertheknife
Kfir Itzhak.
elusive
Posts: 14
Joined: Wed Oct 22, 2008 4:53 am

Re: ZM 1.24.4 Peformance Patch - Completed

Post by elusive »

Just made a new try, I confirm it works fine now, thank you ! ;-)

Will make more tests in the days and weeks to go, see you.
timcraig
Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA

Re: ZM 1.24.4 Peformance Patch - Completed

Post by timcraig »

Very good job! Thank you for taking to the time to make this performance upgrade.

I hope this patch get's added to Zoneminder's SVN and to future Zoneminder releases.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

timcraig wrote:Very good job! Thank you for taking to the time to make this performance upgrade.

I hope this patch get's added to Zoneminder's SVN and to future Zoneminder releases.
Thank you! but so far, it seems not many people tried it and came back with results and reports, so its hard to know if there are any bugs that i missed or something, during my 2 months testing.

mastertheknife
Kfir Itzhak.
graphicw
Posts: 34
Joined: Thu May 19, 2011 12:57 am

Re: ZM 1.24.4 Peformance Patch - Completed

Post by graphicw »

I have installed it on a 32 bit Ubuntu 11.04 server. It works fine in 8 bit grey scale but does not work in color at all. I have a BT878 based card that I know will support BGR24 as I have used it in unmodified ZM. I do have the latest version of libjpeg-turbo installed. I will do a little research to see if I can diagnose the problem. Thanks for all the work that you put into this wonderful mod.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

graphicw wrote:I have installed it on a 32 bit Ubuntu 11.04 server. It works fine in 8 bit grey scale but does not work in color at all. I have a BT878 based card that I know will support BGR24 as I have used it in unmodified ZM. I do have the latest version of libjpeg-turbo installed. I will do a little research to see if I can diagnose the problem. Thanks for all the work that you put into this wonderful mod.
Hi, thanks for trying!

Thats sad to hear. Whats in the system log? also, a debug log (preferably level 8 ) will also help if possible.
If it crashes, try starting it using gdb: gdb --args zmc -d /dev/video0
and after it crashes, type "bt" and paste the contents here, it should really help to know where it crashes.

Also, i'm also in #zoneminder on freenode.

EDIT: I'm also using a bt878 card, a pico2000 clone and it all works here except the RGB24 V4L2 capture palette, which it seems the card or driver do not support.

mastertheknife
Kfir Itzhak.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

Also, what is the target colorspace set to ?

mastertheknife.
Kfir Itzhak.
graphicw
Posts: 34
Joined: Thu May 19, 2011 12:57 am

Re: ZM 1.24.4 Peformance Patch - Completed

Post by graphicw »

It is not that it is crashing, it simply will not display a picture if target color is set to 24 or 32 bit. I only see a box show up where the image should be. Other monitors that are set to grey scale continue to run. My cards are Kodicom 8800 clones. The do not support RGB24 but do support BGR24 and almost all of the other formats.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

If zmc is running, and zma is also running if you are running in modect mode (until there is alarm and it needs to save an image), most likely you have the wrong version of libjpeg loaded.
You can confirm this by running ps ax | grep zma (or zmc) and then:

Code: Select all

cat /proc/<pid>/maps | grep libjpeg
And according to the path, you can know what libjpeg is loaded.

mastertheknife
Kfir Itzhak.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Peformance Patch - Completed

Post by mastertheknife »

Hi,
I tested the V4L2 pixel field option and found it to actually work with the patch. The reason it didn't work earlier is probably because i tried to receive a progressive image (options 2,3 or 7) from a too high resolution.
To get a progressive image, need to use no more than 384x288 for PAL and 320x240 for NTSC, and use options 2,3 or 7. I personally use 2 (top) because i found option 7 (alternate between top and bottom) to make the image shake a little, which can possibly confuse the motion detection.

mastertheknife
Kfir Itzhak.
elusive
Posts: 14
Joined: Wed Oct 22, 2008 4:53 am

Re: ZM 1.24.4 Performance Patch - Completed

Post by elusive »

Hello,

Just noticed that patch breaks the compatibility with the following third party apps :

xlib_shm (0.6.5 GL) -> no more working while choosing 24 or 32 bits color mode

EyeZM -> H264 streaming capability no more working while choosing 32 bits color mode (grey scrambled picture)

Do you think it could be easily fixed or need a full re-factoring ?

Have a nice evening.
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Performance Patch - Completed

Post by mastertheknife »

Hi elusive :D

xlib_shm - Probably broke because i changed the shared memory layout a little, but you can use the old shared memory layout. I did this to have an identical layout and size on both 32bit and 64bit, and also to make its size 16 bytes aligned.
EyeZM - Probably a small issue such as missing 32bit format detection, i'll look into it tomorrow.

Thanks for reporting. How is the performance by the way? Someone in IRC told me his system load reduced from 0.56 to 0.14 on an SSSE3 processor with 8 analog cameras.

mastertheknife
Kfir Itzhak.
elusive
Posts: 14
Joined: Wed Oct 22, 2008 4:53 am

Re: ZM 1.24.4 Performance Patch - Completed

Post by elusive »

Thanks for the fast answer ;-)

Regarding xlib_shm, I'm using it in mmap mode, do you think the shared memory layout could be the reason while using that mode or is it just a color palette issue ?

Unfortunatly the server is not yet in production (it should be in the weeks to go) so I can't give you real usefull feedbacks right now.

I'm still desesperatly looking for an user-friendly interface which is asked by the customer :

He doesn't like the web interface, xlib_shm is the only real alternative I found but a lot of missing functions ... Windows Live Viewer can't be used since he uses Linux distributions and ZM Viewer crashes after a few minutes (filling all the RAM).
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re: ZM 1.24.4 Performance Patch - Completed

Post by mastertheknife »

Hi elusive,

Here is a small patch to add the missing new formats detection to ZM's VideoStream class, which is what is used by EyeZM.
Other than compiling, i have been unable to test this because i don't have eyezm, so it'll be useful to know if it works, so i can add it to the patch in the first post. There is no reason why eyezm should not work now.
About xlib_shm, i'll go check.

EDIT: Small patch removed after it was tested to be working, and was added to the patch in the main post.

mastertheknife
Last edited by mastertheknife on Wed Jun 22, 2011 5:30 pm, edited 2 times in total.
Kfir Itzhak.
Post Reply