Skip to content

Commit df0e38f

Browse files
committed
make sure data pointer in Frame object is 64-byte aligned
1 parent 77e901a commit df0e38f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/protonect/include/libfreenect2/frame_listener.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <cstddef>
3131
#include <stdint.h>
32+
#include <stdlib.h>
3233
#include <libfreenect2/config.h>
3334

3435
namespace libfreenect2
@@ -46,19 +47,21 @@ struct LIBFREENECT2_API Frame
4647
uint32_t timestamp;
4748
uint32_t sequence;
4849
size_t width, height, bytes_per_pixel;
50+
unsigned char* rawdata;
4951
unsigned char* data;
5052

5153
Frame(size_t width, size_t height, size_t bytes_per_pixel) :
5254
width(width),
5355
height(height),
5456
bytes_per_pixel(bytes_per_pixel)
5557
{
56-
data = new unsigned char[width * height * bytes_per_pixel];
58+
rawdata = new unsigned char[width * height * bytes_per_pixel + 128];
59+
data = (unsigned char*)((unsigned long long)(rawdata+64) & (unsigned long long)(0xFFFFFFFFFFFFFFC0ULL));
5760
}
5861

5962
~Frame()
6063
{
61-
delete[] data;
64+
delete[] rawdata;
6265
}
6366
};
6467

0 commit comments

Comments
 (0)