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

add dds custom on-video-frame to avoid data copy #11561

Merged
merged 4 commits into from
Mar 19, 2023

Conversation

maloel
Copy link
Collaborator

@maloel maloel commented Mar 14, 2023

  • adds rsutils::deferred, which is an easy RAII for functions, kinda like a destructor when you go out of scope
  • instead of allocating a new buffer and copying the dds data, we now allocate a vector and just move the data
  • we move the data to an already-existing vector (frame::data)
  • this is a middle step: next step is to not even allocate a new vector and skip over the rs2_software_video_frame usage completely
  • did some optimizations with frame_additional_data being copied and moved around a lot

@maloel maloel requested a review from OhadMeir March 14, 2023 10:25
@@ -699,6 +700,40 @@ namespace librealsense
software_sensor::open( profiles );
}

void custom_on_video_frame( rs2_software_video_frame const & software_frame )
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not override the base class on_video_frame?
custom does not convey any meaning. If not overriding use on_video_frame_deffered_deleter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because eventually we won't even be using rs2_software_video_frame. We can maybe still override the name, but let's do it separately -- for now I like that it's clear that this is not some virtual function (which it isn't) that can be called from elsewhere.

data.metadata_size = (uint32_t)( _metadata_map.size() * sizeof( rs2_metadata_type ) );
memcpy( data.metadata_blob.data(), _metadata_map.data(), data.metadata_size );

auto frame_i
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the i in frame_i stands for? allocated_frame or new_frame seems a more meaningful name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's a frame_interface (as opposed to a frame)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like it that the name is dependent on the type. The name should convey the purpose of the variable and should remain the same even if allocate_new_video_frame will change to return frame or video_frame and not frame_interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll change it when I overhaul the function?

Copy link
Contributor

@OhadMeir OhadMeir left a comment

Choose a reason for hiding this comment

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

Approved, some comments should be handled in the upcoming PR that will further refactor the frame metadata.

@maloel maloel merged commit 610e03a into IntelRealSense:dds Mar 19, 2023
@maloel maloel deleted the continuation branch March 19, 2023 08:19
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.

2 participants