[Mesa-dev] [PATCH 3/3] omx: do not assume that everyone can do bitstream h264 and mpeg12

Emil Velikov emil.l.velikov at gmail.com
Sat Feb 15 11:30:23 PST 2014


 - Bail out early (return 0 components) if there is no
decoder
 - Check if the driver supports the bitstream XXX decoder
before using it.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---

Two issues with first one open to suggestions
 - API does not state what one should do if their
driver support only encoding. I've decided just to
bail out, as I'm not sure how sane the implementation
using the driver is.

 - Some drivers could be ok with bitstream h264 but
not with bitstream mpeg12 (and vice versa). While
there is no such examples currently, it would make
sense to use the VL API and check before forcing the
driver to do something it cannot. ~20 lines of code
that can save some headaches.

*Pardon for the long explanation

-Emil


 src/gallium/state_trackers/omx/entrypoint.c | 18 +++++++++++++++++-
 src/gallium/state_trackers/omx/vid_dec.c    | 20 ++++++++++++++------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/omx/entrypoint.c b/src/gallium/state_trackers/omx/entrypoint.c
index fa654ba..577e394 100644
--- a/src/gallium/state_trackers/omx/entrypoint.c
+++ b/src/gallium/state_trackers/omx/entrypoint.c
@@ -53,7 +53,23 @@ int omx_component_library_Setup(stLoaderComponentType **stComponents)
    struct vl_screen *vscreen = omx_get_screen();
    struct pipe_screen *screen = vscreen ? vscreen->pscreen : NULL;
    OMX_ERRORTYPE r;
-   int num_components = 1;
+   int num_components = 0;
+
+   /*
+    * Check if the driver supports bitstream mpeg12 or h264 decoding.
+    */
+   if (screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG2_MAIN,
+                               PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+                               PIPE_VIDEO_CAP_SUPPORTED) ||
+       screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
+                               PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+                               PIPE_VIDEO_CAP_SUPPORTED)) {
+     num_components++;
+   }
+
+   /* Do not check for encoder if there is no decoder. Just return 0 components */
+   if (!num_components)
+      return 0;
 
    /*
     * Increment the number of components if the driver supports
diff --git a/src/gallium/state_trackers/omx/vid_dec.c b/src/gallium/state_trackers/omx/vid_dec.c
index e2a2891..fdcd95f 100644
--- a/src/gallium/state_trackers/omx/vid_dec.c
+++ b/src/gallium/state_trackers/omx/vid_dec.c
@@ -166,13 +166,21 @@ static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
 
    priv->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
 
-   vid_dec_name_mpeg2(tmpstr);
-   if (!strcmp(name, tmpstr))
-      priv->profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
+   if (screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG2_MAIN,
+                               PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+                               PIPE_VIDEO_CAP_SUPPORTED)) {
+      vid_dec_name_mpeg2(tmpstr);
+      if (!strcmp(name, tmpstr))
+         priv->profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
+   }
 
-   vid_dec_name_avc(tmpstr);
-   if (!strcmp(name, tmpstr))
-      priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
+   if (screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
+                               PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+                               PIPE_VIDEO_CAP_SUPPORTED)) {
+      vid_dec_name_avc(tmpstr);
+      if (!strcmp(name, tmpstr))
+         priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
+   }
 
    priv->BufferMgmtCallback = vid_dec_FrameDecoded;
    priv->messageHandler = vid_dec_MessageHandler;
-- 
1.8.5.5



More information about the mesa-dev mailing list