st/omx: avoid using dynamic vid_(enc|dec)_base and avc_(name|role)
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 10 Jun 2014 01:14:18 +0000 (02:14 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 26 Jun 2014 13:05:12 +0000 (14:05 +0100)
Strictly speaking we should not have done this in the
first place, as all of the above should be static across
the system.

Currently this may cause some minor issues, which will be
resolved in the following patches, by providing a single
library for the OMX api.

Cleanup a few unneeded strcpy cases while we're around.

Note: Make sure to rebuild the .omxregister file, by executing
   $ omxregister-bellagio

If you have more than one omx library (libomx-radeonsi, libomx-r600),
make sure to temporary move the unused one. By the end of the series
there will be only one library that will be used for all hardware -
r600, radeonsi and nouveau.

Cc: Leo Liu <leo.liu@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/state_trackers/omx/vid_dec.c
src/gallium/state_trackers/omx/vid_dec.h
src/gallium/state_trackers/omx/vid_enc.c
src/gallium/state_trackers/omx/vid_enc.h

index de1c382..4442c5c 100644 (file)
@@ -64,21 +64,6 @@ static OMX_ERRORTYPE vid_dec_DecodeBuffer(omx_base_PortType *port, OMX_BUFFERHEA
 static OMX_ERRORTYPE vid_dec_FreeDecBuffer(omx_base_PortType *port, OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf);
 static void vid_dec_FrameDecoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE* input, OMX_BUFFERHEADERTYPE* output);
 
-static void vid_dec_name(char str[OMX_MAX_STRINGNAME_SIZE])
-{
-   snprintf(str, OMX_MAX_STRINGNAME_SIZE, OMX_VID_DEC_BASE_NAME, driver_descriptor.name);
-}
-
-static void vid_dec_name_mpeg2(char str[OMX_MAX_STRINGNAME_SIZE])
-{
-   snprintf(str, OMX_MAX_STRINGNAME_SIZE, OMX_VID_DEC_MPEG2_NAME, driver_descriptor.name);
-}
-
-static void vid_dec_name_avc(char str[OMX_MAX_STRINGNAME_SIZE])
-{
-   snprintf(str, OMX_MAX_STRINGNAME_SIZE, OMX_VID_DEC_AVC_NAME, driver_descriptor.name);
-}
-
 OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType *comp)
 {
    comp->componentVersion.s.nVersionMajor = 0;
@@ -87,67 +72,35 @@ OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType *comp)
    comp->componentVersion.s.nStep = 1;
    comp->name_specific_length = 2;
 
-   comp->name = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (comp->name == NULL)
-      goto error;
-
    comp->name_specific = CALLOC(comp->name_specific_length, sizeof(char *));
    if (comp->name_specific == NULL)
       goto error;
 
-   comp->name_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (comp->name_specific[0] == NULL)
-      goto error;
-
-   comp->name_specific[1] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (comp->name_specific[1] == NULL)
-      goto error;
-
    comp->role_specific = CALLOC(comp->name_specific_length, sizeof(char *));
    if (comp->role_specific == NULL)
       goto error;
 
-   comp->role_specific[0] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (comp->role_specific[0] == NULL)
-      goto error;
-
-   comp->role_specific[1] = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (comp->role_specific[1] == NULL)
-      goto error;
-
-   vid_dec_name(comp->name);
-   vid_dec_name_mpeg2(comp->name_specific[0]);
-   vid_dec_name_avc(comp->name_specific[1]);
+   comp->name = OMX_VID_DEC_BASE_NAME;
+   comp->name_specific[0] = OMX_VID_DEC_MPEG2_NAME;
+   comp->name_specific[1] = OMX_VID_DEC_AVC_NAME;
 
-   strcpy(comp->role_specific[0], OMX_VID_DEC_MPEG2_ROLE);
-   strcpy(comp->role_specific[1], OMX_VID_DEC_AVC_ROLE);
+   comp->role_specific[0] = OMX_VID_DEC_MPEG2_ROLE;
+   comp->role_specific[1] = OMX_VID_DEC_AVC_ROLE;
 
    comp->constructor = vid_dec_Constructor;
+
    return OMX_ErrorNone;
 
 error:
 
-   FREE(comp->name);
-
-   if (comp->name_specific) {
-      FREE(comp->name_specific[0]);
-      FREE(comp->name_specific[1]);
-      FREE(comp->name_specific);
-   }
-
-   if (comp->role_specific) {
-      FREE(comp->role_specific[0]);
-      FREE(comp->role_specific[1]);
-      FREE(comp->role_specific);
-   }
+   FREE(comp->name_specific);
+   FREE(comp->role_specific);
 
    return OMX_ErrorInsufficientResources;
 }
 
 static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING name)
 {
-   char tmpstr[OMX_MAX_STRINGNAME_SIZE];
    vid_dec_PrivateType *priv;
    omx_base_video_PortType *port;
    struct pipe_screen *screen;
@@ -166,12 +119,10 @@ 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))
+   if (!strcmp(name, OMX_VID_DEC_MPEG2_NAME))
       priv->profile = PIPE_VIDEO_PROFILE_MPEG2_MAIN;
 
-   vid_dec_name_avc(tmpstr);
-   if (!strcmp(name, tmpstr))
+   if (!strcmp(name, OMX_VID_DEC_AVC_NAME))
       priv->profile = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
 
    priv->BufferMgmtCallback = vid_dec_FrameDecoded;
index d6c35b5..9acf872 100644 (file)
 #include "os/os_thread.h"
 #include "util/u_double_list.h"
 
-#define OMX_VID_DEC_BASE_NAME "OMX.%s.video_decoder"
+#define OMX_VID_DEC_BASE_NAME "OMX.mesa.video_decoder"
 
-#define OMX_VID_DEC_MPEG2_NAME "OMX.%s.video_decoder.mpeg2"
+#define OMX_VID_DEC_MPEG2_NAME "OMX.mesa.video_decoder.mpeg2"
 #define OMX_VID_DEC_MPEG2_ROLE "video_decoder.mpeg2"
 
-#define OMX_VID_DEC_AVC_NAME "OMX.%s.video_decoder.avc"
+#define OMX_VID_DEC_AVC_NAME "OMX.mesa.video_decoder.avc"
 #define OMX_VID_DEC_AVC_ROLE "video_decoder.avc"
 
 struct vl_vlc;
index db4fc8f..15eeb09 100644 (file)
@@ -96,16 +96,6 @@ static void vid_enc_BufferEncoded(OMX_COMPONENTTYPE *comp, OMX_BUFFERHEADERTYPE*
 
 static void enc_ReleaseTasks(struct list_head *head);
 
-static void vid_enc_name(char str[OMX_MAX_STRINGNAME_SIZE])
-{
-   snprintf(str, OMX_MAX_STRINGNAME_SIZE, OMX_VID_ENC_BASE_NAME, driver_descriptor.name);
-}
-
-static void vid_enc_name_avc(char str[OMX_MAX_STRINGNAME_SIZE])
-{
-   snprintf(str, OMX_MAX_STRINGNAME_SIZE, OMX_VID_ENC_AVC_NAME, driver_descriptor.name);
-}
-
 OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
 {
    comp->componentVersion.s.nVersionMajor = 0;
@@ -115,11 +105,7 @@ OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
    comp->name_specific_length = 1;
    comp->constructor = vid_enc_Constructor;
 
-   comp->name = CALLOC(1, OMX_MAX_STRINGNAME_SIZE);
-   if (!comp->name)
-      return OMX_ErrorInsufficientResources;
-
-   vid_enc_name(comp->name);
+   comp->name = OMX_VID_ENC_BASE_NAME;
 
    comp->name_specific = CALLOC(1, sizeof(char *));
    if (!comp->name_specific)
@@ -129,28 +115,15 @@ OMX_ERRORTYPE vid_enc_LoaderComponent(stLoaderComponentType *comp)
    if (!comp->role_specific)
       goto error_arrays;
 
-   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]);
+   comp->name_specific[0] = OMX_VID_ENC_AVC_NAME;
 
-   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);
+   comp->role_specific[0] = OMX_VID_ENC_AVC_ROLE;
 
    return OMX_ErrorNone;
 
-error_specific:
-   FREE(comp->name_specific[0]);
-   FREE(comp->role_specific[0]);
-
 error_arrays:
    FREE(comp->role_specific);
    FREE(comp->name_specific);
-   FREE(comp->name);
 
    return OMX_ErrorInsufficientResources;
 }
index 47e4b96..ca6ee91 100644 (file)
@@ -46,8 +46,8 @@
 #include "vl/vl_defines.h"
 #include "vl/vl_compositor.h"
 
-#define OMX_VID_ENC_BASE_NAME "OMX.%s.video_encoder"
-#define OMX_VID_ENC_AVC_NAME "OMX.%s.video_encoder.avc"
+#define OMX_VID_ENC_BASE_NAME "OMX.mesa.video_encoder"
+#define OMX_VID_ENC_AVC_NAME "OMX.mesa.video_encoder.avc"
 #define OMX_VID_ENC_AVC_ROLE "video_encoder.avc"
 
 #define OMX_VID_ENC_BITRATE_MIN 64000