[vlc-devel] [PATCH 12/21] Convert utils.c to C++

Martin Storsjö martin at martin.st
Mon Sep 5 14:31:16 CEST 2011


This is necessary for using IOMX, which is a C++ API.
---
 modules/codec/omxil/Modules.am             |    2 +-
 modules/codec/omxil/{utils.c => utils.cpp} |   23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
 rename modules/codec/omxil/{utils.c => utils.cpp} (98%)

diff --git a/modules/codec/omxil/Modules.am b/modules/codec/omxil/Modules.am
index 5941515..a14edd8 100644
--- a/modules/codec/omxil/Modules.am
+++ b/modules/codec/omxil/Modules.am
@@ -1,3 +1,3 @@
-SOURCES_omxil = omxil.cpp utils.c omxil.h omxil_utils.h \
+SOURCES_omxil = omxil.cpp utils.cpp omxil.h omxil_utils.h \
 	OMX_Component.h OMX_Core.h OMX_Image.h OMX_IVCommon.h OMX_Types.h \
         OMX_Audio.h OMX_Index.h OMX_Other.h OMX_Video.h
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.cpp
similarity index 98%
rename from modules/codec/omxil/utils.c
rename to modules/codec/omxil/utils.cpp
index 8155a6f..6d6b590 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.cpp
@@ -24,6 +24,7 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#define __STDC_CONSTANT_MACROS
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -51,7 +52,7 @@ OMX_ERRORTYPE PostOmxEvent(decoder_t *p_dec, OMX_EVENTTYPE event,
     decoder_sys_t *p_sys = p_dec->p_sys;
     OmxEvent *p_event;
 
-    p_event = malloc(sizeof(OmxEvent));
+    p_event = (OmxEvent*) malloc(sizeof(OmxEvent));
     if(!p_event) return OMX_ErrorInsufficientResources;
 
     p_event->event = event;
@@ -290,10 +291,10 @@ const char *ErrorToString(OMX_ERRORTYPE error)
 
     if(error == OMX_ErrorNone) return "OMX_ErrorNone";
 
-    error -= OMX_ErrorInsufficientResources;
+    error = (OMX_ERRORTYPE) ((int) error - OMX_ErrorInsufficientResources);
 
     if((unsigned int)error > sizeof(psz_names)/sizeof(char*)-1)
-        error = (OMX_STATETYPE)(sizeof(psz_names)/sizeof(char*)-1);
+        error = (OMX_ERRORTYPE)(sizeof(psz_names)/sizeof(char*)-1);
     return psz_names[error];
 }
 
@@ -320,7 +321,7 @@ static const struct
     { VLC_CODEC_RV20, OMX_VIDEO_CodingRV,    "video_decoder.rv"    },
     { VLC_CODEC_RV30, OMX_VIDEO_CodingRV,    "video_decoder.rv"    },
     { VLC_CODEC_RV40, OMX_VIDEO_CodingRV,    "video_decoder.rv"    },
-    { 0, 0, 0 }
+    { 0, (OMX_VIDEO_CODINGTYPE) 0, 0 }
 };
 
 static const struct
@@ -335,7 +336,7 @@ static const struct
     { VLC_CODEC_AMR_WB, OMX_AUDIO_CodingAMR, "audio_decoder.amr" },
     { VLC_CODEC_MP4A,   OMX_AUDIO_CodingAAC, "audio_decoder.aac" },
     { VLC_CODEC_S16N,   OMX_AUDIO_CodingPCM, "audio_decoder.pcm" },
-    { 0, 0, 0 }
+    { 0, (OMX_AUDIO_CODINGTYPE) 0, 0 }
 };
 
 static const struct
@@ -358,7 +359,7 @@ static const struct
     { VLC_CODEC_RV20, OMX_VIDEO_CodingRV,    "video_encoder.rv"    },
     { VLC_CODEC_RV30, OMX_VIDEO_CodingRV,    "video_encoder.rv"    },
     { VLC_CODEC_RV40, OMX_VIDEO_CodingRV,    "video_encoder.rv"    },
-    { 0, 0, 0 }
+    { 0, (OMX_VIDEO_CODINGTYPE) 0, 0 }
 };
 
 static const struct
@@ -373,7 +374,7 @@ static const struct
     { VLC_CODEC_AMR_WB, OMX_AUDIO_CodingAMR, "audio_encoder.amr" },
     { VLC_CODEC_MP4A,   OMX_AUDIO_CodingAAC, "audio_encoder.aac" },
     { VLC_CODEC_S16N,   OMX_AUDIO_CodingPCM, "audio_encoder.pcm" },
-    { 0, 0, 0 }
+    { 0, (OMX_AUDIO_CODINGTYPE) 0, 0 }
 };
 
 static const struct
@@ -389,12 +390,12 @@ static const struct
     { VLC_CODEC_I420, OMX_COLOR_FormatYUV420Planar, 3, 1, 2 },
     { VLC_CODEC_I420, OMX_COLOR_FormatYUV420PackedPlanar, 3, 1, 2 },
     { VLC_CODEC_I420, OMX_COLOR_FormatYUV420SemiPlanar, 3, 1, 2 },
-    { VLC_CODEC_I420, OMX_QCOM_COLOR_FormatYVU420SemiPlanar, 3, 1, 2 },
+    { VLC_CODEC_I420, (OMX_COLOR_FORMATTYPE) OMX_QCOM_COLOR_FormatYVU420SemiPlanar, 3, 1, 2 },
     { VLC_CODEC_YUYV, OMX_COLOR_FormatYCbYCr, 4, 2, 0 },
     { VLC_CODEC_YVYU, OMX_COLOR_FormatYCrYCb, 4, 2, 0 },
     { VLC_CODEC_UYVY, OMX_COLOR_FormatCbYCrY, 4, 2, 0 },
     { VLC_CODEC_VYUY, OMX_COLOR_FormatCrYCbY, 4, 2, 0 },
-    { 0, 0, 0, 0, 0 }
+    { 0, (OMX_COLOR_FORMATTYPE) 0, 0, 0, 0 }
 };
 
 int GetOmxVideoFormat( vlc_fourcc_t i_fourcc,
@@ -602,7 +603,7 @@ static const struct {
       sizeof(OMX_AUDIO_PARAM_WMATYPE) },
     { OMX_AUDIO_CodingRA, OMX_IndexParamAudioRa,
       sizeof(OMX_AUDIO_PARAM_RATYPE) },
-    { OMX_AUDIO_CodingUnused, 0, 0 }
+    { OMX_AUDIO_CodingUnused, (OMX_INDEXTYPE) 0, 0 }
 };
 
 static OMX_INDEXTYPE GetAudioParamFormatIndex(OMX_AUDIO_CODINGTYPE encoding)
@@ -853,7 +854,7 @@ void PrintOmx(decoder_t *p_dec, OMX_HANDLETYPE omx_handle, OMX_U32 i_port)
 
     for(i = 0; i < 3; i++)
     {
-        omx_error = OMX_GetParameter(omx_handle, OMX_IndexParamAudioInit + i, &param);
+        omx_error = OMX_GetParameter(omx_handle, (OMX_INDEXTYPE) (OMX_IndexParamAudioInit + i), &param);
         if(omx_error != OMX_ErrorNone) continue;
 
         if(i_port == OMX_ALL)
-- 
1.7.2.5




More information about the vlc-devel mailing list