What is the right way to do ?
I have a video pipeline and I use an appsink to copy the buffer to create a new texture , this new texture is being render in the GUI context.
The question is there a better way to do it ?
How to prevent the copy of the frame ?
(I’m running on Nvidia and I add a nvvidconv to move the buffer from NVMM to CPU), that is a lot of copies.
processing → pipeline → appsink
!
!
!
gui_app <-------------- create texture
(create window, (with copy of frame data)
create GL context) !
swap buffers
void gui_update_video_texture(GstCapture* capture) {
if (!capture || !capture->video_out_appsink) return;
nvtxRangePush("Video Texture Update");
GstSample *videosample = gst_app_sink_try_pull_sample(
GST_APP_SINK(capture->video_out_appsink), 1 * GST_MSECOND);
if (videosample) {
nvtxRangePush("Video Buffer Processing");
GstBuffer *videobuf = gst_sample_get_buffer(videosample);
GstMapInfo map;
if (gst_buffer_map(videobuf, &map, GST_MAP_READ)) {
glBindTexture(GL_TEXTURE_2D, g_gui_state.videotex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1280, 720, 0, GL_RGBA,
GL_UNSIGNED_BYTE, map.data);
gst_buffer_unmap(videobuf, &map);
}
gst_sample_unref(videosample);
nvtxRangePop();
}
nvtxRangePop();
}