File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
examples/protonect/include/libfreenect2 Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 3434namespace libfreenect2
3535{
3636
37- struct LIBFREENECT2_API Frame
37+ class LIBFREENECT2_API Frame
3838{
39+ public:
3940 enum Type
4041 {
4142 Color = 1 ,
@@ -46,22 +47,28 @@ struct LIBFREENECT2_API Frame
4647 uint32_t timestamp;
4748 uint32_t sequence;
4849 size_t width, height, bytes_per_pixel;
49- unsigned char * rawdata;
5050 unsigned char * data;
5151
5252 Frame (size_t width, size_t height, size_t bytes_per_pixel) :
5353 width (width),
5454 height (height),
5555 bytes_per_pixel (bytes_per_pixel)
5656 {
57- rawdata = new unsigned char [width * height * bytes_per_pixel + 128 ];
58- data = (unsigned char *)((unsigned long long )(rawdata+64 ) & (unsigned long long )(0xFFFFFFFFFFFFFFC0ULL ));
57+ const size_t alignment = 64 ;
58+ size_t space = width * height * bytes_per_pixel + alignment;
59+ rawdata = new unsigned char [space];
60+ uintptr_t ptr = reinterpret_cast <uintptr_t >(rawdata);
61+ uintptr_t aligned = (ptr - 1u + alignment) & -alignment;
62+ data = reinterpret_cast <unsigned char *>(aligned);
5963 }
6064
6165 ~Frame ()
6266 {
6367 delete[] rawdata;
6468 }
69+
70+ protected:
71+ unsigned char * rawdata;
6572};
6673
6774class LIBFREENECT2_API FrameListener
You can’t perform that action at this time.
0 commit comments