st/omx: always advertise all components
authorChristian König <christian.koenig@amd.com>
Sat, 1 Mar 2014 11:31:20 +0000 (12:31 +0100)
committerChristian König <christian.koenig@amd.com>
Mon, 3 Mar 2014 17:22:38 +0000 (18:22 +0100)
omx_component_library_Setup should return all entrypoints the library
implements, independent of what is available on the current hardware.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74944

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
src/gallium/state_trackers/omx/entrypoint.c
src/gallium/state_trackers/omx/vid_enc.c

index 52b2495dd9986407dff5f686d1491ee30c9b9662..d6f149e623eaadf95dd1744f883907c059a80490 100644 (file)
@@ -51,21 +51,22 @@ static unsigned omx_usecount = 0;
 int omx_component_library_Setup(stLoaderComponentType **stComponents)
 {
    OMX_ERRORTYPE r;
+   unsigned i = 0;
 
    if (stComponents == NULL)
       return 2;
 
    /* component 0 - video decoder */
-   r = vid_dec_LoaderComponent(stComponents[0]);
-   if (r != OMX_ErrorNone)
-      return r;
+   r = vid_dec_LoaderComponent(stComponents[i]);
+   if (r == OMX_ErrorNone)
+      ++i;
 
    /* component 1 - video encoder */
-   r = vid_enc_LoaderComponent(stComponents[1]);
-   if (r != OMX_ErrorNone)
-      return r;
+   r = vid_enc_LoaderComponent(stComponents[i]);
+   if (r == OMX_ErrorNone)
+      ++i;
 
-   return 2;
+   return i;
 }
 
 struct vl_screen *omx_get_screen(void)
index 3f1d01c6eca40ef9ec11ff7a2a7003d28e3528a5..993ff5739b7a411fdf08d271edc4d8570fd35315 100644 (file)
@@ -95,53 +95,38 @@ static void vid_enc_name_avc(char str[OMX_MAX_STRINGNAME_SIZE])
 
 OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
 {
-   struct vl_screen *vscreen = omx_get_screen();
-   struct pipe_screen *screen = vscreen ? vscreen->pscreen : NULL;
-
-   if (!screen)
-      return OMX_ErrorInsufficientResources;
-
    comp->componentVersion.s.nVersionMajor = 0;
    comp->componentVersion.s.nVersionMinor = 0;
    comp->componentVersion.s.nRevision = 0;
    comp->componentVersion.s.nStep = 1;
+   comp->name_specific_length = 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;
-
-   omx_put_screen();
-
    comp->name = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
    if (!comp->name)
       return OMX_ErrorInsufficientResources;
 
    vid_enc_name(comp->name);
 
-   comp->name_specific = CALLOC(comp->name_specific_length, sizeof(char *));
+   comp->name_specific = CALLOC(1, sizeof(char *));
    if (!comp->name_specific)
       goto error_arrays;
 
-   comp->role_specific = CALLOC(comp->name_specific_length, sizeof(char *));
+   comp->role_specific = CALLOC(1, sizeof(char *));
    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;
 
@@ -189,6 +174,10 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
       return OMX_ErrorInsufficientResources;
 
    screen = priv->screen->pscreen;
+   if (!screen->get_video_param(screen, PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH,
+                                PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_SUPPORTED))
+      return OMX_ErrorBadParameter;
    priv->s_pipe = screen->context_create(screen, priv->screen);
    if (!priv->s_pipe)
       return OMX_ErrorInsufficientResources;