Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

sample decode on-screen rendering fails under ubuntu 19.04 #1396

Closed
dvrogozh opened this issue Apr 26, 2019 · 4 comments · Fixed by #1397
Closed

sample decode on-screen rendering fails under ubuntu 19.04 #1396

dvrogozh opened this issue Apr 26, 2019 · 4 comments · Fixed by #1397

Comments

@dvrogozh
Copy link
Contributor

dvrogozh commented Apr 26, 2019

Install Ubuntu 19.04 and mediasdk coming from the OS:

sudo apt-get install libmfx1 libmfx-tools
sudo apt-get install libva-drm2 libva-x11-2

And run the following sample decode rendering command which will fail:

export LIBVA_DRIVER_NAME=iHD
wget https://fate-suite.libav.org/h264-conformance/AUD_MW_E.264
/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264 -r -f 30

X Error of failed request:  BadAlloc (insufficient resources for operation)
        Major opcode of failed request:  149 ()
        Minor opcode of failed request:  2
        Serial number of failed request:  19
        Current serial number in output stream:  22
dvrogozh added a commit to dvrogozh/MediaSDK that referenced this issue Apr 26, 2019
Fixes: Intel-Media-SDK#1396

In case of X11 DRI3 we try to directly render output surfaces via memory
sharing mechanism. For that we extract DMA buffer handle (file descriptor)
from video surfaces and create XCB pixmap from it, but this operation
might fail since rendering scanout might not be supported for some color
formats we use for media. For example, typically we decode into NV12 which
is not supported for scanouts. Hence the following might fail:
  sample_decode h264 -i input.264 -r -f 30

Before this patch user will see the following error which is not very
descriptive:
  X Error of failed request:  BadAlloc (insufficient resources for operation)
    Major opcode of failed request:  149 ()
    Minor opcode of failed request:  2
    Serial number of failed request:  19
    Current serial number in output stream:  22

After this patch user will get:
  Failed to create xcb pixmap from the NV12 surface: try another
    color format (e.g. RGB4)
  DeliverOutput return error = -6

Which hopefull will lead user trying to run the following command line
which should work assuming scanout from rgb4 is supported (which usually is):
  sample_decode h264 -i input.264 -r -f 30 -rgb4

Signed-off-by: Dmitry Rogozhkin <[email protected]>
@dvrogozh
Copy link
Contributor Author

dvrogozh commented Apr 26, 2019

This is a bad error reporting issue from sample_decode. Effectively sample tried to render NV12 frames via XCB pixmaps. For that it exports DMA file descriptor handle from NV12 frames and creates pixmap. The problem is that not all color formats can be used for rendering scanout. NV12 usually can not, hence pixmap creation just fails. PR #1397 improves error reporting and transforms the above error to:

Failed to create xcb pixmap from the NV12 surface: try another color format (e.g. RGB4)
DeliverOutput return error = -6

As implied by the error message, NV12 simply can not be rendered and color conversion is required. Since this is a sample application, I don't think it is needed to be handled automatically. For the successful rendering we need to run:

/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264 -r -f 30 -rgb4

Mind that NV12->RGB4 color conversion should be supported by underlying VAAPI driver. In case of iHD it is definitely supported by intel-media-va-driver-non-free, but it might not be supported by intel-media-va-driver for some platforms (basically, VP are supported by this driver for ICL+, on BDW, SKL, KBL it is not supported). Hence, before running the above command line, make sure to install intel-media-va-driver-non-free:

sudo apt-get install intel-media-va-driver-non-free
/usr/share/mfx/samples/sample_decode h264 -i AUD_MW_E.264 -r -f 30 -rgb4

intel-media-va-driver-non-free and intel-media-va-driver are distributed under the same license. The difference between them is that the first one includes binary EU shaders while the later one includes EU shaders with available source code.

onabiull pushed a commit that referenced this issue Apr 29, 2019
Fixes: #1396

In case of X11 DRI3 we try to directly render output surfaces via memory
sharing mechanism. For that we extract DMA buffer handle (file descriptor)
from video surfaces and create XCB pixmap from it, but this operation
might fail since rendering scanout might not be supported for some color
formats we use for media. For example, typically we decode into NV12 which
is not supported for scanouts. Hence the following might fail:
  sample_decode h264 -i input.264 -r -f 30

Before this patch user will see the following error which is not very
descriptive:
  X Error of failed request:  BadAlloc (insufficient resources for operation)
    Major opcode of failed request:  149 ()
    Minor opcode of failed request:  2
    Serial number of failed request:  19
    Current serial number in output stream:  22

After this patch user will get:
  Failed to create xcb pixmap from the NV12 surface: try another
    color format (e.g. RGB4)
  DeliverOutput return error = -6

Which hopefull will lead user trying to run the following command line
which should work assuming scanout from rgb4 is supported (which usually is):
  sample_decode h264 -i input.264 -r -f 30 -rgb4

Signed-off-by: Dmitry Rogozhkin <[email protected]>
@dvrogozh
Copy link
Contributor Author

As clarified above, that's bad error reporting behavior of sample decode. It was improved and fix is available in Ubuntu 19.10. Please, consider switching from Ubuntu 19.04 to Ubuntu 19.10 if you are affected by this issue.

@dmitryermilov
Copy link
Contributor

PR #1297 improves error reporting and transforms the above error to:

@dvrogozh , #1297 is about gtest

@dvrogozh
Copy link
Contributor Author

It should be #1397. I'll fix a comment above. Thx.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants