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

Framesync API #1325

Merged
merged 1 commit into from
Feb 7, 2024
Merged

Framesync API #1325

merged 1 commit into from
Feb 7, 2024

Conversation

kylophone
Copy link
Collaborator

Re-opening of PR #1287.

Co-authored-by: Niranjan Kumar <niranjan.kumar@ittiam.com>
Co-authored-by: Mallikarjun Kamble <mallikarjun.kamble@ittiam.com>
Co-authored-by: Nil Fons Miret <nilf@netflix.com>
@kylophone
Copy link
Collaborator Author

Squashed and rebased, ready for merge.

new_buf_node->next = NULL;
fs_ctx->buf_cnt++;

new_buf_node->frame_data = *data = malloc(data_sz);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: There is some duplicated logic here, maybe it is possible to extract out the "create new node" and "allocate node's data" into two functions to be reused. But we can refactor this later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed with 2 functions the code can made reusable.

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)
Copy link
Collaborator

@nilfm99 nilfm99 Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naive question: what is the purpose of this check?

It seems that to succeed, the pair (index, data) needs to match the pair (buf_que->index, buf_que->frame_data). Curious about:

  1. Why that condition is needed
  2. Why the treatment is different if the index doesn't match (do nothing) vs if the index matches but the data pointer doesn't (mark as filled and return -1)
  3. What if the entire loop finishes without finding a match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarded to Ittiam.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q1:
Index matching is done to find the node which holds the data buffer of picture "index"

Q2:
Index matching is the primary check to change the buffer status to FILLED,
Data pointer checking is for error checking purpose, which can be cleaned up if not necessary. if the caller has not passed the matching data buffer, then there can be OOB or unallocated buffer access, this additional check is added to catch such cases.
Q3:
This condition is not applicable since the thread which has acquired new buffer for any particular picture index is responsible for submitting it after filling, so index should match with a node in the queue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @IttiamVijayakumarGR for clarifying, I was discussing this with @kylophone and it seemed like the extra check can be cleaned up, so I did that in the PR below. I will leave the last call to Kyle though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this with @nilfm99, we'll merge this one as-is for now to unblock the funque upstreaming work. However, I think it's likely that we'll have some small changes to the api in a later iteration. Since this is an internal api with just one use so far, we do have some flexibility when it comes to refactoring.

@kylophone kylophone merged commit 8b2687a into master Feb 7, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants