gpalsingh / mesa

Mesa 3D graphics library (mirror; no pull requests here please)
http://mesa3d.org
4 stars 0 forks source link

Release video buffer #7

Closed gpalsingh closed 7 years ago

gpalsingh commented 7 years ago

The code for releasing allocated buffers is commented out as of now https://github.com/gpalsingh/mesa/blob/gsoc-dev/src/gallium/state_trackers/omx_tizonia/h264dprc.c#L78

Not sure if it is possible or is even needed since the dec works.

CapOM commented 7 years ago

I think you just need to call video_buffer->destroy(video_buffer) in hash_table_clear_item_callback. This is useful when restarting the pipeline or for resolution change so that we do not leak bigs images :)

gpalsingh commented 7 years ago

Made the changes in https://github.com/gpalsingh/mesa/commit/5ee3bf329eb98fb9b9f623cfa1a94e01a49a02ad

It clears the video but I the error

*** Error in `/home/gpalsingh/gst/master/gstreamer/tools/.libs/lt-gst-launch-1.0': corrupted double-linked list: 0x00007f81d8128300 ***

Also while debugging I see that four eglimages are registered. egl_image_validation_hook is called 5 times and returns OMX_TRUE all times. This might be related to this since we were expecting 4 eglimages?

CapOM commented 7 years ago

I double check and 5 looks correct because:

min is 1 here https://github.com/gpalsingh/gst-omx/blob/tizonia-dev/omx/gstomxvideodec.c#L608 in min + port->port_def.nBufferCountMin because of gstgl requires set it as 1 here: https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst-libs/gst/gl/gstglupload.c#n398 And port->port_def.nBufferCountMin is 4 as set here: https://github.com/gpalsingh/mesa/blob/gsoc-dev/src/gallium/state_trackers/omx_tizonia/h264d.h#L16

But this would lead to 5 registered eglimage so this needs more digging if you see only 4.

Could you debug around "min = MAX (min + port->port_def.nBufferCountMin, 4);" in gstomxvideodec.c and check what is the value for each var ?

gpalsingh commented 7 years ago

Ah that looks right because I see 5 too. So there might be some error in clearing the video buffers that leads to crash.

CapOM commented 7 years ago

Same question here, does it happen with and without tee element ?

gpalsingh commented 7 years ago

The crash doesn't happen while using tee. Gst pipeline: MESA_ENABLE_OMX_EGLIMAGE=1 GST_GL_API=gles2 GST_GL_PLATFORM=egl gst-launch-1.0 filesrc location=~/mp4_tests/10\ Second\ countdown.mp4.mp4 ! qtdemux ! h264parse ! omxh264dectiz ! tee ! glimagesink But removing 'tee' makes the error appear again

CapOM commented 7 years ago

Ah right, my mistake since this code is only for eglimage

CapOM commented 7 years ago

Fixed by https://github.com/CapOM/mesa/commit/377c62d39c9e2d637dd1f1115554458fd5655d4d , please cherry-pick this commit into your branch. We were just passing the texture without incrementing the reference counter. Which results in a double free when terminating the pipeline.

gpalsingh commented 7 years ago

Works too. Thx!