Browse Source

omx-il: strictly treat building warning as error and fix warning

Signed-off-by: Andy Hu <andy.hu@starfivetech.com>
Andy Hu 2 years ago
parent
commit
796aab84e6

+ 4 - 6
soft_3rdpart/omx-il/Makefile

@@ -38,10 +38,10 @@ INCLUDES += -I$(STAGING_DIR)/usr/include/
 #mjpeg
 INCLUDES += -I./component/image/common
 
-CFLAGS  += -g -I. -Wno-implicit-function-declaration -Wno-format -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
+CFLAGS  += -g -I. $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
 CFLAGS  += -fpic
 ARFLAGS += cru
-LDFLAGS = -ldl -lpthread
+LDFLAGS = -ldl -lpthread -Wl,--fatal-warning
 LDFLAGS_FFMPEG = -lavformat -lavcodec -lavutil -lswresample
 
 OBJDIR=obj
@@ -82,7 +82,7 @@ OBJECTPATHS_MJPEG_DEC_TEST=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_MJPEG_D
 all: omx-il
 
 omx-il: CREATE_DIR $(OBJECTPATHS_COMMON)
-	$(CC) -g -fPIC -shared -o libsf-omx-il.so $(LDFLAGS) $(OBJECTPATHS_COMMON)
+	$(CC) -g -fPIC -shared -o libsf-omx-il.so $(OBJECTPATHS_COMMON)
 
 test: video-dec-test video-enc-test mjpeg-dec-test
 
@@ -101,6 +101,4 @@ CREATE_DIR:
 	-mkdir -p $(OBJDIR)
 
 obj/%.o: %.c $(MAKEFILE)
-	$(CC) $(CFLAGS) -Wall -c $< -o $@ -MD -MF $(@:.o=.dep)
-
-
+	$(CC) $(CFLAGS) -Wall -Werror -c $< -o $@ -MD -MF $(@:.o=.dep)

+ 7 - 4
soft_3rdpart/omx-il/component/image/common/SF_OMX_mjpeg_common.h

@@ -132,10 +132,13 @@ extern "C"
 {
 #endif
 
-    OMX_ERRORTYPE GetStateMjpegCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
-    OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *hComponent);
-    OMX_U8* AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeBytes);
-    void GetMpegfunctions(SF_CODAJ12_FUNCTIONS *funcs, OMX_PTR *sohandle);
+OMX_ERRORTYPE GetStateMjpegCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
+OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *hComponent);
+OMX_BOOL AttachOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8* pBuffer, OMX_U32 nSizeBytes);
+OMX_U8* AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeBytes);
+OMX_ERRORTYPE CreateThread(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument);
+void ThreadExit(void *value_ptr);
+void CodaJ12FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPortNumber);
 
 #ifdef __cplusplus
 }

+ 1 - 0
soft_3rdpart/omx-il/component/image/dec/SF_OMX_Mjpeg_decoder.c

@@ -4,6 +4,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include "SF_OMX_mjpeg_common.h"
 #include "SF_OMX_Core.h"

+ 1 - 1
soft_3rdpart/omx-il/core/SF_OMX_Core.c

@@ -351,7 +351,7 @@ void SF_LogMsg(int level, const char *function, int line, const char *format, ..
         break;
     }
     gettimeofday(&tv, NULL);
-    printf("[%06d:%06d]%10s%32s%10d\t", tv.tv_sec, tv.tv_usec, prefix, function, line);
+    printf("[%06ld:%06ld]%10s%32s%10d\t", tv.tv_sec, tv.tv_usec, prefix, function, line);
     va_start(ptr, format);
     vprintf(format, ptr);
     va_end(ptr);

+ 8 - 5
soft_3rdpart/omx-il/core/SF_OMX_Core.h

@@ -27,6 +27,7 @@ enum
     SF_LOG_ALL,
 };
 void SF_LogMsg(int level, const char *function, int line, const char *format, ...);
+void SF_LogMsgAppend(int level, const char *format, ...);
 #define LOG(level, ...) SF_LogMsg(level, __FUNCTION__, __LINE__, __VA_ARGS__);
 #define LOG_APPEND(level, ...) SF_LogMsgAppend(level, __VA_ARGS__);
 #define FunctionIn() SF_LogMsg(SF_LOG_DEBUG, __FUNCTION__, __LINE__, "FUN IN\r\n");
@@ -98,11 +99,13 @@ typedef struct _SF_PORT_PRIVATE
 extern "C"
 {
 #endif
-    
-    OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr);
-    OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
-    OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
-    OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent);
+
+int GetNumberOfComponent();
+OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr);
+OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
+OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
+OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent);
+
 #ifdef __cplusplus
 }
 #endif

+ 8 - 6
soft_3rdpart/omx-il/tests/dec_test.c

@@ -3,6 +3,7 @@
  * Copyright (C) 2021 StarFive Technology Co., Ltd.
  */
 #include <stdio.h>
+#include <unistd.h>
 #include <signal.h>
 #include <getopt.h>
 #include <fcntl.h>
@@ -169,7 +170,8 @@ static OMX_S32 FillInputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFERH
         }
         else
         {
-            printf("%s:%d failed to av_read_frame error(0x%08x)\n", __FUNCTION__, __LINE__, error);
+            printf("%s:%d failed to av_read_frame, error: %s\n",
+                    __FUNCTION__, __LINE__, av_err2str(error));
             return 0;
         }
     }
@@ -262,16 +264,16 @@ int main(int argc, char **argv)
     printf("avformat_open_input\r\n");
     if ((error = avformat_open_input(&avContext, decodeTestContext->sInputFilePath, fmt, NULL)))
     {
-        printf("%s:%d failed to av_open_input_file error(%d), %s\n",
-               __FILE__, __LINE__, error, decodeTestContext->sInputFilePath);
+        printf("%s:%d failed to av_open_input_file error(%s), %s\n",
+               __FILE__, __LINE__, av_err2str(error), decodeTestContext->sInputFilePath);
         return -1;
     }
 
     printf("avformat_find_stream_info\r\n");
     if ((error = avformat_find_stream_info(avContext, NULL)) < 0)
     {
-        printf("%s:%d failed to avformat_find_stream_info. error(%d)\n",
-               __FUNCTION__, __LINE__, error);
+        printf("%s:%d failed to avformat_find_stream_info. error(%s)\n",
+               __FUNCTION__, __LINE__, av_err2str(error));
         return -1;
     }
 
@@ -282,7 +284,7 @@ int main(int argc, char **argv)
         printf("%s:%d failed to av_find_best_stream.\n", __FUNCTION__, __LINE__);
         return -1;
     }
-    printf("video index = %d\r\n", videoIndex);
+    printf("video index = %ld\r\n", videoIndex);
     decodeTestContext->avContext = avContext;
     /*get video info*/
     codecParameters = avContext->streams[videoIndex]->codecpar;

+ 1 - 0
soft_3rdpart/omx-il/tests/enc_test.c

@@ -3,6 +3,7 @@
  * Copyright (C) 2021 StarFive Technology Co., Ltd.
  */
 #include <stdio.h>
+#include <unistd.h>
 #include <signal.h>
 #include <getopt.h>
 #include <fcntl.h>

+ 12 - 10
soft_3rdpart/omx-il/tests/mjpeg_dec_test.c

@@ -3,6 +3,7 @@
  * Copyright (C) 2021 StarFive Technology Co., Ltd.
  */
 #include <stdio.h>
+#include <unistd.h>
 #include <signal.h>
 #include <getopt.h>
 #include <fcntl.h>
@@ -75,7 +76,7 @@ static OMX_ERRORTYPE event_handler(
         OMX_GetParameter(pDecodeTestContext->hComponentDecoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
         OMX_U32 nOutputBufferSize = pOutputPortDefinition.nBufferSize;
         OMX_U32 nOutputBufferCount = pOutputPortDefinition.nBufferCountMin;
-        printf("allocate %d output buffers size %d\r\n", nOutputBufferCount, nOutputBufferSize);
+        printf("allocate %lu output buffers size %lu\r\n", nOutputBufferCount, nOutputBufferSize);
         for (int i = 0; i < nOutputBufferCount; i++)
         {
             OMX_BUFFERHEADERTYPE *pBuffer = NULL;
@@ -179,14 +180,15 @@ static OMX_S32 FillInputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFERH
         }
         else
         {
-            printf("%s:%d failed to av_read_frame error(0x%08x)\n", __FUNCTION__, __LINE__, error);
+            printf("%s:%d failed to av_read_frame, error: %s\n",
+                    __FUNCTION__, __LINE__, av_err2str(error));
             return 0;
         }
     }
     pInputBuffer->nFlags = 0x10;
     pInputBuffer->nFilledLen = avpacket.size;
     memcpy(pInputBuffer->pBuffer, avpacket.data, avpacket.size);
-    printf("%s, address = %p, size = %d, flag = %x\r\n", 
+    printf("%s, address = %p, size = %lu, flag = %lx\r\n",
         __FUNCTION__, pInputBuffer->pBuffer, pInputBuffer->nFilledLen, pInputBuffer->nFlags);
     return avpacket.size;
 }
@@ -326,16 +328,16 @@ int main(int argc, char **argv)
     printf("avformat_open_input\r\n");
     if ((error = avformat_open_input(&avContext, decodeTestContext->sInputFilePath, fmt, NULL)))
     {
-        printf("%s:%d failed to av_open_input_file error(%d), %s\n",
-               __FILE__, __LINE__, error, decodeTestContext->sInputFilePath);
+        printf("%s:%d failed to av_open_input_file error(%s), %s\n",
+               __FILE__, __LINE__, av_err2str(error), decodeTestContext->sInputFilePath);
         return -1;
     }
 
     printf("avformat_find_stream_info\r\n");
     if ((error = avformat_find_stream_info(avContext, NULL)) < 0)
     {
-        printf("%s:%d failed to avformat_find_stream_info. error(%d)\n",
-               __FUNCTION__, __LINE__, error);
+        printf("%s:%d failed to avformat_find_stream_info. error(%s)\n",
+               __FUNCTION__, __LINE__, av_err2str(error));
         return -1;
     }
 
@@ -346,7 +348,7 @@ int main(int argc, char **argv)
         printf("%s:%d failed to av_find_best_stream.\n", __FUNCTION__, __LINE__);
         return -1;
     }
-    printf("image index = %d\r\n", imageIndex);
+    printf("image index = %lu\r\n", imageIndex);
     decodeTestContext->avContext = avContext;
     /*get image info*/
     codecParameters = avContext->streams[imageIndex]->codecpar;
@@ -540,13 +542,13 @@ int main(int argc, char **argv)
         {
             OMX_BUFFERHEADERTYPE *pBuffer = data.pBuffer;
             OMX_STRING sFilePath = decodeTestContext->sOutputFilePath;
-            printf("write %d buffers to file\r\n", pBuffer->nFilledLen);
+            printf("write %lu buffers to file\r\n", pBuffer->nFilledLen);
             FILE *fb = fopen(sFilePath, "ab+");
             size_t size = fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, fb);
             int error = ferror(fb);
             printf("write error = %d\r\n", error);
             fclose(fb);
-            printf("write %d buffers finish\r\n", size);
+            printf("write %lu buffers finish\r\n", size);
             if ((pBuffer->nFlags) & (OMX_BUFFERFLAG_EOS == OMX_BUFFERFLAG_EOS))
             {
                 goto end;