Skip to content

Commit

Permalink
Realign to 16 bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed May 6, 2024
1 parent fe28e5c commit 336c297
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stddef.h>
#include "platform.h"

#define VIDEOFRAME_ALIGN 64
#define VIDEOFRAME_ALIGN 16

#ifdef __cplusplus

Expand Down
1 change: 1 addition & 0 deletions acquire-video-runtime/src/runtime/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ video_source_thread(struct video_source_s* self)
const size_t padding =
(alignment - (nbytes & (alignment - 1))) & (alignment - 1);
const size_t nbytes_aligned = nbytes + padding;
CHECK(nbytes_aligned % alignment == 0);

struct channel* channel =
(self->enable_filter) ? self->to_filter : self->to_sink;
Expand Down
9 changes: 6 additions & 3 deletions acquire-video-runtime/tests/aligned-videoframe-pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ acquire(AcquireRuntime* runtime)
OK(acquire_get_configuration(runtime, &props));

const auto next = [](VideoFrame* cur) -> VideoFrame* {
return (VideoFrame*)(((uint8_t*)cur) +
align_up(cur->bytes_of_frame, 8));
return (VideoFrame*)(((uint8_t*)cur) + cur->bytes_of_frame);
};

const auto consumed_bytes = [](const VideoFrame* const cur,
Expand Down Expand Up @@ -149,7 +148,10 @@ acquire(AcquireRuntime* runtime)
props.video[0].camera.settings.shape.y);

// check pointer is aligned
CHECK((size_t)cur % 64 == 0);
const auto cur_size_t = (size_t)cur;
EXPECT(cur_size_t % 16 == 0,
"Pointer not aligned: %lu",
cur_size_t % 16);
++nframes;
}

Expand Down Expand Up @@ -177,6 +179,7 @@ acquire(AcquireRuntime* runtime)
int
main()
{
const size_t a = alignof(VideoFrame);
int retval = 1;
AcquireRuntime* runtime = acquire_init(reporter);

Expand Down

0 comments on commit 336c297

Please sign in to comment.