[Mesa-dev] [PATCHv3 1/3] omx: query driver encode capability at omx_component_library_Setup

Emil Velikov emil.l.velikov at gmail.com
Sun Feb 16 04:40:01 PST 2014


... and report second component only when the driver supports h264 encode.

v2: Drop if (name_specific_length) conditional.
v3: Reword comment and commit message.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/state_trackers/omx/entrypoint.c | 14 ++++++++++++--
 src/gallium/state_trackers/omx/vid_enc.c    | 25 +++++++++----------------
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/gallium/state_trackers/omx/entrypoint.c b/src/gallium/state_trackers/omx/entrypoint.c
index 52b2495..9187f13 100644
--- a/src/gallium/state_trackers/omx/entrypoint.c
+++ b/src/gallium/state_trackers/omx/entrypoint.c
@@ -50,10 +50,20 @@ static unsigned omx_usecount = 0;
 
 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;
+
+   /* Provide a component only when the driver supports h264 encoding. */
+   if (screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
+                               PIPE_VIDEO_ENTRYPOINT_ENCODE,
+                               PIPE_VIDEO_CAP_SUPPORTED)) {
+      num_components++;
+   }
 
    if (stComponents == NULL)
-      return 2;
+      return num_components;
 
    /* component 0 - video decoder */
    r = vid_dec_LoaderComponent(stComponents[0]);
@@ -65,7 +75,7 @@ int omx_component_library_Setup(stLoaderComponentType **stComponents)
    if (r != OMX_ErrorNone)
       return r;
 
-   return 2;
+   return num_components;
 }
 
 struct vl_screen *omx_get_screen(void)
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index 6e65274..564f5b6 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -106,12 +106,7 @@ OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
    comp->componentVersion.s.nRevision = 0;
    comp->componentVersion.s.nStep = 1;
    comp->constructor = vid_enc_Constructor;
-
-   if (screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
-			       PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_SUPPORTED))
-      comp->name_specific_length = 1;
-   else
-      comp->name_specific_length = 0;
+   comp->name_specific_length = 1;
 
    omx_put_screen();
 
@@ -129,19 +124,17 @@ OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
    if (!comp->role_specific)
       goto error_arrays;
 
-   if (comp->name_specific_length) {
-      comp->name_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-      if (!comp->name_specific[0])
-         goto error_specific;
+   comp->name_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
+   if (!comp->name_specific[0])
+      goto error_specific;
 
-      vid_enc_name_avc(comp->name_specific[0]);
+   vid_enc_name_avc(comp->name_specific[0]);
 
-      comp->role_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-      if (!comp->role_specific[0])
-         goto error_specific;
+   comp->role_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
+   if (!comp->role_specific[0])
+      goto error_specific;
 
-      strcpy(comp->role_specific[0], OMX_VID_ENC_AVC_ROLE);
-   }
+   strcpy(comp->role_specific[0], OMX_VID_ENC_AVC_ROLE);
 
    return OMX_ErrorNone;
 
-- 
1.9.0



More information about the mesa-dev mailing list