Possible fix for incorrect fps and zoom values
Possible fix for incorrect fps and zoom values
I was having a problem with incorrect fps and zoom values in live and montage views. I found that the following change seems to fix the problem.
Line 94 in web/ajax/stream.php reads something like:
$data = unpack("ltype/imonitor/dfps/istate ....
I changed it to:
$data = unpack("ltype/imonitor/C/C/C/C/dfps/istate ...
And now the fps and zoom numbers seem fine.
It's best to change the one in web/ajax under the zm directory and run make install again, rather the just changing the one that the web server is using because next time you install it will overwrite the one in the web server directory.
Hope this helps,
Andy
Line 94 in web/ajax/stream.php reads something like:
$data = unpack("ltype/imonitor/dfps/istate ....
I changed it to:
$data = unpack("ltype/imonitor/C/C/C/C/dfps/istate ...
And now the fps and zoom numbers seem fine.
It's best to change the one in web/ajax under the zm directory and run make install again, rather the just changing the one that the web server is using because next time you install it will overwrite the one in the web server directory.
Hope this helps,
Andy
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
I'm also experiencing problems with the fps and zoom values. Here are my system values for comparision. Yet to try the fix.genanr wrote: I do think the problem is related to 64-bit and possibly the version of gcc/g++ that is being used.
Linux 2.6.27-12-generic #1 SMP x86_64 GNU/Linux
gcc.real (Ubuntu 4.3.2-1ubuntu12) 4.3.2
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Right, and int is in fact 4 bytes on my 64 bit system. I believe the real problem is is how g++ deals with structures, here is a little test program I wrote to figure out what really is going on.
#include <stdio>
#define FIELD_OFFSET(strptr,field) ((char*)&((strptr)->field)-(char*)strptr)
main()
{
struct {
int id;
double fps;
int state;
int buffer_level;
bool delayed;
bool paused;
int rate;
double delay;
int zoom;
bool enabled;
bool forced;
} __attribute__((packed)) status_data_packed;
struct {
int id;
double fps;
int state;
int buffer_level;
bool delayed;
bool paused;
int rate;
double delay;
int zoom;
bool enabled;
bool forced;
} status_data;
printf("sizeof(int) : %d sizeof(bool) : %d\n",sizeof(int),sizeof(bool));
printf("sizeof(status_data_packed) : %d\n",sizeof(status_data_packed));
printf("sizeof(status_data) : %d\n",sizeof(status_data));
printf("offset(fps) with __attribute__((packed)) %d\n" ,FIELD_OFFSET(&status_data_packed,fps));
printf("offset(fps) : %d\n",FIELD_OFFSET(&status_data,fps));
}
My results:
sizeof(int) : 4 sizeof(bool) : 1
sizeof(status_data_packed) : 40
sizeof(status_data) : 48
offset(fps) with __attribute__((packed)) : 4
offset(fps) : 8
This cause of the problem makes sense to me.
I'll try the packed attribute on Monday in ZoneMinder.
Andy
#include <stdio>
#define FIELD_OFFSET(strptr,field) ((char*)&((strptr)->field)-(char*)strptr)
main()
{
struct {
int id;
double fps;
int state;
int buffer_level;
bool delayed;
bool paused;
int rate;
double delay;
int zoom;
bool enabled;
bool forced;
} __attribute__((packed)) status_data_packed;
struct {
int id;
double fps;
int state;
int buffer_level;
bool delayed;
bool paused;
int rate;
double delay;
int zoom;
bool enabled;
bool forced;
} status_data;
printf("sizeof(int) : %d sizeof(bool) : %d\n",sizeof(int),sizeof(bool));
printf("sizeof(status_data_packed) : %d\n",sizeof(status_data_packed));
printf("sizeof(status_data) : %d\n",sizeof(status_data));
printf("offset(fps) with __attribute__((packed)) %d\n" ,FIELD_OFFSET(&status_data_packed,fps));
printf("offset(fps) : %d\n",FIELD_OFFSET(&status_data,fps));
}
My results:
sizeof(int) : 4 sizeof(bool) : 1
sizeof(status_data_packed) : 40
sizeof(status_data) : 48
offset(fps) with __attribute__((packed)) : 4
offset(fps) : 8
This cause of the problem makes sense to me.
I'll try the packed attribute on Monday in ZoneMinder.
Andy
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Using the packed attribute fixed the fps problem, but I had to take out the two /C after the paused field that were already in the SVN code to get zoom right.
This is my current line:
unpack( "ltype/imonitor/dfps/istate/ilevel/Cdelayed/Cpaused/irate/ddelay/izoom/Cenabled/Cforced")
Is this problem specific to gcc compilers?
Andy
This is my current line:
unpack( "ltype/imonitor/dfps/istate/ilevel/Cdelayed/Cpaused/irate/ddelay/izoom/Cenabled/Cforced")
Is this problem specific to gcc compilers?
Andy
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
I don't know if it is specific to GNU compilers , probably not. It is an issue getting the php and c++ elements looking for things in the same place. I will post a proper solution in the next couple of days though I don't have a 64 bit system here. I will try and set up a 64 bit VM to play with.
Phil
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Re: Possible fix for incorrect fps and zoom values
Yap! works perferct now! Tanks Man.genanr wrote:I was having a problem with incorrect fps and zoom values in live and montage views. I found that the following change seems to fix the problem.
Line 94 in web/ajax/stream.php reads something like:
$data = unpack("ltype/imonitor/dfps/istate ....
I changed it to:
$data = unpack("ltype/imonitor/C/C/C/C/dfps/istate ...
And now the fps and zoom numbers seem fine.
It's best to change the one in web/ajax under the zm directory and run make install again, rather the just changing the one that the web server is using because next time you install it will overwrite the one in the web server directory.
Hope this helps,
Andy