[Mesa-dev] [PATCH 18/26] st/omx: avoid using dynamic vid_(enc|dec)_base and avc_(name|role)
Emil Velikov
emil.l.velikov at gmail.com
Thu Jun 12 12:56:38 PDT 2014
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.
Cc: Leo Liu <leo.liu at amd.com>
Cc: Christian König <christian.koenig at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/gallium/state_trackers/omx/vid_dec.c | 69 +++++---------------------------
src/gallium/state_trackers/omx/vid_dec.h | 6 +--
src/gallium/state_trackers/omx/vid_enc.c | 33 ++-------------
src/gallium/state_trackers/omx/vid_enc.h | 4 +-
4 files changed, 18 insertions(+), 94 deletions(-)
diff --git a/src/gallium/state_trackers/omx/vid_dec.c b/src/gallium/state_trackers/omx/vid_dec.c
index de1c3825..4442c5c 100644
--- a/src/gallium/state_trackers/omx/vid_dec.c
+++ b/src/gallium/state_trackers/omx/vid_dec.c
@@ -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;
diff --git a/src/gallium/state_trackers/omx/vid_dec.h b/src/gallium/state_trackers/omx/vid_dec.h
index d6c35b5..9acf872 100644
--- a/src/gallium/state_trackers/omx/vid_dec.h
+++ b/src/gallium/state_trackers/omx/vid_dec.h
@@ -50,12 +50,12 @@
#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;
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index d16fa01..c9976cc 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -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;
}
diff --git a/src/gallium/state_trackers/omx/vid_enc.h b/src/gallium/state_trackers/omx/vid_enc.h
index 47e4b96..ca6ee91 100644
--- a/src/gallium/state_trackers/omx/vid_enc.h
+++ b/src/gallium/state_trackers/omx/vid_enc.h
@@ -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
--
1.9.3
More information about the mesa-dev
mailing list