Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify framesync API #1327

Open
wants to merge 1 commit into
base: framesync_api
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions libvmaf/src/framesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ int vmaf_framesync_acquire_new_buf(VmafFrameSyncContext *fs_ctx, void **data,
return 0;
}

int vmaf_framesync_submit_filled_data(VmafFrameSyncContext *fs_ctx, void *data,
unsigned index)
int vmaf_framesync_submit_filled_data(VmafFrameSyncContext *fs_ctx, unsigned index)
{
VmafFrameSyncBuf *buf_que = fs_ctx->buf_que;

Expand All @@ -121,8 +120,6 @@ int vmaf_framesync_submit_filled_data(VmafFrameSyncContext *fs_ctx, void *data,
for (unsigned i = 0; i < fs_ctx->buf_cnt; i++) {
if ((buf_que->index == index) && (buf_que->buf_status == BUF_ACQUIRED)) {
buf_que->buf_status = BUF_FILLED;
if (data != buf_que->frame_data)
return -1;
break;
}

Expand Down Expand Up @@ -167,18 +164,14 @@ int vmaf_framesync_retrieve_filled_data(VmafFrameSyncContext *fs_ctx,
return 0;
}

int vmaf_framesync_release_buf(VmafFrameSyncContext *fs_ctx, void *data,
unsigned index)
int vmaf_framesync_release_buf(VmafFrameSyncContext *fs_ctx, unsigned index)
{
VmafFrameSyncBuf *buf_que = fs_ctx->buf_que;

pthread_mutex_lock(&(fs_ctx->acquire_lock));
// loop until a matching buffer is found
for (unsigned i = 0; i < fs_ctx->buf_cnt; i++) {
if ((buf_que->index == index) && (buf_que->buf_status == BUF_RETRIEVED)) {
if (data != buf_que->frame_data)
return -1;

free(buf_que->frame_data);
buf_que->frame_data = NULL;
buf_que->buf_status = BUF_FREE;
Expand Down
6 changes: 2 additions & 4 deletions libvmaf/src/framesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ int vmaf_framesync_init(VmafFrameSyncContext **fs_ctx);
int vmaf_framesync_acquire_new_buf(VmafFrameSyncContext *fs_ctx, void **data,
unsigned data_sz, unsigned index);

int vmaf_framesync_submit_filled_data(VmafFrameSyncContext *fs_ctx, void *data,
unsigned index);
int vmaf_framesync_submit_filled_data(VmafFrameSyncContext *fs_ctx, unsigned index);

int vmaf_framesync_retrieve_filled_data(VmafFrameSyncContext *fs_ctx, void **data,
unsigned index);

int vmaf_framesync_release_buf(VmafFrameSyncContext *fs_ctx, void *data,
unsigned index);
int vmaf_framesync_release_buf(VmafFrameSyncContext *fs_ctx, unsigned index);

int vmaf_framesync_destroy(VmafFrameSyncContext *fs_ctx);

Expand Down
6 changes: 2 additions & 4 deletions libvmaf/test/test_framesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ static void my_worker(void *data)
shared_buf[ctr] = thread_data->ref[ctr] + thread_data->dist[ctr] + 2;

//submit filled buffer back to frame sync
vmaf_framesync_submit_filled_data(thread_data->fs_ctx, shared_buf,
thread_data->index);
vmaf_framesync_submit_filled_data(thread_data->fs_ctx, thread_data->index);

//sleep to simulate work load
const int sleep_seconds = 1;
Expand All @@ -81,8 +80,7 @@ static void my_worker(void *data)
}

//release dependent buffer from frame sync
vmaf_framesync_release_buf(thread_data->fs_ctx, dependent_buf,
thread_data->index - 1);
vmaf_framesync_release_buf(thread_data->fs_ctx, thread_data->index - 1);

cleanup:
free(thread_data->ref);
Expand Down
Loading