summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhongteng <hongteng@google.com>2011-04-22 13:48:46 -0700
committerhongteng <hongteng@google.com>2011-04-22 13:48:46 -0700
commit0a389ab70db304fb840e33f33781ecc0503eae3c (patch)
tree85ef41c9a4b6a32c9647fe81c6330cb110aa94fa
parent3b25fdc4a33b53cfcf67315c2d42ad699b8cefe2 (diff)
downloadframeworks_av-0a389ab70db304fb840e33f33781ecc0503eae3c.zip
frameworks_av-0a389ab70db304fb840e33f33781ecc0503eae3c.tar.gz
frameworks_av-0a389ab70db304fb840e33f33781ecc0503eae3c.tar.bz2
Fix for issue 3385135 "source code cleanup" engine part
- Removed below unused functions a. M4PTO3GPP_RegisterExternalVideoEncoder b. M4VSS3GPP_editRegisterExternalVideoDecoder c. M4VSS3GPP_editRegisterExternalVideoEncoder d. M4VSS3GPP_extractPictureRegisterExternalVideoDecoder e. M4VSS3GPP_editRegisterExternalCodec f. M4VSS3GPP_editSubscribeExternalCodecs g. M4VSS3GPP_intSubscribeExternalCodecs h. M4VSS3GPP_intClipRegisterExternalVideoDecoder i. M4xVSS_RegisterExternalVideoDecoder j. M4xVSS_RegisterExternalVideoEncoder k. M4MCS_registerExternalVideoDecoder l. M4MCS_registerExternalVideoEncoder m. M4MCS_registerExternalAudioDecoder n. M4MCS_registerExternalAudioEncoder o. M4DECODER_EXTERNAL_getInterface - Also remove small code associated with these functions and Remove below unsused src + header files a. M4CLOCK.h b. M4MDP_API.h c. M4VD_EXTERNAL_Internal.h d. M4VD_HW_API.h e. M4VE_API.h f. M4_Logo.h g. M4VD_EXTERNAL_Interface.c h. LV_Types.h i. M4OSA_FileAccess.h j. M4OSA_FileCache.h k. M4OSA_FileExtra.h l. M4OSA_FileReaderRam.h m. M4OSA_FileWriterRam.h n. M4OSA_String.h o. M4OSA_String_priv.h p. M4OSA_FileCache.c q. M4OSA_FileExtra.c r. M4OSA_FileReader_RAM.c s. M4OSA_FileWriter_RAM.c t. M4OSA_String.c u. M4OSA_String_priv.c Change-Id: I7271cbe92168e665a8e5b7afe7c7fe1c331eaa1e
-rwxr-xr-xlibvideoeditor/osal/inc/LV_Types.h78
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_FileAccess.h71
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_FileCache.h69
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_FileExtra.h70
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_FileReaderRam.h75
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_FileWriterRam.h77
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_String.h267
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_String_priv.h101
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_FileCache.c2978
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_FileExtra.c527
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_FileReader_RAM.c419
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_FileWriter_RAM.c448
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_String.c2417
-rwxr-xr-xlibvideoeditor/osal/src/M4OSA_String_priv.c1136
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4CLOCK.h50
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4ENCODER_AudioCommon.h3
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4MDP_API.h430
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h12
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4VD_EXTERNAL_Internal.h119
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4VD_HW_API.h159
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4VE_API.h824
-rwxr-xr-xlibvideoeditor/vss/common/inc/M4_Logo.h30
-rwxr-xr-xlibvideoeditor/vss/inc/M4PTO3GPP_API.h8
-rwxr-xr-xlibvideoeditor/vss/inc/M4PTO3GPP_InternalTypes.h7
-rwxr-xr-xlibvideoeditor/vss/inc/M4VSS3GPP_API.h140
-rwxr-xr-xlibvideoeditor/vss/inc/M4VSS3GPP_InternalFunctions.h11
-rwxr-xr-xlibvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h17
-rwxr-xr-xlibvideoeditor/vss/inc/M4xVSS_API.h44
-rwxr-xr-xlibvideoeditor/vss/inc/M4xVSS_Internal.h14
-rwxr-xr-xlibvideoeditor/vss/mcs/inc/M4MCS_API.h92
-rwxr-xr-xlibvideoeditor/vss/mcs/src/M4MCS_API.c296
-rwxr-xr-xlibvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c944
-rwxr-xr-xlibvideoeditor/vss/src/Android.mk1
-rwxr-xr-xlibvideoeditor/vss/src/M4ChannelCoverter.c2
-rwxr-xr-xlibvideoeditor/vss/src/M4PTO3GPP_API.c96
-rwxr-xr-xlibvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c1
-rwxr-xr-xlibvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c1126
-rwxr-xr-xlibvideoeditor/vss/src/M4VSS3GPP_Clip.c81
-rwxr-xr-xlibvideoeditor/vss/src/M4VSS3GPP_Edit.c602
-rwxr-xr-xlibvideoeditor/vss/src/M4xVSS_API.c77
-rwxr-xr-xlibvideoeditor/vss/src/M4xVSS_internal.c95
41 files changed, 6 insertions, 14008 deletions
diff --git a/libvideoeditor/osal/inc/LV_Types.h b/libvideoeditor/osal/inc/LV_Types.h
deleted file mode 100755
index 5a45182..0000000
--- a/libvideoeditor/osal/inc/LV_Types.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*******************************************************************************
-* @file LV_Types.h
-* @brief Types definition for Smartphone team
-*******************************************************************************/
-
-#ifndef LV_TYPES_H
-#define LV_TYPES_H
-
-/*------------*/
-/* INCLUDES */
-/*------------*/
-#include "M4OSA_Error.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/*--------------------------------------*/
-/* CHARACTER ENCODING CONVERSION FCTS */
-/*--------------------------------------*/
-/******************************************************************************
-*
-* M4OSA_UInt32 (*LV_fromUTF8ToNative_Fct)(const M4OSA_Char* pStart,
-* M4OSA_Void** pOut);
-* @note This function converts a string from UTF8 format which is the default
-* encoding in the engines and application logics to the character encoding
-* supported by the OS or platform. The memory will be allocated within this
-* function and then, caller will have to free *targetStart thanks to free.
-* Both strings must be NULL-terminateed.
-* @param pStart (IN): String to convert.
-* @param pOut (OUT): This pointer will be filled by this function. It contains the
-* string converted to the native format.
-* @return Success: Size in bytes allocated including the NULL character. Failure: 0
-*
-******************************************************************************/
-typedef M4OSA_UInt32 (*LV_fromUTF8ToNative_Fct)(const M4OSA_Char* pStart,
- M4OSA_Void** pOut);
-
-/******************************************************************************
-*
-* M4OSA_UInt32 (*LV_fromNativeToUTF8_Fct)(const M4OSA_Char* pStart,
-* M4OSA_Void** targetStart);
-* @note This function converts a string in the character encoding supported by the
-* OS or platform to from UTF8 format which is the default encoding in the
-* engines and application logics. The memory will be allocated within this
-* function and then, caller will have to free *targetStart thanks to free.
-* Both strings must be NULL-terminateed.
-* @param pStart (IN): String to convert.
-* @param pOut (OUT): This pointer will be filled by this function. It contains the
-* string converted to UTF8 format.
-* @return Success: Size in bytes allocated including the NULL character. Failure: 0
-*
-******************************************************************************/
-typedef M4OSA_UInt32 (*LV_fromNativeToUTF8_Fct)(const M4OSA_Void** pStart,
- M4OSA_Char** pOut);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*--- LV_TYPES_H ---*/
diff --git a/libvideoeditor/osal/inc/M4OSA_FileAccess.h b/libvideoeditor/osal/inc/M4OSA_FileAccess.h
deleted file mode 100755
index 489a981..0000000
--- a/libvideoeditor/osal/inc/M4OSA_FileAccess.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __M4OSA_FILEACESS_H__
-#define __M4OSA_FILEACESS_H__
-
-#include "M4OSA_Types.h"
-#include "M4OSA_Semaphore.h"
-#include "M4OSA_Debug.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- ******************************************************************************
- * struct M4OSA_FilePtrFct
- * @brief Defines the available functions for File read/write.
- ******************************************************************************
-*/
-typedef enum
-{
- M4OSA_FILEINTERFACE_RAM,
- M4OSA_FILEINTERFACE_FFS,
- M4OSA_FILEINTERFACE_OPTIM_FFS
-
-} M4OSA_FileInterface_t;
-
-
-typedef struct
-{
- M4OSA_FileWriterPointer *pFileWriter; /**< Pointer to file writer functions */
- M4OSA_FileReadPointer *pFileReader; /**< Pointer to file reader functions */
-} M4OSA_FilePtrFct;
-
-/*Semaphore for handling of R/W access*/
-extern M4OSA_Context M4OSA_FileInterface_RWsemaphore; /*defined in M4OSA_FileInterface.c*/
-
-/**
- ******************************************************************************
- * func M4_FileInterface_xxx
- * @brief Manage the interface pointers for filesystem access
- ******************************************************************************
-*/
-M4OSA_FilePtrFct* M4_FileInterface_InitPointer(void);
-M4OSA_ERR M4_FileInterface_SelectPointer(M4OSA_FilePtrFct *pFileFctPtr,
- M4OSA_FileInterface_t mode);
-M4OSA_Void M4_FileInterface_FreePointer(M4OSA_FilePtrFct *pFileFctPtr);
-M4OSA_ERR M4OSA_fileReadOpen_optim_SetInterfaceFFS(M4OSA_Context* pContext,
- M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus*/
-
-#endif /* __M4OSA_FILEACESS_H__*/
diff --git a/libvideoeditor/osal/inc/M4OSA_FileCache.h b/libvideoeditor/osal/inc/M4OSA_FileCache.h
deleted file mode 100755
index cb4c2ba..0000000
--- a/libvideoeditor/osal/inc/M4OSA_FileCache.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file M4OSA_FileCache.h
- * @ingroup OSAL
- * @brief Osal File Reader and Writer with cache
- * @note This file implements functions to manipulate
- * filesystem access with intermediate buffers used to
- * read and to write.
- ******************************************************************************
-*/
-
-#ifndef M4OSA_FILECACHE_H
-#define M4OSA_FILECACHE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-M4OSA_ERR M4OSA_fileOpen_cache(M4OSA_Context* pContext,
- M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess);
-M4OSA_ERR M4OSA_fileReadData_cache( M4OSA_Context context,
- M4OSA_MemAddr8 buffer,
- M4OSA_UInt32* size );
-M4OSA_ERR M4OSA_fileWriteData_cache( M4OSA_Context context,
- M4OSA_MemAddr8 buffer,
- M4OSA_UInt32 size );
-M4OSA_ERR M4OSA_fileReadSeek_cache( M4OSA_Context context,
- M4OSA_FileSeekAccessMode seekMode,
- M4OSA_FilePosition* position );
-M4OSA_ERR M4OSA_fileWriteSeek_cache( M4OSA_Context context,
- M4OSA_FileSeekAccessMode seekMode,
- M4OSA_FilePosition* position );
-M4OSA_ERR M4OSA_fileGetOption_cache( M4OSA_Context context,
- M4OSA_OptionID optionID,
- M4OSA_DataOption *optionValue );
-M4OSA_ERR M4OSA_fileSetOption_cache( M4OSA_Context context,
- M4OSA_OptionID optionID,
- M4OSA_DataOption optionValue );
-M4OSA_ERR M4OSA_fileFlush_cache( M4OSA_Context pContext);
-M4OSA_ERR M4OSA_fileClose_cache( M4OSA_Context context );
-
-/* Used in VA */
-M4OSA_ERR M4OSA_fileExtrafTruncate_cache(M4OSA_Context context,
- M4OSA_UInt32 length);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* M4OSA_FILECACHE_H */
diff --git a/libvideoeditor/osal/inc/M4OSA_FileExtra.h b/libvideoeditor/osal/inc/M4OSA_FileExtra.h
deleted file mode 100755
index 0c9bac2..0000000
--- a/libvideoeditor/osal/inc/M4OSA_FileExtra.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/************************************************************************/
-/* */
-/* @file M4OSA_FileExtra.h */
-/* @ingroup OSAL */
-/************************************************************************/
-
-
-#ifndef M4OSA_FILE_EXTRA_H
-#define M4OSA_FILE_EXTRA_H
-
-#include "M4OSA_Types.h"
-#include "M4OSA_Error.h"
-#include "M4OSA_FileCommon.h"
-/* size of the copy buffer (in bytes) for M4OSA_fileExtraCopy */
-#define BUFFER_COPY_SIZE 1024
-
-typedef enum
-{
- M4OSA_TypeInvalid = 0,
- M4OSA_TypeFile,
- M4OSA_TypeDir
-} M4OSA_EntryType;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-M4OSA_ERR M4OSA_fileExtraDelete(const M4OSA_Char* url);
-
-M4OSA_ERR M4OSA_fileExtraCopy(M4OSA_Char* srcUrl, M4OSA_Char* dstUrl);
-
-M4OSA_ERR M4OSA_fileExtraRename(M4OSA_Char* srcUrl, M4OSA_Char* dstUrl);
-
-M4OSA_ERR M4OSA_fileExtraChangeCurrentDir(const M4OSA_Char* url);
-
-M4OSA_ERR M4OSA_fileExtraCreateDir(const M4OSA_Char* pUrl);
-
-M4OSA_ERR M4OSA_fileExtraRemoveDir(const M4OSA_Char* pUrl);
-
-M4OSA_UInt32 M4OSA_fileExtraGetFreeSpace(const M4OSA_Char* pUrl);
-
-M4OSA_UInt32 M4OSA_fileExtraGetTotalSpace(const M4OSA_Char* pUrl);
-
-M4OSA_EntryType M4OSA_fileExtraGetType(const M4OSA_Char* pUrl);
-
-M4OSA_ERR M4OSA_fileExtrafTruncate(M4OSA_Context context, M4OSA_FilePosition length);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*M4OSA_FILE_EXTRA_H*/
-
diff --git a/libvideoeditor/osal/inc/M4OSA_FileReaderRam.h b/libvideoeditor/osal/inc/M4OSA_FileReaderRam.h
deleted file mode 100755
index 0480192..0000000
--- a/libvideoeditor/osal/inc/M4OSA_FileReaderRam.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file M4OSA_FileReaderRam.h
- * @ingroup OSAL
- * @note This file implements functions to read a "file" stored in RAM.
- ******************************************************************************
-*/
-
-
-
-#ifndef M4OSA_FILEREADERRAM_H
-#define M4OSA_FILEREADERRAM_H
-
-#include "M4OSA_FileReader.h"
-
-/**
- ******************************************************************************
- * structure M4FI_FileReaderRam_Descriptor
- * @brief This structure defines the File descriptor (public)
- * @note This structure is used to store the pointer to the data in memory
- * @note and its size
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr8 pFileDesc; /* Pointer on file data */
- M4OSA_Int32 dataSize; /* Size of data */
-} M4OSA_FileReaderRam_Descriptor;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* reader API : RAM functions */
-M4OSA_ERR M4OSA_fileReadRamOpen( M4OSA_Context* context,
- M4OSA_Void* fileDescriptor,
- M4OSA_UInt32 fileModeAccess );
-M4OSA_ERR M4OSA_fileReadRamData( M4OSA_Context context,
- M4OSA_MemAddr8 buffer,
- M4OSA_UInt32* size );
-M4OSA_ERR M4OSA_fileReadRamSeek( M4OSA_Context context,
- M4OSA_FileSeekAccessMode seekMode,
- M4OSA_FilePosition* position );
-M4OSA_ERR M4OSA_fileReadRamClose( M4OSA_Context context );
-M4OSA_ERR M4OSA_fileReadRamGetOption( M4OSA_Context context,
- M4OSA_FileReadOptionID optionID,
- M4OSA_DataOption *optionValue );
-M4OSA_ERR M4OSA_fileReadRamSetOption( M4OSA_Context context,
- M4OSA_FileReadOptionID optionID,
- M4OSA_DataOption optionValue );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*M4OSA_FILEREADERRAM_H*/
-
diff --git a/libvideoeditor/osal/inc/M4OSA_FileWriterRam.h b/libvideoeditor/osal/inc/M4OSA_FileWriterRam.h
deleted file mode 100755
index bc19a05..0000000
--- a/libvideoeditor/osal/inc/M4OSA_FileWriterRam.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file M4OSA_FileWriterRam.h
- * @ingroup OSAL
- * @brief File writer to RAM
- * @note This file implements functions to write a "file" in RAM.
- ******************************************************************************
-*/
-
-
-#ifndef M4OSA_FILEWRITERRAM_H
-#define M4OSA_FILEWRITERRAM_H
-
-#include "M4OSA_FileWriter.h"
-
-
-/**
- ******************************************************************************
- * structure M4OSA_FileWriterRam_Descriptor
- * @brief This structure defines the File descriptor (public)
- * @note This structure is used to store the pointer to the data in memory
- * @note and its size
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr8 pFileDesc; /* Pointer on file data */
- M4OSA_Int32 dataSize; /* Size of data */
-} M4OSA_FileWriterRam_Descriptor;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Writer API : RAM functions */
-M4OSA_ERR M4OSA_fileWriteRamOpen(M4OSA_Context* context,
- M4OSA_Void* fileDescriptor,
- M4OSA_UInt32 fileModeAccess);
-M4OSA_ERR M4OSA_fileWriteRamData(M4OSA_Context context,
- M4OSA_MemAddr8 data,
- M4OSA_UInt32 Size);
-M4OSA_ERR M4OSA_fileWriteRamSeek(M4OSA_Context context,
- M4OSA_FileSeekAccessMode SeekMode,
- M4OSA_FilePosition* position);
-M4OSA_ERR M4OSA_fileWriteRamClose(M4OSA_Context context);
-M4OSA_ERR M4OSA_fileWriteRamFlush(M4OSA_Context context);
-M4OSA_ERR M4OSA_fileWriteRamSetOption(M4OSA_Context context,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption OptionValue);
-M4OSA_ERR M4OSA_fileWriteRamGetOption(M4OSA_Context context,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption* optionValue);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*M4OSA_FILEWRITERRAM_H*/
-
diff --git a/libvideoeditor/osal/inc/M4OSA_String.h b/libvideoeditor/osal/inc/M4OSA_String.h
deleted file mode 100755
index 3fcf4ed..0000000
--- a/libvideoeditor/osal/inc/M4OSA_String.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ************************************************************************
- * @file M4OSA_String.h
- * @ingroup OSAL
- * @brief public definition for string library
- ************************************************************************
-*/
-
-#ifndef _M4OSA_STRING_H_
-#define _M4OSA_STRING_H_
-
-#include "M4OSA_Types.h"
-#include "M4OSA_FileCommon.h"
-#include "M4OSA_Time.h"
-#include "M4OSA_CharStar.h"
-
-
-
-typedef void* M4OSA_String;
-
-typedef enum
-{
- M4OSA_kstrAll = 0,
- M4OSA_kstrBegin,
- M4OSA_kstrEnd
-} M4OSA_strMode;
-
-/* types definition */
-typedef enum
-{
- M4OSA_kstrDec = M4OSA_kchrDec,
- M4OSA_kstrHexa = M4OSA_kchrHexa,
- M4OSA_kstrOct = M4OSA_kchrOct
-} M4OSA_strNumBase;
-
-/* Error and Warnings codes */
-#define M4ERR_STR_BAD_STRING M4OSA_ERR_CREATE(M4_ERR,M4OSA_STRING,0x000001)
-#define M4ERR_STR_CONV_FAILED M4OSA_ERR_CREATE(M4_ERR,M4OSA_STRING,0x000002)
-#define M4ERR_STR_OVERFLOW M4OSA_ERR_CREATE(M4_ERR,M4OSA_STRING,0x000003)
-#define M4ERR_STR_BAD_ARGS M4OSA_ERR_CREATE(M4_ERR,M4OSA_STRING,0x000004)
-
-#define M4WAR_STR_OVERFLOW M4OSA_ERR_CREATE(M4_WAR,M4OSA_STRING,0x000001)
-#define M4WAR_STR_NOT_FOUND M4OSA_ERR_CREATE(M4_WAR,M4OSA_STRING,0x000002)
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCreate( M4OSA_String* pstr);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strReset( M4OSA_String str);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strDestroy( M4OSA_String str);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetCharContent( M4OSA_String str,
- M4OSA_Char* pchar);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetCharContent( M4OSA_String str,
- M4OSA_Char** ppchar);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetChar( M4OSA_String str,
- M4OSA_Char c);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetChar( M4OSA_String str,
- M4OSA_Char* pc);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetInt8( M4OSA_String str,
- M4OSA_Int8 i8,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetInt8( M4OSA_String str,
- M4OSA_Int8* pi8,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetUInt8( M4OSA_String str,
- M4OSA_UInt8 ui8,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetUInt8( M4OSA_String str,
- M4OSA_UInt8* pui8,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetInt16( M4OSA_String str,
- M4OSA_Int16 i16,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetInt16( M4OSA_String str,
- M4OSA_Int16* pi16,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetUInt16( M4OSA_String str,
- M4OSA_UInt16 ui16,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetUInt16( M4OSA_String str,
- M4OSA_UInt16* pui16,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetInt32( M4OSA_String str,
- M4OSA_Int32 i32,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetInt32( M4OSA_String str,
- M4OSA_Int32* pi32,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetUInt32( M4OSA_String str,
- M4OSA_UInt32 ui32,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetUInt32( M4OSA_String str,
- M4OSA_UInt32* pui32,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetDouble( M4OSA_String str,
- M4OSA_Double d);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetDouble( M4OSA_String str,
- M4OSA_Double* pd);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetInt64( M4OSA_String str,
- M4OSA_Int64 i64,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetInt64( M4OSA_String str,
- M4OSA_Int64* pi64,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetFilePosition( M4OSA_String str,
- M4OSA_FilePosition fpos,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetFilePosition( M4OSA_String str,
- M4OSA_FilePosition* pfpos,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetTime( M4OSA_String str,
- M4OSA_Time t,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetTime( M4OSA_String str,
- M4OSA_Time* pt,
- M4OSA_strNumBase base);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetLength( M4OSA_String str,
- M4OSA_UInt32 *pui32);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strTruncate( M4OSA_String str,
- M4OSA_UInt32 ui32_length);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCopy( M4OSA_String str_in,
- M4OSA_String str_out);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCopySubStr( M4OSA_String str_out,
- M4OSA_UInt32 ui32_pos,
- M4OSA_String str_in,
- M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* ui32_num);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strConcat( M4OSA_String str_first,
- M4OSA_String str_second);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strInsertSubStr( M4OSA_String str_out,
- M4OSA_UInt32 ui32_pos,
- M4OSA_String str_in,
- M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* pui32_num);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCompare( M4OSA_String str_in1,
- M4OSA_String str_in2,
- M4OSA_Int32* pi32_result);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCompareSubStr( M4OSA_String str_in1,
- M4OSA_UInt32 ui32_offset1,
- M4OSA_String str_in2,
- M4OSA_UInt32 ui32_offset2,
- M4OSA_UInt32* pui32_num,
- M4OSA_Int32* pi32_result);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCaseCompare( M4OSA_String str_in1,
- M4OSA_String str_in2,
- M4OSA_Int32* pi32_result);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strCaseCompareSubStr( M4OSA_String str_in1,
- M4OSA_UInt32 ui32_offset1,
- M4OSA_String str_in2,
- M4OSA_UInt32 ui32_offset2,
- M4OSA_UInt32* pui32_num,
- M4OSA_Int32* pi32_result);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSpan( M4OSA_String str_in,
- M4OSA_Char* charset,
- M4OSA_UInt32* pui32_result);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSpanComplement( M4OSA_String str_in,
- M4OSA_Char* charset,
- M4OSA_UInt32* pui32_pos);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strFindFirstChar( M4OSA_String str_in,
- M4OSA_Char c,
- M4OSA_UInt32* pui32_pos);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strFindLastChar( M4OSA_String str_in,
- M4OSA_Char c,
- M4OSA_UInt32* pui32_pos);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strFindFirstSubStr( M4OSA_String str_in1,
- M4OSA_String str_in2,
- M4OSA_UInt32* pui32_pos);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strFindLastSubStr( M4OSA_String str_in1,
- M4OSA_String str_in2,
- M4OSA_UInt32* pui32_pos);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetFirstToken( M4OSA_String str_in,
- M4OSA_String str_delim,
- M4OSA_String pstr_token);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strGetLastToken( M4OSA_String str_in,
- M4OSA_String str_delim,
- M4OSA_String pstr_token);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetUpperCase( M4OSA_String str);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetLowerCase( M4OSA_String str);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strDelSubStr( M4OSA_String str_in,
- M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* ui32_num);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strReplaceSubStr( M4OSA_String str_in,
- M4OSA_String str_old,
- M4OSA_String str_new,
- M4OSA_strMode mode);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSprintf( M4OSA_String str,
- M4OSA_Char* format,
- ...);
-
-M4OSAL_STRING_EXPORT_TYPE M4OSA_ERR M4OSA_strSetMinAllocationSize( M4OSA_String str,
- M4OSA_UInt32 ui32_size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/libvideoeditor/osal/inc/M4OSA_String_priv.h b/libvideoeditor/osal/inc/M4OSA_String_priv.h
deleted file mode 100755
index 3303c1d..0000000
--- a/libvideoeditor/osal/inc/M4OSA_String_priv.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ************************************************************************
- * @file M4OSA_String.h
- * @ingroup OSAL
- * @brief public definition for string library
-************************************************************************
-*/
-
-
-#ifndef _M4OSA_STRING_PRIV_H
-#define _M4OSA_STRING_PRIV_H
-
-
-#include "M4OSA_Types.h"
-#include "M4OSA_String.h"
-
-#include <stdarg.h>
-
-typedef struct
-{
- /* string identifiant */
- M4OSA_UInt32 coreID;
- /** data buffer */
- M4OSA_Char* pui8_buffer;
- /** allocated size of the data buffer */
- M4OSA_UInt32 ui32_size;
- /** size of valid data in the buffer */
- M4OSA_UInt32 ui32_length;
-} M4OSA_strStruct;
-
-
-
-M4OSA_ERR M4OSA_strPrivRealloc( M4OSA_strStruct* str,
- M4OSA_UInt32 ui32_length);
-
-M4OSA_ERR M4OSA_strPrivReallocCopy( M4OSA_strStruct* str,
- M4OSA_UInt32 ui32_length);
-
-M4OSA_ERR M4OSA_strPrivSet( M4OSA_strStruct* str,
- M4OSA_Char* pchar,
- M4OSA_UInt32 ui32_length);
-
-M4OSA_ERR M4OSA_strPrivDuplicate( M4OSA_strStruct** ostr,
- M4OSA_strStruct* istr);
-
-M4OSA_Int32 M4OSA_strPrivFindLastSubStr( M4OSA_strStruct* str1,
- M4OSA_strStruct* str2,
- M4OSA_UInt32 ui32_pos);
-
-M4OSA_ERR M4OSA_strPrivSetAndRepleceStr( M4OSA_strStruct* istr,
- M4OSA_UInt32 ui32_pos,
- M4OSA_UInt32 olength,
- M4OSA_Char* nbuff,
- M4OSA_UInt32 nlength);
-
-M4OSA_ERR M4OSA_strPrivReplaceSameSizeStr( M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode);
-
-M4OSA_ERR M4OSA_strPrivReplaceSmallerStr( M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode);
-
-M4OSA_ERR M4OSA_strPrivReplaceBiggerStr( M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode);
-
-M4OSA_ERR M4OSA_strPrivSPrintf( M4OSA_strStruct* str,
- M4OSA_Char *format,
- va_list marker);
-
-
-#define M4OSA_CHECK_MALLOC(buff, string)\
- if(buff == M4OSA_NULL)\
- {\
- M4OSA_DEBUG(M4ERR_ALLOC, string);\
- return M4ERR_ALLOC;\
- }\
-
-
-#endif
-
diff --git a/libvideoeditor/osal/src/M4OSA_FileCache.c b/libvideoeditor/osal/src/M4OSA_FileCache.c
deleted file mode 100755
index 718c0fb..0000000
--- a/libvideoeditor/osal/src/M4OSA_FileCache.c
+++ /dev/null
@@ -1,2978 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *************************************************************************
- * @file M4OSA_FileCache.c
- *
- * @brief Osal File Reader and Writer with cache
- * @note This file implements functions to manipulate
- * filesystem access with intermediate buffers used to
- * read and to write.
- *************************************************************************
-*/
-
-/**
- *************************************************************************
- * File cache buffers parameters (size, number of buffers, etc)
- *************************************************************************
-*/
-#define M4OSA_CACHEBUFFER_SIZE (8*1024)
-#define M4OSA_CACHEBUFFER_NB 6
-#define M4OSA_CACHEBUFFER_NONE -1
-#define M4OSA_CACHEBUFFER_ALL -2
-#define M4OSA_EOF -1
-
-/** Strategy used by Osal File Cache to flush the buffers to disk.
-Depending on the service, the strategy will have more or less success */
-//#define BUFFER_SELECT_INITIAL /** Initial implementation of Osal File Reader optim */
-//#define BUFFER_SELECT_WITH_TIME /** To flush in priority the buffers which have not been used for a certain time */
-//#define BUFFER_SELECT_WITH_SPACE /** To flush in priority the buffers which have not been used a lot of times */
-#define BUFFER_SELECT_WITH_POS /** To flush in priority the buffers which have the smallest position on the file */
-
-/* to measure success of cache operations */
-//#define FILECACHE_STATS
-
-/* For performance measure */
-//#define M4OSA_FILE_CACHE_TIME_MEAS
-
-/*** To debug */
-//#define NO_STRATEGY
-//#define BUFFER_DISPLAY
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
-#include "M4OSA_clock.h"
-
-typedef enum
-{
- fileOpentime,
- fileClosetime,
- fileReadDatatime,
- fileWriteDatatime,
- fileSeektime,
- fileGetOptiontime,
- fileSetOptiontime,
- fileExternalFlushtime,
- enum_size /* for enum size */
-} M4OSA_filetimeType;
-
-typedef M4OSA_Time TabFiletime[enum_size+1];
-
-void M4OSA_FileCache_initTimeMeas(M4OSA_Context pContext);
-void M4OSA_FileCache_displayTimeMeas(M4OSA_Context pContext);
-
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-/* ANSI C*/
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/stat.h>
-/* End: ANSI C includes */
-
-#include "M4OSA_FileCommon.h"
-#include "M4OSA_FileReader.h"
-#include "M4OSA_FileWriter.h"
-
-#include "M4OSA_FileCache.h"
-
-#include "M4OSA_Memory.h"
-#include "M4OSA_Debug.h"
-#include "M4OSA_CharStar.h"
-#include "M4OSA_Mutex.h"
-
-
-#define LOCK \
- M4OSA_mutexLock(apContext->m_mutex, M4OSA_WAIT_FOREVER);
-
-#define UNLOCK \
- M4OSA_mutexUnlock(apContext->m_mutex);
-
-typedef struct
-{
- M4OSA_Void* FileDesc;
-} M4OSA_FileSystem_FFS_t_cache;
-
-typedef struct
-{
- M4OSA_Void* (*pFctPtr_Open)( M4OSA_Void* fd,
- M4OSA_UInt32 FileModeAccess,
- M4OSA_UInt16* errno_ffs );
- M4OSA_FilePosition (*pFctPtr_Read)( M4OSA_Void* fd,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ffs );
- M4OSA_FilePosition (*pFctPtr_Write)( M4OSA_Void* fd,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ffs );
- M4OSA_FilePosition (*pFctPtr_Seek)( M4OSA_Void* fd,
- M4OSA_FilePosition pos,
- M4OSA_FileSeekAccessMode mode,
- M4OSA_UInt16* errno_ffs );
- M4OSA_FilePosition (*pFctPtr_Tell)( M4OSA_Void* fd,
- M4OSA_UInt16* errno_ffs );
- M4OSA_Int32 (*pFctPtr_Close)( M4OSA_Void* fd,
- M4OSA_UInt16* errno_ffs );
- M4OSA_Void (*pFctPtr_AccessType)( M4OSA_UInt32 FileModeAccess_In,
- M4OSA_Void* FileModeAccess_Out );
-
-} M4OSA_FileSystem_FctPtr_cache;
-
-M4OSA_Void* M4OSA_FileSystem_FFS_Open_cache( M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess,
- M4OSA_UInt16* errno_ffs );
-M4OSA_Int32 M4OSA_FileSystem_FFS_Close_cache( M4OSA_Void* pContext,
- M4OSA_UInt16* errno_ffs );
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Read_cache( M4OSA_Void* pContext,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ffs );
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Write_cache( M4OSA_Void* pContext,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ );
-M4OSA_Int32 M4OSA_FileSystem_FFS_Seek_cache( M4OSA_Void* pContext,
- M4OSA_FilePosition pos,
- M4OSA_FileSeekAccessMode mode,
- M4OSA_UInt16* errno_ffs );
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Tell_cache( M4OSA_Void* pContext,
- M4OSA_UInt16* errno_ffs );
-
-M4OSA_ERR M4OSA_fileOpen_cache_internal(M4OSA_Context* pContext,
- M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess,
- M4OSA_FileSystem_FctPtr_cache *FS);
-
-/*
-------------------User--------------------
- ^
- |
--------- -------- ----------
-|Filled| |Copied| |Modified|
--------- -------- ----------
- ^
- |
-------------------Disk--------------------
-
-Atomic states for a buffer:
-
-0x00 initialized or flushed (When it is initialized again, it is flushed if necessary)
-0x01 Filled from disk
-0x03 Filled and Copied to user
-
-0x80 Modified and newly created (does not exist on disk) => must be flushed
-0x83 Modified after having been read from disk => must be flushed
-
-*/
-
-typedef enum
-{
- M4OSA_kInitialized = 0,
- M4OSA_kFilled = 0x1,
- M4OSA_kCopied = 0x2,
- M4OSA_kModified = 0x80
-} M4OSA_FileCacheStateAtomic;
-
-
-/**
- ******************************************************************************
- * structure M4OSA_FileCache_Buffer
- * @brief This structure defines the File Buffers context (private)
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr8 data; /**< buffer data */
- M4OSA_FilePosition size; /**< size of the buffer */
- M4OSA_FilePosition filepos; /**< position in the file of the buffer's first octet */
- M4OSA_FilePosition remain; /**< data amount not already copied from buffer */
-
- M4OSA_UInt32 nbFillSinceLastAcess; /**< To know since how many time we didn't use this buffer. to detect dead buffers */
-
- M4OSA_UInt32 nbAccessed; /**< nb of times the buffer has been accessed without being reinitialized */
- M4OSA_Time timeAccessed; /**< last time at which the buffer has been accessed without being reinitialized */
-
- M4OSA_UInt8 state;
-} M4OSA_FileCache_Buffer;
-
-/**
- ******************************************************************************
- * structure M4OSA_FileCache_Context
- * @brief This structure defines the File context (private)
- * @note This structure is used for all File calls to store the context
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_Bool IsOpened; /**< Micro state machine */
- M4OSA_FileAttribute FileAttribute; /**< Opening mode */
- M4OSA_FilePosition readFilePos; /**< Effective position of the file pointer */
- M4OSA_FilePosition absolutePos; /**< Virtual position for next reading */
- M4OSA_FilePosition absoluteWritePos; /**< Virtual position for next writing */
- M4OSA_FilePosition fileSize; /**< Size of the file */
- M4OSA_FilePosition virtualFileSize; /**< Size of the file */
-
- M4OSA_FileCache_Buffer buffer[M4OSA_CACHEBUFFER_NB]; /**< buffers */
-
- M4OSA_Void* aFileDesc; /**< File descriptor */
- M4OSA_FileSystem_FctPtr_cache *FS; /**< Filesystem interface */
-
-#ifdef FILECACHE_STATS
- M4OSA_UInt32 cacheSuccessRead;
- M4OSA_UInt32 cacheSuccessWrite;
- M4OSA_UInt32 nbReadCache;
- M4OSA_UInt32 nbWriteCache;
-
- M4OSA_UInt32 nbReadFFS;
- M4OSA_UInt32 nbWriteFFS;
-#endif /* FILECACHE_STATS */
- M4OSA_Context m_mutex;
-
- M4OSA_Time chrono;
- M4OSA_Char m_filename[256];
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- TabFiletime gMyPerfFileTab;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-} M4OSA_FileCache_Context;
-
-
-#define M4ERR_CHECK_NULL_RETURN_VALUE(retval, pointer) if ((pointer) == M4OSA_NULL) return (retval);
-
-/* used to detect dead buffers */
-#define MAX_FILLS_SINCE_LAST_ACCESS M4OSA_CACHEBUFFER_NB*2
-
-
-/* __________________________________________________________ */
-/*| |*/
-/*| Quick Sort function (private) |*/
-/*|__________________________________________________________|*/
-
-M4OSA_Void M4OSA_FileCache_internalQuicksort(M4OSA_Int32* const table,
- const M4OSA_Int32 first , const M4OSA_Int32 last)
- {
- M4OSA_Int32 startIndex;
- M4OSA_Int32 endIndex;
- M4OSA_Int32 begin;
- M4OSA_Int32 end;
- M4OSA_Int32 pivot;
- M4OSA_Int32 temp;
- M4OSA_Int32 index=0;
- M4OSA_Int32 size=0;
- M4OSA_Int32 capacity = M4OSA_CACHEBUFFER_NB * 5;
- //allocation of the fifo
- M4OSA_Int32* queue = M4OSA_NULL;
- M4OSA_Int32* cursor;
- M4OSA_Int32* indexc;
-
- queue = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(capacity*sizeof(M4OSA_Int32), 0,
- (M4OSA_Char*) "quicksort FIFO of FileCache");
-
- if(queue == M4OSA_NULL)
- return;
- cursor = queue;
- indexc = queue;
- *(cursor++) = first; //remember the array first element
- *(cursor++) = last; //remember the array end
- index = 0;
- size = 2;
- do
- {
- startIndex = *(indexc++);
- endIndex = *(indexc++);
- index+=2;
- if(startIndex < endIndex)
- {
- begin = startIndex;
- end = endIndex;
- pivot = table[endIndex];
- do
- {
- while ( (begin < endIndex) && (table[begin]<=pivot) )
- begin++;
- while ( (end > begin) && (table[end]>=pivot) )
- end--;
- if (begin < end)
- {
- temp = table[end];
- table[end] = table[begin];
- table[begin] = temp;
- }
- }while(begin < end);
-
- temp = table[endIndex];
- table[endIndex] = table[begin];
- table[begin] = temp;
- *(cursor++) = startIndex;
- *(cursor++) = begin-1;
- *(cursor++) = begin+1;
- *(cursor++) = endIndex;
- size+=4;
- if(size==capacity)
- {
- M4OSA_TRACE1_0("Overflow in quickSort. increase capacity size");
- return;
- }
- }
- }
- while(index<size);
- cursor = NULL;
- indexc = NULL;
- free(queue);
-}
-
-M4OSA_Void M4OSA_FileCache_internalQuicksort64(M4OSA_Int64* const table,
- const M4OSA_Int32 first , const M4OSA_Int32 last)
- {
- M4OSA_Int32 startIndex;
- M4OSA_Int32 endIndex;
- M4OSA_Int32 begin;
- M4OSA_Int32 end;
- M4OSA_Int64 pivot;
- M4OSA_Int64 temp;
- M4OSA_Int32 index=0;
- M4OSA_Int32 size=0;
- M4OSA_Int32 capacity = M4OSA_CACHEBUFFER_NB * 5;
- //allocation of the fifo
- M4OSA_Int32* queue = M4OSA_NULL;
- M4OSA_Int32* cursor;
- M4OSA_Int32* indexc;
-
- queue = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(capacity*sizeof(M4OSA_Int32), 0,
- (M4OSA_Char*) "quicksort FIFO of FileCache");
-
- if(queue == M4OSA_NULL)
- return;
- cursor = queue;
- indexc = queue;
- *(cursor++) = first; //remember the array first element
- *(cursor++) = last; //remember the array end
- index = 0;
- size = 2;
- do
- {
- startIndex = *(indexc++);
- endIndex = *(indexc++);
- index+=2;
- if(startIndex < endIndex)
- {
- begin = startIndex;
- end = endIndex;
- pivot = table[endIndex];
- do
- {
- while ( (begin < endIndex) && (table[begin]<=pivot) )
- begin++;
- while ( (end > begin) && (table[end]>=pivot) )
- end--;
- if (begin < end)
- {
- temp = table[end];
- table[end] = table[begin];
- table[begin] = temp;
- }
- }while(begin < end);
-
- temp = table[endIndex];
- table[endIndex] = table[begin];
- table[begin] = temp;
- *(cursor++) = startIndex;
- *(cursor++) = begin-1;
- *(cursor++) = begin+1;
- *(cursor++) = endIndex;
- size+=4;
- if(size==capacity)
- {
- M4OSA_TRACE1_0("Overflow in quickSort. increase capacity size");
- return;
- }
- }
- }
- while(index<size);
- cursor = NULL;
- indexc = NULL;
- free(queue);
-}
-
-/* Sorts an array of size size */
-M4OSA_Void M4OSA_FileCache_QS_quickSort (M4OSA_FilePosition array[],
- M4OSA_UInt32 size)
-{
- if (size==1 || size==0)
- {
- M4OSA_TRACE3_0("Sort not necessary");
- return;
- }
-
- M4OSA_FileCache_internalQuicksort(array,0,size-1);
-}
-
-M4OSA_Void M4OSA_FileCache_QS_quickSort64 (M4OSA_Time array[], M4OSA_UInt32 size)
-{
- if (size==1 || size==0)
- {
- M4OSA_TRACE3_0("Sort not necessary");
- return;
- }
-
- M4OSA_FileCache_internalQuicksort64((M4OSA_Int64 * const)array, 0, size-1);
-}
-
-/* __________________________________________________________ */
-/*| |*/
-/*| Buffer handling functions for RW access (private) |*/
-/*|__________________________________________________________|*/
-
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_BuffersInit(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_UInt8 i;
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- apContext->buffer[i].state = M4OSA_kInitialized;
- M4OSA_memset((M4OSA_MemAddr8)&(apContext->buffer[i]),
- sizeof(M4OSA_FileCache_Buffer) , 0);
- }
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- apContext->buffer[i].data = (M4OSA_MemAddr8) M4OSA_32bitAlignedMalloc(M4OSA_CACHEBUFFER_SIZE,
- M4OSA_FILE_READER, (M4OSA_Char*)"M4OSA_FileCache_BufferInit");
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, apContext->buffer[i].data);
- apContext->buffer[i].filepos = M4OSA_EOF;
-
- }
-
- return M4NO_ERROR;
-}
-
-/**************************************************************/
-M4OSA_Void M4OSA_FileCache_BuffersFree(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_UInt8 i;
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].data != M4OSA_NULL)
- {
- free(apContext->buffer[i].data);
- apContext->buffer[i].data = M4OSA_NULL;
- }
- }
-}
-
-#ifdef BUFFER_DISPLAY
-M4OSA_Void M4OSA_FileCache_BufferDisplay(M4OSA_FileCache_Context* apContext)
-{
- M4OSA_UInt32 i;
-
- M4OSA_TRACE1_0("------ Buffers display ");
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- M4OSA_TRACE1_5("------ Buf%d : FilePos=%d state=0x%x nbAccessed=%d -- timeAccessed=%d",
- i, apContext->buffer[i].filepos,
- apContext->buffer[i].state,
- apContext->buffer[i].nbAccessed,
- apContext->buffer[i].timeAccessed);
- }
- M4OSA_TRACE1_0("---------------------- ");
-}
-#endif
-
-
-/* reads from an existing buffer (number i) at absolute position pos and fills pData. it reads maximum one bloc */
-/**************************************************************/
-M4OSA_FilePosition M4OSA_FileCache_BufferCopy(M4OSA_FileCache_Context* apContext,
- M4OSA_Int8 i, M4OSA_FilePosition pos,
- M4OSA_FilePosition size,
- M4OSA_MemAddr8 pData)
-/**************************************************************/
-{
- M4OSA_FilePosition copysize;
- M4OSA_FilePosition offset;
-
- M4OSA_TRACE3_2("BufferCopy of %d, pos=%d", i, pos);
-
- if(apContext->buffer[i].size == M4OSA_EOF) return M4OSA_EOF;
-
- /* verification pos is inside buffer i*/
- if( (pos < apContext->buffer[i].filepos)
- || (pos > (apContext->buffer[i].filepos + apContext->buffer[i].size - 1)) )
- {
- return 0; /* nothing copied */
- }
-
- offset = pos - apContext->buffer[i].filepos; /* offset to read from in the buffer */
-
- copysize = apContext->buffer[i].size - offset; /* buffer size - offset, it is the maximum we can read from a buffer */
- copysize = (size < copysize) ? size : copysize; /* adjust in case user wants to read less than the data available in the buffer (copysize)
- in that case, take the min(copysize, size)*/
-
- M4OSA_memcpy(pData, apContext->buffer[i].data + offset, copysize);
-
- apContext->buffer[i].remain -= copysize;
- apContext->buffer[i].nbFillSinceLastAcess = 0;
-
-
- /* it is a read access */
- apContext->buffer[i].nbAccessed++;
- apContext->buffer[i].timeAccessed = apContext->chrono;
- apContext->chrono++;
-
-
- apContext->buffer[i].state |= M4OSA_kCopied;
-
- return copysize;
-}
-
-/* writes on cache. at absolute position pos and writes pData to the buffer. it writes maximum one bloc */
-/**************************************************************/
-M4OSA_FilePosition M4OSA_FileCache_BufferModifyContent(M4OSA_FileCache_Context* apContext,
- M4OSA_Int8 i, M4OSA_FilePosition pos,
- M4OSA_FilePosition size,
- M4OSA_MemAddr8 pData)
-/**************************************************************/
-{
- M4OSA_FilePosition copysize;
- M4OSA_FilePosition offset, gridPos;
-
- M4OSA_TRACE3_2("BufferModify of %d, pos=%d", i, pos);
-
- /* Relocate to absolute postion if necessary */
- gridPos = (pos / M4OSA_CACHEBUFFER_SIZE) * M4OSA_CACHEBUFFER_SIZE;
-
- apContext->buffer[i].filepos = gridPos;
-
- /* in case of an existing block (not at eof) */
- if (apContext->buffer[i].size != 0)
- {
- /* test if we are already inside this buffer */
- if ( (pos < apContext->buffer[i].filepos)
- || (pos > (apContext->buffer[i].filepos + M4OSA_CACHEBUFFER_SIZE)) )
- {
- M4OSA_TRACE1_0("BufferModify ERR nothing copied, should never happen");
- return 0; /* nothing copied */
- }
- }
-
- offset = pos - apContext->buffer[i].filepos; /* offset to write to, in the buffer */
-
- /* buffer size - offset, it is the maximum we can write into a buffer */
- copysize = M4OSA_CACHEBUFFER_SIZE - offset;
- /* adjust in case user wants to write less than the data available in the buffer (copysize) in that case, take the min(copysize, size)*/
- copysize = (copysize < size) ? copysize : size;
-
- M4OSA_memcpy(apContext->buffer[i].data + offset, pData, copysize);
-
- /* update buffer size if it is a new buffer or expanded one*/
- if (apContext->buffer[i].size < copysize+offset)
- {
- apContext->buffer[i].size = copysize+offset;
- }
-
- apContext->buffer[i].remain = M4OSA_CACHEBUFFER_SIZE - apContext->buffer[i].size; /* not temporary */
-
- /* mark this buffer as modified */
- apContext->buffer[i].state |= M4OSA_kModified;
-
- apContext->buffer[i].nbFillSinceLastAcess = 0;
- apContext->buffer[i].nbAccessed++;
- apContext->buffer[i].timeAccessed = apContext->chrono;
- apContext->chrono++;
-
- return copysize;
-}
-
-
-/* writes in a buffer (number i) with the data read from disk*/
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_BufferFill(M4OSA_FileCache_Context* apContext,
- M4OSA_Int8 i, M4OSA_FilePosition pos)
-/**************************************************************/
-{
- M4OSA_FilePosition gridPos;
- M4OSA_FilePosition diff;
- M4OSA_FilePosition size;
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Int32 ret_val;
- M4OSA_UInt16 errReturned;
-
- M4OSA_TRACE3_2("BufferFill i = %d pos = %d", i, pos);
-
- /* Avoid cycling statement because of EOF */
- if(pos > apContext->virtualFileSize)
- return M4WAR_NO_MORE_AU;
-
- /* Relocate to absolute postion if necessary */
- gridPos = (pos / M4OSA_CACHEBUFFER_SIZE) * M4OSA_CACHEBUFFER_SIZE;
-
- /* diff is how much shall we fs_seek from current position to reach gridPos*/
- diff = gridPos - apContext->readFilePos;
-
- /* on some filesystems it is necessary to do a seek between an ffs read and ffs write even if it is same pos */
- ret_val = apContext->FS->pFctPtr_Seek(apContext->aFileDesc,
- diff, M4OSA_kFileSeekCurrent, &errReturned);
- apContext->readFilePos = gridPos;
-
- if(ret_val != 0)
- {
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE2_1("M4OSA_FileCache_BufferFill ERR1 = 0x%x", err);
- return err;
- }
- /* end. on some */
-
-/* the buffer will be reused to be filled with another filepos so reinit counters of access */
- if (apContext->buffer[i].filepos != gridPos)
- {
- apContext->buffer[i].nbAccessed = 0;
- apContext->buffer[i].timeAccessed = 0;
- }
-
- /* stores the information relative to this buffer */
- apContext->buffer[i].filepos = gridPos;
-
- /* Read Data */
- size = apContext->FS->pFctPtr_Read(apContext->aFileDesc,
- (M4OSA_UInt8*)apContext->buffer[i].data,
- M4OSA_CACHEBUFFER_SIZE, &errReturned);
-
-#ifdef FILECACHE_STATS
- apContext->nbReadFFS++;
-#endif /* FILECACHE_STATS */
-
- if(size == -1)
- {
- apContext->buffer[i].size = M4OSA_EOF;
- apContext->buffer[i].remain = 0;
-
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE2_1("M4OSA_FileCache_BufferFill ERR2 = 0x%x", err);
- return err;
- }
-
- apContext->buffer[i].size = size;
- apContext->buffer[i].remain = size;
- apContext->buffer[i].nbFillSinceLastAcess = 0;
-
-
- /* Retrieve current position */
- apContext->readFilePos = apContext->FS->pFctPtr_Tell(apContext->aFileDesc,
- &errReturned);
-
- if( (apContext->buffer[i].size >= 0)
- && (apContext->buffer[i].size < M4OSA_CACHEBUFFER_SIZE) )
- {
- err = M4WAR_NO_DATA_YET;
- M4OSA_TRACE2_1("M4OSA_FileCache_BufferFill ERR3 = 0x%x", err);
- return err;
- }
-
- /* mark this buffer as modified */
- apContext->buffer[i].state |= M4OSA_kFilled;
-
- /* it is a write access */
- apContext->buffer[i].nbAccessed++;
- apContext->buffer[i].timeAccessed = apContext->chrono;
- apContext->chrono++;
-
- /* Return without error */
- return M4NO_ERROR;
-}
-
-/* Reinitializes a buffer for filling it for data at end of file. fileposition is given */
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_BufferReinitialize(M4OSA_FileCache_Context* apContext,
- M4OSA_Int8 i, M4OSA_FilePosition pos)
-/**************************************************************/
-{
- M4OSA_FilePosition gridPos;
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_MemAddr8 saveDataAddress;
-
- M4OSA_TRACE3_2("BufferReinitialize i = %d pos = %d", i, pos);
-
- /* Relocate to absolute postion if necessary */
- if (pos != -1)
- gridPos = (pos / M4OSA_CACHEBUFFER_SIZE) * M4OSA_CACHEBUFFER_SIZE;
- else
- gridPos = -1;
-
- /* RAZ the buffer, only "data address" stays*/
- saveDataAddress = apContext->buffer[i].data;
-
- M4OSA_memset((M4OSA_MemAddr8)&(apContext->buffer[i]),
- sizeof(M4OSA_FileCache_Buffer) , 0);
-
- /* put again the precious "data address" previously allocated */
- apContext->buffer[i].data = saveDataAddress;
-
- /* initializations already done in the memset: */
- /* mark this buffer as initialized*/
- apContext->buffer[i].state= M4OSA_kInitialized;
- apContext->buffer[i].nbAccessed = 0;
- apContext->buffer[i].timeAccessed = 0;
-
- /* Relocate to absolute postion if necessary */
- apContext->buffer[i].filepos = gridPos;
-
- /* Return without error */
- return M4NO_ERROR;
-}
-
-
-/* flushes a buffer (number i) to the disk*/
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_BufferFlush(M4OSA_FileCache_Context* apContext,
- M4OSA_UInt8 i)
-/**************************************************************/
-{
- M4OSA_FilePosition gridPos, pos;
- M4OSA_FilePosition diff;
- M4OSA_FilePosition size;
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Int32 ret_val;
- M4OSA_UInt16 errReturned;
-
- M4OSA_TRACE3_2("BufferFlush of buffer i=%d its pos=%d", i,
- apContext->buffer[i].filepos);
-
- pos = apContext->buffer[i].filepos;
-
- /* Relocate to absolute postion if necessary */
- gridPos = (pos / M4OSA_CACHEBUFFER_SIZE) * M4OSA_CACHEBUFFER_SIZE;
-
- /* diff is how much shall we fs_seek from current position to reach gridPos*/
- diff = gridPos - apContext->readFilePos;
-
- if (pos > apContext->fileSize)
- {
- M4OSA_TRACE1_2("M4OSA_FileCache_BufferFlush: Error! Attempt to seek at pos=%d, whilst fileSize=%d ",
- pos, apContext->fileSize);
- return M4WAR_NO_MORE_AU;
- }
-
- /* on some filesystems it is necessary to do a seek between an ffs read and ffs write even if it is same pos */
- ret_val = apContext->FS->pFctPtr_Seek(apContext->aFileDesc, diff,
- M4OSA_kFileSeekCurrent, &errReturned);
- apContext->readFilePos = gridPos;
-
- if(ret_val != 0)
- {
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE1_1("M4OSA_FileCache_BufferFill ERR1 = 0x%x", err);
- return err;
- }
- /* end: on some filesystems*/
-
- /* update the read file pos after the seek */
- apContext->readFilePos = apContext->buffer[i].filepos;
-
- /* Write Data */
- size = apContext->FS->pFctPtr_Write(apContext->aFileDesc,
- (M4OSA_UInt8*)apContext->buffer[i].data,
- apContext->buffer[i].size, &errReturned);
-#ifdef FILECACHE_STATS
- apContext->nbWriteFFS++;
-#endif /* FILECACHE_STATS */
- /* verify if all data requested to be written, has been written */
- if(size < apContext->buffer[i].size)
- {
- apContext->buffer[i].size = M4OSA_EOF;
- apContext->buffer[i].remain = 0;
-
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE1_1("M4OSA_FileCache_BufferFlush ERR2 = 0x%x", err);
- return err;
- }
-
- /* Retrieve current position */
- apContext->readFilePos = apContext->FS->pFctPtr_Tell(apContext->aFileDesc,
- &errReturned);
-
- apContext->fileSize = (apContext->readFilePos > apContext->fileSize) ? apContext->readFilePos : apContext->fileSize;
-
- /* mark this buffer as not modified */
- apContext->buffer[i].state &= ~(M4OSA_kModified);
-
- /* Return without error */
- return M4NO_ERROR;
-}
-
-/* flushes all modified buffers until the position of buffer i
-if index is M4OSA_CACHEBUFFER_ALL then flush all*/
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_BuffersFlushUntil(M4OSA_FileCache_Context* apContext,
- M4OSA_Int8 index)
-/**************************************************************/
-{
- M4OSA_UInt8 i, j, howManyToFlush;
- M4OSA_FilePosition bufPos[M4OSA_CACHEBUFFER_NB];
- M4OSA_Bool flushed = M4OSA_FALSE;
- M4OSA_ERR err = M4NO_ERROR;
-
-
- i=0;
- for(j=0; j<M4OSA_CACHEBUFFER_NB; j++)
- {
- if ( ((apContext->buffer[j].state & M4OSA_kModified) == M4OSA_kModified) )
- {
- bufPos[i] = apContext->buffer[j].filepos;
- i++;
- }
- }
- howManyToFlush = i;
-
- if (howManyToFlush == 0)
- {
- M4OSA_TRACE2_0("BuffersFlush : no flush needed");
- return M4NO_ERROR;
- }
- else if (howManyToFlush == 1)
- {
- goto flushing;
- }
-
- M4OSA_FileCache_QS_quickSort(bufPos, howManyToFlush);
-
-flushing:
- if (index == M4OSA_CACHEBUFFER_ALL)
- {/* simply flush all buffers in order of positions */
- for(j=0; j<howManyToFlush; j++)
- {
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- if (apContext->buffer[i].filepos == bufPos[j] )
- {
- M4OSA_TRACE2_2("M4OSA_FileCache_BuffersFlushUntil(1) : We Need to Flush buffer %d its pos=%d",
- i, apContext->buffer[i].filepos);
- err = M4OSA_FileCache_BufferFlush(apContext, i);
- if (M4NO_ERROR!= err)
- {
- return err;
- }
- break;
- }
- }
- }
- else
- { /* there is a given index to flush until it*/
- for(j=0; j<howManyToFlush; j++)
- {
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if (
- apContext->buffer[i].filepos == bufPos[j]
- && apContext->buffer[i].filepos <= apContext->buffer[index].filepos
- && apContext->buffer[i].filepos >= apContext->fileSize - M4OSA_CACHEBUFFER_SIZE
- )
- {
- M4OSA_TRACE2_2("M4OSA_FileCache_BuffersFlushUntil(2) : We Need to Flush buffer %d its pos=%d",
- i, apContext->buffer[i].filepos);
- err = M4OSA_FileCache_BufferFlush(apContext, i);
- if (M4NO_ERROR!= err)
- {
- return err;
- }
- if (i==index)
- { /* the buffer with the given index has been flushed */
- flushed = M4OSA_TRUE;
- }
- break;
- }
- }
-
- }
-
- if (M4OSA_TRUE == flushed)
- {
- err = M4NO_ERROR;
- }
- else
- {
- M4OSA_TRACE1_1("M4OSA_FileCache_BuffersFlushUntil err=0x%x", err);
- err = M4ERR_BAD_CONTEXT;
- }
-
- }
-
- return err;
-
-}
-
-#ifdef BUFFER_DISPLAY
-M4OSA_Void M4OSA_FileCache_BufferDisplay(M4OSA_FileCache_Context* apContext)
-{
- M4OSA_UInt32 i;
-
- M4OSA_TRACE1_0("------ Buffers display ");
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- M4OSA_TRACE1_3("------ Buf%d : FilePos=%d state=0x%x ",
- i, apContext->buffer[i].filepos, apContext->buffer[i].state);
-#ifdef BUFFER_DATE
- M4OSA_TRACE1_2("nbAccessed=%d - nbModified =%d",
- apContext->buffer[i].nbAccessed, apContext->buffer[i].nbModified);
- M4OSA_TRACE1_2("timeAccessed=%d - timeModified =%d",
- apContext->buffer[i].timeAccessed,
- apContext->buffer[i].timeModified);
-#endif /* BUFFER_DATE */
- }
- M4OSA_TRACE1_0("---------------------- ");
-}
-#endif
-
-
-/* provides the buffer corresponding to a position pos
-and with pos inside the read data into this buffer
-else returns CACHE_BUFFER_NONE*/
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferMatchToRead(M4OSA_FileCache_Context* apContext,
- M4OSA_FilePosition pos)
-/**************************************************************/
-{
- M4OSA_Int8 i;
-
- /* Select the buffer which matches with given pos */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if( (pos >= apContext->buffer[i].filepos)
- && (pos < apContext->buffer[i].filepos + apContext->buffer[i].size)
- && (apContext->buffer[i].filepos != M4OSA_EOF) )
- {
- M4OSA_TRACE3_1("BufferMatch returns i = %d", i);
- return i;
- }
- }
-
- M4OSA_TRACE3_1("BufferMatch returns N O N E !!!", i);
- return M4OSA_CACHEBUFFER_NONE;
-}
-
-
-/* provides the buffer corresponding to a position pos
-and with pos inside its maximum capacity
-else returns CACHE_BUFFER_NONE*/
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferMatchToWrite(M4OSA_FileCache_Context* apContext,
- M4OSA_FilePosition pos)
-/**************************************************************/
-{
- M4OSA_Int8 i;
-
- /* Select the buffer which matches with given pos */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if( (pos >= apContext->buffer[i].filepos)
- && (pos < apContext->buffer[i].filepos + M4OSA_CACHEBUFFER_SIZE)
- && (apContext->buffer[i].filepos != M4OSA_EOF) )
- {
- M4OSA_TRACE3_1("BufferMatch returns i = %d", i);
- return i;
- }
- }
-
- M4OSA_TRACE3_1("BufferMatch returns N O N E !!!", i);
- return M4OSA_CACHEBUFFER_NONE;
-}
-
-/* chooses a buffer by overwriting an existing one and returns i */
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferSelectForWrite(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_Int8 i;
- M4OSA_UInt8 selected = 0;
- M4OSA_UInt32 j, toSort;
- M4OSA_FilePosition bufPos[M4OSA_CACHEBUFFER_NB];
- M4OSA_ERR err;
-
- // update nbFillSinceLastAcess field
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- apContext->buffer[i].nbFillSinceLastAcess ++;
- }
-#ifdef NO_STRATEGY
- goto end_selection;
-#endif
-
- /*********************************************/
- /* 1/ if there is still a new buffer, use it */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].state == M4OSA_kInitialized)
- {
- selected = i;
- goto end_selection;
- }
- }
-
- /*********************************************/
- /* 2/ Choose a filled and copied buffer */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if( ((apContext->buffer[i].state & M4OSA_kFilled) == M4OSA_kFilled)
- && ((apContext->buffer[i].state & M4OSA_kCopied) == M4OSA_kCopied)
- && ((apContext->buffer[i].state & M4OSA_kModified) != M4OSA_kModified) /* bug fix modified */
- )
- {
- selected = i;
- goto end_selection;
- }
- }
-
- /****************************************************************/
- /* 3/ Choose a modified buffer with filepos>threshold and min */
- i=0;
-
- /* sort the buffers by filepos and choose the min and not < threshold*/
- for(j=0; j<M4OSA_CACHEBUFFER_NB; j++)
- {
- if (
- ((apContext->buffer[j].state & M4OSA_kModified) == M4OSA_kModified)
- && (apContext->buffer[j].filepos > -1) /* not EOF */
- )
- {
- bufPos[i] = apContext->buffer[j].filepos;
- i++;
- }
- }
-
- toSort = i;
- if (toSort == 0 )
- {
- selected = 0;
- goto end_selection;
- }
- else if (toSort ==1 )
- {
- goto skip_sort;
- }
- else
- {
- M4OSA_FileCache_QS_quickSort(bufPos, toSort);
- }
-
-skip_sort:
- /* take the smallest filepos */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if (apContext->buffer[i].filepos == bufPos[0])
- {
- selected = i;
- goto end_selection;
- }
- }
-
-end_selection:
- if (apContext->buffer[selected].filepos > apContext->fileSize )
- {
- /* in case it selects a modified buffer outside real file size,
- in that case, flush all buffers before this one
- unless there will be a seek outside filesize*/
- M4OSA_FileCache_BuffersFlushUntil(apContext, selected);
- }
- else if ((apContext->buffer[selected].state & M4OSA_kModified) == M4OSA_kModified )
- {
- /* in case it selects a modified buffer inside filesize, simply flush it*/
- err = M4OSA_FileCache_BufferFlush(apContext, selected);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_CACHEBUFFER_NONE;
- }
- }
-
-#ifdef NO_STRATEGY
- /* selected stays 0 */
- err = M4OSA_FileCache_BuffersFlushUntil(apContext, M4OSA_CACHEBUFFER_ALL);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_FILE_CACHE_BUFFER_NONE;
- }
-#endif
-
- M4OSA_TRACE3_1("---------- BufferSelect returns i = %d", selected);
- return selected;
-}
-
-
-/* chooses a buffer by overwriting an existing one and returns i */
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferSelectWithTime(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_Int8 i;
- M4OSA_UInt8 selected = 0;
- M4OSA_UInt32 j, toSort;
- M4OSA_Time bufTime[M4OSA_CACHEBUFFER_NB];
- M4OSA_ERR err;
-
- /*********************************************/
- /* 1/ if there is still a new buffer, use it */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].state == M4OSA_kInitialized)
- {
- selected = i;
- goto end_selection;
- }
- }
-
- i=0;
- /* sort all buffers with order of timeAccessed */
- for(j=0; j<M4OSA_CACHEBUFFER_NB; j++)
- {
- bufTime[i] = apContext->buffer[j].timeAccessed;
- i++;
- }
-
- toSort = i;
- if (toSort == 0 )
- {
- selected = 0;
- goto end_selection;
- }
- else if (toSort ==1 )
- {
- goto skip_sort;
- }
- else
- {
- M4OSA_FileCache_QS_quickSort64(bufTime, toSort);
- }
-
-skip_sort:
- /* take the smallest timeAccessed */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if (apContext->buffer[i].timeAccessed == bufTime[0])
- {
- selected = i;
- goto end_selection;
- }
- }
-
-end_selection:
- if (apContext->buffer[selected].filepos > apContext->fileSize )
- {
- /* in case it selects a modified buffer outside real file size,
- in that case, flush all buffers before this one
- unless there will be a seek outside filesize*/
- M4OSA_FileCache_BuffersFlushUntil(apContext, selected);
- }
- else if ((apContext->buffer[selected].state & M4OSA_kModified) == M4OSA_kModified )
- {
- /* in case it selects a modified buffer inside filesize, simply flush it*/
- err = M4OSA_FileCache_BufferFlush(apContext, selected);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_CACHEBUFFER_NONE;
- }
- }
- M4OSA_TRACE3_1("---------- BufferSelect returns i = %d", selected);
- return selected;
-}
-
-/* chooses a buffer by overwriting an existing one and returns i */
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferSelectWithPos(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_Int8 i;
- M4OSA_UInt8 selected = 0, j;
- M4OSA_ERR err;
- M4OSA_FilePosition minPos;
-
- /*********************************************/
- /* 1/ if there is still a new buffer, use it */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].state == M4OSA_kInitialized)
- {
- selected = i;
- goto end_selection;
- }
- }
-
- minPos = apContext->buffer[0].filepos;
- selected = 0;
- for(j=1; j<M4OSA_CACHEBUFFER_NB; j++)
- {
- if (apContext->buffer[j].filepos < minPos)
- {
- minPos = apContext->buffer[j].filepos;
- selected = j;
- }
- }
-
-end_selection:
- if (apContext->buffer[selected].filepos > apContext->fileSize )
- {
- /* in case it selects a modified buffer outside real file size,
- in that case, flush all buffers before this one
- unless there will be a seek outside filesize*/
- M4OSA_TRACE3_2("BufferSelectWithPos selected buffer is ouside file b.filepos=%d > fileSize=%d",
- apContext->buffer[selected].filepos,
- apContext->fileSize );
- M4OSA_FileCache_BuffersFlushUntil(apContext, selected);
- }
- else if ((apContext->buffer[selected].state & M4OSA_kModified) == M4OSA_kModified )
- {
- /* in case it selects a modified buffer inside filesize, simply flush it*/
- err = M4OSA_FileCache_BufferFlush(apContext, selected);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_CACHEBUFFER_NONE;
- }
- }
- M4OSA_TRACE3_1("---------- BufferSelectWithPos returns i = %d", selected);
- return selected;
-}
-
-
-/* chooses a buffer by overwriting an existing one and returns i */
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferSelectWithSpace(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_Int8 i;
- M4OSA_UInt8 selected = 0;
- M4OSA_UInt32 j, toSort;
- M4OSA_FilePosition bufStat[M4OSA_CACHEBUFFER_NB];
- M4OSA_ERR err;
-
- /*********************************************/
- /* 1/ if there is still a new buffer, use it */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].state == M4OSA_kInitialized)
- {
- selected = i;
- goto end_selection;
- }
- }
-
- i=0;
- /* sort all buffers with order of nbAccessed */
- for(j=0; j<M4OSA_CACHEBUFFER_NB; j++)
- {
- bufStat[i] = apContext->buffer[j].nbAccessed + apContext->buffer[j].timeAccessed*2; /* try hybrid */
- i++;
- }
-
- toSort = i;
- if (toSort == 0 )
- {
- selected = 0;
- goto end_selection;
- }
- else if (toSort ==1 )
- {
- goto skip_sort;
- }
- else
- {
- M4OSA_FileCache_QS_quickSort(bufStat, toSort);
- }
-
-skip_sort:
- /* take the smallest nbAccessed */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if ((M4OSA_Int64) apContext->buffer[i].nbAccessed + apContext->buffer[i].timeAccessed*2 == bufStat[0]) /* hybrid */
- {
- selected = i;
- goto end_selection;
- }
- }
-
-end_selection:
- if (apContext->buffer[selected].filepos > apContext->fileSize )
- {
- /* in case it selects a modified buffer outside real file size,
- in that case, flush all buffers before this one
- unless there will be a seek outside filesize*/
- M4OSA_FileCache_BuffersFlushUntil(apContext, selected);
- }
- else if ((apContext->buffer[selected].state & M4OSA_kModified) == M4OSA_kModified )
- {
- /* in case it selects a modified buffer inside filesize, simply flush it*/
- err = M4OSA_FileCache_BufferFlush(apContext, selected);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_CACHEBUFFER_NONE;
- }
- }
- M4OSA_TRACE3_1("---------- BufferSelect returns i = %d", selected);
- return selected;
-}
-
-
-/**************************************************************/
-M4OSA_Int8 M4OSA_FileCache_BufferSelectForRead(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_Int8 i,j, selected;
- M4OSA_FilePosition min_amount,max_amount;
- M4OSA_Int8 min_i,max_count;
- M4OSA_ERR err;
-
- /* update nbFillSinceLastAcess field */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- apContext->buffer[i].nbFillSinceLastAcess ++;
- }
-
- /**************************************************/
- /* Plan A/ if there is still a new buffer, use it */
-
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].state == M4OSA_kInitialized)
- {
- selected = i;
- goto end_selection;
- }
- }
-
- max_count = M4OSA_CACHEBUFFER_NB;
- max_amount = MAX_FILLS_SINCE_LAST_ACCESS;
-
- /* Plan B : Scan for dead buffer */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- if(apContext->buffer[i].nbFillSinceLastAcess >= (M4OSA_UInt32) max_amount)
- {
- max_amount = apContext->buffer[i].nbFillSinceLastAcess;
- max_count = i;
- }
- }
- if(max_count<M4OSA_CACHEBUFFER_NB)
- {
- M4OSA_TRACE3_2("DEAD BUFFER: %d, %d",max_count,apContext->buffer[max_count].nbFillSinceLastAcess);
- selected = max_count;
- goto end_selection;
- }
-
- min_i = 0;
- min_amount = M4OSA_CACHEBUFFER_NB;
-
- /* Select the buffer which is the most "empty" */
- for(i=0; i<M4OSA_CACHEBUFFER_NB; i++)
- {
- j = i % M4OSA_CACHEBUFFER_NB;
-
- if(apContext->buffer[j].remain < min_amount)
- {
- min_amount = apContext->buffer[j].remain;
- min_i = j;
- }
- }
- selected = min_i;
-
-end_selection:
- if (apContext->buffer[selected].filepos > apContext->fileSize )
- {
- /* in case it selects a modified buffer outside real file size,
- in that case, flush all buffers before this one
- unless there will be a seek outside filesize*/
- M4OSA_FileCache_BuffersFlushUntil(apContext, selected);
- }
- else if ((apContext->buffer[selected].state & M4OSA_kModified) == M4OSA_kModified )
- {
- /* in case it selects a modified buffer inside filesize, simply flush it*/
- err = M4OSA_FileCache_BufferFlush(apContext, selected);
- if (M4NO_ERROR!= err)
- {
- return M4OSA_CACHEBUFFER_NONE;
- }
- }
-
- return selected;
-}
-
-
-/**************************************************************/
-M4OSA_ERR M4OSA_FileCache_CalculateSize(M4OSA_FileCache_Context* apContext)
-/**************************************************************/
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Int32 ret_val;
- M4OSA_UInt16 errReturned;
-
- /* go to the end of file*/
- ret_val = apContext->FS->pFctPtr_Seek(apContext->aFileDesc, 0,
- M4OSA_kFileSeekEnd,
- &errReturned);
-
- if (ret_val != 0)
- {
- apContext->readFilePos = M4OSA_EOF;
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE2_1("M4OSA_FileCache_CalculateSize ERR = 0x%x", err);
- }
- else
- {
- /* Retrieve size of the file */
- apContext->fileSize = apContext->FS->pFctPtr_Tell(apContext->aFileDesc,
- &errReturned);
- apContext->readFilePos = apContext->fileSize;
- }
-
- return err;
-}
-
-/* _____________________________________________________________ */
-/*| | */
-/*| OSAL filesystem functions dependent on Platform FileSystem | */
-/*|_____________________________________________________________| */
-
-/**
- ************************************************************************
- * @brief Opens a file
- * @note
- * @param pFileDescriptor : IN url of the file
- * FileModeAccess : IN access mode for opening the file
- * errno_ffs : OUT internal error returned by the filesystem
- * @return pC : internal context
- ************************************************************************
-*/
-M4OSA_Void* M4OSA_FileSystem_FFS_Open_cache( M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess,
- M4OSA_UInt16* errno_ffs )
-{
-
- M4OSA_FileSystem_FFS_t_cache *pC = M4OSA_NULL;
- FILE* fp;
-
- M4OSA_Char mode[4] = "";
- M4OSA_Char* pReadString = (M4OSA_Char*)"r";
- M4OSA_Char* pWriteString = (M4OSA_Char*)"w";
- M4OSA_Char* pAppendString = (M4OSA_Char*)"a";
- M4OSA_Char* pBinaryString = (M4OSA_Char*)"b";
- M4OSA_Char* pPlusString = (M4OSA_Char*)"+";
-
- fp = M4OSA_NULL;
- *errno_ffs = 0;
-
- M4OSA_TRACE3_0("M4OSA_FileSystem_FFS_Open_cache : Open **** \n");
-
- /************************/
- /* Verify access mode */
- /************************/
-
- /*
- All possible file accesses:
-
- r : Read only, file must exist
-
- w : Write only. If the file exists, it is overwritten. If it does not exist, it is created.
-
- a : write at end of file (append). If the file exists, it is extended. If the file does not exist, it is created.
-
- r+ : update (i.e. read and write). The file must exist. It is not possible to do a read after a write (or a write after a read)
- unless we reposition the file pointer.
-
- w+ : creation, to update. If the file exists, it is overwritten. If the files does not exist, it is created.
- a+ : extension and update. If the file does not exist, it is created. If the file exists, the file pointer is put at end of file.
-
- All possible cases for fileModeAccess parameter:
-
- Write(2) w
- WriteRead(3) r+ // r+b Used by MM
- WriteReadCreate(11) w+ // w+b Used by MM
- WriteReadAppend(7) a+
- WriteCreate(10) w
- WriteAppend(12) a
- Read r // rb Used by MM
- Error
- */
-
-
- if ((FileModeAccess & M4OSA_kFileWrite) && (FileModeAccess & M4OSA_kFileRead) && (FileModeAccess & M4OSA_kFileCreate)) /* Used by MM */
- {
- /** "w+" */
- M4OSA_chrNCat(mode, pWriteString, 1);
- M4OSA_chrNCat(mode, pPlusString, 1);
- }
- else if ((FileModeAccess & M4OSA_kFileWrite) && (FileModeAccess & M4OSA_kFileRead) && (FileModeAccess & M4OSA_kFileAppend))
- {
- /** "a+" */
- M4OSA_chrNCat(mode, pAppendString, 1);
- M4OSA_chrNCat(mode, pPlusString, 1);
- }
- else if ((FileModeAccess & M4OSA_kFileWrite) && (FileModeAccess & M4OSA_kFileRead)) /* Used by MM */
- {
- /** "r+" */
- M4OSA_chrNCat(mode, pReadString, 1);
- M4OSA_chrNCat(mode, pPlusString, 1);
- }
- else if ((FileModeAccess & M4OSA_kFileWrite) && (FileModeAccess & M4OSA_kFileCreate))
- {
- /** "w" */
- M4OSA_chrNCat(mode, pWriteString, 1);
- }
- else if ((FileModeAccess & M4OSA_kFileWrite) && (FileModeAccess & M4OSA_kFileAppend))
- {
- /** "a" */
- M4OSA_chrNCat(mode, pAppendString, 1);
- }
- else if (FileModeAccess & M4OSA_kFileRead)
- {
- /** "r" */
- M4OSA_chrNCat(mode, pReadString, 1);
- }
- else if (FileModeAccess & M4OSA_kFileWrite)
- {
- /** "w" */
- M4OSA_chrNCat(mode, pWriteString, 1);
- }
- else
- {
- M4OSA_TRACE1_1("M4OSA_FileSystem_FFS_Open_cache : invalid FileModeAccess = %x", FileModeAccess);
- *errno_ffs = (M4OSA_UInt16)M4ERR_FILE_BAD_MODE_ACCESS;
- }
-
- /* add the b */
- M4OSA_chrNCat(mode, pBinaryString, 1);
-
- fp = fopen((const char *) pFileDescriptor, (const char *)mode); /* Open in rb or in r+b*/
- if( fp != NULL )
- {
- pC = (M4OSA_FileSystem_FFS_t_cache *) M4OSA_32bitAlignedMalloc(sizeof * pC, M4OSA_FILE_READER, (M4OSA_Char*)"M4OSA_FileSystem_FFS_Open_cache");
-
- if (pC == M4OSA_NULL) return M4OSA_NULL; /*error occured => return NULL pointer*/
-
- pC->FileDesc = fp;
- }
- else
- {
- switch(errno)
- {
- case ENOENT:
- M4OSA_DEBUG(M4ERR_FILE_NOT_FOUND, "M4OSA_fileReadOpen: No such file or directory");
- *errno_ffs=(M4OSA_UInt16)M4ERR_FILE_NOT_FOUND;
- break;
-
- case EACCES:
- M4OSA_DEBUG(M4ERR_FILE_LOCKED, "M4OSA_fileReadOpen: Permission denied");
- *errno_ffs=(M4OSA_UInt16)M4ERR_FILE_LOCKED;
- break;
-
- case EINVAL:
- M4OSA_DEBUG(M4ERR_FILE_BAD_MODE_ACCESS, "M4OSA_fileReadOpen: Invalid Argument");
- *errno_ffs=(M4OSA_UInt16)M4ERR_FILE_BAD_MODE_ACCESS;
- break;
-
- case EMFILE:
- case ENOSPC:
- case ENOMEM:
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_fileReadOpen: Too many open files");
- *errno_ffs=(M4OSA_UInt16)M4ERR_ALLOC;
- break;
-
- default:
- M4OSA_DEBUG(M4ERR_NOT_IMPLEMENTED, "M4OSA_fileReadOpen");
- *errno_ffs=(M4OSA_UInt16)M4ERR_NOT_IMPLEMENTED;
-
- } /* end switch */
- } /* end else */
-
- return (M4OSA_Void*)pC;
-}
-
-/**
- ************************************************************************
- * @brief Reads data from file
- * @note
- * @param pContext : IN internal context
- * data : IN buffer for reading data
- * size : IN amount of bytes to read
- * errno_ffs : OUT internal error returned by the filesystem
- * @return ret : effective amount of bytes read / -1 if an error occurs
- ************************************************************************
-*/
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Read_cache( M4OSA_Void* pContext,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ffs )
-{
- M4OSA_FileSystem_FFS_t_cache *pC = (M4OSA_FileSystem_FFS_t_cache *)pContext;
- M4OSA_Int32 res;
-
- M4OSA_TRACE2_1("M4OSA_FileSystem_FFS_Read size = %ld", size);
-
- res = -1;
-
- res = fread(data,sizeof(M4OSA_Char), size, pC->FileDesc);
- if( -1 < res )
- {
- *errno_ffs = M4NO_ERROR;
- }
- else
- {
- *errno_ffs = errno;
- }
-
- return (M4OSA_FilePosition)res;
-}
-
-
-
-/**
- ************************************************************************
- * @brief Writes data to file
- * @note
- * @param pContext : IN internal context
- * data : IN buffer with data to write
- * size : IN amount of bytes to read
- * errno_ffs : OUT internal error returned by the filesystem
- * @return ret : effective amount of bytes read / an error code if an error occurs
- ************************************************************************
-*/
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Write_cache( M4OSA_Void* pContext,
- M4OSA_UInt8* data,
- M4OSA_FilePosition size,
- M4OSA_UInt16* errno_ffs )
-{
- M4OSA_FileSystem_FFS_t_cache *pC = (M4OSA_FileSystem_FFS_t_cache *)pContext;
- M4OSA_Int32 res;
-
- M4OSA_TRACE2_1("M4OSA_FileSystem_FFS_Write size = %ld", size);
-
- res = 0;
-
- res = fwrite(data,sizeof(M4OSA_Char), size, pC->FileDesc);
- if( -1 < res )
- {
- *errno_ffs = M4NO_ERROR;
- }
- else
- {
- *errno_ffs = errno;
- M4OSA_TRACE1_1("M4OSA_FileSystem_FFS_Write error", *errno_ffs);
- }
-
- fflush(pC->FileDesc);
-
- return (M4OSA_FilePosition)res;
-}
-
-/**
- ************************************************************************
- * @brief Seeks at given position in a file
- * @note
- * @param pContext : IN internal context
- * pos : IN amount of bytes for the move
- * mode : IN kind of seek to perform
- * errno_ffs : OUT internal error returned by the filesystem
- * @return ret : 0 on success / any other value if an error occurs
- ************************************************************************
-*/
-M4OSA_Int32 M4OSA_FileSystem_FFS_Seek_cache( M4OSA_Void* pContext,
- M4OSA_FilePosition pos,
- M4OSA_FileSeekAccessMode mode,
- M4OSA_UInt16* errno_ffs )
-{
- M4OSA_FileSystem_FFS_t_cache *pC = (M4OSA_FileSystem_FFS_t_cache *)pContext;
-
- M4OSA_TRACE2_2("M4OSA_FileSystem_FFS_Seek pos = %ld mode = %d", pos, mode);
-
- switch(mode)
- {
- case M4OSA_kFileSeekBeginning :
- *errno_ffs = fseek(pC->FileDesc, pos, SEEK_SET);
- break;
-
- case M4OSA_kFileSeekCurrent :
- *errno_ffs= fseek(pC->FileDesc, pos, SEEK_CUR);
- break;
-
- case M4OSA_kFileSeekEnd :
- *errno_ffs = fseek(pC->FileDesc, pos, SEEK_END);
- break;
- }
-
- return *errno_ffs;
-
-}
-
-/**
- ************************************************************************
- * @brief Tells the position of the file pointer
- * @note
- * @param pContext : IN internal context
- * errno_ffs : OUT internal error returned by the filesystem
- * @return ret : position of the file pointer/ -1 if an error occurs
- ************************************************************************
-*/
-M4OSA_FilePosition M4OSA_FileSystem_FFS_Tell_cache( M4OSA_Void* pContext,
- M4OSA_UInt16* errno_ffs )
-{
- M4OSA_FileSystem_FFS_t_cache *pC = (M4OSA_FileSystem_FFS_t_cache *)pContext;
- M4OSA_FilePosition pos;
-
- pos = ftell(pC->FileDesc);
-
- *errno_ffs = 0;
-
- return pos;
-}
-
-/**
- ************************************************************************
- * @brief Closes the file
- * @note
- * @param pContext : IN internal context
- * errno_ffs : OUT internal error returned by the filesystem
- * @return ret : 0 on success / any other value if an error occurs
- ************************************************************************
-*/
-M4OSA_Int32 M4OSA_FileSystem_FFS_Close_cache( M4OSA_Void* pContext,
- M4OSA_UInt16* errno_ffs )
-{
- M4OSA_FileSystem_FFS_t_cache *pC = (M4OSA_FileSystem_FFS_t_cache *)pContext;
-
- *errno_ffs = fclose(pC->FileDesc);
-
- return *errno_ffs;
-}
-
-/* __________________________________________________________ */
-/*| |*/
-/*| OSAL fileCache |*/
-/*|__________________________________________________________|*/
-
-/**************************************************************/
-M4OSA_ERR M4OSA_fileOpen_cache(M4OSA_Context* pContext,
- M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess)
-/**************************************************************/
-{
- M4OSA_FileSystem_FctPtr_cache *FS;
-
- /* Allocate memory for the File System interface */
- FS = (M4OSA_FileSystem_FctPtr_cache *)M4OSA_32bitAlignedMalloc(sizeof * FS,
- M4OSA_FILE_READER,(M4OSA_Char*)"M4OSA_FileSystem_FctPtr_cache");
-
- if(M4OSA_NULL == FS)
- return M4ERR_ALLOC;
-
- FS->pFctPtr_Open = M4OSA_FileSystem_FFS_Open_cache;
- FS->pFctPtr_Read = M4OSA_FileSystem_FFS_Read_cache;
- FS->pFctPtr_Write = M4OSA_FileSystem_FFS_Write_cache;
- FS->pFctPtr_Seek = M4OSA_FileSystem_FFS_Seek_cache;
- FS->pFctPtr_Tell = M4OSA_FileSystem_FFS_Tell_cache;
- FS->pFctPtr_Close = M4OSA_FileSystem_FFS_Close_cache;
-
- return M4OSA_fileOpen_cache_internal(pContext, pFileDescriptor,
- FileModeAccess, FS);
-}
-
-/**
-******************************************************************************
-* @brief This method opens the provided fileDescriptor and returns its context.
-* @param pContext: (OUT) File Cache context.
-* @param pFileDescriptor : (IN) File Descriptor of the input file.
-* @param FileModeAccess : (IN) File mode access.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_PARAMETER pContext or fileDescriptor is NULL
-* @return M4ERR_ALLOC there is no more memory available
-* @return M4ERR_FILE_BAD_MODE_ACCESS the file mode access is not correct
-* @return M4ERR_FILE_NOT_FOUND The file can not be opened.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileOpen_cache_internal(M4OSA_Context* pContext,
- M4OSA_Void* pFileDescriptor,
- M4OSA_UInt32 FileModeAccess,
- M4OSA_FileSystem_FctPtr_cache *FS)
-{
- M4OSA_FileCache_Context* apContext = M4OSA_NULL;
-
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Void* aFileDesc = M4OSA_NULL;
- M4OSA_Bool buffers_allocated = M4OSA_FALSE;
- M4OSA_UInt16 errReturned = 0;
- M4OSA_Int32 len,name_len;
- M4OSA_Char* pCharFileDesc = (M4OSA_Char*)pFileDescriptor;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE2_2("M4OSA_fileOpen_cache fd = %s mode = %d", pFileDescriptor,
- FileModeAccess);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pContext);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pFileDescriptor);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, FS);
-
- *pContext = M4OSA_NULL;
-
- /* Allocate memory for the File reader context. */
- apContext = (M4OSA_FileCache_Context *)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileCache_Context),
- M4OSA_FILE_READER, (M4OSA_Char*)"M4OSA_FileCache_Context");
-
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, apContext);
-
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_FileCache_initTimeMeas(apContext);
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- /* Set filesystem interface */
- apContext->FS = FS;
-
- if (M4OSA_kFileWrite == FileModeAccess)
- {
- FileModeAccess |= M4OSA_kFileWrite | M4OSA_kFileCreate; /* for VA in case of open with only Write flag, we add the Create */
- }
-
- /* For VA and VES, we need to add access in read, to write the moov for example */
- /* Add the flag Read in all cases, because Osal File Cache uses read at the same time */
- FileModeAccess |= M4OSA_kFileRead;
-
- aFileDesc = apContext->FS->pFctPtr_Open(pFileDescriptor, FileModeAccess,
- &errReturned);
-
- if (aFileDesc != M4OSA_NULL)
- {
- apContext->IsOpened = M4OSA_TRUE;
- }
- else
- {
- /* converts the error to PSW format*/
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE1_2("M4OSA_fileOpen_cache error 0x%x for fd = %s", err,
- pFileDescriptor);
- apContext->IsOpened = M4OSA_FALSE;
-
- /*free the context and associated FS pointers*/
- if (M4OSA_NULL != apContext) /*should never be null*/
- {
- if (M4OSA_NULL != apContext->FS) /*should never be null*/
- {
- free(apContext->FS);
- }
-
- free(apContext);
- apContext = M4OSA_NULL;
- }
-
- if (M4NO_ERROR != err) goto cleanup;
- }
-
- /* Allocate buffers */
- err = M4OSA_FileCache_BuffersInit(apContext);
- buffers_allocated = M4OSA_TRUE;
-
- if (M4NO_ERROR != err) goto cleanup;
-
- /* Initialize parameters */
- apContext->fileSize = 0;
- apContext->virtualFileSize = 0;
- apContext->absolutePos = 0;
- apContext->absoluteWritePos = 0;
-
-
- apContext->readFilePos = 0;
-
- /* Retrieve the File Descriptor*/
- apContext->aFileDesc = aFileDesc;
-
- /* Retrieve the File mode Access */
- apContext->FileAttribute.modeAccess = (M4OSA_FileModeAccess)FileModeAccess;
-
- apContext->chrono = 0;
-
-#ifdef FILECACHE_STATS
- apContext->nbReadCache = 0;
- apContext->nbWriteCache = 0;
-
- apContext->nbReadFFS = 0;
- apContext->nbWriteFFS = 0;
-#endif
-
- /*Retrieve the File reader context */
- *pContext= (M4OSA_Context)apContext;
-
- /* Compute file size */
- err = M4OSA_FileCache_CalculateSize(apContext);
-
- if (M4NO_ERROR != err) goto cleanup;
-
- apContext->virtualFileSize = apContext->fileSize;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileOpentime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_mutexOpen(&(apContext->m_mutex));
-
- /* filename extraction, just for traces */
- M4OSA_memset(apContext->m_filename, 256, 0);
- len=( M4OSA_chrLength(pCharFileDesc) )+1;
- for( --len ; (len >= 0 && pCharFileDesc[len] != '\\' && pCharFileDesc[len] != '/') ; len-- );
- name_len=M4OSA_chrLength( &pCharFileDesc[len+1] );
- err=M4OSA_chrNCopy(apContext->m_filename, &pCharFileDesc[len+1], name_len);
-
- M4OSA_TRACE2_2("M4OSA_fileOpen_cache of %s has pC = 0x%x", apContext->m_filename, apContext);
-
- return M4NO_ERROR;
-
-cleanup:
-
- /* free context */
- if (M4OSA_NULL != apContext)
- {
- if(buffers_allocated == M4OSA_TRUE)
- {
- M4OSA_FileCache_BuffersFree(apContext);
- }
-
- if (M4OSA_NULL != apContext)
- {
- free(apContext);
- apContext = M4OSA_NULL;
- }
- *pContext = M4OSA_NULL;
- }
-
- return err;
-}
-
-/**
-******************************************************************************
-* @brief This method reads the 'size' bytes in the core file reader (selected by its 'context')
-* and writes the data to the 'data' pointer. If 'size' byte can not be read in the core file reader,
-* 'size' parameter is updated to match the correct number of read bytes.
-* @param pContext: (IN) File reader context.
-* @param pData : (OUT) Data pointer of the read data.
-* @param pSize : (INOUT) Size of the data to read (in byte).
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_PARAMETER pSize, fileDescriptor or pData is NULL
-* @return M4ERR_ALLOC there is no more memory available
-* @return M4ERR_BAD_CONTEXT provided context is not a valid one.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadData_cache(M4OSA_Context pContext,M4OSA_MemAddr8 pData,
- M4OSA_UInt32* pSize)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
-
- M4OSA_ERR err;
- M4OSA_FilePosition aSize;
- M4OSA_FilePosition copiedSize;
- M4OSA_Int8 selected_buffer, current_buffer;
- M4OSA_Int32 castedSize;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE2_3("M4OSA_fileReadData_cache of %s size=%d at pos=%d ",
- apContext->m_filename, *pSize, apContext->absolutePos);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pData);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pSize);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
-LOCK
-
-/* 20080125 Start : if *pSize is too high, adjust it to the size left in the file. MI-958*/
- castedSize = * pSize;
- if (castedSize < 0)
- {
- copiedSize = 0;
- err = M4WAR_NO_MORE_AU;
-#ifdef M4OSA_FILECACHE_MM
- err = M4WAR_NO_DATA_YET; /* no_data_yet for MM */
-#endif
- goto cleanup;
- }
-/* 20080125 End : if *pSize is too high, adjust it to the size left in the file. MI-958*/
-
- /* Prevent reading beyond EOF */
- if((*pSize > 0) && (apContext->absolutePos >= apContext->virtualFileSize)) /* virtual FSize*/
- {
- copiedSize = 0;
- err = M4WAR_NO_MORE_AU; /* for VA and VPS */
-#ifdef M4OSA_FILECACHE_MM
- err = M4WAR_NO_DATA_YET; /* no_data_yet for MM */
-#endif
- goto cleanup;
- }
-
-/* 20080125 Start : if *pSize is too high, adjust it to the size left in the file. MI-958*/
- if (*pSize > (M4OSA_UInt32)(apContext->virtualFileSize - apContext->absolutePos))
- {
- M4OSA_TRACE1_0("M4OSA_fileReadData_cache : Attempted to read beyond file size, adjusted size");
- *pSize = apContext->virtualFileSize - apContext->absolutePos;
- }
-/* 20080125 End : if *pSize is too high, adjust it to the size left in the file. MI-958*/
-
- /* Check if data can be read from a buffer */
- /* If not, fill one according to quantized positions */
- copiedSize = 0;
- err = M4NO_ERROR;
-
- selected_buffer = M4OSA_FileCache_BufferMatchToRead(apContext,
- apContext->absolutePos);
-
- if(selected_buffer == M4OSA_CACHEBUFFER_NONE)
- {
-
-#if defined(BUFFER_SELECT_INITIAL)
- selected_buffer = M4OSA_FileCache_BufferSelectForRead(apContext);
-#elif defined(BUFFER_SELECT_WITH_TIME)
- selected_buffer = M4OSA_FileCache_BufferSelectWithTime(apContext);
-#elif defined(BUFFER_SELECT_WITH_SPACE)
- selected_buffer = M4OSA_FileCache_BufferSelectWithSpace(apContext);
-#elif defined(BUFFER_SELECT_WITH_POS)
- selected_buffer = M4OSA_FileCache_BufferSelectWithPos(apContext);
-#endif
-
- if (M4OSA_CACHEBUFFER_NONE == selected_buffer)
- {
- err = M4ERR_BAD_CONTEXT; /* temporary error code */
- goto cleanup;
- }
-
- err = M4OSA_FileCache_BufferFill(apContext, selected_buffer,
- apContext->absolutePos);
- }
-#ifdef FILECACHE_STATS
- else
- {
- /* bufferMatch has success in read */
- apContext->nbReadCache++;
- }
-#endif /* FILECACHE_STATS */
-
- if(err != M4NO_ERROR)
- {
- if((err == M4WAR_NO_DATA_YET) && (*pSize <= (M4OSA_UInt32)apContext->buffer[selected_buffer].size))
- err = M4NO_ERROR;
- else goto cleanup;
- }
-
- M4OSA_TRACE3_3("readData size = %d buffer = %d pos = %d",
- *pSize, selected_buffer, apContext->absolutePos);
-
- /* Copy buffer into pData */
- while(((M4OSA_UInt32)copiedSize < *pSize) && (err == M4NO_ERROR))
- {
- aSize = M4OSA_FileCache_BufferCopy(apContext, selected_buffer,
- apContext->absolutePos+copiedSize,
- *pSize-copiedSize, pData+copiedSize);
- copiedSize += aSize;
-
- if(aSize == 0)
- {
- err = M4WAR_NO_DATA_YET;
- }
- else
- {
- if((M4OSA_UInt32)copiedSize < *pSize)
- {
- current_buffer = selected_buffer;
- selected_buffer = M4OSA_FileCache_BufferMatchToRead(apContext,
- apContext->absolutePos+copiedSize);
-
- if(selected_buffer == M4OSA_CACHEBUFFER_NONE)
- {
-#if defined(BUFFER_SELECT_INITIAL)
- selected_buffer = M4OSA_FileCache_BufferSelectForRead(apContext);
-#elif defined(BUFFER_SELECT_WITH_TIME)
- selected_buffer = M4OSA_FileCache_BufferSelectWithTime(apContext);
-#elif defined(BUFFER_SELECT_WITH_SPACE)
- selected_buffer = M4OSA_FileCache_BufferSelectWithSpace(apContext);
-#elif defined(BUFFER_SELECT_WITH_POS)
- selected_buffer = M4OSA_FileCache_BufferSelectWithPos(apContext);
-#endif
-
- if (M4OSA_CACHEBUFFER_NONE == selected_buffer)
- {
- err = M4ERR_BAD_CONTEXT; /* temporary error code */
- goto cleanup;
- }
-
- err = M4OSA_FileCache_BufferFill(apContext, selected_buffer,
- apContext->absolutePos+copiedSize);
-
- if(err != M4NO_ERROR)
- {
- if((err == M4WAR_NO_DATA_YET) && ((*pSize-copiedSize) <= (M4OSA_UInt32)apContext->buffer[selected_buffer].size))
- err = M4NO_ERROR;
- else goto cleanup;
- }
- }
-#ifdef FILECACHE_STATS
- else
- {
- /* bufferMatch has success in read */
- apContext->nbReadCache++;
- }
-#endif /* FILECACHE_STATS */
-
- }
- }
- }
-
-cleanup :
-
- /* Update the new position of the pointer */
- apContext->absolutePos = apContext->absolutePos + copiedSize;
-
-#ifdef M4OSA_FILECACHE_MM
- apContext->absoluteWritePos = apContext->absolutePos;
-#endif /* M4OSA_FILECACHE_MM */
-
- if(err != M4NO_ERROR)
- {
- M4OSA_TRACE1_3("M4OSA_fileReadData_cache size = %d copied = %d err = 0x%x",
- *pSize, copiedSize, err);
- }
-
- /* Effective copied size must be returned */
- *pSize = copiedSize;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileReadDatatime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-UNLOCK
-
- /* Read is done */
- return err;
-}
-
-
-/**
- ************************************************************************
- * @brief This function writes the 'size' bytes stored at 'data' memory
- * in the file selected by its context.
- * @note The caller is responsible for allocating/de-allocating the
- * memory for 'data' parameter.
- * @note Moreover the data pointer must be allocated to store at least
- * 'size' bytes.
- * @param pContext: (IN/OUT) Context of the core file reader
- * @param pData: (IN) Data pointer of the write data
- * @param size: (IN) Size of the data to write (in bytes)
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_ALLOC: there is no more memory available
- ************************************************************************/
-
-M4OSA_ERR M4OSA_fileWriteData_cache(M4OSA_Context pContext,M4OSA_MemAddr8 pData,
- M4OSA_UInt32 size)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
-
- M4OSA_ERR err;
- M4OSA_FilePosition aSize;
- M4OSA_FilePosition copiedSize;
- M4OSA_Int8 selected_buffer, current_buffer;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE2_3("M4OSA_fileWriteData_cache of %s size=%d at pos=%d ",
- apContext->m_filename, size, apContext->absoluteWritePos);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pData);
-
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
- /*protection*/
- if (apContext->absoluteWritePos > apContext->virtualFileSize)
- {
- M4OSA_TRACE1_0("M4OSA_fileWriteData_cache ERROR : attempting to write beyond EOF");
- return M4WAR_NO_DATA_YET;
- }
-
-LOCK
-
- /* Check if data has been read into a buffer */
- /* If not, we should read that buffer first and then fill it */
- copiedSize = 0;
- err = M4NO_ERROR;
-
- selected_buffer = M4OSA_FileCache_BufferMatchToWrite(apContext,
- apContext->absoluteWritePos);
-
- if(selected_buffer == M4OSA_CACHEBUFFER_NONE)
- {
-#if defined(BUFFER_SELECT_INITIAL)
- selected_buffer = M4OSA_FileCache_BufferSelectForWrite(apContext);
-#elif defined(BUFFER_SELECT_WITH_TIME)
- selected_buffer = M4OSA_FileCache_BufferSelectWithTime(apContext);
-#elif defined(BUFFER_SELECT_WITH_SPACE)
- selected_buffer = M4OSA_FileCache_BufferSelectWithSpace(apContext);
-#elif defined(BUFFER_SELECT_WITH_POS)
- selected_buffer = M4OSA_FileCache_BufferSelectWithPos(apContext);
-#endif
-
- if (M4OSA_CACHEBUFFER_NONE == selected_buffer)
- {
- M4OSA_TRACE1_1("M4OSA_fileWriteData_cache ERR1 err=0x%x", err);
- err = M4ERR_BAD_CONTEXT; /* temporary error code */
- goto cleanup;
- }
-
- if (apContext->absoluteWritePos - M4OSA_CACHEBUFFER_SIZE < apContext->fileSize) /* absolutePos not readfilepo strictly < */
- {
- err = M4OSA_FileCache_BufferFill(apContext, selected_buffer,
- apContext->absoluteWritePos);
- }
- else
- {
- err = M4OSA_FileCache_BufferReinitialize(apContext, selected_buffer,
- apContext->absoluteWritePos);
- }
-
- }
-#ifdef FILECACHE_STATS
- else
- {
- /* bufferMatch has success in write */
- apContext->nbWriteCache++;
- }
-#endif /* FILECACHE_STATS */
-
- if(err != M4NO_ERROR)
- {
- if(err == M4WAR_NO_DATA_YET) /* means the buffer is small, it is at EOF, bufferFill didn't fully fill it*/
- err = M4NO_ERROR;
- else goto cleanup;
- }
-
- M4OSA_TRACE3_3("writeData size = %d buffer = %d pos = %d", size,
- selected_buffer, apContext->absoluteWritePos);
-
- /* Copy buffer into pData */
- while(((M4OSA_UInt32)copiedSize < size) && (err == M4NO_ERROR))
- {
- aSize = M4OSA_FileCache_BufferModifyContent(apContext, selected_buffer,
- apContext->absoluteWritePos+copiedSize,
- size-copiedSize, pData+copiedSize);
- copiedSize += aSize;
-
- /* update virtualFileSize in case we write at the end */
- if (apContext->absoluteWritePos+copiedSize>apContext->virtualFileSize)
- {
- apContext->virtualFileSize = apContext->absoluteWritePos+copiedSize;
- M4OSA_TRACE3_1("virtualFileSize incremented to %d", apContext->virtualFileSize);
- }
-
- if((M4OSA_UInt32)copiedSize < size)
- {
- current_buffer = selected_buffer;
- selected_buffer = M4OSA_FileCache_BufferMatchToWrite(apContext,
- apContext->absoluteWritePos+copiedSize);
-
- if(selected_buffer == M4OSA_CACHEBUFFER_NONE)
- {
-#if defined(BUFFER_SELECT_INITIAL)
- selected_buffer = M4OSA_FileCache_BufferSelectForWrite(apContext);
-#elif defined(BUFFER_SELECT_WITH_TIME)
- selected_buffer = M4OSA_FileCache_BufferSelectWithTime(apContext);
-#elif defined(BUFFER_SELECT_WITH_SPACE)
- selected_buffer = M4OSA_FileCache_BufferSelectWithSpace(apContext);
-#elif defined(BUFFER_SELECT_WITH_POS)
- selected_buffer = M4OSA_FileCache_BufferSelectWithPos(apContext);
-#endif
-
- if (M4OSA_CACHEBUFFER_NONE == selected_buffer)
- {
- M4OSA_TRACE1_1("M4OSA_fileWriteData_cache ERR2 err=0x%x", err);
- err = M4ERR_BAD_CONTEXT; /* temporary error code */
- goto cleanup;
- }
-
- if (apContext->absoluteWritePos+copiedSize < apContext->fileSize) /* absolutePos not readfilepo strictly < */
- {
- err = M4OSA_FileCache_BufferFill(apContext, selected_buffer,
- apContext->absoluteWritePos+copiedSize);
- }
- else
- {
- err = M4OSA_FileCache_BufferReinitialize(apContext,
- selected_buffer,
- apContext->absoluteWritePos+copiedSize);
- }
-
-
- if(err != M4NO_ERROR)
- {
- if((err == M4WAR_NO_DATA_YET))
- err = M4NO_ERROR;
- else goto cleanup;
- }
- }
-#ifdef FILECACHE_STATS
- else /* (selected_buffer == M4OSA_CACHEBUFFER_NONE) */
- {
- /* bufferMatch has success in write */
- apContext->nbWriteCache++;
- }
-#endif /* FILECACHE_STATS */
-
- }
-
- }
-
-cleanup :
-
- /* Update the new position of the pointer */
- apContext->absoluteWritePos = apContext->absoluteWritePos + copiedSize;
-#ifdef M4OSA_FILECACHE_MM
- apContext->absolutePos = apContext->absoluteWritePos;
-#endif /* M4OSA_FILECACHE_MM */
-
- if(err != M4NO_ERROR)
- {
- M4OSA_TRACE3_3("M4OSA_fileWriteData_cache size = %d copied = %d err = 0x%x",
- size, copiedSize, err);
- }
-
- /* Effective copied size must be returned */
- size = copiedSize;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileWriteDatatime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-UNLOCK
-
- /* Read is done */
- return err;
-}
-
-
-/**
-******************************************************************************
-* @brief This method seeks at the provided position in the core file reader (selected by its 'context').
-* The position is related to the seekMode parameter it can be either :
-* From the beginning (position MUST be positive) : end position = position
-* From the end (position MUST be negative) : end position = file size + position
-* From the current position (signed offset) : end position = current position + position.
-* @param pContext: (IN) File reader context.
-* @param SeekMode : (IN) Seek access mode.
-* @param pPosition : (IN) Position in the file.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_PARAMETER Seekmode or fileDescriptor is NULL
-* @return M4ERR_ALLOC there is no more memory available
-* @return M4ERR_BAD_CONTEXT provided context is not a valid one.
-* @return M4ERR_FILE_INVALID_POSITION the position cannot be reached.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadSeek_cache( M4OSA_Context pContext,
- M4OSA_FileSeekAccessMode SeekMode,
- M4OSA_FilePosition* pPosition)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_FilePosition finalPos;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE3_2("M4OSA_fileReadSeek_cache mode = %d pos = %d", SeekMode, *pPosition);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pPosition);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, SeekMode);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /*< The context can not be correct */
- }
-
-LOCK
-
- /* Go to the desired position */
- switch(SeekMode)
- {
- case M4OSA_kFileSeekBeginning :
- finalPos = *pPosition;
- break;
-
- case M4OSA_kFileSeekEnd :
- finalPos = apContext->virtualFileSize + *pPosition;
- break;
-
- case M4OSA_kFileSeekCurrent :
- finalPos = apContext->absolutePos + *pPosition;
- break;
-
- default :
- UNLOCK
- return M4ERR_PARAMETER; /**< Bad SeekAcess mode */
- break;
- }
-
- M4OSA_TRACE2_1("M4OSA_fileReadSeek_cache to absolutePos = %d ", finalPos);
-
-/* 20080125 Start : Protect against seek outside file. MI-958*/
- if (finalPos <= apContext->virtualFileSize && finalPos>=0)
- {
- apContext->absolutePos = finalPos;
- *pPosition = finalPos;
- }
- else
- {
- M4OSA_TRACE1_2("M4OSA_fileReadSeek_cache: attempted to seek at %d whilst filesize=%d",
- finalPos, apContext->virtualFileSize);
- *pPosition = apContext->absolutePos; /* keep the previous position */
- //err = M4ERR_FILE_INVALID_POSITION;
- err = M4NO_ERROR; /* for VA */
- }
-/* 20080125 End : Protect against seek outside file. MI-958*/
-
-#ifdef M4OSA_FILECACHE_MM
- apContext->absoluteWritePos = apContext->absolutePos;
-#endif /* M4OSA_FILECACHE_MM */
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileSeektime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-UNLOCK
-
- /* Return without error */
- return err;
-}
-
-
-/**
-******************************************************************************
-* @brief This method seeks at the provided position in the core file reader (selected by its 'context').
-* The position is related to the seekMode parameter it can be either :
-* From the beginning (position MUST be positive) : end position = position
-* From the end (position MUST be negative) : end position = file size + position
-* From the current position (signed offset) : end position = current position + position.
-* @param pContext: (IN) File reader context.
-* @param SeekMode : (IN) Seek access mode.
-* @param pPosition : (IN) Position in the file.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_PARAMETER Seekmode or fileDescriptor is NULL
-* @return M4ERR_ALLOC there is no more memory available
-* @return M4ERR_BAD_CONTEXT provided context is not a valid one.
-* @return M4ERR_FILE_INVALID_POSITION the position cannot be reached.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteSeek_cache( M4OSA_Context pContext,
- M4OSA_FileSeekAccessMode SeekMode,
- M4OSA_FilePosition* pPosition)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_FilePosition finalPos;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE3_2("M4OSA_fileWriteSeek_cache mode = %d pos = %d", SeekMode, *pPosition);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pPosition);
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, SeekMode);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /*< The context can not be correct */
- }
-
-LOCK
-
- /* Go to the desired position */
- switch(SeekMode)
- {
- case M4OSA_kFileSeekBeginning :
- finalPos = *pPosition;
- break;
-
- case M4OSA_kFileSeekEnd :
- finalPos = apContext->virtualFileSize + *pPosition;
- break;
-
- case M4OSA_kFileSeekCurrent :
- finalPos = apContext->absoluteWritePos + *pPosition;
- break;
-
- default :
- UNLOCK
- return M4ERR_PARAMETER; /**< Bad SeekAcess mode */
- break;
- }
-
- M4OSA_TRACE2_1("M4OSA_fileWriteSeek_cache to absoluteWritePos = %d ", finalPos);
-
-/* 20080125 Start : Protect against seek outside file. MI-958*/
- if (finalPos <= apContext->virtualFileSize && finalPos>=0)
- {
- apContext->absoluteWritePos = finalPos;
- *pPosition = finalPos;
- }
- else
- {
- M4OSA_TRACE1_2("M4OSA_fileWriteSeek_cache: attempted to seek at %d whilst filesize=%d ",
- finalPos, apContext->virtualFileSize);
- *pPosition = apContext->absoluteWritePos; /* keep the previous position */
- //err = M4ERR_FILE_INVALID_POSITION;
- err = M4NO_ERROR; /* for VA */
- }
-/* 20080125 End : Protect against seek outside file. MI-958*/
-
-#ifdef M4OSA_FILECACHE_MM
- apContext->absolutePos = apContext->absoluteWritePos;
-#endif /* M4OSA_FILECACHE_MM */
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileSeektime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-UNLOCK
-
- /* Return without error */
- return err;
-}
-
-M4OSA_ERR M4OSA_fileFlush_cache( M4OSA_Context pContext)
-{
- /* Do nothing, M4OSA_fileCache module manages its caches by itself */
-
- return M4NO_ERROR;
-}
-/**
-******************************************************************************
-* @brief This method asks the core file reader to close the file (associated to the context).
-* @param pContext: (IN) File reader context.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_BAD_CONTEXT provided context is not a valid one.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileClose_cache(M4OSA_Context pContext)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
-
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Int32 aRet_Val = 0;
- M4OSA_UInt16 errReturned = 0;
-
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_TRACE2_1("M4OSA_fileClose_cache pC = 0x%x", pContext);
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /**< The context can not be correct */
- }
-
-LOCK
-
-#ifdef BUFFER_DISPLAY
- M4OSA_FileCache_BufferDisplay(apContext);
-#endif
-
- M4OSA_FileCache_BuffersFlushUntil(apContext, M4OSA_CACHEBUFFER_ALL);
-
- /* buffer */
- M4OSA_FileCache_BuffersFree(apContext);
-
- /* Close the file */
- aRet_Val = apContext->FS->pFctPtr_Close(apContext->aFileDesc, &errReturned);
-
- if (aRet_Val != 0)
- {
- /* converts the error to PSW format*/
- err = M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_READER, errReturned);
- M4OSA_TRACE1_1("M4OSA_fileClose_cache ERR1 = 0x%x", err);
- }
- apContext->IsOpened = M4OSA_FALSE;
-
- /* Free the context */
- free(apContext->FS);
- free(apContext->aFileDesc);
-
-#ifdef FILECACHE_STATS
-{
- M4OSA_Int32 successRateRead, successRateWrite;
-
- successRateRead= (apContext->nbReadFFS + apContext->nbReadCache ==0)? (-1) : (apContext->nbReadCache)*100 / (apContext->nbReadCache + apContext->nbReadFFS);
-
- successRateWrite = (apContext->nbWriteFFS + apContext->nbWriteCache == 0)? (-1) : (apContext->nbWriteCache)*100 / (apContext->nbWriteCache + apContext->nbWriteFFS);
-
-#if defined(BUFFER_SELECT_INITIAL)
- M4OSA_TRACE1_0("BUFFER_SELECT_INITIAL");
-#elif defined(BUFFER_SELECT_WITH_TIME)
- M4OSA_TRACE1_0("BUFFER_SELECT_WITH_TIME");
-#elif defined(BUFFER_SELECT_WITH_SPACE)
- M4OSA_TRACE1_0("BUFFER_SELECT_WITH_SPACE");
-#elif defined(BUFFER_SELECT_WITH_POS)
- M4OSA_TRACE1_0("BUFFER_SELECT_WITH_POS");
-#endif
-
- M4OSA_TRACE1_1("Osal File Cache Stats for %s", apContext->m_filename);
- M4OSA_TRACE1_2("FILECACHE_STATS: nbReadCache=%d / nbReadFFS=%d",
- apContext->nbReadCache, apContext->nbReadFFS);
- M4OSA_TRACE1_2("FILECACHE_STATS: nbWriteCache=%d / nbWriteFFS=%d",
- apContext->nbWriteCache, apContext->nbWriteFFS);
- M4OSA_TRACE1_2("FILECACHE_STATS: Success in reading : %d percent - Success in writing %d percent",
- successRateRead, successRateWrite);
- M4OSA_TRACE1_0("---------------------------------------------------------");
-}
-#endif /* FILECACHE_STATS */
-
- UNLOCK
-
- if (apContext->m_mutex != M4OSA_NULL)
- {
- M4OSA_mutexClose(apContext->m_mutex);
- apContext->m_mutex = M4OSA_NULL;
- }
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileClosetime] += time2-time1;
-
- M4OSA_FileCache_displayTimeMeas(apContext);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- M4OSA_memset((M4OSA_MemAddr8)apContext, sizeof(M4OSA_FileCache_Context), 0);
-
- free(apContext);
-
- M4OSA_TRACE2_1("M4OSA_fileClose_cache leaving with err = 0x%x", err);
-
- /* Return without error */
- return err;
-}
-
-/**
-******************************************************************************
-* @brief This method asks the core file reader to set the value associated with the optionID.
-* The caller is responsible for allocating/de-allocating the memory of the value field.
-* @note The options handled by the component depend on the implementation of the component.
-* @param pContext: (IN) Execution context.
-* @param OptionId : (IN) Id of the option to set.
-* @param OptionValue : (IN) Value of the option.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_BAD_CONTEXT pContext is NULL
-* @return M4ERR_BAD_OPTION_ID the option id is not valid.
-* @return M4ERR_NOT_IMPLEMENTED The option is not implemented yet.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileSetOption_cache(M4OSA_Context pContext,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption OptionValue)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /**< The context can not be correct */
- }
-
- /* Set the desired option if it is avalaible */
- switch(OptionID)
- {
- case M4OSA_kFileReadGetFileSize : /**< Get size of the file, limited to 32 bit size */
- case M4OSA_kFileReadGetFileAttribute : /**< Get the file attribute*/
- case M4OSA_kFileReadGetURL : /**< Get the directory + name of the file */
- case M4OSA_kFileReadIsEOF : /**< See if we are at the end of the file */
- case M4OSA_kFileReadGetFilePosition : /**< Get file position */
- return M4ERR_READ_ONLY;
- break;
-
- case M4OSA_kFileWriteDescMode:
- return M4NO_ERROR; /* for MM */
-
- default : /**< Bad option ID */
- return M4ERR_BAD_OPTION_ID;
- break;
- }
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileSetOptiontime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- /* Return without error */
- return M4NO_ERROR;
-}
-
-/**
-******************************************************************************
-* @brief This method asks the core file reader to return the value associated with the optionID.
-* The caller is responsible for allocating/de-allocating the memory of the value field.
-* @note The options handled by the component depend on the implementation of the component.
-* @param pContext: (IN) Execution context.
-* @param OptionId : (IN) Id of the option to set.
-* @param pOptionValue : (OUT) Value of the option.
-* @return M4NO_ERROR: there is no error
-* @return M4ERR_BAD_CONTEXT pContext is NULL
-* @return M4ERR_BAD_OPTION_ID the option id is not valid.
-* @return M4ERR_NOT_IMPLEMENTED The option is not implemented yet.
-******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileGetOption_cache(M4OSA_Context pContext,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption* pOptionValue)
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_Bool isEof;
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_Time time1 = 0;
- M4OSA_Time time2 = 0;
-
- M4OSA_clockGetTime(&time1,1000);
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
-
- /* Check input parameters */
- M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_BAD_CONTEXT, apContext);
-
- if (apContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /**< The context can not be correct */
- }
-
-LOCK
-
- /* Get the desired option if it is avalaible */
- switch(OptionID)
- {
- /* Get File Size */
- case M4OSA_kFileReadGetFileSize:/**< Get size of the file, limited to 32 bit size */
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache ReadGetFileSize return filesize = %d ",
- apContext->virtualFileSize);
- (*(M4OSA_UInt32 *)pOptionValue) = apContext->virtualFileSize; /* return virtual */
- break;
-
-
- case M4OSA_kFileWriteGetFileSize:/**< Get size of the file, limited to 32 bit size */
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache WriteGetFileSize return filesize = %d ",
- apContext->virtualFileSize);
- (*(M4OSA_UInt32 *)pOptionValue) = apContext->virtualFileSize; /* return virtual */
- break;
-
- /* Check End of file Occurs */
- case M4OSA_kFileReadIsEOF : /**< See if we are at the end of the file */
- isEof = (apContext->absolutePos >= apContext->virtualFileSize) ? M4OSA_TRUE : M4OSA_FALSE; /* virtual */
- (*(M4OSA_Bool *)pOptionValue) = isEof;
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache ReadIsEOF return isEof=%d ",
- isEof);
- break;
-
- /* Get File Position */
- case M4OSA_kFileReadGetFilePosition : /**< Get file position */
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache ReadGetFilePosition return rpos=%d ",
- apContext->absolutePos);
- *(M4OSA_FilePosition *)pOptionValue = apContext->absolutePos;
- break;
-
- /* Get File Position */
- case M4OSA_kFileWriteGetFilePosition : /**< Get file position */
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache WriteGetFilePosition return wpos=%d ",
- apContext->absoluteWritePos);
- *(M4OSA_FilePosition *)pOptionValue = apContext->absoluteWritePos;
- break;
-
- /* Get Attribute */
- case M4OSA_kFileReadGetFileAttribute : /**< Get the file attribute = access mode */
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache ReadGetFileAttribute return mode=%d ",
- apContext->FileAttribute.modeAccess);
- (*(M4OSA_FileAttribute *)pOptionValue).modeAccess = apContext->FileAttribute.modeAccess;
- break;
- /** Get the reader context for read & write file. (M4OSA_Context*)*/
- case M4OSA_kFileWriteGetReaderContext:
- M4OSA_TRACE2_1("M4OSA_fileGetOption_cache WriteGetReaderContext return c=0x%x ",
- apContext);
- (*(M4OSA_Context *)pOptionValue) = apContext;
- break;
- default:
- /**< Bad option ID */
- UNLOCK
- return M4ERR_BAD_OPTION_ID;
- break;
- }
-
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
- M4OSA_clockGetTime(&time2,1000);
- if (time2>time1)
- apContext->gMyPerfFileTab[fileGetOptiontime] += time2-time1;
-#endif /* M4OSA_FILE_CACHE_TIME_MEAS */
-
- UNLOCK
-
-
- /*Return without error */
- return err;
-}
-
-/* For VA */
-M4OSA_ERR M4OSA_fileExtrafTruncate_cache(M4OSA_Context context, M4OSA_UInt32 length)
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_UInt16 result = M4OSA_FALSE;
- M4OSA_FileCache_Context* apContext = context;
-
-
- FILE* filedesc1 = ((M4OSA_FileSystem_FFS_t_cache*) ( apContext->aFileDesc))->FileDesc;
-
- result = ftruncate(filedesc1->_file, length);
-
- if(result != 0)
- {
- err = errno;
- M4OSA_TRACE1_1("SetEndOfFile returns err: 0x%x\n", err);
- return M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_EXTRA, err);
- }
- return M4NO_ERROR;
-}
-#ifdef M4OSA_FILE_CACHE_TIME_MEAS
-
-/**************************************************************/
-void M4OSA_FileCache_initTimeMeas(M4OSA_Context pContext)
-/**************************************************************/
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
- M4OSA_Time time1 = 0;
-
- memset(apContext->gMyPerfFileTab, 0, sizeof(apContext->gMyPerfFileTab)); //Reset perf measurement array
-
- M4OSA_clockGetTime(&time1,1000);
- apContext->gMyPerfFileTab[enum_size] = time1; //to compute total application time
-
-}
-
-/**************************************************************/
-void M4OSA_FileCache_displayTimeMeas(M4OSA_Context pContext)
-/**************************************************************/
-{
- M4OSA_FileCache_Context* apContext = (M4OSA_FileCache_Context*) pContext;
-
- M4OSA_Time globalfileperfmeas = 0;
- M4OSA_Time time2 = 0;
- M4OSA_UInt32 i=0;
-
- M4OSA_clockGetTime(&time2,1000);
-
- /* Time spent in application */
- time2 = time2-apContext->gMyPerfFileTab[enum_size];
-
- /* Time spent in File System procedures */
- for (i=0; i<enum_size; i++)
- globalfileperfmeas += apContext->gMyPerfFileTab[i];
-
- M4OSA_TRACE1_1("Osal File Cache Time measurement for %s ",
- apContext->m_filename);
- M4OSA_TRACE1_2("Application time =%d, fileCache total time =%d",
- (M4OSA_Int32)time2,
- (M4OSA_Int32)globalfileperfmeas);
- M4OSA_TRACE1_4("Opentime:%d, ReadDatatime:%d, WriteDatatime: %d, Seektime:%d",
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileOpentime] ,
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileReadDatatime] ,
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileWriteDatatime] ,
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileSeektime] );
- M4OSA_TRACE1_4("GetOptiontime:%d, SetOptiontime:%d, ExternalFlush: %d, Closetime: %d",
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileGetOptiontime] ,
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileSetOptiontime],
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileExternalFlushtime],
- (M4OSA_Int32)apContext->gMyPerfFileTab[fileClosetime]);
- M4OSA_TRACE1_0("--------------------------------------------------------------------");
-}
-
-#endif /* M4OSA_FILE_INTERFACE_MM_TIME_MEAS */
diff --git a/libvideoeditor/osal/src/M4OSA_FileExtra.c b/libvideoeditor/osal/src/M4OSA_FileExtra.c
deleted file mode 100755
index bcac97c..0000000
--- a/libvideoeditor/osal/src/M4OSA_FileExtra.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
-************************************************************************
-* @file M4OSA_FileExtra.c
-* @brief File extra for Android
-* @note This file implements a set of basic functions to handle file
-* itself.
-************************************************************************
-*/
-
-#include "M4OSA_Debug.h"
-#include "M4OSA_FileCommon.h"
-#include "M4OSA_FileCommon_priv.h"
-#include "M4OSA_FileExtra.h"
-#include "M4OSA_FileReader.h"
-#include "M4OSA_FileWriter.h"
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
-
-
-
-/**
- ************************************************************************
- * @brief This function deletes the provided URL.
- * @note
- * @param pUrl: (IN) URL of the file to delete
- * @param fileModeAccess: (IN) File mode access
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtraDelete(const M4OSA_Char* pUrl)
-{
-
- M4OSA_Int32 err;
-#ifdef UTF_CONVERSION
- M4OSA_Void* tempConversionBuf;
- M4OSA_UInt32 tempConversionSize = 1000; /*size of the decoded buffer,
- can be increase if necessary*/
-#endif /* UTF_CONVERSION */
-
- M4OSA_TRACE1_1("M4OSA_fileExtraDelete\t\tM4OSA_Char* %s", pUrl);
- M4OSA_DEBUG_IF2(M4OSA_NULL == pUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraDelete: pUrl is M4OSA_NULL");
-
-#ifdef UTF_CONVERSION
- /*FB: to test the UTF16->UTF8 conversion into Video Artist*/
- /*Convert the URL from UTF16 to UTF8*/
- tempConversionBuf = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(tempConversionSize +1, 0,
- (M4OSA_Char*)"conversion buf");
- if(tempConversionBuf == M4OSA_NULL)
- {
- M4OSA_TRACE1_0("Error when allocating conversion buffer\n");
- return M4ERR_PARAMETER;
- }
- M4OSA_ToUTF8_OSAL((M4OSA_Void*)pUrl, tempConversionBuf, &tempConversionSize);
- ((M4OSA_Char*)tempConversionBuf)[tempConversionSize ] = '\0';
-
- printf("remove file %s\n", tempConversionBuf);
-
- /*Open the converted path*/
- err = remove (tempConversionBuf);
- /*Free the temporary decoded buffer*/
- free(tempConversionBuf);
-#else
- err = remove((const char *)pUrl);
-#endif /* UTF_CONVERSION */
-
- if(-1 == err)
- {
- M4OSA_DEBUG(M4ERR_PARAMETER,
- "M4OSA_fileExtraDelete: Cannot remove the input url");
- return M4ERR_PARAMETER;
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function copies the file located by 'pSrcUrl' to 'pDstUrl'.
- * @note
- * @param pSrcUrl: (IN) source URL
- * @param pDstUrl: (IN) Destination URL
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtraCopy(M4OSA_Char* pSrcUrl, M4OSA_Char* pDstUrl)
-{
- M4OSA_Context pInputFileContext = M4OSA_NULL;
- M4OSA_Context pOutputFileContext= M4OSA_NULL;
-
- M4OSA_ERR err;
- M4OSA_UInt32 uiSizeRead = BUFFER_COPY_SIZE;
- M4OSA_MemAddr32 copy_buffer;
-
- M4OSA_TRACE1_2("M4OSA_fileExtraDelete\t\tM4OSA_Char* %s\tM4OSA_Char* %s",
- pSrcUrl, pDstUrl);
- M4OSA_DEBUG_IF2(M4OSA_NULL == pDstUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraCopy: pDstUrl is M4OSA_NULL");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pSrcUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraCopy: pSrcUrl is M4OSA_NULL");
-
- /* Open input file */
- err = M4OSA_fileReadOpen(&pInputFileContext, pSrcUrl, M4OSA_kFileRead);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err, "M4OSA_fileExtraCopy: M4OSA_fileReadOpen");
- return err;
- }
-
- /* Open output file */
- err = M4OSA_fileWriteOpen(&pOutputFileContext, pDstUrl,
- M4OSA_kFileWrite|M4OSA_kFileCreate);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err, "M4OSA_fileExtraCopy: M4OSA_fileWriteOpen");
- return err;
- }
-
- /* Allocate buffer */
- copy_buffer = M4OSA_32bitAlignedMalloc(BUFFER_COPY_SIZE, M4OSA_FILE_EXTRA,
- (M4OSA_Char*)"M4OSA_fileExtraCopy: copy buffer");
- if(M4OSA_NULL == copy_buffer)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_fileExtraCopy");
- return M4ERR_ALLOC;
- }
-
- /* Copy input file to output file using copy buffer */
- while (1)
- {
- /* Load data into copy buffer */
- err = M4OSA_fileReadData(pInputFileContext,
- (M4OSA_MemAddr8)copy_buffer, &uiSizeRead);
- if(M4NO_ERROR == err)
- {
- /* Write data to output file */
- err = M4OSA_fileWriteData(pOutputFileContext,
- (M4OSA_MemAddr8)copy_buffer, uiSizeRead);
- if(M4NO_ERROR != err)
- {
- break;
- }
- }
- else if (M4WAR_NO_DATA_YET == err)
- {
- /* no more data to copy, end of file reached */
- err = M4OSA_fileWriteData(pOutputFileContext,
- (M4OSA_MemAddr8)copy_buffer, uiSizeRead);
- break;
- }
- else
- {
- break; /* an error occur */
- }
- }
-
- /* Free copy buffer */
- free(copy_buffer);
-
- err = M4OSA_fileWriteClose(pOutputFileContext);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err, "M4OSA_fileExtraCopy: M4OSA_fileWriteClose");
- }
-
- err = M4OSA_fileReadClose(pInputFileContext);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err, "M4OSA_fileExtraCopy: M4OSA_fileReadClose");
- }
-
- return err;
-}
-
-
-/**
- ************************************************************************
- * @brief This function renames the 'pSrcUrl' to 'pDstUrl'.
- * @note
- * @param pSrcUrl: (IN) source URL
- * @param pDstUrl: (IN) Destination URL
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtraRename(M4OSA_Char* pSrcUrl, M4OSA_Char* pDstUrl)
-{
- M4OSA_ERR err;
- M4OSA_Int32 iValue;
- M4OSA_Char* pSrcFilename = M4OSA_NULL;
- M4OSA_Char* pDstFilename = M4OSA_NULL;
-
- M4OSA_TRACE1_2("M4OSA_fileExtraRename\t\tM4OSA_Char* %s\tM4OSA_Char* %s",
- pSrcUrl, pDstUrl);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pDstUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraRename: pSrcUrl is M4OSA_NULL");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pSrcUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraRename: pDstUrl is M4OSA_NULL");
-
- err = M4OSA_fileCommonGetFilename(pSrcUrl, &pSrcFilename);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err, "M4OSA_fileExtraRename: M4OSA_fileCommonGetFilename");
- return err;
- }
-
- err = M4OSA_fileCommonGetFilename(pDstUrl, &pDstFilename);
- if(M4NO_ERROR != err)
- {
- free(pSrcFilename);
- M4OSA_DEBUG(err, "M4OSA_fileExtraRename: M4OSA_fileCommonGetFilename");
- return err;
- }
-
- /* Rename file */
- iValue = rename((const char *)pSrcFilename, (const char *)pDstFilename);
- if (0 != iValue)
- {
- /*
- What error code shall be returned ? From MSDN:
- Each of these functions returns 0 if it is successful. On an error, the
- function returns a nonzero value and sets errno to one of the following
- values:
- - EACCES: File or directory specified by newname already exists or could
- not be created (invalid path); or oldname is a directory and newname
- specifies a different path.
- - ENOENT: File or path specified by oldname not found.
- - EINVAL: Name contains invalid characters.
- For other possible return values, see _doserrno, _errno, syserrlist, and
- _sys_nerr. */
- M4OSA_DEBUG(M4ERR_PARAMETER, "M4OSA_fileExtraRename: rename failed");
- return M4ERR_PARAMETER;
- }
-
- free(pDstFilename);
- free(pSrcFilename);
-
- return M4NO_ERROR;
-}
-
-
-
-/**
- ************************************************************************
- * @brief This function changes the current directory to the specified new
- * directory 'url'.
- * @note
- * @param pUrl: (IN) Directory to which current directory to be changed
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-
-M4OSA_ERR M4OSA_fileExtraChangeCurrentDir(const M4OSA_Char* pUrl)
-{
- M4OSA_ERR err;
- M4OSA_Char* pFileName = M4OSA_NULL;
- M4OSA_Int32 iValue = 0;
-
- M4OSA_TRACE1_1("M4OSA_fileExtraChangeCurrentDir\t\tM4OSA_Char* %s", pUrl);
- M4OSA_DEBUG_IF2(M4OSA_NULL == pUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraChangeCurrentDir: pUrl is M4OSA_NULL");
-
- err = M4OSA_fileCommonGetFilename((M4OSA_Char*)pUrl, &pFileName);
- if(M4NO_ERROR != err)
- {
- M4OSA_DEBUG(err,
- "M4OSA_fileExtraChangeCurrentDir: M4OSA_fileCommonGetFilename");
- return err;
- }
-
- iValue = chdir((char*)pFileName);
-
- if (iValue != 0)
- {
- /*
- What error code shall be returned ? From MSDN:
- Each of these functions returns a value of 0 if successful. A return
- value of -1 indicates that the specified path could not be found, in
- which case errno is set to ENOENT.*/
- M4OSA_DEBUG(M4ERR_PARAMETER,
- "M4OSA_fileExtraChangeCurrentDir: chdir failed");
- return(M4ERR_PARAMETER);
- }
-
- free(pFileName);
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function creates a new directory to the specified 'url'.
- * @note
- * @param pUrl: (IN) Path to create new directory with name
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtraCreateDir(const M4OSA_Char* pUrl)
-{
- M4OSA_Int32 err;
-
- M4OSA_TRACE2_1("M4OSA_fileExtraCreateDir %s", pUrl);
- M4OSA_DEBUG_IF2(M4OSA_NULL == pUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraCreateDir: pUrl is M4OSA_NULL");
-
- err = mkdir((char*)pUrl, S_IRWXU | S_IRWXG | S_IRWXO);
-
- if( err < 0 )
- {
- return M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_EXTRA, errno);
- }
-
- return M4NO_ERROR;
-}
-
-
-/**
- ************************************************************************
- * @brief This function removes the current directory.
- * @note
- * @param pUrl: (IN) Path of directory with name
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtraRemoveDir(const M4OSA_Char* pUrl)
-{
- M4OSA_Int32 err;
-
- M4OSA_TRACE2_1("M4OSA_fileExtraRemoveDir %s", pUrl);
- M4OSA_DEBUG_IF2(M4OSA_NULL == pUrl, M4ERR_PARAMETER,
- "M4OSA_fileExtraRemoveDir: pUrl is M4OSA_NULL");
-
- err = rmdir((char*)pUrl);
- if(err < 0 )
- {
- M4OSA_DEBUG(M4ERR_PARAMETER, "M4OSA_fileExtraRemoveDir failed");
- return M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_EXTRA, errno);
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief retrieves the free space.
- * @note
- * @param pUrl: (IN) root directory
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_UInt32 M4OSA_fileExtraGetFreeSpace(const M4OSA_Char* pUrl)
-{
- M4OSA_UInt32 size = 0;
- struct statfs stat;
-
- if ( M4OSA_NULL != pUrl )
- {
- if (0 == statfs( (const char *)pUrl, &stat ))
- {
- if ((stat.f_bfree * stat.f_bsize) > M4OSA_UINT32_MAX)
- {
- size = M4OSA_UINT32_MAX;
- }
- else
- {
- size = (M4OSA_UInt32)(stat.f_bfree * stat.f_bsize);
- }
- }
- }
-
- return (size);
-}
-
-/**
- ************************************************************************
- * @brief This function gets the total space
- * @note
- * @param pUrl: (IN) Path of directory with name
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_UInt32 M4OSA_fileExtraGetTotalSpace(const M4OSA_Char* pUrl)
-{
- M4OSA_UInt32 size = 0;
- struct statfs stat;
-
- if ( M4OSA_NULL != pUrl )
- {
- if (0 == statfs( (const char *)pUrl, &stat ))
- {
- if ((stat.f_blocks * stat.f_bsize) > M4OSA_UINT32_MAX)
- {
- size = M4OSA_UINT32_MAX;
- }
- else
- {
- size = (M4OSA_UInt32)(stat.f_blocks * stat.f_bsize);
- }
- }
- }
-
- return (size);
-}
-
-/**
- ************************************************************************
- * @brief This function retrieve the file type (Directory or file).
- * @note
- * @param pUrl: (IN) Path of directory with name
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- ************************************************************************
-*/
-M4OSA_EntryType M4OSA_fileExtraGetType(const M4OSA_Char* pUrl)
-{
- M4OSA_EntryType type = M4OSA_TypeInvalid;
- struct stat fileStat;
-
- if ( M4OSA_NULL != pUrl )
- {
- if (0 == stat( (const char *)pUrl, &fileStat))
- {
- if ( S_ISDIR( fileStat.st_mode ) )
- {
- type = M4OSA_TypeDir;
- }
- else
- {
- type = M4OSA_TypeFile;
- }
- }
- }
-
- return (type);
-}
-
-
-/**
- ************************************************************************
- * @brief This function truncate a file.
- * the file must be previously opened in write mode
- * @note the position pointer in the file is set to the beginning
- * of the file after the truncate
- * @param context: (IN) media context
- * @param length: (IN) length of the file after truncation
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_fileExtrafTruncate(M4OSA_Context context, M4OSA_FilePosition length)
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4OSA_UInt16 result = M4OSA_FALSE;
- M4OSA_FileContext* pFileContext = context;
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == context, M4ERR_PARAMETER,
- "M4OSA_fileExtrafTruncate: context is M4OSA_NULL");
- M4OSA_DEBUG_IF2(M4OSA_NULL == length, M4ERR_PARAMETER,
- "M4OSA_fileExtrafTruncate: length is M4OSA_NULL");
-
- result = ftruncate(pFileContext->file_desc->_file, length);
-
- if(result != 0)
- {
- err = errno;
- M4OSA_TRACE1_1("SetEndOfFile returns err: 0x%x\n", err);
- return M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_EXTRA, err);
- }
- return M4NO_ERROR;
-}
-
-
diff --git a/libvideoeditor/osal/src/M4OSA_FileReader_RAM.c b/libvideoeditor/osal/src/M4OSA_FileReader_RAM.c
deleted file mode 100755
index 0cfc006..0000000
--- a/libvideoeditor/osal/src/M4OSA_FileReader_RAM.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file M4OSA_FileReaderRam.c
- * @ingroup OSAL
- * @brief File reader from RAM
- * @note This file implements functions to read a "file" stored in RAM.
- * @date - 2004-05-11: creation
- ******************************************************************************
-*/
-
-#include "M4OSA_Debug.h"
-#include "M4OSA_FileReaderRam.h"
-#include "M4OSA_Memory.h"
-
-/**
- ******************************************************************************
- * structure M4OSA_FileReaderRam_Context
- * @brief This structure defines the File reader in Ram context (private)
- * @note This structure is used for all File Reader calls to store the context
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr8 pFileDesc; /* Pointer on file data */
- M4OSA_UInt32 dataSize; /* Size of data to read */
- M4OSA_UInt32 dataOffset; /* Actual offset */
- M4OSA_Bool IsOpened; /* Micro state machine */
-} M4OSA_FileReaderRam_Context;
-
-/**
- ******************************************************************************
- * @brief This function sets the read pointer at the provided adress and
- * returns a context.
- * If an error occured, the context is set to NULL.
- * @param context: (OUT) Context of the core file reader
- * @param url: (IN) URL of the input file
- * @param fileModeAccess: (IN) File mode access
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_NOT_IMPLEMENTED: the URL does not match with the supported
- * file
- * @return M4ERR_FILE_NOT_FOUND: the file cannot be found
- * @return M4ERR_FILE_LOCKED: the file is locked by an other
- * application/process
- * @return M4ERR_FILE_BAD_MODE_ACCESS: the file mode access is not correct
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamOpen( M4OSA_Context* context,
- M4OSA_Void* fileDescriptor,
- M4OSA_UInt32 fileModeAccess )
-{
- M4OSA_FileReaderRam_Context* pContext=M4OSA_NULL;
- M4OSA_FileReaderRam_Descriptor* pDescriptor=fileDescriptor;
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_TRACE3_3("M4OSA_fileReadRamOpen\t\tM4OSA_Context* 0x%x\tM4OSA_Void* 0x%x"
- "\tM4OSA_UInt32 %d", context, fileDescriptor,
- fileModeAccess);
-
- /* Check input parameters */
- if(M4OSA_NULL == context)
- {
- return M4ERR_PARAMETER;
- }
- *context = M4OSA_NULL;
- if(M4OSA_NULL == fileDescriptor)
- {
- return M4ERR_PARAMETER;
- }
-
- /* Allocates memory for the context */
- pContext = (M4OSA_FileReaderRam_Context*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileReaderRam_Context),
- M4OSA_FILE_READER, (M4OSA_Char*)"Context allocation");
- if(pContext == M4OSA_NULL)
- {
- return M4ERR_ALLOC;
- }
-
- /* Verify access mode */
- if (((fileModeAccess & M4OSA_kFileAppend) != 0)
- ||(0 == (fileModeAccess & M4OSA_kFileRead)))
- {
- err=M4ERR_FILE_BAD_MODE_ACCESS;
- goto cleanup;
- }
-
- /* Open file in read mode and in binary/text mode with/without creation right */
- if((fileModeAccess & M4OSA_kFileCreate) != 0)
- {
- err=M4ERR_FILE_BAD_MODE_ACCESS;
- }
- else
- {
- if ((fileModeAccess & M4OSA_kFileRead))
- {
- pContext->pFileDesc = (M4OSA_MemAddr8)(pDescriptor->pFileDesc);
- pContext->dataSize = (M4OSA_Int32)(pDescriptor->dataSize);
- pContext->dataOffset = 0;
- pContext->IsOpened = M4OSA_TRUE;
- }
- else
- {
- err=M4ERR_FILE_BAD_MODE_ACCESS;
- }
- }
-
-cleanup:
- if(err != M4NO_ERROR)
- {
- if(pContext != M4OSA_NULL)
- {
- free(pContext);
- *context = M4OSA_NULL;
- }
- }
- else
- {
- *context = pContext;
- }
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This function reads the 'size' bytes in memory
- * (selected by its 'context') and writes the data to the 'data'
- * pointer.
- * @note If 'size' byte cannot be read in the core file reader, 'size'
- * parameter is updated to match the correct
- * number of read bytes.
- * @param context: (IN/OUT) Context of the core file reader
- * @param data: (OUT) Data pointer of the read data
- * @param size: (IN/OUT) Size of the data to read (in bytes)
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4WAR_NO_DATA_YET: there is no enough data to fill the 'data'
- * buffer, so the size parameter has been updated.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamData( M4OSA_Context context, M4OSA_MemAddr8 data,
- M4OSA_UInt32* pSize )
-{
- M4OSA_FileReaderRam_Context* pContext=(M4OSA_FileReaderRam_Context*)context;
- M4OSA_UInt32 aSize = *pSize;
- M4OSA_ERR err = M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL || data == M4OSA_NULL || pSize == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
- /* Check if there is enough data to read or not */
- if((pContext->dataOffset + aSize) > pContext->dataSize)
- {
- aSize = pContext->dataSize - pContext->dataOffset;
- M4OSA_memcpy(data, (pContext->pFileDesc + pContext->dataOffset), aSize);
- *pSize = aSize;
- err = M4WAR_NO_DATA_YET;
- }
- else
- {
- M4OSA_memcpy(data, (pContext->pFileDesc + pContext->dataOffset), aSize);
- err = M4NO_ERROR;
- }
-
- pContext->dataOffset += aSize;
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This function seeks at the provided position in the core file
- * reader (selected by its 'context'). The position is related to
- * the seekMode parameter it can be either from the beginning, from
- * the end or from the current postion.
- * @note If this function returns an error the current position pointer
- * in the file must not change. Else the current
- * position pointer must be updated.
- * @param context: (IN/OUT) Context of the core file reader
- * @param seekMode: (IN) Seek access mode
- * @param position: (IN/OUT) Position in the file
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_ALLOC: there is no more memory available
- * @return M4ERR_FILE_INVALID_POSITION: the position cannot be reached
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamSeek( M4OSA_Context context,
- M4OSA_FileSeekAccessMode seekMode,
- M4OSA_FilePosition* position )
-{
- M4OSA_FileReaderRam_Context* pContext=(M4OSA_FileReaderRam_Context*)context;
- M4OSA_ERR err = M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL || seekMode == M4OSA_NULL || position == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
- /* */
- switch(seekMode)
- {
- case M4OSA_kFileSeekBeginning:
- /* Check if position is reachable and update dataOffset */
- if(((M4OSA_UInt32)(*position) <= pContext->dataSize) && (*position >= 0))
- {
- pContext->dataOffset = *position;
- *position = pContext->dataOffset;
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- break;
-
- case M4OSA_kFileSeekEnd:
- /* Check if position is reachable and update dataOffset */
- if(((M4OSA_Int32)(pContext->dataSize) + *position >= 0) && (*position <= 0))
- {
- pContext->dataOffset = pContext->dataSize + *position;
- *position = pContext->dataOffset;
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- break;
-
- case M4OSA_kFileSeekCurrent:
- /* Check if position is reachable and update dataOffset */
- if((*position + (M4OSA_Int32)(pContext->dataOffset) >= 0) &&
- (*position + (M4OSA_Int32)(pContext->dataOffset) <=
- (M4OSA_Int32)pContext->dataSize))
- {
- pContext->dataOffset += *position;
- *position = pContext->dataOffset;
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- break;
-
- default:
- err = M4ERR_PARAMETER;
- break;
- }
-
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This function asks the core file reader to close the file
- * (associated to the context).
- * @note The context of the core file reader is freed.
- * @param context: (IN/OUT) Context of the core file reader
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_ALLOC: there is no more memory available
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamClose(M4OSA_Context context)
-{
- M4OSA_FileReaderRam_Context* pContext=(M4OSA_FileReaderRam_Context*)context;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
- pContext->IsOpened = M4OSA_FALSE;
-
- free(pContext);
-
- return M4NO_ERROR;
-}
-
-/**
- ******************************************************************************
- * @brief This function asks the core file reader to return the value
- * associated with the optionID. The caller is responsible for
- * allocating/de-allocating the memory of the value field.
- * @note 'value' must be cast according to the type related to the
- * optionID As the caller is responsible for
- * allocating/de-allocating the 'value' field, the callee must copy
- * this field to its internal variable.
- * @param context: (IN/OUT) Context of the core file reader
- * @param optionID: (IN) ID of the option
- * @param value: (OUT) Value of the option
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_BAD_OPTION_ID: the optionID is not a valid one
- * @return M4ERR_NOT_IMPLEMENTED: this option is not implemented
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamGetOption( M4OSA_Context context,
- M4OSA_FileReadOptionID optionID,
- M4OSA_DataOption* optionValue )
-{
- M4OSA_FileReaderRam_Context* pContext=(M4OSA_FileReaderRam_Context*)context;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT;
- }
-
- switch(optionID)
- {
- case M4OSA_kFileReadGetFileSize:
- (*(M4OSA_UInt32 *)optionValue) = (pContext->dataSize);
- break;
-
- case M4OSA_kFileReadIsEOF:
- if(pContext->dataOffset == pContext->dataSize)
- {
- (*(M4OSA_UInt8 *)optionValue) = M4OSA_TRUE;
- }
- else
- {
- (*(M4OSA_UInt8 *)optionValue) = M4OSA_FALSE;
- }
- break;
-
- case M4OSA_kFileReadGetFileAttribute:
- err = M4ERR_NOT_IMPLEMENTED;
- break;
-
- case M4OSA_kFileReadGetURL:
- err = M4ERR_NOT_IMPLEMENTED;
- break;
-
- case M4OSA_kFileReadGetFilePosition :
- (*(M4OSA_UInt32 *)optionValue) = pContext->dataOffset;
- break;
-
- default:
- err = M4ERR_BAD_OPTION_ID;
- M4OSA_TRACE1_1("M4OSA_fileReadRamGetOption invalid option ID 0x%x",
- optionID);
- break;
- }
-
- return err;
-}
-
-/**
- ***************************************************************************
- * @fn M4OSA_ERR M4OSA_fileReadSetOption (M4OSA_Context context,
- * M4OSA_OptionID optionID,
- * M4OSA_DataOption optionValue))
- * @brief This function asks the core file reader to set the value associated with the optionID.
- * The caller is responsible for allocating/de-allocating the memory of the value field.
- * @note As the caller is responsible for allocating/de-allocating the 'value' field, the callee must copy this field
- * to its internal variable.
- * @param context: (IN/OUT) Context of the core file reader
- * @param optionID: (IN) ID of the option
- * @param value: (IN) Value of the option
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: at least one parameter is NULL
- * @return M4ERR_BAD_CONTEXT: provided context is not a valid one
- * @return M4ERR_BAD_OPTION_ID: the optionID is not a valid one
- * @return M4ERR_READ_ONLY: this option is a read only one
- * @return M4ERR_NOT_IMPLEMENTED: this option is not implemented
- ***************************************************************************
-*/
-M4OSA_ERR M4OSA_fileReadRamSetOption( M4OSA_Context context,
- M4OSA_FileReadOptionID optionID,
- M4OSA_DataOption optionValue )
-{
- return M4ERR_NOT_IMPLEMENTED;
-}
-
diff --git a/libvideoeditor/osal/src/M4OSA_FileWriter_RAM.c b/libvideoeditor/osal/src/M4OSA_FileWriter_RAM.c
deleted file mode 100755
index 4a8ff6f..0000000
--- a/libvideoeditor/osal/src/M4OSA_FileWriter_RAM.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ******************************************************************************
- * @file M4OSA_FileReaderRam.c
-
- * @brief File reader from RAM
- * @note This file implements functions to read a "file" stored in RAM.
-******************************************************************************
-*/
-
-#include "M4OSA_Debug.h"
-#include "M4OSA_FileWriterRam.h"
-#include "M4OSA_FileReaderRam.h"
-#include "M4OSA_Memory.h"
-
-
-/**
- ******************************************************************************
- * structure M4OSA_FileWriteRam_Context
- * @brief This structure defines the File writer context (private)
- * @note This structure is used for all File writer calls to store the context
- ******************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr8 pFileDesc; /* Pointer on file data */
- M4OSA_UInt32 dataSize; /* Size of data to write */
- M4OSA_UInt32 dataOffset; /* Actual offset */
- M4OSA_Bool IsOpened; /* Micro state machine */
- M4OSA_UInt32 bufferSize; /* Actual used size inside the buffer */
-} M4OSA_FileWriterRam_Context;
-
-
-/**
- ******************************************************************************
- * @brief This method "opens" the provided fileDescriptor (in fact address)
- * and returns its context.
- * @param pContext: (OUT) File writer context.
- * @param pFileDescriptor : (IN) File Descriptor of the input file.
- * @param FileModeAccess : (IN) File mode access.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER pContext or fileDescriptor is NULL
- * @return M4ERR_ALLOC there is no more memory available
- * @return M4ERR_FILE_BAD_MODE_ACCESS the file mode access is not correct
- * @return M4ERR_FILE_NOT_FOUND The file can not be opened.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamOpen(M4OSA_Context* context, M4OSA_Void* fileDescriptor,
- M4OSA_UInt32 fileModeAccess)
-{
- M4OSA_FileWriterRam_Context* pContext=M4OSA_NULL;
- M4OSA_FileWriterRam_Descriptor* pDescriptor = fileDescriptor;
- M4OSA_Int32 aFileDesc=-1;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
- *context = M4OSA_NULL;
- if(fileDescriptor == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- /* Allocate memory for the File writer context. */
- pContext = (M4OSA_FileWriterRam_Context *)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileWriterRam_Context),
- M4OSA_FILE_WRITER, (M4OSA_Char*)"Context allocation");
- if(pContext == M4OSA_NULL)
- {
- return M4ERR_ALLOC;
- }
-
- if ((fileModeAccess & M4OSA_kFileWrite))
- {
- pContext->pFileDesc = (M4OSA_MemAddr8)(pDescriptor->pFileDesc);
- pContext->dataSize = (M4OSA_Int32)(pDescriptor->dataSize);
- pContext->dataOffset = 0;
- pContext->bufferSize = 0;
- pContext->IsOpened = M4OSA_TRUE;
- }
- else
- {
- err = M4ERR_FILE_BAD_MODE_ACCESS;
- }
- if (M4NO_ERROR != err)
- {
- if (M4OSA_NULL != pContext)
- {
- free(pContext);
- }
- *context=M4OSA_NULL;
- }
- else
- {
- *context = pContext;
- }
-
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This method writes the 'size' bytes stored at 'data' memory at the end
- * of the file selected by its context.
- * The caller is responsible for allocating/de-allocating the memory for 'data' parameter.
- * Moreover, the data pointer must be allocated to store at least 'size' bytes.
- * @param pContext: (IN) File writer context.
- * @param pData : (IN) Data pointer of the written data.
- * @param Size : (IN) Size of the data to write (in bytes).
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER pData is NULL
- * @return M4ERR_ALLOC there is no more memory available
- * @return M4ERR_BAD_CONTEXT provided context is not a valid one.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamData(M4OSA_Context context,M4OSA_MemAddr8 data, M4OSA_UInt32 Size)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL || data == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /* The context can not be correct */
- }
-
- /* Check if there is enough room to write or not */
- if (pContext->dataOffset + Size < pContext->dataSize )
- {
- M4OSA_memcpy((pContext->pFileDesc + pContext->dataOffset), data, Size);
- pContext->dataOffset += Size;
- if(pContext->dataOffset> pContext->bufferSize) pContext->bufferSize = pContext->dataOffset;
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
-
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This method seeks at the provided position in the core file writer (selected by its 'context').
- * The position is related to the seekMode parameter it can be either :
- * From the beginning (position MUST be positive) : end position = position
- * From the end (position MUST be negative) : end position = file size + position
- * From the current position (signed offset) : end position = current position + position.
- * @param pContext: (IN) File reader context.
- * @param SeekMode : (IN) Seek access mode.
- * @param pPosition : (IN) Position in the file.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER Seekmode or fileDescriptor is NULL
- * @return M4ERR_ALLOC there is no more memory available
- * @return M4ERR_BAD_CONTEXT provided context is not a valid one.
- * @return M4ERR_FILE_INVALID_POSITION the position cannot be reached.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamSeek(M4OSA_Context context, M4OSA_FileSeekAccessMode SeekMode,
- M4OSA_FilePosition* position)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL || SeekMode == M4OSA_NULL || position == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /* The context can not be correct */
- }
-
- /* Go to the desired position */
- switch(SeekMode)
- {
- case M4OSA_kFileSeekBeginning:
- /* Check if position is reachable and update dataOffset */
- if (((*position) >= 0) && ((M4OSA_UInt32)(*position) <= pContext->dataSize))
- {
- pContext->dataOffset = *position;
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- break;
-
- case M4OSA_kFileSeekEnd:
- /* Check if position is reachable and update dataOffset */
- if ((*position) < 0)
- {
- if (pContext->dataSize >= (M4OSA_UInt32)(-(*position)))
- {
- pContext->dataOffset = (M4OSA_UInt32) (pContext->pFileDesc + pContext->dataSize + (*position));
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- }
- else if ((*position) == 0)
- {
- pContext->dataOffset = (M4OSA_UInt32)(pContext->pFileDesc + pContext->dataSize);
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- break;
-
- case M4OSA_kFileSeekCurrent:
- /* Check if position is reachable and update dataOffset */
- if ((*position) < 0)
- {
- if (pContext->dataOffset >= (M4OSA_UInt32)(-(*position)))
- {
- pContext->dataOffset = (M4OSA_UInt32) (pContext->dataOffset + (*position));
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- }
- else
- {
- if (pContext->dataSize >= (M4OSA_UInt32)(pContext->dataOffset + (*position)))
- {
- pContext->dataOffset = (M4OSA_UInt32) (pContext->dataOffset + (*position));
- err = M4NO_ERROR;
- }
- else
- {
- err = M4ERR_FILE_INVALID_POSITION;
- }
- }
- break;
-
- default:
- err = M4ERR_PARAMETER;
- break;
- }
-
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This method asks the core file writer to close the file (associated to the context).
- * The context of the core file reader must be freed.
- * @param pContext: (IN) File reader context.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_BAD_CONTEXT provided context is not a valid one.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamClose(M4OSA_Context context)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(pContext == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /* The context can not be correct */
- }
-
- pContext->IsOpened = M4OSA_FALSE;
-
- /* Free the context */
- free(pContext);
-
- /* Return error */
- return err;
-}
-
-/**
- ******************************************************************************
- * @brief This method asks the core file writer to flush the pending data
- * to the file (associated to the context).
- * All pending written data are written in the file.
- * @param pContext: (IN) File reader context.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_BAD_CONTEXT provided context is not a valid one.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamFlush(M4OSA_Context context)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /* The context can not be correct */
- }
-
- /*
- * DO NOTHING */
-
- /**
- * Return without error */
- return M4NO_ERROR;
-}
-
-/**
- ******************************************************************************
- * @brief This method asks the core file writer to set the value associated with the optionID.
- * The caller is responsible for allocating/de-allocating the memory of the value field.
- * @note The options handled by the component depend on the implementation of the component.
- * @param pContext: (IN) Execution context.
- * @param OptionId : (IN) Id of the option to set.
- * @param OptionValue : (IN) Value of the option.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_BAD_CONTEXT pContext is NULL
- * @return M4ERR_READ_ONLY The option is not implemented yet.
- * @return M4ERR_BAD_OPTION_ID the option id is not valid.
- * @return M4ERR_NOT_IMPLEMENTED The option is not implemented yet.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamSetOption(M4OSA_Context context,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption OptionValue)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /**< The context can not be correct */
- }
-
- /* Set the desired option if it is avalaible */
- switch(OptionID)
- {
- case M4OSA_kFileWriteGetReaderContext : /* Get the file attribute*/
- case M4OSA_kFileWriteGetURL : /* Get the directory + name of the file */
- case M4OSA_kFileWriteGetFilePosition : /* Get file position */
- return M4ERR_READ_ONLY;
- break;
-
- case M4OSA_kFileWriteGetAttribute :
- /**
- * Get the reader context for read & write file. It is NULL if the file is opened
- * with write attribute only */
- return M4ERR_NOT_IMPLEMENTED;
-
- default : /* Bad option ID */
- return M4ERR_BAD_OPTION_ID;
- }
-
- /* Return without error */
- return M4NO_ERROR;
-}
-
-/**
- ******************************************************************************
- * @brief This method asks the core file reader to return the value associated with the optionID.
- * The caller is responsible for allocating/de-allocating the memory of the value field.
- * @note The options handled by the component depend on the implementation of the component.
- * @param pContext: (IN) Execution context.
- * @param OptionId : (IN) Id of the option to set.
- * @param pOptionValue : (OUT) Value of the option.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_BAD_CONTEXT pContext is NULL
- * @return M4ERR_BAD_OPTION_ID the option id is not valid.
- * @return M4ERR_ALLOC there is no more memory available
- * @return M4ERR_NOT_IMPLEMENTED The option is not implemented yet.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_fileWriteRamGetOption(M4OSA_Context context,
- M4OSA_OptionID OptionID,
- M4OSA_DataOption* optionValue)
-{
- M4OSA_FileWriterRam_Context* pContext=(M4OSA_FileWriterRam_Context*)context;
- M4OSA_ERR err=M4NO_ERROR;
-
- /* Check input parameters */
- if(context == M4OSA_NULL)
- {
- return M4ERR_PARAMETER;
- }
-
- if (pContext->IsOpened != M4OSA_TRUE)
- {
- return M4ERR_BAD_CONTEXT; /**< The context can not be correct */
- }
-
- /* Get the desired option if it is avalaible */
- switch(OptionID)
- {
- case M4OSA_kFileWriteGetFileSize:/* Get size of the file, limited to 32 bit size */
- (*(M4OSA_UInt32 *)optionValue) = (pContext->bufferSize);
- break;
-
- case M4OSA_kFileWriteGetURL : /* Get the directory + name of the file */
- return M4ERR_NOT_IMPLEMENTED;
-
- default : /**< Bad option ID */
- return M4ERR_BAD_OPTION_ID;
- break;
- }
-
- /* Return without error */
- return err;
-}
diff --git a/libvideoeditor/osal/src/M4OSA_String.c b/libvideoeditor/osal/src/M4OSA_String.c
deleted file mode 100755
index 7cf7801..0000000
--- a/libvideoeditor/osal/src/M4OSA_String.c
+++ /dev/null
@@ -1,2417 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ************************************************************************
- * @file M4OSA_String.c
- ************************************************************************
-*/
-
-#include "M4OSA_Debug.h"
-#include "M4OSA_Memory.h"
-#include "M4OSA_Types.h"
-#include "M4OSA_Error.h"
-#include "M4OSA_CharStar.h"
-#include "M4OSA_FileCommon.h"
-#include "M4OSA_String_priv.h"
-#include "M4OSA_String.h"
-
-
-/**
- ************************************************************************
- * @brief This function creates an empty M4OSA_String
- * @note
- * @param pStrOut
- * @return M4OSA_ERROR
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_strCreate(M4OSA_String* pStrOut)
-{
- M4OSA_strStruct* pStr = M4OSA_NULL;
-
- M4OSA_TRACE1_1("M4OSA_strCreate\t\tM4OSA_String* 0x%x", pStrOut);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStrOut, M4ERR_PARAMETER, "M4OSA_strCreate");
- M4OSA_DEBUG_IF2(M4OSA_NULL != *pStrOut, M4ERR_STR_BAD_STRING,
- "M4OSA_strCreate");
-
- /* Allocate the output M4OSA_String */
- pStr = (M4OSA_strStruct*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_strStruct), M4OSA_STRING,
- (M4OSA_Char*)"M4OSA_strPrivCreate: output string");
-
- /* Check memory allocation error */
- if(M4OSA_NULL == pStr)
- {
- *pStrOut = M4OSA_NULL ;
-
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strPrivCreate");
-
- return M4ERR_ALLOC;
- }
-
- pStr->coreID = M4OSA_STRING;
- pStr->pui8_buffer = M4OSA_NULL;
- pStr->ui32_length = 0;
- pStr->ui32_size = 0;
-
- *pStrOut = pStr;
-
- return M4NO_ERROR;
-}
-
-
-
-
-/**
- ************************************************************************
- * @brief This function reset the M4OSA_String
- * @note
- * @param str_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strReset(M4OSA_String str_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_Char* pBuffer;
-
- M4OSA_TRACE1_1("M4OSA_strReset\t\tM4OSA_String* 0x%x", str_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strReset");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strReset");
-
- pBuffer = pStr->pui8_buffer;
-
- if(M4OSA_NULL != pBuffer)
- {
- free(pBuffer);
-
- pStr->pui8_buffer = M4OSA_NULL;
- }
-
- pStr->ui32_length = 0;
- pStr->ui32_size = 0;
-
-
- return M4NO_ERROR;
-}
-
-
-
-
-/**
- ************************************************************************
- * @brief This function free the memory of the input M4OSA_String
- * @note
- * @param str_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strDestroy(M4OSA_String str_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_1("M4OSA_strDestroy\t\tM4OSA_String 0x%x", str_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strDestroy");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strDestroy");
-
-
- /* Free M4OSA_String buffer */
- free((pStr->pui8_buffer));
-
- /* Free M4OSA_String structure memory */
- free(pStr);
-
-
- return M4NO_ERROR;
-}
-
-
-
-
-/**
- ************************************************************************
- * @brief str_in content
- * @note
- * @param str_in
- * @param pChar
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strSetCharContent(M4OSA_String str_in, M4OSA_Char *pChar)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_2("M4OSA_strSetContent\t\tM4OSA_String 0x%x\tM4OSA_Char*"
- " 0x%x", str_in, pChar);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetContent");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pChar, M4ERR_PARAMETER,
- "M4OSA_strSetContent");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetContent");
-
- return M4OSA_strPrivSet(pStr, pChar, M4OSA_chrLength(pChar));
-}
-
-
-
-
-/**
- ************************************************************************
-* @brief This function returns, in pac_content, the "C-String" of str_in
- * @note
- * @param str_in
- * @param pac_content
- * @return M4OSA_ERROR
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_strGetCharContent(M4OSA_String str_in, M4OSA_Char** ppchar)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_2("M4OSA_strGetContent\t\tM4OSA_String 0x%x\tM4OSA_Char**"
- " 0x%x", str_in, ppchar);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetContent");
- M4OSA_DEBUG_IF2(M4OSA_NULL == ppchar, M4ERR_PARAMETER,
- "M4OSA_strGetContent");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetContent");
-
- *ppchar = pStr->pui8_buffer;
-
-
- return M4NO_ERROR;
-}
-
-M4OSA_ERR M4OSA_strSetChar(M4OSA_String str_in, M4OSA_Char c_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err;
-
- M4OSA_TRACE1_2("M4OSA_strSetChar\t\tM4OSA_String 0x%x\tM4OSA_Char %c",
- str_in, c_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetChar");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetChar");
-
-
- err = M4OSA_strPrivRealloc(pStr, 1);
-
- if(M4OSA_ERR_IS_ERROR(err))
- {
- return err;
- }
-
- pStr->pui8_buffer[0] = c_in;
- pStr->pui8_buffer[1] = '\0';
- pStr->ui32_length = 1;
-
-
- return M4NO_ERROR;
-}
-
-
-
-
-M4OSA_ERR M4OSA_strGetChar(M4OSA_String str_in, M4OSA_Char* pc_out)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_2("M4OSA_strGetChar\t\tM4OSA_String 0x%x\tM4OSA_Char* 0x%x",
- str_in, pc_out);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pc_out, M4ERR_PARAMETER, "M4OSA_strGetChar");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetChar");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetChar");
-
- if(pStr->ui32_length == 0)
- {
- return M4ERR_STR_CONV_FAILED;
- }
-
- *pc_out = pStr->pui8_buffer[0];
-
-
- return M4NO_ERROR;
-}
-
-M4OSA_ERR M4OSA_strSetInt8(M4OSA_String str_in, M4OSA_Int8 i8_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[8];
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_2("M4OSA_strSetInt8\t\tM4OSA_String 0x%x\tM4OSA_Int8 %d",
- str_in, i8_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetInt8");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetInt8");
-
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%d", i8_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(i8_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"-%X",
- -i8_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%X",
- i8_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(i8_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"-%o",
- -i8_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%o",
- i8_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-M4OSA_ERR M4OSA_strGetInt8(M4OSA_String str_in, M4OSA_Int8* pi8_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetInt8\t\tM4OSA_String 0x%x\tM4OSA_Int8* 0x%x\t"
- "M4OSA_strNumBase %d", str_in, pi8_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetInt8");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi8_out, M4ERR_PARAMETER, "M4OSA_strGetInt8");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa) &&
- (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetInt8");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID,M4ERR_STR_BAD_STRING,
- "M4OSA_strGetInt8");
-
-
- err_code = M4OSA_chrGetInt8(pStr->pui8_buffer, pi8_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetInt8");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
-
- return M4NO_ERROR;
-}
-
-
-
-M4OSA_ERR M4OSA_strSetUInt8(M4OSA_String str_in, M4OSA_UInt8 ui8_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[4];
- M4OSA_ERR err_code;
- M4OSA_Char* pFormat;
-
- M4OSA_TRACE1_2("M4OSA_strSetUInt8\t\tM4OSA_String* 0x%x\tM4OSA_UInt8 %d",
- str_in, ui8_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetUInt8");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetUInt8");
-
- if (base == M4OSA_kchrDec)
- {
- pFormat = (M4OSA_Char*)"%u";
- }
- else if (base == M4OSA_kchrHexa)
- {
- pFormat = (M4OSA_Char*)"%X";
- }
- else if (base == M4OSA_kchrOct)
- {
- pFormat = (M4OSA_Char*)"%o";
- }
- else
- {
- pFormat = M4OSA_NULL;
- }
-
- /* Convert input number into "C-String" */
- err_code = M4OSA_chrSPrintf(aui8_buffer, 4, pFormat, ui8_in);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-
-M4OSA_ERR M4OSA_strGetUInt8(M4OSA_String str_in,
- M4OSA_UInt8* pui8_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetUInt8\t\tM4OSA_String 0x%x\tM4OSA_UInt8* 0x%x\t"
- "M4OSA_strNumBase %d", str_in, pui8_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetUInt8");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui8_out, M4ERR_PARAMETER,
- "M4OSA_strGetUInt8");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetUInt8");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetUInt8");
-
-
- err_code = M4OSA_chrGetUInt8(pStr->pui8_buffer, pui8_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetUInt8");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-
-M4OSA_ERR M4OSA_strSetInt16(M4OSA_String str_in, M4OSA_Int16 i16_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[8];
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_2("M4OSA_strSetInt16\t\tM4OSA_String* 0x%x\tM4OSA_Int16 %d",
- str_in, i16_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetInt16");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetInt16");
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%d",
- i16_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(i16_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"-%X",
- -i16_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%X",
- i16_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(i16_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"-%o",
- -i16_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, (M4OSA_Char*)"%o",
- i16_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-
-M4OSA_ERR M4OSA_strGetInt16(M4OSA_String str_in, M4OSA_Int16* pi16_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetInt16\t\tM4OSA_String 0x%x\tM4OSA_Int16* 0x%x"
- "\tM4OSA_strNumBase %d", str_in, pi16_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetInt16");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi16_out, M4ERR_PARAMETER,
- "M4OSA_strGetInt16");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct),M4ERR_PARAMETER, "M4OSA_strGetInt16");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetInt16");
-
- err_code = M4OSA_chrGetInt16(pStr->pui8_buffer, pi16_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetInt16");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetUInt16(M4OSA_String str_in, M4OSA_UInt16 ui16_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[8];
- M4OSA_ERR err_code;
- M4OSA_Char* pFormat;
-
- M4OSA_TRACE1_2("M4OSA_strSetUInt16\t\tM4OSA_String* 0x%x\tM4OSA_UInt16 %d",
- str_in, ui16_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetUInt16");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetUInt16");
-
- if (M4OSA_kchrDec == base)
- {
- pFormat = (M4OSA_Char*)"%u";
- }
- else if (M4OSA_kchrHexa == base)
- {
- pFormat = (M4OSA_Char*)"%X";
- }
- else if (M4OSA_kchrOct == base)
- {
- pFormat = (M4OSA_Char*)"%o";
- }
- else
- {
- pFormat = M4OSA_NULL;
- }
-
- /* Convert input number into "C-String" */
- err_code = M4OSA_chrSPrintf(aui8_buffer, 8, pFormat, ui16_in);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-M4OSA_ERR M4OSA_strGetUInt16(M4OSA_String str_in, M4OSA_UInt16* pui16_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetUInt16\t\tM4OSA_String 0x%x\tM4OSA_UInt16* "
- "0x%x\tM4OSA_strNumBase %d", str_in, pui16_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetUInt16");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui16_out, M4ERR_PARAMETER,
- "M4OSA_strGetUInt16");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetUInt16");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetUInt16");
-
- err_code = M4OSA_chrGetUInt16(pStr->pui8_buffer, pui16_out, M4OSA_NULL,
- base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetUInt16");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetInt32(M4OSA_String str_in, M4OSA_Int32 i32_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[16];
- M4OSA_ERR err_code;
- M4OSA_Char* pFormat;
-
- M4OSA_TRACE1_2("M4OSA_strSetInt32\t\tM4OSA_String* 0x%x\tM4OSA_Int32 %d",
- str_in, i32_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetInt32");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetInt32");
-
- if (M4OSA_kchrDec == base)
- {
- pFormat = (M4OSA_Char*)"%d";
- }
- else if (M4OSA_kchrHexa == base)
- {
- pFormat = (M4OSA_Char*)"%X";
- }
- else if (M4OSA_kchrOct == base)
- {
- pFormat = (M4OSA_Char*)"%o";
- }
- else
- {
- pFormat = M4OSA_NULL;
- }
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 16, (M4OSA_Char*)"%d",
- i32_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(i32_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 16, (M4OSA_Char*)"-%X",
- -i32_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 16, (M4OSA_Char*)"%X",
- i32_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(i32_in < 0)
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 16, (M4OSA_Char*)"-%o",
- -i32_in);
- }
- else
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 16, (M4OSA_Char*)"%o",
- i32_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-M4OSA_ERR M4OSA_strGetInt32(M4OSA_String str_in,
- M4OSA_Int32* pi32_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetInt32\t\tM4OSA_String 0x%x\tM4OSA_Int32* 0x%x"
- "\tM4OSA_strNumBase %d", str_in, pi32_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetInt32");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi32_out, M4ERR_PARAMETER,
- "M4OSA_strGetInt32");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetInt32");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetInt32");
-
- err_code = M4OSA_chrGetInt32(pStr->pui8_buffer, pi32_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetInt32");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-M4OSA_ERR M4OSA_strSetUInt32(M4OSA_String str_in, M4OSA_UInt32 ui32_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[12];
- M4OSA_ERR err_code;
- M4OSA_Char* pFormat;
-
- M4OSA_TRACE1_2("M4OSA_strSetUInt32\t\tM4OSA_String* 0x%x\tM4OSA_UInt32 %d",
- str_in, ui32_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetUInt32");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetUInt32");
-
- if (M4OSA_kchrDec == base)
- {
- pFormat = (M4OSA_Char*)"%u";
- }
- else if (M4OSA_kchrHexa == base)
- {
- pFormat = (M4OSA_Char*)"%X";
- }
- else if (M4OSA_kchrOct == base)
- {
- pFormat = (M4OSA_Char*)"%o";
- }
- else
- {
- pFormat = M4OSA_NULL;
- }
-
- /* Convert input number into "C-String" */
- err_code = M4OSA_chrSPrintf(aui8_buffer, 12, pFormat, ui32_in);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-M4OSA_ERR M4OSA_strGetUInt32(M4OSA_String str_in, M4OSA_UInt32* pui32_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetUInt32\t\tM4OSA_String 0x%x\tM4OSA_UInt32* "
- "0x%x\tM4OSA_strNumBase %d", str_in, pui32_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetUInt32");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_out, M4ERR_PARAMETER,
- "M4OSA_strGetUInt32");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetUInt32");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetUInt32");
-
- err_code = M4OSA_chrGetUInt32(pStr->pui8_buffer, pui32_out,
- M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetUInt32");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetInt64(M4OSA_String str_in, M4OSA_Int64 i64_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[24];
- M4OSA_ERR err_code;
-
-
- M4OSA_TRACE1_2("M4OSA_strSetInt64\t\tM4OSA_String* 0x%x\tM4OSA_Int64 0x%x",
- str_in, &i64_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetInt64");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetInt64");
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%lld",
- i64_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(M4OSA_INT64_IS_POSITIVE(i64_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%llX",
- i64_in);
- }
- else
- {
- M4OSA_INT64_NEG(i64_in, i64_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%llX",
- i64_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(M4OSA_INT64_IS_POSITIVE(i64_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%llo",
- i64_in);
- }
- else
- {
- M4OSA_INT64_NEG(i64_in, i64_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%llo",
- i64_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-M4OSA_ERR M4OSA_strGetInt64(M4OSA_String str_in, M4OSA_Int64* pi64_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetInt64\t\tM4OSA_String 0x%x\tM4OSA_Int64* 0x%x"
- "\tM4OSA_strNumBase %d", str_in, pi64_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetInt64");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi64_out, M4ERR_PARAMETER,
- "M4OSA_strGetInt64");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetInt64");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetInt64");
-
- err_code = M4OSA_chrGetInt64(pStr->pui8_buffer, pi64_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetInt64");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetDouble(M4OSA_String str_in, M4OSA_Double d_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[24];
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_2("M4OSA_strSetDouble\t\tM4OSA_String* 0x%x\tM4OSA_Double* "
- "0x%x", str_in, &d_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetDouble");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetDouble");
-
- /* Convert input number into "C-String" */
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%e", d_in);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-M4OSA_ERR M4OSA_strGetDouble(M4OSA_String str_in, M4OSA_Double* pd_out)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_2("M4OSA_strGetDouble\t\tM4OSA_String 0x%x\tM4OSA_Double* "
- "0x%x", str_in, pd_out);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetDouble");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pd_out, M4ERR_PARAMETER, "M4OSA_strGetDouble");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetDouble");
-
- err_code = M4OSA_chrGetDouble(pStr->pui8_buffer, pd_out, M4OSA_NULL);
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetDouble");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetFilePosition(M4OSA_String str_in, M4OSA_FilePosition fpos_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[24];
- M4OSA_ERR err_code;
-
-
- M4OSA_TRACE1_2("M4OSA_strSetFilePosition\t\tM4OSA_String* 0x%x\t"
- "M4OSA_FilePosition* 0x%x", str_in, &fpos_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER,
- "M4OSA_strSetFilePosition");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetFilePosition");
-
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%aad",
- fpos_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(M4OSA_FPOS_IS_POSITIVE(fpos_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%aaX",
- fpos_in);
- }
- else
- {
- M4OSA_FPOS_NEG(fpos_in, fpos_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%aaX",
- fpos_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(M4OSA_FPOS_IS_POSITIVE(fpos_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%aao",
- fpos_in);
- }
- else
- {
- M4OSA_FPOS_NEG(fpos_in, fpos_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%aao",
- fpos_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-M4OSA_ERR M4OSA_strGetFilePosition(M4OSA_String str_in, M4OSA_FilePosition* pfpos_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetFilePosition\t\tM4OSA_String 0x%x\t"
- "M4OSA_FilePosition* 0x%x\t\tM4OSA_strNumBase %d",
- str_in, pfpos_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER,
- "M4OSA_strGetFilePosition");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pfpos_out, M4ERR_PARAMETER,
- "M4OSA_strGetFilePosition");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetFilePosition");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetFilePosition");
-
- err_code = M4OSA_chrGetFilePosition(pStr->pui8_buffer, pfpos_out,
- M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetFilePosition");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetTime(M4OSA_String str_in, M4OSA_Time t_in,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char aui8_buffer[24];
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_2("M4OSA_strSetDouble\t\tM4OSA_String* 0x%x\tM4OSA_Time* 0x%x",
- str_in, &t_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetTime");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetTime");
-
- /* Convert input number into "C-String" */
- switch(base)
- {
- case M4OSA_kstrDec:
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%tmd",
- t_in);
- break;
- }
-
- case M4OSA_kstrHexa:
- {
- if(M4OSA_TIME_IS_POSITIVE(t_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%tmX",
- t_in);
- }
- else
- {
- M4OSA_TIME_NEG(t_in, t_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%tmX",
- t_in);
- }
- break;
- }
-
- case M4OSA_kstrOct:
- {
- if(M4OSA_TIME_IS_POSITIVE(t_in))
- {
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"%tmo",
- t_in);
- }
- else
- {
- M4OSA_TIME_NEG(t_in, t_in);
- err_code = M4OSA_chrSPrintf(aui8_buffer, 24, (M4OSA_Char*)"-%tmo",
- t_in);
- }
- break;
- }
-
- default:
- {
- return M4ERR_PARAMETER;
- }
- }
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- return err_code;
- }
-
- /* Calculate M4OSA_String content length */
- ui32_length = M4OSA_chrLength(aui8_buffer) ;
-
- return M4OSA_strPrivSet(pStr, aui8_buffer, ui32_length);
-}
-
-
-M4OSA_ERR M4OSA_strGetTime(M4OSA_String str_in, M4OSA_Time* pt_out,
- M4OSA_strNumBase base)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetTime\t\tM4OSA_String 0x%x\tM4OSA_Time* 0x%x"
- "\tM4OSA_strNumBase %d", str_in, pt_out, base);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetTime");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pt_out, M4ERR_PARAMETER, "M4OSA_strGetTime");
- M4OSA_DEBUG_IF2((base != M4OSA_kstrDec) && (base != M4OSA_kstrHexa)
- && (base != M4OSA_kstrOct), M4ERR_PARAMETER, "M4OSA_strGetTime");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID,M4ERR_STR_BAD_STRING,
- "M4OSA_strGetTime");
-
- err_code = M4OSA_chrGetTime(pStr->pui8_buffer, pt_out, M4OSA_NULL, base);
-
- if(M4NO_ERROR != err_code)
- {
- M4OSA_DEBUG(M4ERR_STR_CONV_FAILED, "M4OSA_strGetTime");
-
- return M4ERR_STR_CONV_FAILED;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strGetLength(M4OSA_String str_in, M4OSA_UInt32* pui32_len)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_2("M4OSA_strGetLength\t\tM4OSA_String 0x%x\tM4OSA_UInt32* "
- "0x%x", str_in, pui32_len);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strGetLength");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_len, M4ERR_PARAMETER, "M4OSA_strGetLength");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING, "M4OSA_strGetLength");
-
- /* Get the M4OSA_StringStuct length field */
- *pui32_len = pStr->ui32_length ;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strCompare(M4OSA_String str_in1, M4OSA_String str_in2,
- M4OSA_Int32* pi32_result)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_UInt32 length, length1, length2;
- M4OSA_Int32 result;
- M4OSA_UInt32 i;
- M4OSA_Char* buffer1;
- M4OSA_Char* buffer2;
- M4OSA_Char* pTmp1;
- M4OSA_Char* pTmp2;
-
- M4OSA_TRACE1_3("M4OSA_strCompare\t\tM4OSA_String 0x%x\tM4OSA_String 0x%x\t"
- "M4OSA_UInt32* 0x%x", str_in1, str_in2, pi32_result);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER, "M4OSA_strCompare");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER, "M4OSA_strCompare");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi32_result, M4ERR_PARAMETER, "M4OSA_strCompare");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING, "M4OSA_strCompare");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING, "M4OSA_strCompare");
-
- buffer1 = pStr1->pui8_buffer;
- buffer2 = pStr2->pui8_buffer;
-
- length1 = pStr1->ui32_length;
- length2 = pStr2->ui32_length;
-
- length = (length1 < length2) ? length1 : length2;
-
- pTmp1 = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(2 * length * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strCompare");
-
- M4OSA_CHECK_MALLOC(pTmp1, "M4OSA_strCompare");
-
- pTmp2 = pTmp1 + length;
-
- M4OSA_memcpy(pTmp1, buffer1, length);
-
- M4OSA_memcpy(pTmp2, buffer2, length);
-
- for(i=0; i<length; i++)
- {
- pTmp1[i] = M4OSA_chrToLower(buffer1[i]);
- pTmp2[i] = M4OSA_chrToLower(buffer2[i]);
- }
-
- M4OSA_chrNCompare(pTmp1, pTmp2, length, &result);
-
- free(pTmp1);
-
- if(result != 0)
- {
- *pi32_result = result;
- }
- else
- {
- if (length1 == length2)
- {
- *pi32_result = 0;
- }
- else if (length1 > length2)
- {
- *pi32_result = 1;
- }
- else
- {
- *pi32_result = -1;
- }
- }
-
- return M4NO_ERROR;
-}
-
-M4OSA_ERR M4OSA_strCompareSubStr(M4OSA_String str_in1,
- M4OSA_UInt32 ui32_offset1,
- M4OSA_String str_in2,
- M4OSA_UInt32 ui32_offset2,
- M4OSA_UInt32* pui32_num,
- M4OSA_Int32* pi32_result)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_Char* pBuffer1;
- M4OSA_Char* pBuffer2;
- M4OSA_Char* pTmp1;
- M4OSA_Char* pTmp2;
- M4OSA_UInt32 length1, length2, i;
- M4OSA_ERR err_code, return_code = M4NO_ERROR;
-
- M4OSA_TRACE1_5("M4OSA_strCompareSubStr\t\tM4OSA_String 0x%x\tM4OSA_UInt32 "
- "%d\tM4OSA_String 0x%x\tM4OSA_UInt32 %d\tM4OSA_UInt32* 0x%x"
- "\tM4OSA_Int32* 0x%x", str_in1, ui32_offset1, str_in2,
- ui32_offset2, *pui32_num);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi32_result, M4ERR_PARAMETER,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_num, M4ERR_PARAMETER,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(*pui32_num == 0, M4ERR_PARAMETER, "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(ui32_offset1 >= pStr1->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCompareSubStr");
- M4OSA_DEBUG_IF2(ui32_offset2 >= pStr2->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCompareSubStr");
-
- length1 = pStr1->ui32_length - ui32_offset1;
- length2 = pStr2->ui32_length - ui32_offset2;
-
- pBuffer1 = pStr1->pui8_buffer + ui32_offset1;
- pBuffer2 = pStr2->pui8_buffer + ui32_offset2;
-
- if(length1 < *pui32_num)
- {
- *pui32_num = length1;
-
- return_code = M4WAR_STR_OVERFLOW;
- }
-
- if(length2 < *pui32_num)
- {
- *pui32_num = length2;
-
- return_code = M4WAR_STR_OVERFLOW;
- }
-
- pTmp1 = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(2 * (*pui32_num) * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strCompareSubStr");
-
- M4OSA_CHECK_MALLOC(pTmp1, "M4OSA_strCompareSubStr");
-
- pTmp2 = pTmp1 + (*pui32_num);
-
- M4OSA_memcpy(pTmp1, pBuffer1, *pui32_num);
-
- M4OSA_memcpy(pTmp2, pBuffer2, *pui32_num);
-
- for(i=0; i<(*pui32_num); i++)
- {
- pTmp1[i] = M4OSA_chrToLower(pBuffer1[i]);
- pTmp2[i] = M4OSA_chrToLower(pBuffer2[i]);
- }
-
- err_code = M4OSA_chrNCompare(pTmp1, pTmp2, *pui32_num, pi32_result);
-
- M4OSA_DEBUG_IF2((M4OSA_ERR)M4ERR_PARAMETER == err_code, M4ERR_PARAMETER,
- "M4OSA_strCompareSubStr: M4OSA_chrNCompare");
-
- free(pTmp1);
-
- return return_code;
-}
-
-
-M4OSA_ERR M4OSA_strCaseCompare(M4OSA_String str_in1, M4OSA_String str_in2,
- M4OSA_Int32* pi32_result)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_UInt32 length, length1, length2;
- M4OSA_Char *pBuffer1, *pBuffer2;
- M4OSA_Int32 result;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strCaseCompare\t\tM4OSA_String 0x%x\tM4OSA_String "
- "0x%x\tM4OSA_UInt32* 0x%x", str_in1, str_in2, pi32_result);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER, "M4OSA_strCaseCompare");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER, "M4OSA_strCaseCompare");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi32_result,M4ERR_PARAMETER,
- "M4OSA_strCaseCompare");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCaseCompare");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCaseCompare");
-
- length1 = pStr1->ui32_length;
- length2 = pStr2->ui32_length;
-
- /** NB: Never use this expression "i = (value1 == value2) ? x: y;"
- * because that doens't compile on other platforms (ADS for example)
- * Use: if(value1 == value2)
- * { i= x; ..etc
- */
- if (M4OSA_NULL == pStr1->pui8_buffer)
- {
- pBuffer1 = (M4OSA_Char*)"";
- }
- else
- {
- pBuffer1 = pStr1->pui8_buffer;
- }
-
- if (M4OSA_NULL == pStr2->pui8_buffer)
- {
- pBuffer2 = (M4OSA_Char*)"";
- }
- else
- {
- pBuffer2 = pStr2->pui8_buffer;
- }
-
- if ((length1 < length2))
- {
- length = length1;
- }
- else
- {
- length = length2;
- }
-
- err_code = M4OSA_chrNCompare(pBuffer1, pBuffer2, length, &result);
-
- M4OSA_DEBUG_IF2((M4OSA_ERR)M4ERR_PARAMETER == err_code, M4ERR_PARAMETER,
- "M4OSA_strCaseCompare: M4OSA_chrNCompare");
-
- if (result != 0)
- {
- *pi32_result = result;
- }
- else if (length1 > length2)
- {
- *pi32_result = 1 ;
- }
- else
- {
- *pi32_result = -1;
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @author Nicolas Santini (PDSL-P)
- * @author Hilaire Verschuere (PDSL-P)
- * @brief
- * @note
- * @param str_in
- * @param
- * @return M4OSA_ERROR
- * @date - 2002-12-32: creation
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strCaseCompareSubStr(M4OSA_String str_in1,
- M4OSA_UInt32 ui32_offset1,
- M4OSA_String str_in2,
- M4OSA_UInt32 ui32_offset2,
- M4OSA_UInt32* pui32_num,
- M4OSA_Int32* pi32_result)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_Char* pBuffer1;
- M4OSA_Char* pBuffer2;
- M4OSA_UInt32 length1, length2;
- M4OSA_ERR err_code = M4NO_ERROR;
-
- M4OSA_TRACE1_5("M4OSA_strCaseCompareSubStr\t\tM4OSA_String 0x%x\t"
- "M4OSA_UInt32 %d\tM4OSA_String 0x%x\tM4OSA_UInt32 %d\t"
- "M4OSA_UInt32* 0x%x\tM4OSA_Int32* 0x%x", str_in1,
- ui32_offset1, str_in2, ui32_offset2, *pui32_num);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pi32_result, M4ERR_PARAMETER,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_num, M4ERR_PARAMETER,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(*pui32_num == 0, M4ERR_PARAMETER,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(ui32_offset1 >= pStr1->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCaseCompareSubStr");
- M4OSA_DEBUG_IF2(ui32_offset2 >= pStr2->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCaseCompareSubStr");
-
-
- length1 = pStr1->ui32_length - ui32_offset1;
- length2 = pStr2->ui32_length - ui32_offset2;
-
- pBuffer1 = pStr1->pui8_buffer + ui32_offset1;
- pBuffer2 = pStr2->pui8_buffer + ui32_offset2;
-
- if(length1 < *pui32_num)
- {
- *pui32_num = length1;
-
- err_code = M4WAR_STR_OVERFLOW;
- }
-
- if(length2 < *pui32_num)
- {
- *pui32_num = length2;
-
- err_code = M4WAR_STR_OVERFLOW;
- }
-
- M4OSA_chrNCompare(pBuffer1, pBuffer2, *pui32_num, pi32_result);
-
- return err_code;
-}
-
-
-M4OSA_ERR M4OSA_strSpan(M4OSA_String str_in, M4OSA_Char* charset,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char* pBuffer;
- M4OSA_ERR err_code;
-
-
- M4OSA_TRACE1_3("M4OSA_strSpan\t\tM4OSA_String 0x%x\tM4OSA_Char* 0x%x\t"
- "M4OSA_UInt32* 0x%x", str_in, charset, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSpan");
- M4OSA_DEBUG_IF2(M4OSA_NULL == charset, M4ERR_PARAMETER, "M4OSA_strSpan");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER, "M4OSA_strSpan");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSpan");
-
- pStr = (M4OSA_strStruct*)str_in ;
-
- if(*pui32_pos >= pStr->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- pBuffer = pStr->pui8_buffer + *pui32_pos;
-
- err_code = M4OSA_chrSpan(pBuffer, charset, &ui32_length);
-
- M4OSA_DEBUG_IF2((M4OSA_ERR)M4ERR_PARAMETER == err_code, M4ERR_PARAMETER,
- "M4OSA_strSpan: M4OSA_chrSpan");
-
- *pui32_pos += ui32_length;
-
- return M4NO_ERROR;
-}
-
-
-
-
-
-M4OSA_ERR M4OSA_strSpanComplement(M4OSA_String str_in, M4OSA_Char* charset,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code;
- M4OSA_UInt32 ui32_length;
-
- M4OSA_TRACE1_3("M4OSA_strSpanComplement\t\tM4OSA_String 0x%x\tM4OSA_Char* "
- "0x%x\tM4OSA_UInt32* 0x%x", str_in, charset, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER,
- "M4OSA_strSpanComplement");
- M4OSA_DEBUG_IF2(M4OSA_NULL == charset, M4ERR_PARAMETER,
- "M4OSA_strSpanComplement");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER,
- "M4OSA_strSpanComplement");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSpanComplement");
-
- if(*pui32_pos >= pStr->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- err_code = M4OSA_chrSpanComplement(pStr->pui8_buffer + *pui32_pos,
- charset, &ui32_length);
-
- M4OSA_DEBUG_IF2((M4OSA_ERR)M4ERR_PARAMETER == err_code, M4ERR_PARAMETER,
- "M4OSA_strSpanComplement: M4OSA_chrSpanComplement");
-
- if(M4WAR_CHR_NOT_FOUND == err_code)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- *pui32_pos += ui32_length;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strFindFirstChar(M4OSA_String str_in, M4OSA_Char c,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_Char* pBuffer;
- M4OSA_Char* pchar;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strFindFirstChar\t\tM4OSA_String 0x%x\tM4OSA_Char"
- " 0x%x\tM4OSA_UInt32* 0x%x", str_in, c, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER,
- "M4OSA_strFindFirstChar");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER,
- "M4OSA_strFindFirstChar");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindFirstChar");
-
- if(*pui32_pos >= pStr->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- pBuffer = pStr->pui8_buffer + *pui32_pos;
-
- err_code = M4OSA_chrFindChar(pBuffer, c, &pchar);
-
- M4OSA_DEBUG_IF2(err_code == (M4OSA_ERR)M4ERR_PARAMETER,
- M4ERR_PARAMETER, "M4OSA_strFindFirstChar");
-
- if(M4WAR_CHR_NOT_FOUND == err_code)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- *pui32_pos = pchar - pStr->pui8_buffer;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strFindLastChar(M4OSA_String str_in, M4OSA_Char c,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_Char* pBuffer;
- M4OSA_UInt32 i;
-
- M4OSA_TRACE1_3("M4OSA_strFindLastChar\t\tM4OSA_String 0x%x\tM4OSA_Char"
- " 0x%x\tM4OSA_UInt32* 0x%x", str_in, c, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER,"M4OSA_strFindLastChar");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER,
- "M4OSA_strFindLastChar");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindLastChar");
-
- if(*pui32_pos > pStr->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- pBuffer = pStr->pui8_buffer;
-
- for(i=(*pui32_pos); i!=0; i--)
- {
- if(pBuffer[i] == c)
- {
- *pui32_pos = i;
-
- return M4NO_ERROR;
- }
- }
-
- return M4WAR_STR_NOT_FOUND;
-}
-
-
-M4OSA_ERR M4OSA_strFindFirstSubStr(M4OSA_String str_in1, M4OSA_String str_in2,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_Char* pResult;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strFindFirstSubStr\t\tM4OSA_String 0x%x\tM4OSA_String"
- " 0x%x\tM4OSA_UInt32* 0x%x", str_in1, str_in2, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER,
- "M4OSA_strFindFirstSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER,
- "M4OSA_strFindFirstSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER,
- "M4OSA_strFindFirstSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindFirstSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindFirstSubStr");
-
- if(*pui32_pos >= pStr1->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- if(pStr2->ui32_length == 0)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- err_code = M4OSA_chrFindPattern(pStr1->pui8_buffer + (*pui32_pos),
- pStr2->pui8_buffer, &pResult);
-
- M4OSA_DEBUG_IF2((M4OSA_ERR)M4ERR_PARAMETER == err_code, M4ERR_PARAMETER,
- "M4OSA_strFindFirstSubStr: M4OSA_chrFindPattern");
-
- if(M4WAR_CHR_NOT_FOUND == err_code)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- *pui32_pos = pResult - pStr1->pui8_buffer;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strFindLastSubStr(M4OSA_String str_in1, M4OSA_String str_in2,
- M4OSA_UInt32* pui32_pos)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_in1;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_in2;
- M4OSA_Int32 i32_result;
-
-
- M4OSA_TRACE1_3("M4OSA_strFindLastSubStr\t\tM4OSA_String 0x%x\tM4OSA_String"
- " 0x%x\tM4OSA_UInt32* 0x%x", str_in1, str_in2, pui32_pos);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER,
- "M4OSA_strFindLastSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER,
- "M4OSA_strFindLastSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pui32_pos, M4ERR_PARAMETER,
- "M4OSA_strFindLastSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindLastSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strFindLastSubStr");
-
- if(*pui32_pos > pStr1->ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- if((pStr2->ui32_length == 0) || (pStr1->ui32_length == 0))
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- i32_result = M4OSA_strPrivFindLastSubStr(pStr1, pStr2, *pui32_pos);
-
- if(i32_result < 0)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- *pui32_pos = i32_result;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strTruncate(M4OSA_String str_in, M4OSA_UInt32 ui32_length)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
-
- M4OSA_TRACE1_2("M4OSA_strTroncate\t\tM4OSA_String 0x%x\tM4OSA_UInt32 %d",
- str_in, ui32_length);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strTroncate");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strTroncate");
-
- if(ui32_length >= pStr->ui32_length)
- {
- return M4WAR_STR_OVERFLOW;
- }
-
- pStr->ui32_length = ui32_length;
-
- if(pStr->pui8_buffer != M4OSA_NULL)
- {
- pStr->pui8_buffer[ui32_length] = '\0';
- }
-
- return M4NO_ERROR;
-}
-
-M4OSA_ERR M4OSA_strCopy(M4OSA_String str_out, M4OSA_String str_in)
-{
- M4OSA_strStruct* pIstr = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct* pOstr = (M4OSA_strStruct*)str_out;
-
- M4OSA_TRACE1_2("M4OSA_strCopy\t\tM4OSA_String 0x%x\tM4OSA_String 0x%x",
- str_in, str_out);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIstr, M4ERR_PARAMETER, "M4OSA_strCopy");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pOstr, M4ERR_PARAMETER, "M4OSA_strCopy");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCopy");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pOstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCopy");
-
- return M4OSA_strPrivSet(pOstr, pIstr->pui8_buffer, pIstr->ui32_length);
-}
-
-
-M4OSA_ERR M4OSA_strCopySubStr(M4OSA_String str_out,
- M4OSA_UInt32 ui32_pos,
- M4OSA_String str_in,
- M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* ui32_num)
-{
- M4OSA_strStruct *pIstr = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct *pOstr = (M4OSA_strStruct*)str_out;
- M4OSA_ERR err_code = M4NO_ERROR;
- M4OSA_UInt32 ui32_length, olength;
- M4OSA_Char* pSrc;
- M4OSA_Char* pDest;
-
-
- M4OSA_TRACE1_5("M4OSA_strCopySubStr\t\tM4OSA_String 0x%x\tM4OSA_UInt32 %d"
- "\tM4OSA_String 0x%x\tM4OSA_UInt32 %d\tM4OSA_UInt32* %0x%x",
- str_out, str_in, str_out, ui32_pos, ui32_num);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIstr, M4ERR_PARAMETER, "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pOstr, M4ERR_PARAMETER, "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == ui32_num, M4ERR_PARAMETER,
- "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(*ui32_num == 0, M4ERR_PARAMETER, "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pOstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(ui32_pos > pOstr->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCopySubStr");
- M4OSA_DEBUG_IF2(ui32_offset > pIstr->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strCopySubStr");
-
- /* Calculate there is enough char in str_in after ui32_offset */
- ui32_length = pIstr->ui32_length - ui32_offset;
-
- if(*ui32_num > ui32_length)
- {
- *ui32_num = ui32_length;
-
- err_code = M4WAR_STR_OVERFLOW;
- }
-
- /* Calculate the future length of str2 */
- ui32_length = ui32_pos + *ui32_num;
-
- olength = pOstr->ui32_length;
-
- if(ui32_length >= olength)
- {
- olength = ui32_length;
- }
-
- /* Reallocation if needed */
- if(M4OSA_strPrivReallocCopy(pOstr, olength) != M4NO_ERROR)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strCopySubStr");
-
- return M4ERR_ALLOC;
- }
-
- pSrc = pIstr->pui8_buffer + ui32_offset;
- pDest = pOstr->pui8_buffer + ui32_pos;
-
- M4OSA_memcpy(pDest, pSrc, *ui32_num);
-
- pOstr->ui32_length = olength;
- pOstr->pui8_buffer[pOstr->ui32_length] = '\0';
-
- return err_code;
-}
-
-
-M4OSA_ERR M4OSA_strConcat(M4OSA_String str_first, M4OSA_String str_second)
-{
- M4OSA_strStruct* pStr1 = (M4OSA_strStruct*)str_first;
- M4OSA_strStruct* pStr2 = (M4OSA_strStruct*)str_second;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char* pBuffer;
-
- M4OSA_TRACE1_2("M4OSA_strConcat\t\tM4OSA_String 0x%x\tM4OSA_String 0x%x",
- str_first, str_second);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr1, M4ERR_PARAMETER, "M4OSA_strConcat");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr2, M4ERR_PARAMETER, "M4OSA_strConcat");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr1->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strConcat");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr2->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strConcat");
-
- if(pStr2->ui32_length == 0)
- {
- return M4NO_ERROR;
- }
-
- ui32_length = pStr1->ui32_length + pStr2->ui32_length;
-
- if(M4OSA_strPrivReallocCopy(pStr1, ui32_length) != M4NO_ERROR)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strConcat");
-
- return M4ERR_ALLOC;
- }
-
- pBuffer = pStr1->pui8_buffer + pStr1->ui32_length;
-
- /* Fill the actual M4OSA_String content */
- M4OSA_memcpy(pBuffer, pStr2->pui8_buffer, pStr2->ui32_length+1);
-
- pStr1->ui32_length = ui32_length;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strInsertSubStr(M4OSA_String str_out,
- M4OSA_UInt32 ui32_pos,
- M4OSA_String str_in,
- M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* ui32_num)
-{
- M4OSA_strStruct *pIstr = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct *pOstr = (M4OSA_strStruct*)str_out;
- M4OSA_ERR err_code, return_code = M4NO_ERROR;
- M4OSA_UInt32 ui32_length;
-
- M4OSA_TRACE1_5("M4OSA_strInsertSubStr\t\tM4OSA_String 0x%x\tM4OSA_UInt32 %d"
- "\tM4OSA_String 0x%x\tM4OSA_UInt32 %d\tM4OSA_UInt32* %0x%x",
- str_out, str_in, str_out, ui32_pos, ui32_num);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIstr, M4ERR_PARAMETER,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pOstr, M4ERR_PARAMETER,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == ui32_num, M4ERR_PARAMETER,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(*ui32_num == 0, M4ERR_PARAMETER,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pOstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(ui32_pos > pOstr->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strInsertSubStr");
- M4OSA_DEBUG_IF2(ui32_offset > pIstr->ui32_length, M4ERR_STR_OVERFLOW,
- "M4OSA_strInsertSubStr");
-
- /* Calculate there is enough char in str_in after ui32_offset */
- ui32_length = pIstr->ui32_length - ui32_offset;
-
- if(*ui32_num > ui32_length)
- {
- *ui32_num = ui32_length;
-
- return_code = M4WAR_STR_OVERFLOW;
- }
-
- err_code = M4OSA_strPrivSetAndRepleceStr(pOstr, ui32_pos, 0,
- pIstr->pui8_buffer + ui32_offset, *ui32_num);
-
- if(err_code == (M4OSA_ERR)M4ERR_ALLOC)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strInsertSubStr");
-
- return M4ERR_ALLOC;
- }
-
- return return_code;
-}
-
-
-M4OSA_ERR M4OSA_strDelSubStr(M4OSA_String str_in, M4OSA_UInt32 ui32_offset,
- M4OSA_UInt32* ui32_num)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_length;
- M4OSA_Char* pBuffer;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strDelSubStr\t\tM4OSA_String 0x%x\tM4OSA_UInt32 %d\t"
- "M4OSA_UInt32* 0x%x", str_in, ui32_offset, ui32_num);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strDelSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == ui32_num, M4ERR_PARAMETER,
- "M4OSA_strDelSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strDelSubStr");
-
- pBuffer = pStr->pui8_buffer;
-
- ui32_length = pStr->ui32_length ;
-
- if(ui32_offset >= ui32_length)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- ui32_length -= ui32_offset;
-
- if(*ui32_num >= ui32_length)
- {
- *ui32_num = ui32_length;
-
- pStr->ui32_length -= ui32_length;
-
- pBuffer[pStr->ui32_length] = '\0';
-
- err_code = M4WAR_STR_OVERFLOW;
- }
- else
- {
- err_code = M4OSA_strPrivSetAndRepleceStr(pStr, ui32_offset, *ui32_num,
- M4OSA_NULL, 0);
- }
-
- return err_code;
-}
-
-
-M4OSA_ERR M4OSA_strReplaceSubStr(M4OSA_String str_in, M4OSA_String str_old,
- M4OSA_String str_new, M4OSA_strMode mode)
-{
- M4OSA_strStruct* pIstr = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct* pOstr = (M4OSA_strStruct*)str_old;
- M4OSA_strStruct* pNstr = (M4OSA_strStruct*)str_new;
- M4OSA_UInt32 olength, nlength, ilength;
- M4OSA_Bool ostr2free = M4OSA_FALSE;
- M4OSA_Bool nstr2free = M4OSA_FALSE;
- M4OSA_ERR err_code;
-
-
- M4OSA_TRACE1_4("M4OSA_strReplaceSubStr\t\tM4OSA_String 0x%x\tM4OSA_String "
- "0x%x\tM4OSA_String 0x%x\tM4OSA_strSupprMode %d",
- str_in, str_old, str_new, mode);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIstr, M4ERR_PARAMETER,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pOstr, M4ERR_PARAMETER,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pNstr, M4ERR_PARAMETER,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2((mode != M4OSA_kstrAll) && (mode != M4OSA_kstrEnd)
- && (mode != M4OSA_kstrBegin), M4ERR_PARAMETER,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pOstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strReplaceSubStr");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pNstr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strReplaceSubStr");
-
- olength = pOstr->ui32_length;
- nlength = pNstr->ui32_length;
- ilength = pIstr->ui32_length;
-
- if((olength == 0) || (ilength == 0) || (olength > ilength))
- {
- M4OSA_DEBUG(M4WAR_STR_NOT_FOUND, "M4OSA_strReplaceSubStr");
-
- return M4WAR_STR_NOT_FOUND;
- }
-
- if(pIstr == pOstr)
- {
- M4OSA_strPrivDuplicate(&pOstr, pIstr);
-
- ostr2free = M4OSA_TRUE;
- }
-
- if(pIstr == pNstr)
- {
- M4OSA_strPrivDuplicate(&pNstr, pIstr);
-
- nstr2free = M4OSA_TRUE;
- }
-
- if(nlength == olength)
- {
- err_code = M4OSA_strPrivReplaceSameSizeStr(pIstr, pOstr, pNstr, mode);
- }
- else if(nlength < olength)
- {
- err_code = M4OSA_strPrivReplaceSmallerStr(pIstr, pOstr, pNstr, mode);
- }
- else
- {
- err_code = M4OSA_strPrivReplaceBiggerStr(pIstr, pOstr, pNstr, mode);
- }
-
- if(ostr2free == M4OSA_TRUE)
- {
- free(pOstr->pui8_buffer);
- free(pOstr);
- }
-
- if(nstr2free == M4OSA_TRUE)
- {
- free(pNstr->pui8_buffer);
- free(pNstr);
- }
-
- return err_code;
-}
-
-
-M4OSA_ERR M4OSA_strGetFirstToken(M4OSA_String str_in, M4OSA_String str_token,
- M4OSA_String str_delim)
-{
- M4OSA_strStruct* pIn = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct* pToken = (M4OSA_strStruct*)str_token;
- M4OSA_strStruct* pDelim = (M4OSA_strStruct*)str_delim;
- M4OSA_UInt32 length_token, length_delim;
- M4OSA_Char* pBuffer;
- M4OSA_Char* pchar;
- M4OSA_ERR err_code;
-
-
- M4OSA_TRACE1_3("M4OSA_strGetFirstToken\t\tM4OSA_String 0x%x\tM4OSA_String"
- " 0x%x\tM4OSA_String 0x%x", str_in, str_token, str_delim);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIn, M4ERR_PARAMETER,"M4OSA_strGetFirstToken");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pToken, M4ERR_PARAMETER,
- "M4OSA_strGetFirstToken");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pDelim, M4ERR_PARAMETER,
- "M4OSA_strGetFirstToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIn->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetFirstToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pToken->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetFirstToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pDelim->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetFirstToken");
-
- length_delim = pDelim->ui32_length;
-
- if(pDelim->ui32_length == 0)
- {
- M4OSA_DEBUG(M4WAR_STR_NOT_FOUND, "M4OSA_strGetFirstToken");
-
- return M4WAR_STR_NOT_FOUND;
- }
-
- pBuffer = pIn->pui8_buffer;
-
- err_code = M4OSA_chrFindPattern(pBuffer,pDelim->pui8_buffer, &pchar);
-
- if(err_code != M4NO_ERROR)
- {
- M4OSA_DEBUG(M4WAR_STR_NOT_FOUND, "M4OSA_strGetFirstToken");
-
- return M4WAR_STR_NOT_FOUND;
- }
-
- length_token = pchar - pBuffer;
-
- err_code = M4OSA_strPrivSet(pToken, pBuffer, length_token);
-
- if(err_code == (M4OSA_ERR)M4ERR_ALLOC)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strGetFirstToken: M4OSA_strPrivSet");
-
- return M4ERR_ALLOC;
- }
-
- err_code = M4OSA_strPrivSetAndRepleceStr(pIn, 0, length_token + length_delim,
- M4OSA_NULL, 0);
-
- if(err_code == (M4OSA_ERR)M4ERR_ALLOC)
- {
- M4OSA_DEBUG(M4ERR_ALLOC,
- "M4OSA_strGetFirstToken: M4OSA_strPrivSetAndRepleceStr");
-
- return M4ERR_ALLOC;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strGetLastToken(M4OSA_String str_in, M4OSA_String str_token,
- M4OSA_String str_delim)
-{
- M4OSA_strStruct* pIn = (M4OSA_strStruct*)str_in;
- M4OSA_strStruct* pToken = (M4OSA_strStruct*)str_token;
- M4OSA_strStruct* pDelim = (M4OSA_strStruct*)str_delim;
- M4OSA_UInt32 in_length, token_length, delim_length;
- M4OSA_Char* pIn_buffer;
- M4OSA_Char* pToken_buffer;
- M4OSA_Int32 delim_pos;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE1_3("M4OSA_strGetLastToken\t\tM4OSA_String 0x%x\tM4OSA_String"
- " 0x%x\tM4OSA_String 0x%x", str_in, str_token, str_delim);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pIn, M4ERR_PARAMETER,
- "M4OSA_strGetLastToken");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pToken, M4ERR_PARAMETER,
- "M4OSA_strGetLastToken");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pDelim, M4ERR_PARAMETER,
- "M4OSA_strGetLastToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pIn->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetLastToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pToken->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetLastToken");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pDelim->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strGetLastToken");
-
- in_length = pIn->ui32_length;
- delim_length = pDelim->ui32_length;
- pIn_buffer = pIn->pui8_buffer;
-
- if(pDelim->ui32_length > pIn->ui32_length)
- {
- M4OSA_DEBUG(M4WAR_STR_NOT_FOUND, "M4OSA_strGetLastToken");
-
- return M4WAR_STR_NOT_FOUND;
- }
-
- delim_pos = M4OSA_strPrivFindLastSubStr(pIn, pDelim, in_length-delim_length);
-
- if(delim_pos < 0)
- {
- M4OSA_DEBUG(M4WAR_STR_NOT_FOUND, "M4OSA_strGetLastToken");
-
- return M4WAR_STR_NOT_FOUND;
- }
-
- pToken_buffer = pIn_buffer + delim_pos + delim_length;
- token_length = in_length - delim_pos + delim_length;
-
- err_code = M4OSA_strPrivSet(str_token, pToken_buffer, token_length);
-
- if(err_code == (M4OSA_ERR)M4ERR_ALLOC)
- {
- M4OSA_DEBUG(M4ERR_ALLOC,
- "M4OSA_strGetLastToken: M4OSA_strPrivSet");
-
- return err_code;
- }
-
- pIn_buffer[delim_pos] = '\0';
-
- pIn->ui32_length = delim_pos;
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetUpperCase(M4OSA_String str_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_Char* pBuffer;
- M4OSA_Char* pchar;
-
-
- M4OSA_TRACE1_1("M4OSA_strSetUpperCase\t\tM4OSA_String 0x%x", str_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetUpperCase");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetUpperCase");
-
- pBuffer = pStr->pui8_buffer;
-
- for(pchar=pBuffer; pchar!=(pBuffer+pStr->ui32_length); pchar++)
- {
- *pchar = M4OSA_chrToUpper(*pchar);
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetLowerCase(M4OSA_String str_in)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_Char* pBuffer;
- M4OSA_Char* pchar;
-
- M4OSA_TRACE1_1("M4OSA_strSetLowerCase\t\tM4OSA_String 0x%x", str_in);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetLowerCase");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetLowerCase");
-
- pBuffer = pStr->pui8_buffer;
-
- for(pchar=pBuffer; pchar!=(pBuffer+pStr->ui32_length); pchar++)
- {
- *pchar = M4OSA_chrToLower(*pchar);
- }
-
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSprintf(M4OSA_String str_in, M4OSA_Char* pFormat, ...)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_ERR err_code = M4ERR_STR_OVERFLOW;
- M4OSA_UInt32 ui32_size;
- va_list args;
-
- M4OSA_TRACE1_2("M4OSA_strSprintf\t\tM4OSA_String 0x%x\tM4OSA_Char* 0x%x",
- str_in, pFormat);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pFormat, M4ERR_PARAMETER, "M4OSA_strSprintf");
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSprintf");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetLowerCase");
-
- ui32_size = pStr->ui32_length + (M4OSA_UInt32)(1.5 * M4OSA_chrLength(pFormat));
-
- va_start(args, pFormat);
-
- while(err_code == (M4OSA_ERR)M4ERR_STR_OVERFLOW)
- {
- err_code = M4OSA_strPrivReallocCopy(pStr, ui32_size);
-
- if(err_code == (M4OSA_ERR)M4ERR_ALLOC)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strSprintf");
-
- va_end(args);
-
- return M4ERR_ALLOC;
- }
-
- ui32_size *= 2;
-
- err_code = M4OSA_strPrivSPrintf(pStr, pFormat, args);
- }
-
- va_end(args);
-
- pStr->ui32_length = M4OSA_chrLength(pStr->pui8_buffer);
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strSetMinAllocationSize(M4OSA_String str_in, M4OSA_UInt32 ui32_newsize)
-{
- M4OSA_strStruct* pStr = (M4OSA_strStruct*)str_in;
- M4OSA_UInt32 ui32_size;
- M4OSA_Char* pBuffer;
- M4OSA_Char* pIbuffer;
-
- M4OSA_TRACE1_2("M4OSA_strSetMinAllocationSize\t\tM4OSA_String 0x%x\t"
- "M4OSA_Int32 %d", str_in, ui32_newsize);
-
- M4OSA_DEBUG_IF2(M4OSA_NULL == pStr, M4ERR_PARAMETER, "M4OSA_strSetInt32");
- M4OSA_DEBUG_IF2(M4OSA_STRING != pStr->coreID, M4ERR_STR_BAD_STRING,
- "M4OSA_strSetInt32");
-
- ui32_size = pStr->ui32_size;
- pIbuffer = pStr->pui8_buffer;
-
- if(ui32_newsize > ui32_size)
- {
- ui32_size = ui32_newsize + ((4 - (ui32_newsize % 4)) % 4);
- }
-
- /* Allocate the actual M4OSA_String content */
- pBuffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strSetMinAllocationSize");
-
- M4OSA_CHECK_MALLOC(pBuffer, "M4OSA_strSetMinAllocationSize");
-
- if(pIbuffer != M4OSA_NULL)
- {
- M4OSA_memcpy(pBuffer, pIbuffer, pStr->ui32_length+1);
-
- free(pIbuffer);
- }
-
- pStr->pui8_buffer = pBuffer;
-
- pStr->ui32_size = ui32_size;
-
- return M4NO_ERROR;
-}
-
diff --git a/libvideoeditor/osal/src/M4OSA_String_priv.c b/libvideoeditor/osal/src/M4OSA_String_priv.c
deleted file mode 100755
index 79a26a0..0000000
--- a/libvideoeditor/osal/src/M4OSA_String_priv.c
+++ /dev/null
@@ -1,1136 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- ************************************************************************
- * @file M4OSA_String_priv.c
- ************************************************************************
-*/
-
-#include "M4OSA_Debug.h"
-#include "M4OSA_Types.h"
-#include "M4OSA_Memory.h"
-#include "M4OSA_Error.h"
-#include "M4OSA_String_priv.h"
-#include "M4OSA_String.h"
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivRealloc(M4OSA_strStruct* str,
- M4OSA_UInt32 ui32_length)
-{
- M4OSA_UInt32 ui32_size;
- M4OSA_Char* buffer;
-
- M4OSA_TRACE2_2("M4OSA_strPrivRealloc\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_UInt32* %d", str, ui32_length);
-
- ui32_size = str->ui32_size;
-
- /* Realloc if size is not sufficient to contain it entirely */
- if(ui32_length >= ui32_size)
- {
- if(ui32_size == 0)
- {
- ui32_size = 16;
- }
-
- while(ui32_length >= ui32_size)
- {
- ui32_size <<= 1;
- }
-
- buffer = str->pui8_buffer;
-
- if(buffer != M4OSA_NULL)
- {
- free(buffer);
- }
-
- /* Allocate the actual M4OSA_String content */
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivRealloc");
-
- /* Check memory allocation error */
- if(buffer == M4OSA_NULL)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strPrivRealloc");
-
- str->pui8_buffer = M4OSA_NULL;
- str->ui32_size = 0;
- str->ui32_length = 0;
-
- return M4ERR_ALLOC;
- }
-
- str->pui8_buffer = buffer;
- str->ui32_size = ui32_size;
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivReallocCopy(M4OSA_strStruct* str,
- M4OSA_UInt32 ui32_length)
-{
- M4OSA_UInt32 ui32_size;
- M4OSA_Char* buffer;
- M4OSA_Char* pui8_buffer;
-
- M4OSA_TRACE2_2("M4OSA_strPrivReallocCopy\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_UInt32* %d", str, ui32_length);
-
-
- ui32_size = str->ui32_size;
-
- /* Realloc if size is not sufficient to contain it entirely */
- if(ui32_length >= ui32_size)
- {
- if(ui32_size == 0)
- {
- ui32_size = 16;
- }
-
- while(ui32_length >= ui32_size)
- {
- ui32_size <<= 1;
- }
-
- /* Allocate the actual M4OSA_String content */
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivReallocCopy");
-
- /* Check memory allocation error */
- if(buffer == M4OSA_NULL)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strPrivReallocCopy");
-
- str->pui8_buffer = M4OSA_NULL;
- str->ui32_size = 0;
- str->ui32_length = 0;
-
- return M4ERR_ALLOC;
- }
-
- pui8_buffer = str->pui8_buffer;
-
- if(pui8_buffer != M4OSA_NULL)
- {
- M4OSA_memcpy(buffer, pui8_buffer, str->ui32_length + 1);
-
- free(pui8_buffer);
- }
-
- str->pui8_buffer = buffer;
- str->ui32_size = ui32_size;
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strPrivDuplicate(M4OSA_strStruct** ostr,
- M4OSA_strStruct* istr)
-{
- M4OSA_strStruct* str;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE2_2("M4OSA_strPrivDuplicate\t\tM4OSA_strStruct** 0x%x\t"
- "M4OSA_strStruct** 0x%x", ostr, istr);
-
- /* Allocate the output M4OSA_String */
- str = (M4OSA_strStruct*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_strStruct), M4OSA_STRING,
- (M4OSA_Char*)"M4OSA_strPrivDuplicate: output string");
-
- /* Check memory allocation error */
- if(str == M4OSA_NULL)
- {
- *ostr = M4OSA_NULL ;
-
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strPrivDuplicate");
-
- return M4ERR_ALLOC;
- }
-
- str->coreID = M4OSA_STRING;
- str->pui8_buffer = M4OSA_NULL;
- str->ui32_length = 0;
- str->ui32_size = 0;
-
- err_code = M4OSA_strPrivSet(str, istr->pui8_buffer, istr->ui32_length);
-
- if(err_code != M4NO_ERROR)
- {
- return err_code;
- }
-
- *ostr = str;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_strPrivSet(M4OSA_strStruct* str,
- M4OSA_Char* pchar,
- M4OSA_UInt32 ui32_length)
-{
- M4OSA_UInt32 length;
- M4OSA_Char* buffer;
-
- M4OSA_TRACE2_3("M4OSA_strPrivSet\t\tM4OSA_strStruct* 0x%x\tM4OSA_Char* "
- "0x%x\tM4OSA_UInt32 %d", str, pchar, ui32_length);
-
- if(ui32_length != 0)
- {
- length = M4OSA_chrLength(pchar);
-
- if(length < ui32_length)
- {
- ui32_length = length;
- }
-
- if(M4OSA_strPrivRealloc(str, ui32_length) != M4NO_ERROR)
- {
- M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_strPrivSet");
-
- return M4ERR_ALLOC;
- }
-
- buffer = str->pui8_buffer;
-
- /* Fill the actual M4OSA_String content */
- M4OSA_memcpy(buffer, pchar, ui32_length);
-
- buffer[ui32_length] = '\0';
- }
- else if(str->pui8_buffer != M4OSA_NULL)
- {
- str->pui8_buffer[0] = '\0';
- }
-
- str->ui32_length = ui32_length;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
-*/
-M4OSA_Int32 M4OSA_strPrivFindLastSubStr(M4OSA_strStruct* str1,
- M4OSA_strStruct* str2,
- M4OSA_UInt32 ui32_pos)
-{
- M4OSA_Char *pchar;
- M4OSA_Char *buffer1;
- M4OSA_Char *buffer2;
- M4OSA_Int32 i32_result;
- M4OSA_UInt32 length1, length2;
- M4OSA_Int32 dist;
-
- M4OSA_TRACE2_3("M4OSA_strPrivFindLastSubStr\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strStruct* 0x%x\tM4OSA_UInt32 %d",
- str1, str2, ui32_pos);
-
- length1 = str1->ui32_length;
- length2 = str2->ui32_length;
-
- if((length1 == 0) || (length2 == 0))
- {
- return -1;
- }
-
- buffer1 = str1->pui8_buffer;
- buffer2 = str2->pui8_buffer;
-
- dist = length1 - length2;
-
- if(dist < 0)
- {
- return -1;
- }
-
- if((M4OSA_Int32)ui32_pos > dist)
- {
- ui32_pos = dist;
- }
-
- for(pchar = buffer1 + ui32_pos; pchar != buffer1; pchar--)
- {
- M4OSA_chrNCompare(pchar, buffer2, length2, &i32_result);
-
- if(i32_result == 0)
- {
- return pchar - buffer1;
- }
- }
-
- return -1;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivSetAndRepleceStr(M4OSA_strStruct* istr,
- M4OSA_UInt32 ui32_pos,
- M4OSA_UInt32 olength,
- M4OSA_Char* nbuff,
- M4OSA_UInt32 nlength)
-{
- M4OSA_Char* buffer;
- M4OSA_Char* ibuffer;
- M4OSA_UInt32 ui32_length, ui32_size, ui32_lend, ui32_poso, ui32_posn;
-
- M4OSA_TRACE2_5("M4OSA_strPrivSetAndRepleceStr\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_UInt32 %d\tM4OSA_UInt32 %d\tM4OSA_Char* 0x%x\t"
- "M4OSA_UInt32 %d", istr, ui32_pos, olength, nbuff, nlength);
-
- ui32_length = istr->ui32_length - olength + nlength;
-
- ibuffer = istr->pui8_buffer;
-
- /* string to replace has the same this that new string */
- if(nlength == olength)
- {
- if(nlength == 0)
- {
- return M4NO_ERROR;
- }
-
- M4OSA_memcpy(ibuffer + ui32_pos, nbuff, nlength);
- }
- else
- {
- ui32_lend = istr->ui32_length - ui32_pos - olength;
- ui32_poso = ui32_pos + olength;
- ui32_posn = ui32_pos + nlength;
-
- /* string to replace is bigger that new string */
- if(nlength < olength)
- {
- if(nlength > 0)
- {
- M4OSA_memcpy(ibuffer + ui32_pos, nbuff, nlength);
- }
-
- if((olength - nlength) >= ui32_lend)
- {
- M4OSA_memcpy(ibuffer + ui32_posn, ibuffer + ui32_poso, ui32_lend);
- }
- else
- {
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_lend * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivSetAndRepleceStr");
-
- M4OSA_CHECK_MALLOC(buffer, "M4OSA_strPrivSetAndRepleceStr");
- M4OSA_memcpy(buffer, ibuffer + ui32_poso, ui32_lend);
- M4OSA_memcpy(ibuffer + ui32_posn, buffer, ui32_lend);
- free(buffer);
- }
- }
- /* string to replace is smaller that new string */
- else
- {
- ui32_size = istr->ui32_size;
-
- /* check if there is enough memory allocated in istr */
- if(ui32_length >= ui32_size)
- {
- if(ui32_size == 0)
- {
- ui32_size = 16;
- }
-
- while(ui32_length >= ui32_size)
- {
- ui32_size <<= 1;
- }
-
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivSetAndRepleceStr");
-
- M4OSA_CHECK_MALLOC(buffer, "M4OSA_strPrivSetAndRepleceStr");
-
- M4OSA_memcpy(buffer, ibuffer, ui32_pos);
-
- M4OSA_memcpy(buffer + ui32_pos, nbuff, nlength);
-
- M4OSA_memcpy(buffer + ui32_posn, ibuffer + ui32_poso, ui32_lend);
-
- free(ibuffer);
-
- istr->pui8_buffer = buffer;
-
- istr->ui32_size = ui32_size;
- }
- else
- {
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_lend * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivSetAndRepleceStr");
-
- M4OSA_CHECK_MALLOC(buffer, "M4OSA_strPrivSetAndRepleceStr");
-
- M4OSA_memcpy(buffer, ibuffer + ui32_poso, ui32_lend);
-
- M4OSA_memcpy(ibuffer + ui32_pos, nbuff, nlength);
-
- M4OSA_memcpy(ibuffer + ui32_posn, buffer, ui32_lend);
-
- free(buffer);
- }
- }
- }
-
-
- istr->pui8_buffer[ui32_length] = '\0';
-
- istr->ui32_length = ui32_length;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivReplaceSameSizeStr(M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode)
-{
- M4OSA_Char* ibuffer;
- M4OSA_Char* obuffer;
- M4OSA_Char* nbuffer;
- M4OSA_Char* ptr;
- M4OSA_UInt32 ilength, nlength;
- M4OSA_Int32 i32_pos;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE2_4("M4OSA_strPrivReplaceSameSizeStr\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strStruct* 0x%x\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strMode %d", istr, ostr, nstr, mode);
-
- ibuffer = istr->pui8_buffer;
- obuffer = ostr->pui8_buffer;
- nbuffer = nstr->pui8_buffer;
-
- ilength = istr->ui32_length;
- nlength = nstr->ui32_length;
-
- if(mode != M4OSA_kstrEnd)
- {
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- if(err_code == M4WAR_CHR_NOT_FOUND)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- if(mode == M4OSA_kstrAll)
- {
- do
- {
- M4OSA_memcpy(ptr, nbuffer, nlength);
-
- err_code = M4OSA_chrFindPattern(ptr+nlength, obuffer, &ptr);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- } while(err_code != M4WAR_CHR_NOT_FOUND);
- }
- else
- {
- M4OSA_memcpy(ptr, nbuffer, nlength);
- }
- }
- else
- {
- i32_pos = M4OSA_strPrivFindLastSubStr(istr, ostr, ilength-1);
-
- if(i32_pos < 0)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- M4OSA_memcpy(ibuffer + i32_pos, nbuffer, nlength);
- }
-
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivReplaceSmallerStr(M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode)
-{
- M4OSA_Char* ibuffer;
- M4OSA_Char* obuffer;
- M4OSA_Char* nbuffer;
- M4OSA_Char* buffer;
- M4OSA_Char* ptr_src;
- M4OSA_Char* ptr_dest;
- M4OSA_UInt32 ilength, nlength, olength, size, length;
- M4OSA_Int32 i32_pos;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE2_4("M4OSA_strPrivReplaceSmallerStr\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strStruct* 0x%x\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strMode %d", istr, ostr, nstr, mode);
-
- ibuffer = istr->pui8_buffer;
- obuffer = ostr->pui8_buffer;
- nbuffer = nstr->pui8_buffer;
-
- ilength = istr->ui32_length;
- olength = ostr->ui32_length;
- nlength = nstr->ui32_length;
-
- length = ilength;
-
- if(mode == M4OSA_kstrAll)
- {
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr_src);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- if(err_code == M4WAR_CHR_NOT_FOUND)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- /* Allocate the actual M4OSA_String content */
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(istr->ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivReplaceSmallerStr");
-
- M4OSA_CHECK_MALLOC(buffer, "M4OSA_strPrivReplaceSmallerStr");
-
- ptr_dest = buffer;
-
- do
- {
- size = (M4OSA_UInt32)ptr_src - (M4OSA_UInt32)ibuffer;
-
- length += (nlength - olength);
-
- M4OSA_memcpy(ptr_dest, ibuffer, size);
-
- ptr_dest += size;
-
- M4OSA_memcpy(ptr_dest, nbuffer, nlength);
-
- ptr_dest += nlength;
-
- ibuffer += (size + olength);
-
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr_src);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- } while(err_code != M4WAR_CHR_NOT_FOUND);
-
- size = ilength - (M4OSA_UInt32)(ibuffer - istr->pui8_buffer);
-
- M4OSA_memcpy(ptr_dest, ibuffer, size);
-
- free(istr->pui8_buffer);
-
- istr->ui32_length = length ;
-
- buffer[length] = '\0';
-
- istr->pui8_buffer = buffer;
- }
- else
- {
- if(mode == M4OSA_kstrBegin)
- {
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr_src);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- if(err_code == M4WAR_CHR_NOT_FOUND)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- i32_pos = (M4OSA_UInt32)ptr_src - (M4OSA_UInt32)ibuffer;
- }
- else
- {
- i32_pos = M4OSA_strPrivFindLastSubStr(istr, ostr, ilength-1);
-
- if(i32_pos == -1)
- {
- return M4WAR_STR_NOT_FOUND;
- }
- }
-
- err_code = M4OSA_strPrivSetAndRepleceStr(istr, i32_pos, olength,
- nbuffer, nlength);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- M4OSA_DEBUG(err_code, "M4OSA_strPrivReplaceSmallerStr");
-
- return err_code;
- }
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief This function replaces a string buffer by a new "C-String"
- * and manage memory if needed
- * @note
- * @param pstr_src
- * @param pac_in
- * @return M4OSA_ERROR
- ************************************************************************
- */
-M4OSA_ERR M4OSA_strPrivReplaceBiggerStr(M4OSA_strStruct* istr,
- M4OSA_strStruct* ostr,
- M4OSA_strStruct* nstr,
- M4OSA_strMode mode)
-{
- M4OSA_Char* ibuffer;
- M4OSA_Char* obuffer;
- M4OSA_Char* nbuffer;
- M4OSA_Char* buffer;
- M4OSA_Char* ptr;
- M4OSA_UInt32 ilength, nlength, olength, length;
- M4OSA_Int32 i32_pos;
- M4OSA_ERR err_code;
-
- M4OSA_TRACE2_4("M4OSA_strPrivReplaceBiggerStr\t\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strStruct* 0x%x\tM4OSA_strStruct* 0x%x\t"
- "M4OSA_strMode %d", istr, ostr, nstr, mode);
-
- ibuffer = istr->pui8_buffer;
- obuffer = ostr->pui8_buffer;
- nbuffer = nstr->pui8_buffer;
-
- ilength = istr->ui32_length;
- olength = ostr->ui32_length;
- nlength = nstr->ui32_length;
-
-
- if(mode == M4OSA_kstrAll)
- {
- M4OSA_UInt32 n=0, i;
- M4OSA_Int32* patterns;
- M4OSA_UInt32 pos=0, size;
- M4OSA_UInt32 max_pattern = ilength / olength;
- M4OSA_UInt32 ui32_size = istr->ui32_size;
- M4OSA_Char* src;
- M4OSA_Char* dest;
-
- /* Allocate the actual M4OSA_String content */
- patterns = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(max_pattern * sizeof(M4OSA_UInt32),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivReplaceBiggerStr");
-
- M4OSA_CHECK_MALLOC(patterns, (M4OSA_Char*)"M4OSA_strPrivReplaceBiggerStr");
-
-
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceBiggerStr");
-
- if(err_code == M4WAR_CHR_NOT_FOUND)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- do
- {
- patterns[n] = (M4OSA_UInt32)ptr - (M4OSA_UInt32)ibuffer;
-
- n++;
-
- err_code = M4OSA_chrFindPattern(ptr + olength, obuffer, &ptr);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceBiggerStr");
-
- } while(err_code != M4WAR_CHR_NOT_FOUND);
-
- length = ilength - (n * olength) + (n * nlength);
-
-
- if(length >= ui32_size)
- {
- do
- {
- ui32_size <<= 1;
-
- } while(length >= ui32_size);
- }
-
- /* Allocate the actual M4OSA_String content */
- buffer = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(ui32_size * sizeof(M4OSA_Char),
- M4OSA_STRING, (M4OSA_Char*)"M4OSA_strPrivReplaceBiggerStr");
-
- M4OSA_CHECK_MALLOC(buffer, "M4OSA_strPrivReplaceBiggerStr");
-
- src = ibuffer;
- dest = buffer;
-
- for(i=0; i<n; i++)
- {
- size = patterns[i] - pos;
-
- M4OSA_memcpy(dest, src, size);
-
- pos = patterns[i] + olength;
-
- src = ibuffer + pos;
-
- dest += size;
-
- M4OSA_memcpy(dest, nbuffer, nlength);
-
- dest += nlength;
- }
-
- size = ilength - (M4OSA_UInt32)(src - ibuffer);
-
- M4OSA_memcpy(dest, src, size);
-
- free(patterns);
-
- free(ibuffer);
-
- istr->ui32_length = length;
-
- istr->pui8_buffer = buffer;
-
- istr->pui8_buffer[length] = '\0';
- }
- else
- {
- if(mode == M4OSA_kstrBegin)
- {
- err_code = M4OSA_chrFindPattern(ibuffer, obuffer, &ptr);
-
- M4OSA_DEBUG_IF2(M4OSA_ERR_IS_ERROR(err_code), err_code,
- "M4OSA_strPrivReplaceSameSizeStr");
-
- if(err_code == M4WAR_CHR_NOT_FOUND)
- {
- return M4WAR_STR_NOT_FOUND;
- }
-
- i32_pos = (M4OSA_UInt32)ptr - (M4OSA_UInt32)ibuffer;
- }
- else
- {
- i32_pos = M4OSA_strPrivFindLastSubStr(istr, ostr, ilength-1);
-
- if(i32_pos == -1)
- {
- return M4WAR_STR_NOT_FOUND;
- }
- }
-
- err_code = M4OSA_strPrivSetAndRepleceStr(istr, i32_pos, olength,
- nbuffer, nlength);
-
- if(M4OSA_ERR_IS_ERROR(err_code))
- {
- M4OSA_DEBUG(err_code, "M4OSA_strPrivReplaceSmallerStr");
-
- return err_code;
- }
- }
-
- return M4NO_ERROR;
-}
-
-
-M4OSA_ERR M4OSA_strPrivSPrintf(M4OSA_strStruct* str,
- M4OSA_Char *format,
- va_list marker)
-{
- M4OSA_Char *temp;
- M4OSA_Char *percentPointer;
- M4OSA_Char *newFormat;
- M4OSA_Char* strOut = str->pui8_buffer + str->ui32_length;
- M4OSA_UInt32 strOutMaxLen = str->ui32_size-1;
- M4OSA_Int32 newFormatLength = 0;
- M4OSA_UInt32 count_ll = 0;
- M4OSA_UInt32 count_tm = 0;
- M4OSA_UInt32 count_aa = 0;
- M4OSA_UInt32 count;
- M4OSA_UInt32 nbChar;
- M4OSA_Int32 iResult;
-
- M4OSA_Int32 err;
- M4OSA_Char flagChar[] = "'-+ #0";
- M4OSA_Char widthOrPrecisionChar[] = "*0123456789";
- M4OSA_Char otherPrefixChar[] = "hlL";
- M4OSA_Char conversionChar[] = "diouxXnfeEgGcCsSp%";
-
- M4OSA_TRACE2_2("M4OSA_strSPrintf\t\tM4OSA_String 0x%x\tM4OSA_Char* 0x%x",
- str, format);
-
-
- /* count the number of %[flags][width][.precision]ll[conversion] */
- temp = format;
-
- while(*temp)
- {
- /* get the next percent character */
- err = M4OSA_chrFindChar (temp, '%', &percentPointer);
-
- if((!percentPointer) || (M4WAR_CHR_NOT_FOUND == err))
- {
- break; /* "This is the End", (c) J. Morrisson */
- }
-
- temp = percentPointer+1; /* span it */
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- /* span the optional flags */
- M4OSA_chrSpan(format, conversionChar, &nbChar);
- temp += nbChar;
-
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- /* span the optional width */
- M4OSA_chrSpan(temp, widthOrPrecisionChar, &nbChar);
- temp += nbChar;
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- if(*temp=='.')
- {
- /* span the optional precision */
- M4OSA_chrSpan(++temp, widthOrPrecisionChar, &nbChar);
- temp += nbChar;
- }
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- if(M4OSA_chrLength(temp)>=2)
- {
-
- M4OSA_chrNCompare(temp, (M4OSA_Char*)"ll",2, &iResult);
- if (iResult != 0)
- {
- count_ll++; /* I got ONE */
- temp +=2; /* span the "ll" prefix */
- }
- else
- {
- M4OSA_chrNCompare(temp, (M4OSA_Char*)"tm",2, &iResult);
- if (iResult != 0) /* à voir si ce n'est pas == 0 */
- {
- count_tm++;
- temp +=2;
- }
- else
- {
- M4OSA_chrNCompare(temp, (M4OSA_Char*)"aa",2, &iResult);
- if (iResult != 0) /* à voir si ce n'est pas == 0 */
- {
- count_aa++;
- temp +=2;
- }
- }
- }
- }
-
- /* span the other optional prefix */
- M4OSA_chrSpan(temp, otherPrefixChar, &nbChar);
- temp += nbChar;
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- M4OSA_chrSpan(temp, conversionChar, &nbChar);
- temp += nbChar;
- if(!*temp) /* "This is the End", (c) J. Morrisson */
- {
- break;
- }
-
- }
-
- count = count_ll + count_tm + count_aa;
-
- if(!count)
- {
- err = M4OSA_chrSPrintf(strOut,strOutMaxLen,format,marker);
-
- if(M4ERR_CHR_STR_OVERFLOW == err)
- {
- return M4ERR_STR_OVERFLOW;
- }
-
- return M4NO_ERROR;
- }
-
-
- newFormatLength = M4OSA_chrLength(format) + 1;
-
-#ifdef M4OSA_64BITS_SUPPORTED
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
- newFormatLength += (count_ll+count_tm+count_aa);
-#else
- newFormatLength += (count_ll+count_tm-count_aa);
-#endif
-#elif defined M4OSA_64BITS_NOT_SUPPORTED
- newFormatLength -= (count_ll+count_tm+count_aa);
-#else
- return M4ERR_NOT_IMPLEMENTED;
-#endif
-
- newFormat =(M4OSA_Char*)M4OSA_32bitAlignedMalloc(newFormatLength,
- M4OSA_CHARSTAR, (M4OSA_Char*)"M4OSA_chrPrintf: newFormat");
- if(newFormat == M4OSA_NULL) return M4ERR_ALLOC;
- newFormat[newFormatLength-1] = '\0';
- temp = newFormat;
- /* copy format to newFormat, replacing
- %[flags][width][.precision]ll[conversion]
- by %[flags][width][.precision]I64[conversion] */
- while(*format)
- {
- M4OSA_chrSpanComplement(format, (M4OSA_Char*)"%", &nbChar);
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar); /* copy characters before the % character */
- format +=nbChar;
- temp +=nbChar;
- }
- if(!*format)
- {
- break;
- }
- *temp++ = *format++; /* copy the % character */
-
- M4OSA_chrSpan(format, flagChar, &nbChar);
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar); /* copy the flag characters */
- format +=nbChar;
- temp +=nbChar;
- }
- if(!*format)
- {
- break;
- }
-
- M4OSA_chrSpan(format, widthOrPrecisionChar, &nbChar);
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar); /* copy the width characters */
- format +=nbChar;
- temp +=nbChar;
- }
- if(!*format)
- {
- break;
- }
- if(*format=='.')
- {
- *temp++ = *format++; /* copy the dot character */
- if(!*format)
- {
- break;
- }
-
- M4OSA_chrSpan(format, widthOrPrecisionChar, &nbChar);
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar); /* copy the width characters */
- format +=nbChar;
- temp +=nbChar;
- }
- if(!*format)
- {
- break;
- }
- }
- if(M4OSA_chrLength(format)>=2)
- {
-
- M4OSA_chrNCompare(format, (M4OSA_Char*)"ll",2, &iResult);
- if (iResult != 0)
- {
-#ifdef M4OSA_64BITS_SUPPORTED
- *temp++ = 'I'; /* %I64 */
- *temp++ = '6';
- *temp++ = '4';
-#else
- *temp++ = 'l'; /* %l */
-#endif
- format +=2; /* span the "ll" prefix */
- }
- else
- {
- M4OSA_chrNCompare(format, (M4OSA_Char*)"tm",2, &iResult);
- if (iResult != 0)
- {
-#ifdef M4OSA_64BITS_SUPPORTED
- *temp++ = 'I'; /* %I64 */
- *temp++ = '6';
- *temp++ = '4';
-#else
- *temp++ = 'l'; /* %l */
-#endif
- format +=2; /* span the "tm" prefix */
- }
- else
- {
- M4OSA_chrNCompare(format, (M4OSA_Char*)"aa",2, &iResult);
- if (iResult != 0) /* à voir si ce n'est pas != 0 */
- {
-#ifdef M4OSA_64BITS_SUPPORTED
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
- *temp++ = 'I'; /* %I64 */
- *temp++ = '6';
- *temp++ = '4';
-#else
- *temp++ = 'l';
-#endif
-#else
- *temp++ = 'l';
-#endif
- format +=2; /* span the "aa" prefix */
- }
- }
- }
- }
-
- M4OSA_chrSpan(format, otherPrefixChar, &nbChar);
-
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar); /* copy the other Prefix */
- format +=nbChar;
- temp +=nbChar;
- }
-
- if(!*format)
- {
- break;
- }
-
- M4OSA_chrSpan(format, conversionChar, &nbChar);
- if(nbChar)
- {
- M4OSA_chrNCopy(temp,format,nbChar);
- format += nbChar;
- temp += nbChar;
- }
-
- if(!*format)
- {
- break;
- }
- }
-
- err = M4OSA_chrSPrintf(strOut,strOutMaxLen,newFormat,marker);
-
- free(newFormat);
-
- if (M4ERR_CHR_STR_OVERFLOW == err)
- {
- return M4ERR_STR_OVERFLOW;
- }
- else
- {
- return M4NO_ERROR;
- }
-}
-
diff --git a/libvideoeditor/vss/common/inc/M4CLOCK.h b/libvideoeditor/vss/common/inc/M4CLOCK.h
deleted file mode 100755
index 963b135..0000000
--- a/libvideoeditor/vss/common/inc/M4CLOCK.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
-*************************************************************************
- * @file M4CLOCK.h
- * @brief Clock and sleep functions types
- *
-*************************************************************************
-*/
-#ifndef __M4CLOCK_H__
-#define __M4CLOCK_H__
-
-#include "M4OSA_Types.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * Type of a function that returns time.
- */
-typedef M4OSA_Double (*M4CLOCK_getTime_fct) ( M4OSA_Void* pContext ) ;
-
-/**
- * Type of a function that suspends a task for a certain amount of time.
- */
-typedef M4OSA_Void (*M4CLOCK_sleep_fct) ( M4OSA_Void* pContext,\
- M4OSA_UInt32 durationInMs ) ;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __M4CLOCK_H__ */
-
diff --git a/libvideoeditor/vss/common/inc/M4ENCODER_AudioCommon.h b/libvideoeditor/vss/common/inc/M4ENCODER_AudioCommon.h
index 1386c8c..f63bcfe 100755
--- a/libvideoeditor/vss/common/inc/M4ENCODER_AudioCommon.h
+++ b/libvideoeditor/vss/common/inc/M4ENCODER_AudioCommon.h
@@ -29,6 +29,7 @@ extern "C" {
#endif /* __cplusplus */
#include "M4OSA_OptionID.h" /* for M4OSA_OPTION_ID_CREATE() */
+#include "M4OSA_CoreID.h"
#define M4ENCODER_AUDIO_NB_CHANNELS_MAX 2
/* WARNING: this value must be equal to the number of samples grabbed */
@@ -45,7 +46,7 @@ extern "C" {
typedef enum
{
/* Maximum generated AU size */
- M4ENCODER_Audio_maxAUsize = M4OSA_OPTION_ID_CREATE(M4_READ, M4ENCODER_AUDIO, 0x01)
+ M4ENCODER_Audio_maxAUsize = M4OSA_OPTION_ID_CREATE(M4_READ,M4ENCODER_AUDIO, 0x01)
} M4ENCODER_Audio_OptionID;
diff --git a/libvideoeditor/vss/common/inc/M4MDP_API.h b/libvideoeditor/vss/common/inc/M4MDP_API.h
deleted file mode 100755
index 1000cd8..0000000
--- a/libvideoeditor/vss/common/inc/M4MDP_API.h
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
-*************************************************************************
- * @file M4MDP_API.h
- * @brief Parser of metadata
- *
-*************************************************************************
-*/
-
-#ifndef __M4MDP_API_H__
-#define __M4MDP_API_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MD4MDP_close M4MDP_close
-
-#include "M4READER_Common.h"
-#include "M4TOOL_VersionInfo.h"
-#include "M4OSA_FileReader.h"
-#include "M4OSA_FileWriter.h"
-
-/*define the buffer size for content detection*/
-#define M4MDP_INPUT_BUFFER_SIZE 8192
-
-/**
- ************************************************************************
- * Public type of the M4MDP_osaFilePtrSt
- ************************************************************************
-*/
-typedef struct
-{
- M4OSA_FileReadPointer* m_pFileReaderFcts;
- M4OSA_FileWriterPointer* m_pFileWriterFcts;
-} M4MDP_osaFilePtrSt;
-
-/**
- ************************************************************************
- * Public type of the MDP execution context
- ************************************************************************
-*/
-typedef M4OSA_Void* M4MDP_Context;
-
-/**
- ************************************************************************
- * Metadata Parser Errors & Warnings definition
- ************************************************************************
-*/
-#define M4WAR_MDP_MEDIATYPE_NOT_DETECTED M4OSA_ERR_CREATE(M4_WAR, M4MDP, 0x000001)
-
-#define M4ERR_MDP_FATAL M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000000)
-#define M4ERR_MDP_UNSUPPORTED_TAG_VERSION M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000001)
-#define M4ERR_MDP_UNSUPPORTED_ENCODING_TYPE M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000002)
-#define M4ERR_MDP_INIT_FAILED M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000003)
-#define M4ERR_MDP_ASSET_PARSING_ERROR M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000004)
-#define M4ERR_MDP_FILE_NOT_FOUND M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000005)
-#define M4ERR_MDP_INVALID_PATH M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000006)
-
-/**
- ************************************************************************
- * Metadata parser FUNCTIONS
- ************************************************************************
-*/
-
-/**
- ************************************************************************
- * @brief Getting the version of the metadata parser
- * This function allows getting the version of the MDP library.
- *
- * @param pVersionInfo (OUT) Pointer on an allocated version info structure
- * After M4MDP_getVersion() successfully returns, this
- * structure is filled with the version numbers.
- * The structure must be allocated and further de-allocated
- * by the application.
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pVersionInfo is null (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getVersion(M4_VersionInfo* pVersionInfo);
-
-
-/**
- ************************************************************************
- * @brief Initializing the MDP
- * This function initializes the MDP and allocates the MDP execution
- * context and parses the metadata
- * @note This function allocates the memory needed to store metadata in
- * TAG ID3 V1&V2, ASF or 3gpp asset structure with the OSAL allocation
- * function.
- * This memory will be freed in M4MDP_cleanUp function
- *
- * @note This function is synchronous.
- *
- * @param pContext (OUT) Execution Context
- * @param pFilePath (IN) Pointer to the multimedia file path
- * @param pFileReaderFcts (IN) Pointer to a structure containing OSAL file reader
- * functions pointers
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER At least, one parameter is null (in DEBUG only)
- * @return M4ERR_ALLOC There is no more memory available
- * @return M4WAR_READER_NO_METADATA The input file doesn't contain metadata
- * @return M4ERR_UNSUPPORTED_MEDIA_TYPE The input file is not recognized
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_init(M4MDP_Context* pContext, M4OSA_Char* pFilePath,
- M4OSA_FileReadPointer* pFileReaderFcts);
-
-/**
- ************************************************************************
- * @brief This function frees the MDP execution context and all metadata
- * structures already allocated by M4MDP_init
- *
- * @note This function is synchronous.
- *
- * @param pContext (IN) Execution Context
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext is NULL. (in DEBUG only)
-************************************************************************
-*/
-M4OSA_ERR M4MDP_cleanUp(M4MDP_Context pContext);
-
-/**
- ************************************************************************
- * @brief This function Initializes the meta data parser only once to check several files one
- * after another.
- *
- * @note This function is synchronous.
- *
- * @param pContext (IN) Execution Context
- * @param pFileReaderFcts (IN) Pointer to a structure containing OSAL file reader
- * functions pointers
-*
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext is NULL. (in DEBUG only)
-************************************************************************
-*/
-M4OSA_ERR M4MDP_globalInit(M4MDP_Context* pContext, M4OSA_FileReadPointer* pFileReaderFcts);
-
-/**
- ************************************************************************
- * @brief This function opens a file in the meta data parser
- *
- * @note This function is synchronous.
- *
- * @param pContext (IN) Execution Context
- * @param pFilePath (IN) Pointer to the multimedia file path
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext is NULL. (in DEBUG only)
-************************************************************************
-*/
-M4OSA_ERR M4MDP_open(M4MDP_Context* pContext, M4OSA_Char* pFilePath);
-
-/**
- ************************************************************************
- * @brief This function closes a file in the meta data parser
- *
- * @note This function is synchronous.
- *
- * @param pContext (IN) Execution Context
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext is NULL. (in DEBUG only)
-************************************************************************
-*/
-M4OSA_ERR M4MDP_close(M4MDP_Context* pContext);
-
-
-/**
- ************************************************************************
- * @brief The function allows the retrieval of all fields of the
- * M4_MetaDataFields structure
- * It basically sets M4_MetaDataFields structure fields pointers to
- * the corresponding already retrieved metadata
- *
- * @note If metadata are retrieved from an MP3 or an AAC files, and both
- * TAG ID3 V1 and V2 are present, then, priority is for metadata of TAG ID3 V2
- *
- * @note This function is synchronous.
- * @note This function is used specially by the music manager project
- *
- * @param pContext (IN) Execution Context
- * @param pMetadata (OUT) Pointer to M4_MetaDataFields structure
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pMetadata is NULL. (in DEBUG only)
- * @return M4WAR_READER_NO_METADATA The input file doesn't contain metadata
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getMetadata(M4MDP_Context pContext, M4_MetaDataFields* pMetadata);
-
-/**
- ************************************************************************
- * @brief This function returns the audio and video media type
- *
- * @note This function is synchronous.
- * @note This function is used specially by the music manager project
- *
- * @param pContext (IN) Execution Context
- * @param pAudio (OUT) Audio media type pointer
- * @param pVideo (OUT) Video media type pointer
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER At least one parameter is NULL. (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getStreamsType(M4MDP_Context pContext,M4_StreamType* pAudio,M4_StreamType* pVideo);
-
-
-/**
- ************************************************************************
- * @brief This function returns the mediaType
- *
- * @note This function is synchronous.
- * @note This function is used specially by the music manager project
- *
- * @param pContext (IN) Execution Context
- * @param pMediaType (OUT) MediaType pointer
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER At least one parameter is NULL. (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getMediaType(M4MDP_Context pContext,M4READER_MediaType* pMediaType);
-
-/******************************************************************************
-* @brief returns mediaType found in a file
-* @note
-* @param pFileDescriptor (IN) : pointer to file descriptor
-* @param pFileFunction (IN) : pointer to file function
-* @param pMediaType (OUT) : mediaType if found
-* @return M4NO_ERROR / M4ERR_ALLOC
-******************************************************************************/
-M4OSA_ERR M4MDP_getMediaTypeFromFile(M4OSA_Void *pFileDescriptor,
- M4OSA_FileReadPointer *pFileFunction,
- M4READER_MediaType *pMediaType);
-
-/******************************************************************************
-* @brief return media type by extension and content detections
-* @note
-* @param pFileDescriptor (IN) : pointer to file descriptor
-* @param dataBuffer (IN) : memory buffer
-* @param bufferSize (IN) : buffer size
-* @param pMediaType (OUT) : mediaType if found
-* @return M4NO_ERROR / M4ERR_ALLOC
-******************************************************************************/
-M4OSA_ERR M4MDP_getMediaTypeFromExtensionAndContent(M4OSA_Void *pFileDescriptor,
- M4OSA_UInt8 *dataBuffer,
- M4OSA_UInt32 bufferSize,
- M4READER_MediaType *pMediaType);
-
-/******************************************************************************
-* @brief return media type by content detection
-* @note
-* @param dataBuffer (IN) : memory buffer
-* @param bufferSize (IN) : buffer size
-* @param pMediaType (OUT) : mediaType if found
-* @return M4NO_ERROR / M4ERR_ALLOC
-******************************************************************************/
-M4OSA_ERR M4MDP_getMediaTypeFromContent(M4OSA_UInt8 *dataBuffer, M4OSA_UInt32 bufferSize,
- M4READER_MediaType *pMediaType);
-
-/**
- ************************************************************************
- * @brief The function parses the buffer pAsfBuffer, extracts metadata,
- * allocates memory for pMetaData and fills in.
- *
- * @note pAsfBuffer owns the application (caller).
- * The application free pAsfBuffer and pMetaData
- *
- * @note This function is synchronous.
- *
- * @param pAsfBuffer (IN) input buffer
- * @param pMetaData (OUT) Pointer to the metadata structure
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pAsfBuffer is NULL. (in DEBUG only)
- * @return M4ERR_ALLOC There is no more memory available
- * @return M4WAR_READER_NO_METADATA The M4READER_Buffer doesn't contain metadata
- * @return M4ERR_UNSUPPORTED_MEDIA_TYPE The input file is not recognized
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_parseASFContentDesc(M4READER_Buffer* pAsfBuffer, M4_MetaDataFields *pMetaData);
-
-
-/**
- ************************************************************************
- * @brief The function allocates memory for pMetaData and copies its
- * pAssetFields fields
- *
- * @note The application which calls M4MDP_parse3GppAssetField MUST free pMetaData.
- *
- * @note This function is synchronous.
- *
- * @param pAssetFields (IN) Asset fields structure filled by the 3gpp reader
- * @param pMetaData (OUT) Metadata structure to be filled in
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pAssetFields is NULL. (in DEBUG only)
- * @return M4ERR_ALLOC There is no more memory available
- * @return M4ERR_UNSUPPORTED_MEDIA_TYPE The input file is not recognized
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_parse3GppAssetField(M4_MetaDataFields* pAssetFields, M4_MetaDataFields *pMetaData);
-
-
-/**
- ************************************************************************
- * @brief The function allocates memory for pMetaData and copies its
- * pExifFields fields
- *
- * @note The application which calls M4MDP_parseExifField MUST free pMetaData.
- *
- * @note This function is synchronous.
- *
- * @param pExifFields (IN) Exif fields structure filled by the exif reader
- * @param pMetaData (OUT) Metadata structure to be filled in
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pAssetFields is NULL. (in DEBUG only)
- * @return M4ERR_ALLOC There is no more memory available
- * @return M4ERR_UNSUPPORTED_MEDIA_TYPE The input file is not recognized
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_parseExifField(M4_MetaDataFields *pExifFields, M4_MetaDataFields *pMetaData);
-
-
-/**
- ************************************************************************
- * @brief The function allocates and fills the pMetaDataStruct by parsing
- * a buffer
- *
- * @note pMetaDataStruct owns the application (caller).
- * It is the responsibility of the application (caller) to free it
- *
- * @note This function is synchronous.
- *
- * @param pBuffer (IN) input buffer
- * @param mediaType (IN) media type of the buffer
- * @param pMetaDataStruct (OUT) Pointer to an array of metadata
- * @param pSize (OUT) pMetaDataStruct size
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pBuffer or pMetaDataStruct is NULL.
- * (in DEBUG only)
- * @return M4ERR_ALLOC There is no more memory available
- * @return M4ERR_UNSUPPORTED_MEDIA_TYPE The media type is not supported
- * @return M4WAR_READER_NO_METADATA No metadata detected
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getMetaDataFromBuffer(M4_MetadataBuffer* pBuffer,
- M4READER_MediaType mediaType,
- M4_MetaDataFields** pMetaDataStruct,
- M4OSA_UInt32* pSize);
-
-/**
- ************************************************************************
- * @brief The function initializes the metadata structure
- *
- * @param pMetadata (OUT) Pointer to M4_MetaDataFields structure
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pMetadata is NULL. (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_InitMetaDataFields(M4_MetaDataFields *pMetaDataTab);
-
-/**
- ************************************************************************
- * @brief The function frees the metadata structure
- *
- * @param pMetadata (IN) Pointer to M4_MetaDataFields structure
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pMetadata is NULL. (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_FreeMetaDataFields(M4_MetaDataFields *pMetaDataTab);
-
-/******************************************************************************
-* @brief returns mediaType found in a file
-* @note
-* @param pContext (IN) : pointer to file descriptor
-* @param pFileDescriptor (IN) : pointer to file descriptor
-* @param pFileFunction (IN) : pointer to file function
-* @param pMediaType (OUT) : mediaType if found
-* @return M4NO_ERROR / M4ERR_ALLOC
-******************************************************************************/
-M4OSA_ERR M4MDP_getMediaTypeFromFileExtended( M4MDP_Context pContext,
- M4OSA_Void *pFileDescriptor,
- M4OSA_FileReadPointer *pFileFunction,
- M4READER_MediaType *pMediaType);
-
-/**
- ************************************************************************
- * @brief The function to get file size
- *
- * @param pContext (IN) Pointer to M4MDP Context structure
- * @param pSize (OUT)Pointer to file size
- *
- * @return M4NO_ERROR No error
- * @return M4ERR_PARAMETER pContext or pMetadata is NULL. (in DEBUG only)
- ************************************************************************
-*/
-M4OSA_ERR M4MDP_getMetaDataFileSize(M4MDP_Context pContext, M4OSA_UInt32 *pSize);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __M4MDP_API_H__ */
diff --git a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h b/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
index 170620c..90df82b 100755
--- a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
+++ b/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Interface.h
@@ -20,22 +20,10 @@
#include "M4DECODER_Common.h"
-#include "M4VD_HW_API.h"/* M4VD_Interface */
-
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct
-{
- M4VD_Interface* externalFuncs;
- M4OSA_Void* externalUserData;
-}* M4DECODER_EXTERNAL_UserDataType;
-
-/* ----- Interface retrieval ----- */
-
-M4OSA_ERR M4DECODER_EXTERNAL_getInterface(M4DECODER_VideoInterface** pDecoderInterface);
-
/* ----- DSI bitstream parser ----- */
/* This function is available to clients of the shell to allow them to analyse clips
diff --git a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Internal.h b/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Internal.h
deleted file mode 100755
index f2dacb2..0000000
--- a/libvideoeditor/vss/common/inc/M4VD_EXTERNAL_Internal.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __M4VD_EXTERNAL_INTERNAL_H__
-#define __M4VD_EXTERNAL_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "NXPSW_CompilerSwitches.h"
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
-#include "M4OSA_Semaphore.h"
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
-/*typedef enum
-{
- M4VS_THREAD_IS_IDLE = 0,
- M4VS_THREAD_IS_RUNNING = 1,
- M4VS_THREAD_IS_STOPPING = 2
-
-} M4VS_ThreadState_t;*/
-
-
-/* ----- internal VS context ----- */
-
-typedef struct
-{
- /* READER */
- /**< Reference to the reader data interface used to read access units */
- M4READER_DataInterface* m_pReader;
- /**< Reference to the access unit used read and decode one frame (the AU could be passed by
- the user instead of reading it from inside the decoder) */
- M4_AccessUnit* m_pNextAccessUnitToDecode;
- /**< Flag to know if we decode just after a (read) jump */
- M4OSA_Bool m_bJump;
- M4_MediaTime m_nextAUCts; /**< CTS of the AU above */
-
- /* DECODER */
-
- M4_MediaTime m_DecodeUpToCts; /**< Target Cts for the decode up to loop */
- M4_MediaTime m_CurrentDecodeCts; /**< Cts of the latest frame decoded */
- M4_MediaTime m_PreviousDecodeCts; /**< Cts of the previous frame decoded */
- M4OSA_UInt32 m_NbDecodedFrames; /**< Number of frames decoded in the decode
- up to loop (can be 0) */
- M4OSA_ERR m_uiDecodeError; /**< Error or warning code (from the VD
- reader or decoder) returned to the
- shell */
- M4OSA_Bool m_bDataDecodePending; /**< There is some data to decode */
- M4OSA_Bool m_bIsWaitNextDecode; /**< Do we need to wait for the anticipated
- decoding to finish ? */
-
- /* RENDER */
-
- M4_MediaTime m_TargetRenderCts; /**< Cts for the rendering step */
- M4_MediaTime m_CurrentRenderCts; /**< Cts of the latest frame decoded */
- M4OSA_ERR m_uiRenderError; /**< Error or warning code (from the
- VD render) returned to the shell */
- M4OSA_Bool m_bForceRender; /**< Force rendering even if 0 frames
- are decoded (i.e. already
- previously decoded) */
- M4OSA_Bool m_bDataRenderPending; /**< There is some data to render */
-
- /* STREAM PARAMS */
-
- M4_VideoStreamHandler* m_pVideoStreamhandler; /**< reference to the video
- stream description passed by
- the user */
- M4VD_StreamInfo* m_pStreamInfo;
- M4DECODER_VideoSize m_VideoSize;
- M4DECODER_MPEG4_DecoderConfigInfo m_Dci; /**< Information collected from
- DSI parsing */
- M4VIFI_ImagePlane* m_pOutputPlane; /**< Pointer to YUV output planes */
-
- /* VD API */
-
- M4VD_Interface* m_VD_Interface; /**< pointers to HW functions */
- M4VD_SignalingInterface m_VD_SignalingInterface; /**< pointers to Shell signaling
- functions */
- M4VD_Context m_VD_Context; /**< pointer to the real hardware
- context */
-
- /* THREAD STUFF */
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- M4OSA_Context m_SemSync;
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-} M4VS_VideoDecoder_Context;
-
-
-/* ----- bitstream parser ----- */
-/*
-typedef struct
-{
- M4OSA_UInt32 stream_byte;
- M4OSA_UInt32 stream_index;
- M4OSA_MemAddr8 in;
-
-} M4VS_Bitstream_ctxt;
-*/
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __M4VD_EXTERNAL_INTERNAL_H__ */
diff --git a/libvideoeditor/vss/common/inc/M4VD_HW_API.h b/libvideoeditor/vss/common/inc/M4VD_HW_API.h
deleted file mode 100755
index ba33d14..0000000
--- a/libvideoeditor/vss/common/inc/M4VD_HW_API.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __M4VD_HW_API_H__
-#define __M4VD_HW_API_H__
-
-#include "M4OSA_Types.h"
-#include "M4OSA_OptionID.h"
-#include "M4OSA_CoreID.h"
-#include "M4OSA_Error.h"
-#include "M4OSA_Memory.h" /* M4OSA_MemAddrN */
-
-#include "M4VIFI_FiltersAPI.h"
-
-/**
- ************************************************************************
- * @file M4VD_HW_API.H
- * @brief
- * @note
- ************************************************************************
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* ----- Hardware decoder errors and warnings ----- */
-
-#define M4ERR_VD_FATAL M4OSA_ERR_CREATE(M4_ERR, M4VD_EXTERNAL, 0x0001)
-
-
-/* ----- enum definitions ----- */
-
-typedef enum
-{
- M4VD_kOptionId_Dummy = 0
-
-} M4VD_OptionID;
-
-typedef enum
-{
- M4VD_kMpeg4VideoDec,
- M4VD_kH263VideoDec,
- M4VD_kH264VideoDec,
- M4VD_kVideoType_NB /* must remain last */
-} M4VD_VideoType;
-
-typedef enum
-{
- M4VD_kNone,
- M4VD_kYUV420,
- M4VD_kYUV422,
- M4VD_kYUYV422,
- M4VD_kRGB565,
- M4VD_kBGR565
-
-} M4VD_OutputFormat;
-
-
-/* ----- structure definitions ----- */
-
-typedef struct
-{
- M4OSA_MemAddr32 pBuffer; /**< pointer to video buffer - 32 bits aligned */
- M4OSA_UInt32 bufferSize; /**< the size in bytes of the buffer */
-
-} M4VD_VideoBuffer;
-
-typedef struct
-{
- M4OSA_UInt32 aWidth; /**< Width of the Image */
- M4OSA_UInt32 aHeight; /**< Height of the Image */
-
-} M4VD_ImageSize;
-
-typedef struct
-{
- M4OSA_MemAddr8 pBuffer; /**< Pointer to the decoder configuration */
- M4OSA_UInt32 aSize; /**< Size of the buffer */
-
-} M4VD_DecoderConfig;
-
-typedef struct
-{
- M4VD_ImageSize anImageSize; /**<Size of the image*/
- M4VD_DecoderConfig decoderConfiguration; /**<configuration of the decoder*/
-
-} M4VD_StreamInfo;
-
-
-/* ----- callbacks prototypes ----- */
-
-typedef M4OSA_ERR (M4VD_CB_signalDecoderOver_fct)( M4OSA_Void* signalTarget,
- M4OSA_Double frameTime, M4OSA_ERR err);
-typedef M4OSA_ERR (M4VD_CB_signalRenderOver_fct) ( M4OSA_Void* signalTarget,
- M4OSA_Double frameTime, M4OSA_ERR err);
-
-typedef struct
-{
- M4OSA_Void* m_pSignalTarget;
-
- /* decoder callbacks that need to be raised by HW decoder functions */
- M4VD_CB_signalDecoderOver_fct* m_pFctSignalDecoderOver;
- M4VD_CB_signalRenderOver_fct* m_pFctSignalRenderOver;
-
-} M4VD_SignalingInterface;
-
-
-/* ----- Hardware decoder functions set ----- */
-
-typedef void* M4VD_Context; /* Video Decoder context (for M4VD_HW_xxxx functions) */
-
-
-/* common */
-typedef M4OSA_ERR (M4VD_init_fct) ( M4VD_Context*, M4VD_SignalingInterface* );
-typedef M4OSA_ERR (M4VD_setOption_fct) ( M4VD_Context, M4VD_OptionID, M4OSA_DataOption );
-typedef M4OSA_ERR (M4VD_getOption_fct) ( M4VD_Context, M4VD_OptionID, M4OSA_DataOption* );
-typedef M4OSA_ERR (M4VD_openDecoder_fct) ( M4VD_Context, M4VD_VideoType, M4VD_StreamInfo*,
- M4VD_OutputFormat*, M4OSA_Void* );
-typedef M4OSA_ERR (M4VD_stepDecode_fct) ( M4VD_Context, M4VD_VideoBuffer*, M4OSA_Double );
-typedef M4OSA_ERR (M4VD_stepRender_fct) ( M4VD_Context, M4VIFI_ImagePlane*, M4OSA_Double );
-typedef M4OSA_ERR (M4VD_closeDecoder_fct)( M4VD_Context );
-typedef M4OSA_ERR (M4VD_cleanUp_fct) ( M4VD_Context );
-typedef M4OSA_ERR (M4VD_setOutputFilter_fct)( M4VD_Context, M4VIFI_PlanConverterFunctionType*,
- M4OSA_Void*);
-
-typedef struct
-{
- M4VD_init_fct* m_pFctInitVideoDecoder;
- M4VD_setOption_fct* m_pFctSetOption;
- M4VD_getOption_fct* m_pFctGetOption;
- M4VD_openDecoder_fct* m_pFctOpenDecoder;
- M4VD_stepDecode_fct* m_pFctStepDecode;
- M4VD_stepRender_fct* m_pFctStepRender;
- M4VD_closeDecoder_fct* m_pFctClose;
- M4VD_cleanUp_fct* m_pFctCleanUp;
- M4VD_setOutputFilter_fct* m_pFctSetOutputFilter;
-} M4VD_Interface;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __M4VD_HW_API_H__ */
diff --git a/libvideoeditor/vss/common/inc/M4VE_API.h b/libvideoeditor/vss/common/inc/M4VE_API.h
deleted file mode 100755
index 5c27003..0000000
--- a/libvideoeditor/vss/common/inc/M4VE_API.h
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- ******************************************************************************
- * @file M4VE_API.h
- * @note This file declares the generic shell interface retrieving function
- * of any external encoder.
-******************************************************************************
-*/
-
-#ifndef __M4VE_API_H__
-#define __M4VE_API_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * OSAL types definition */
-#include "M4OSA_Types.h"
-#include "M4OSA_Time.h"
-#include "M4OSA_Memory.h"
-#include "M4OSA_CoreID.h"
-#include "M4OSA_OptionID.h"
-
-/**
- * Include Video filters interface definition (for the M4VIFI_ImagePlane type) */
-#include "M4VIFI_FiltersAPI.h"
-
-
-/**
- ************************************************************************
- * VE Errors & Warnings definition
- ************************************************************************
-*/
-#define M4ERR_VE_FATAL ((M4OSA_ERR)M4OSA_ERR_CREATE(M4_ERR, M4VE_EXTERNAL, 0x000000))
-
-
-/**
- *********************************************************************************************
- * enum M4VE_EncoderMode
- * @brief This enum defines in which mode the external encoder will be used
- * ("Standalone encoder" or "Encoder + Grabber").
- *********************************************************************************************
- */
-typedef enum
-{
- M4VE_kSEMode, /**< "Standalone Encoder" mode */
- M4VE_kEGMode /**< "Encoder + Grabber" mode */
-} M4VE_EncoderMode;
-
-
-/**
- *********************************************************************************************
- * enum M4VE_EncoderType
- * @brief This enum defines the supported encoder types.
- *********************************************************************************************
- */
-typedef enum
-{
- M4VE_kMpeg4VideoEnc, /**< MPEG-4 */
- M4VE_kH263VideoEnc, /**< H263 */
- M4VE_kH264VideoEnc, /**< H264 */
- M4VE_kMJPEGEnc, /**< MJPEG */
- M4VE_kEncoderType_NB
-} M4VE_EncoderType;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_ImageSize
- * @brief This structure defines video frame size (for both grabbing and encoding).
- *********************************************************************************************
- */
-typedef struct
-{
- M4OSA_UInt32 width; /**< Width of the Image */
- M4OSA_UInt32 height; /**< Height of the Image */
-} M4VE_ImageSize;
-
-
-/**
- *********************************************************************************************
- * enum M4VE_FormatConfig
- * @brief This enum defines the frame format we have in input for the grabbing
- * part of the external encoder.
- *********************************************************************************************
-*/
-typedef enum
-{
- M4VE_kYUV420=0, /**< YUV 4:2:0 planar (standard input for mpeg-4 video) */
- M4VE_kYUV422, /**< YUV422 planar */
- M4VE_kYUYV, /**< YUV422 interlaced, luma first */
- M4VE_kUYVY, /**< YUV422 interlaced, chroma first */
- M4VE_kJPEG, /**< JPEG compressed frames */
- M4VE_kRGB444, /**< RGB 12 bits 4:4:4 */
- M4VE_kRGB555, /**< RGB 15 bits 5:5:5 */
- M4VE_kRGB565, /**< RGB 16 bits 5:6:5 */
- M4VE_kRGB24, /**< RGB 24 bits 8:8:8 */
- M4VE_kRGB32, /**< RGB 32 bits */
- M4VE_kBGR444, /**< BGR 12 bits 4:4:4 */
- M4VE_kBGR555, /**< BGR 15 bits 5:5:5 */
- M4VE_kBGR565, /**< BGR 16 bits 5:6:5 */
- M4VE_kBGR24, /**< BGR 24 bits 8:8:8 */
- M4VE_kBGR32 /**< BGR 32 bits */
-} M4VE_FormatConfig;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_Framerate
- * @brief This structure defines the maximum framerate the encoder will have
- * at input and will generate at output (in frames per second).
- *********************************************************************************************
-*/
-typedef struct
-{
- M4OSA_UInt32 framerateNum; /**< Framerate numerator */
- M4OSA_UInt32 framerateDen; /**< Framrate denominator */
-} M4VE_Framerate;
-/**< For example, a framerate of 29.97 fps for H263 encoding will be expressed as:
- FramerateNum = 30000
- FramerateDen = 1001 */
-
-
-/**
- *********************************************************************************************
- * struct M4VE_GrabbingParameters
- * @brief This structure defines the grabbing parameters set at open step.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_ImageSize size; /**< Size of grabbed frames */
- M4VE_FormatConfig format; /**< Format of the grabbed frames (YUV420, RGB565,etc.) */
-} M4VE_GrabbingParameters;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_EncodingParameters
- * @brief This structure defines the encoding parameters set at open step.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_EncoderType type; /**< coding type (H263/H264/MPEG-4)*/
- M4VE_ImageSize size; /**< Size of frames to encode */
- M4OSA_Bool bRateControlEnable; /**< Flag to enable/disable rate control */
- M4OSA_Bool bLowDelay; /**< force encoder in "low delay" mode */
- M4OSA_UInt32 bitrate; /**< Average targeted bitrate in bit per sec */
- M4VE_Framerate framerate; /**< Maximum input framerate */
- M4OSA_UInt32 timescale; /**< timescale of the video bitstream */
- M4OSA_Context pUserSettings; /**< Additionnal user settings passed by the
- application to the service at Codec registration */
-} M4VE_EncodingParameters;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_VideoBuffer
- * @brief This structure defines the output buffer where the encoded data
- * are stored by the encoder.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4OSA_MemAddr32 pBuffer; /**< pointer to video buffer 32 bits aligned */
- M4OSA_UInt32 bufferSize; /**< the size in bytes of the buffer */
-} M4VE_VideoBuffer;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_ParameterSet
- * @brief Parameter set structure used for H264 headers.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4OSA_UInt16 length; /**< Number of items*/
- M4OSA_UInt8* pParameterSetUnit; /**< Array of items*/
-} M4VE_ParameterSet;
-
-
-/**
- *********************************************************************************************
- * struct M4VE_H264HeaderBuffer
- * @brief This structure defines the buffer where the stream header is stored
- * by the encoder, in case of H264
- *********************************************************************************************
-*/
-typedef struct
-{
- M4OSA_UInt8 NALUnitLength; /**< length in bytes of a NAL access Unit */
- M4OSA_UInt8 nOfSequenceParametersSets; /**< Number of sequence parameter sets*/
- M4OSA_UInt8 nOfPictureParametersSets; /**< Number of picture parameter sets*/
- M4VE_ParameterSet *pSequenceParameterSets; /**< Sequence parameter set array */
- M4VE_ParameterSet *pPictureParameterSets; /**< Picture parameter set array */
-} M4VE_H264HeaderBuffer;
-
-
-
-/**
- *********************************************************************************************
- * struct M4VE_HeaderBuffer
- * @brief This structure defines the buffer where the stream header is stored
- * by the encoder.
- *********************************************************************************************
-*/
-typedef struct
-{
- union
- {
- M4VE_VideoBuffer header; /**< MPEG-4, H263, MJPEG */
- M4VE_H264HeaderBuffer H264Header; /**< H264 */
- }M4VE_SpecificHeader;
-} M4VE_HeaderBuffer;
-
-
-/**
- *********************************************************************************************
- * enum M4VE_OptionID
- * @brief This defines the supported options handled by the video encoder interface.
- *********************************************************************************************
-*/
-typedef enum
-{
- dummy=0
-} M4VE_OptionID;
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalOpenEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the external encoder is opened.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalOpenEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalHeaderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode,
- * M4VE_HeaderBuffer *pBuffer);
- * @brief This function signals to the service that the stream header is ready.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @param pBuffer : (IN) Stream header.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER pBuffer field is null or invalid.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalHeaderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode,
- M4VE_HeaderBuffer *pBuffer);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalStartGrabberDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the grabbing part is started.
- * This callback is unused in the "standalone encoder" mode.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalStartGrabberDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalStartEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the external encoder is started.
- * This callback is unused in the "standalone encoder" mode.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalStartEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalEncodeDone)(M4OSA_Context pUserData, M4OSA_ERR errCode,
- M4OSA_UInt32 cts, M4VE_VideoBuffer* pBuffer);
- * @brief This function signals to the service that the encoding of a frame is done.
- * The integrator must call this function when the encoding of the video
- * frame is completed (for example in an interrupt callback).
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @param cts : (IN) Time of the encoded frame (from stepEncode).
- * @param pBuffer : (IN) Encoded data Buffer.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER At least one parameter is null or invalid.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalEncodeDone)(M4OSA_Context pUserData, M4OSA_ERR errCode,
- M4OSA_Time cts, M4VE_VideoBuffer* pBuffer);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalStopGrabberDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the grabbing part is stopped.
- * This callback is unused in the "standalone encoder" mode.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalStopGrabberDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalStopEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the external encoder is stopped.
- * This callback is unused in the "standalone encoder" mode.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalStopEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-/**
- *********************************************************************************************
- * M4OSA_Int32 (*M4VE_SignalCloseEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
- * @brief This function signals to the service that the external encoder is closed.
- * @note The external encoder returns one of the following codes in the errCode parameter:
- * M4NO_ERROR There is no error
- * M4ERR_VE_FATAL a fatal error occurred
- * @param pUserData: (IN) User data provided by the service at init step.
- * @param errCode : (IN) Error code returned to the service internal layers.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_VE_FATAL: a fatal error occurred.
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SignalCloseEncoderDone)(M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-
-
-
-/**
- *********************************************************************************************
- * struct M4VE_GenericCallback
- * @brief This structure is used to pass the generic callbacks, i.e. the ones that are used
- * in both "Standalone Encoder" and "Encoder + Grabber" modes.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_SignalOpenEncoderDone pOpenEncoderDone; /**< Callback to use at open completion */
- M4VE_SignalHeaderDone pHeaderDone; /**< Callback to use when the stream
- header is ready */
- M4VE_SignalEncodeDone pEncodeDone; /**< Callback to use for any frame
- encoding completion */
- M4VE_SignalCloseEncoderDone pCloseEncoderDone;/**< Callback to use at close completion */
-} M4VE_GenericCallback; /**< Callbacks used in all encoder modes */
-
-/**
- *********************************************************************************************
- * struct M4VE_EGModeCallback
- * @brief This structure is used to pass the callbacks used in the "Encoder + Grabber" mode
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_SignalStartGrabberDone pStartGrabberDone;/**< Callback to use at start
- completion of the grabber part*/
- M4VE_SignalStartEncoderDone pStartEncoderDone;/**< Callback to use at start
- completion of the encoder part*/
- M4VE_SignalStopGrabberDone pStopGrabberDone; /**< Callback to use at stop
- completion of the grabber part*/
- M4VE_SignalStopEncoderDone pStopEncoderDone; /**< Callback to use at stop
- completion of the encoder part*/
-} M4VE_EGModeCallback; /**< Callbacks used in "Encoder + Grabber" mode */
-
-/**
- *********************************************************************************************
- * struct M4VE_SEModeCallback
- * @brief This structure is used to pass the callbacks used in the "Standalone Encoder" mode
- * @note There's no specific callback for the standalone encoder mode,
- * but we have to declare one
- * @note for some compilers
- *********************************************************************************************
-*/
-typedef M4OSA_Int32 (*M4VE_SEDummyCB) (M4OSA_Context pUserData, M4OSA_ERR errCode);
-
-typedef struct
-{
- M4VE_SEDummyCB pDummySECB; /**< No specific callback for
- Standalone encoder mode */
-} M4VE_SEModeCallback; /**< Callbacks used in "Standalone Encoder" mode */
-
-
-/**
- *********************************************************************************************
- * struct M4VE_CallbackInterface
- * @brief This structure is the container for the whole set of callback used by external encoder
- *********************************************************************************************
-*/
-
-typedef struct
-{
- M4VE_GenericCallback genericCallback;/**< Callbacks used in all modes */
- union
- {
- M4VE_EGModeCallback EGModeCallback; /**< Callbacks used in "Encoder + Grabber" mode */
- M4VE_SEModeCallback SEModeCallback; /**< Callbacks used in "Standalone Encoder" mode */
- } M4VE_SpecificModeCallBack;
- M4OSA_Context pUserData; /**< Internal user data to be retrieved in each
- callbach above */
-} M4VE_CallbackInterface;
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_initEncoder_fct)(M4OSA_Context* pContext,
- * M4VE_CallbackInterface* pCallbackInterface);
- * @brief This function initializes the external video encoder API.
- * @note This function typically allocates the user context that will be provided
- * to the other functions as their first argument. The second argument is
- * the callback interface given by the service. Encoder implementation is supposed
- * to use these callbacks in response to each asynchronous API function.
- * All these callbacks must be called with the pUserData field specified
- * by the service inside the M4VE_CallbackInterface structure.
- * @param pContext: (OUT) Execution context of the encoder.
- * @param pCallbackInterface: (IN) Callback interface.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: At least one parameter is not correct (NULL or invalid).
- * @return M4ERR_ALLOC: there is no more available memory.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_initEncoder_fct)(M4OSA_Context* pContext,
- M4VE_CallbackInterface* pCallbackInterface);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_setOption_fct)(M4OSA_Context, M4VE_OptionID, M4OSA_DataOption);
- * @brief This function is used to set an option in the video encoder interface.
- * @note none
- * @param pContext: (IN) Execution context of the encoder.
- * @param optionId: (IN) Id of the option to set.
- * @param pValue: (IN) Pointer of the option data to set.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: At least one parameter is not correct (NULL or invalid).
- * @return M4ERR_BAD_OPTION_ID:The requested option Id is invalid.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_setOption_fct)(M4OSA_Context pContext, M4VE_OptionID optionId,
- M4OSA_DataOption pValue);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_getOption_fct)(M4OSA_Context, M4VE_OptionID, M4OSA_DataOption*);
- * @brief This function is used to retrieve an option in the video interface.
- * @note none
- * @param pContext: (IN) Execution context of the encoder.
- * @param optionId: (IN) Id of the option to set.
- * @param pValue: (OUT) Pointer to the location where the requested option will
- * be stored.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: At least one parameter is not correct (NULL or invalid).
- * @return M4ERR_BAD_OPTION_ID:The requested option Id is invalid.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_getOption_fct)(M4OSA_Context pContext, M4VE_OptionID optionId,
- M4OSA_DataOption* pValue);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_openEncoder_fct)(M4OSA_Context pContext,
- * M4VE_GrabbingParameters *pGrabbingParams,
- * M4VE_EncodingParameters *pEncodingParams);
- * @brief This function opens an instance of the video encoder.
- * Both encoding and grabbing parameters are specified here.
- * @note This function is asynchronous, thus the external encoder must call the corresponding
- * M4VE_SignalOpenEncoderDone callback function when the opening step is internally
- * completed.
- * Please note that both grabber and encoder components are opened at this step in
- * the "encoder + grabber" mode. In response to this open, the encoder must also return
- * the stream header (including VOS, VO & VOL) using the M4VE_SignalHeaderDone callback
- * function. Usually the service waits for this callback between the
- * M4VE_SignalOpenEncoderDone
- * callback and the M4VE_SignalCloseEncoderDone callback in order to handle it.
- * @param pContext: (IN) Execution context of the encoder.
- * @param pGrabbingParams: (IN) Grabbing parameters (can be optional, in this case is
- * must be NULL).
- * @param pEncodingParams: (IN) Encoding parameters.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: At least one parameter is not correct (NULL or invalid).
- * @return M4ERR_ALLOC: there is no more available memory.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not be opened
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_openEncoder_fct)(M4OSA_Context pContext,
- M4VE_GrabbingParameters *pGrabbingParams,
- M4VE_EncodingParameters *pEncodingParams);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_forceIFrame_fct)(M4OSA_Context pContext);
- * @brief This function is used by the service to signal the external encoder that an Intra
- * refresh frame must be encoded. This function is used in both "Standalone Encoder" and
- * "Encoder + grabber" modes and can be called at any time during the encoding session.
- * @note For the "Encoder + Grabber" mode, this function can be called between the reception
- * of the M4VE_SignalStartEncoderDone callback and the call to M4VE_stopEncoder_fct.
- * For the "Standalone Encoder" mode, this function can be called between the reception
- * of the M4VE_SignalOpenEncoderDone callback and the call to M4VE_closeEncoder_fct.
- * The expected behavior is that the external encoder encodes an intra refresh frame
- * for one of the frames coming next to the call of M4VE_forceIFrame_fct.
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not handle this call
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_forceIFrame_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_releaseOutputBuffer_fct)(M4OSA_Context pContext, M4VE_VideoBuffer *pBuffer);
- * @brief This function is called by the service to signal that a particular output buffer,
- * provided in the M4VE_SignalEncodeDone callback by the external encoder, is no more
- * needed by the service and can be considered as free for any remaining data processing.
- * @note none.
- * @param pContext: (IN) Execution context of the encoder.
- * @param pBuffer: (IN) Encoded data Buffer.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: At least one parameter is not correct (NULL or invalid).
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not acknowledge the buffer release for any
- * other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_releaseOutputBuffer_fct)(M4OSA_Context pContext,
- M4VE_VideoBuffer *pBuffer);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_closeEncoder_fct)(M4OSA_Context pContext);
- * @brief This function closes the encoding session.
- * @note This function is asynchronous, thus the external encoder must call the corresponding
- * M4VE_SignalCloseEncoderDone callback function when the closing step is internally
- * completed.
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext pointer is null or invalid.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not be closed for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_closeEncoder_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_cleanUpEncoder_fct)(M4OSA_Context pContext);
- * @brief The function cleans up the encoder context.
- * @note none
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext pointer is null or invalid.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not be closed for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_cleanUpEncoder_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_stepEncode_fct)(M4OSA_Context pContext,M4VIFI_ImagePlane *pInputPlane,
- * M4OSA_Time cts);
- * @brief The function gives a video frame to the external encoder in the "Standalone encoder"
- * mode. The input buffer consists of a raw YUV420 planar frame,
- * allocated by the service.
- * The time (cts) is the composition time stamp of the frame to encode and is unique
- * for each frame. This time is expressed in milliseconds.
- * @note This function is asynchronous and its completion is signaled by the
- * M4VE_SignalEncodeDone callback. It applies that the input buffer is maintained valid
- * by the service till the call of this callback. The encoded data are retrieved in
- * this callback function in a dedicated structure, allocated by the external encoder.
- * The input buffer (YUV raw frame) is considered by the service as free for any
- * remaining data processing after receiving the M4VE_SignalEncodeDone callback.
- * @param pContext: (IN) Execution context of the encoder.
- * @param pInputPlane: (IN) Input buffer where video frame is stored.
- * @param cts: (IN) Composition time stamp in milliseconds.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_ALLOC: there is no more available memory.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: The encoder could not encode the frame for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_stepEncode_fct)(M4OSA_Context pContext,M4VIFI_ImagePlane *pInputPlane,
- M4OSA_Time cts);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_startGrabber_fct)(M4OSA_Context pContext);
- * @brief This function starts the grabber sub-component of the external encoder, in the
- * "encoder + grabber" mode. This function is asynchronous, thus the external
- * encoder must call the corresponding M4VE_SignalStartGrabberDone callback function
- * when this start is internally effective.
- * @note During this step, the service waits for the grabber to launch any video preview if
- * needed.
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_ALLOC: there is no more available memory.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: the encoder could not be started for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_startGrabber_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_startEncoder_fct)(M4OSA_Context pContext);
- * @brief This function starts the video encoder in the "encoder + grabber" mode.
- * @note This function is asynchronous, thus the external encoder must call the corresponding
- * M4VE_SignalStartEncoderDone callback function when this start is internally
- * effective.
- * After the completion of this asynchronous function, the service waits for the
- * external encoder to periodically call the M4VE_SignalEncodeDone callback each time
- * a new frame has been encoded. The external encoder must expect to have several
- * M4VE_startEncoder_fct calls before being closed. See the description of
- * M4VE_stopEncoder_fct function for the expected behaviour.
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_ALLOC: there is no more available memory.
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: the encoder could not be started for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_startEncoder_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR M4OSA_ERR (*M4VE_stopGrabber_fct)(M4OSA_Context pContext);
- * @brief This function stops the video grabber in the "encoder + grabber" mode.
- * @note This function is asynchronous, thus the external encoder must call the corresponding
- * M4VE_SignalStopGrabberDone callback function when this stop is internally effective.
- * During this step, the service waits for the grabber to stop the video preview
- * if needed.
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_FATAL: the encoder could not be stopped for any other reason.
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_stopGrabber_fct)(M4OSA_Context pContext);
-
-
-/**
- *********************************************************************************************
- * M4OSA_ERR (*M4VE_stopEncoder_fct)(M4OSA_Context pContext);
- * @brief This function stops the video encoder in the "encoder + grabber" mode.
- * @note This function is asynchronous, thus the external encoder must call the corresponding
- * M4VE_SignalStopEncoderDone callback function when this stop is internally effective.
- * After the reception of this callback, the service considers that no new frame will be
- * retrieved via the M4VE_SignalEncodeDone callback.
- * The external encoder must expect to have a possible call to M4VE_startEncoder_fct
- * after M4VE_stopEncoder_fct. In this case, the external encoder must consider that it
- * has been paused/resumed. The expected behaviour is the following one:
- * - The result from this two encoding sessions is a Standalone stream, no header is
- * generated for this new session. The external encoder is free to encode a refresh
- * frame (like I VOP) for this new session.
- * - The time stamps of this new session must directly follow the time stamps of the
- * previous one (ie: no time hole coming from the delay between the stop of the first
- * session and the start of the new one).
- * @param pContext: (IN) Execution context of the encoder.
- * @return M4NO_ERROR: there is no error.
- * @return M4ERR_PARAMETER: pContext field is not valid
- * @return M4ERR_STATE: This call is not allowed in the current encoder state.
- * @return M4ERR_VE_ERR_FATAL: the encoder could not be stopped for any other reason
- *********************************************************************************************
-*/
-typedef M4OSA_ERR (*M4VE_stopEncoder_fct)(M4OSA_Context pContext);
-
-
-
-
-
-/**
- *********************************************************************************************
- * struct M4VE_GenericInterface
- * @brief The M4VE_GenericInterface structure defines the set of functions used in
- * both encoder modes.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_initEncoder_fct m_pFctInitEncoder;
- M4VE_setOption_fct m_pFctSetOption;
- M4VE_getOption_fct m_pFctGetOption;
- M4VE_openEncoder_fct m_pFctOpenEncoder;
- M4VE_forceIFrame_fct m_pFctForceIFrame;
- M4VE_releaseOutputBuffer_fct m_pFctReleaseOutputBuffer;
- M4VE_closeEncoder_fct m_pFctCloseEncoder;
- M4VE_cleanUpEncoder_fct m_pFctCleanUpEncoder;
-} M4VE_GenericInterface; /**< Functions used in both "Standalone Encoder" and
- "Encoder + Grabber" modes */
-
-
-/**
- *********************************************************************************************
- * struct M4VE_SEModeInterface
- * @brief The M4VE_SEModeInterface structure defines the set of functions used in
- * "Standalone Encoder" mode.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_stepEncode_fct m_pFctStepEncode;
-} M4VE_SEModeInterface; /**< Functions used only in "Standalone Encoder" mode */
-
-
-/**
- *********************************************************************************************
- * struct M4VE_EGModeInterface
- * @brief The M4VE_EGModeInterface structure defines the set of functions used in
- * "Encoder + Grabber" mode.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_startGrabber_fct m_pFctStartGrabber;
- M4VE_startEncoder_fct m_pFctStartEncoder;
- M4VE_stopGrabber_fct m_pFctStopGrabber;
- M4VE_stopEncoder_fct m_pFctStopEncoder;
-} M4VE_EGModeInterface; /**< Functions used only in "Encoder + Grabber" mode */
-
-
-
-/**
- *********************************************************************************************
- * struct M4VE_Interface
- * @brief The M4VE_Interface structure stores pointers to the video encoder functions.
- *********************************************************************************************
-*/
-typedef struct
-{
- M4VE_GenericInterface genericInterface; /**< Functions used everytime */
- M4VE_EncoderMode encoderMode; /**< "Standalone Encoder"
- or "Encoder + Grabber" */
- union
- {
- M4VE_SEModeInterface SEModeInterface; /**< Functions used only in
- "Standalone Encoder" mode */
- M4VE_EGModeInterface EGModeInterface; /**< Functions used only in
- "Encoder + Grabber" mode */
- }M4VE_SpecificInterface;
-} M4VE_Interface;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /*__M4VE_API_H__*/
diff --git a/libvideoeditor/vss/common/inc/M4_Logo.h b/libvideoeditor/vss/common/inc/M4_Logo.h
deleted file mode 100755
index 79a2e1c..0000000
--- a/libvideoeditor/vss/common/inc/M4_Logo.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef M4_Logo_h
-#define M4_Logo_h
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-extern const unsigned char logo[];
-extern const int logo_width;
-extern const int logo_height;
-#ifdef __cplusplus
-}
-#endif
-#endif
-
diff --git a/libvideoeditor/vss/inc/M4PTO3GPP_API.h b/libvideoeditor/vss/inc/M4PTO3GPP_API.h
index 86c6b93..693f249 100755
--- a/libvideoeditor/vss/inc/M4PTO3GPP_API.h
+++ b/libvideoeditor/vss/inc/M4PTO3GPP_API.h
@@ -44,8 +44,6 @@
* Definitions of M4VIFI_ImagePlane */
#include "M4VIFI_FiltersAPI.h"
-#include "M4VE_API.h"
-
/**
* Common definitions of video editing components */
#include "M4_VideoEditingCommon.h"
@@ -249,12 +247,6 @@ M4OSA_ERR M4PTO3GPP_Close(M4PTO3GPP_Context pContext);
M4OSA_ERR M4PTO3GPP_CleanUp(M4PTO3GPP_Context pContext);
-M4OSA_ERR M4PTO3GPP_RegisterExternalVideoEncoder(M4PTO3GPP_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface* pEncoderInterface,
- M4OSA_Void* pUserData);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libvideoeditor/vss/inc/M4PTO3GPP_InternalTypes.h b/libvideoeditor/vss/inc/M4PTO3GPP_InternalTypes.h
index a858cb2..e6e830d 100755
--- a/libvideoeditor/vss/inc/M4PTO3GPP_InternalTypes.h
+++ b/libvideoeditor/vss/inc/M4PTO3GPP_InternalTypes.h
@@ -193,13 +193,6 @@ typedef struct
* Audio padding mode */
M4OSA_Bool m_bAudioPaddingSilence; /**< A boolean that signals that audio
AU will be padded by silence */
-
- struct
- {
- M4VE_Interface* pEncoderInterface;
- M4OSA_Void* pUserData;
- M4OSA_Bool registered;
- } registeredExternalEncs[M4VE_kEncoderType_NB];
} M4PTO3GPP_InternalContext;
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_API.h b/libvideoeditor/vss/inc/M4VSS3GPP_API.h
index f6f8daa..a1cf225 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_API.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_API.h
@@ -48,11 +48,6 @@
/**
* Common definitions of video editing components */
#include "M4_VideoEditingCommon.h"
-
-
-#include "M4VD_HW_API.h"
-#include "M4VE_API.h"
-
#include "M4ENCODER_AudioCommon.h"
#include "M4AD_Common.h"
#include "M4DA_Types.h"
@@ -591,54 +586,6 @@ M4OSA_ERR M4VSS3GPP_editCleanUp(M4VSS3GPP_EditContext pContext);
/**
******************************************************************************
- * M4OSA_ERR M4VSS3GPP_editRegisterExternalVideoDecoder(M4VSS3GPP_EditContext pContext,
- * M4VD_VideoType decoderType,
- * M4VD_Interface* pDecoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video decoder
- * @note
- * @param pContext (IN) VSS3GPP context
- * @param decoderType (IN) Type of decoder (MPEG4 ...)
- * @param pDecoderInterface (IN) Decoder interface
- * @param pUserData (IN) Pointer on a user data to give to external decoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for this function
- * to be called
- ******************************************************************************
- */
-M4OSA_ERR M4VSS3GPP_editRegisterExternalVideoDecoder(M4VSS3GPP_EditContext pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface* pDecoderInterface,
- M4OSA_Void* pUserData);
-
-/**
- ******************************************************************************
- *M4OSA_ERR M4VSS3GPP_editRegisterExternalVideoEncoder(M4VSS3GPP_EditContext pContext,
- * M4VE_EncoderType encoderType,
- * M4VE_Interface* pEncoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video encoder
- * @note
- * @param pContext (IN) VSS3GPP context
- * @param encoderType (IN) Type of encoder (MPEG4 ...)
- * @param pEncoderInterface (IN) Encoder interface
- * @param pUserData (IN) Pointer on a user data to give to external encoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for this function
- * to be called
- ******************************************************************************
- */
-M4OSA_ERR M4VSS3GPP_editRegisterExternalVideoEncoder(M4VSS3GPP_EditContext pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface* pEncoderInterface,
- M4OSA_Void* pUserData);
-
-
-
-/**
- ******************************************************************************
******************************************************************************
******************************************************************************
*
@@ -828,33 +775,6 @@ M4OSA_ERR M4VSS3GPP_extractPictureCleanUp(M4VSS3GPP_ExtractPictureContext pConte
/**
******************************************************************************
- * M4OSA_ERR M4VSS3GPP_extractPictureRegisterExternalVideoDecoder(
- * M4VSS3GPP_ExtractPictureContext pContext,
- * M4VD_VideoType decoderType,
- * M4VD_Interface* pDecoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video decoder
- * @note
- * @param pContext (IN) Extract picture context
- * @param decoderType (IN) Type of decoder (MPEG4 ...)
- * @param pDecoderInterface (IN) Decoder interface
- * @param pUserData (IN) Pointer on a user data to give to external decoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: Extract picture is not in an appropriate state for this
- * function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4VSS3GPP_extractPictureRegisterExternalVideoDecoder(\
- M4VSS3GPP_ExtractPictureContext pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface* pDecoderInterface,
- M4OSA_Void* pUserData);
-
-
-
-/**
- ******************************************************************************
******************************************************************************
******************************************************************************
*
@@ -893,66 +813,6 @@ M4OSA_ERR M4VSS3GPP_GetErrorMessage(M4OSA_ERR err, M4OSA_Char* sMessage);
#endif /**< WIN32 */
-
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_editRegisterExternalCodec(
- * M4VSS3GPP_EditContext pContext,
- * M4VSS3GPP_codecType codecType,
- * M4OSA_Context pCodecInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video/Audio codec with VSS3GPP
- * @note This is much different from the other external codec registration API to
- * cope up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @param codecType (IN) Type of codec (MPEG4 ...)
- * @param pCodecInterface (IN) Codec interface
- * @param pUserData (IN) Pointer on a user data to give to external codec
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for this function to be called
- ******************************************************************************
- */
- M4OSA_ERR M4VSS3GPP_editRegisterExternalCodec(M4VSS3GPP_EditContext pContext,
- M4VSS3GPP_codecType codecType,
- M4OSA_Context pCodecInterface,
- M4OSA_Void* pUserData);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_editSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext)
- * @brief Subscribes to previously registered external Video/Audio codec
- * @note This is much different from the other external codec registration API to
- * cope up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for this function to be called
- ******************************************************************************
- */
- M4OSA_ERR M4VSS3GPP_editSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_intSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext,
- * M4OSA_Context pShellCtxt)
- * @brief Subscribes to previously registered external Video/Audio codec
- * @note This is much different from the other external codec registration API to
- * cope up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @param pShellContext (IN) Media Codec shell context
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for this function to be called
- ******************************************************************************
- */
- M4OSA_ERR M4VSS3GPP_intSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext,
- M4OSA_Context pShellCtxt);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_InternalFunctions.h b/libvideoeditor/vss/inc/M4VSS3GPP_InternalFunctions.h
index aeddd97..ea09caa 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_InternalFunctions.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_InternalFunctions.h
@@ -39,10 +39,6 @@
#include "M4READER_Common.h" /**< for M4_AccessUnit definition */
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-#include "M4VD_HW_API.h"
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -607,13 +603,6 @@ M4OSA_ERR M4VSS3GPP_intAudioMixingCompatibility(M4VSS3GPP_InternalAudioMixingCon
*/
M4OSA_Void M4VSS3GPP_intClipDeleteAudioTrack(M4VSS3GPP_ClipContext *pClipCtxt);
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-M4OSA_ERR M4VSS3GPP_intClipRegisterExternalVideoDecoder(M4VSS3GPP_ClipContext *pClipCtxt,
- M4VD_VideoType decoderType,
- M4VD_Interface* pDecoderInterface,
- M4OSA_Void* pUserData);
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
/******************************************************************************
* M4OSA_ERR M4VSS3GPP_intStartAU()
* @brief StartAU writer-like interface used for the VSS 3GPP only
diff --git a/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h b/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
index bf627c7..f01e371 100755
--- a/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
+++ b/libvideoeditor/vss/inc/M4VSS3GPP_InternalTypes.h
@@ -53,10 +53,6 @@
#include "From2iToMono_16.h" /**< Stereo to Mono */
#include "MonoTo2I_16.h" /**< Mono to Stereo */
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-#include "M4VD_HW_API.h"
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -599,19 +595,6 @@ typedef struct
* Interfaces of the used modules */
M4VSS3GPP_MediaAndCodecCtxt ShellAPI; /**< Filesystem and shell reader,
decoder functions */
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
- struct
- {
- M4VD_Interface* pDecoderInterface;
- M4OSA_Void* pUserData;
- M4OSA_Bool registered;
- } registeredExternalDecs[M4VD_kVideoType_NB];
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-#ifdef M4VSS_SUPPORT_OMX_CODECS
- M4OSA_Context m_codecInterface[M4VSS3GPP_kCodecType_NB];
- M4OSA_Context pOMXUserData;
-#endif
M4OSA_Bool bIssecondClip;
M4OSA_UInt8 *pActiveEffectsList1; /**< List of the active effects settings. Array of nbEffects RC */
M4OSA_UInt8 nbActiveEffects1; /**< Numbers of active effects RC */
diff --git a/libvideoeditor/vss/inc/M4xVSS_API.h b/libvideoeditor/vss/inc/M4xVSS_API.h
index d69a17c..a66211b 100755
--- a/libvideoeditor/vss/inc/M4xVSS_API.h
+++ b/libvideoeditor/vss/inc/M4xVSS_API.h
@@ -374,50 +374,6 @@ M4OSA_ERR M4xVSS_CloseCommand(M4OSA_Context pContext);
M4OSA_ERR M4xVSS_CleanUp(M4OSA_Context pContext);
/**
-******************************************************************************
- * M4OSA_ERR M4xVSS_RegisterExternalVideoDecoder(M4OSA_Context pContext,
- * M4VD_VideoType decoderType,
- * M4VD_Interface* pDecoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video decoder
- * @note
- * @param pContext (IN) xVSS context
- * @param decoderType (IN) Type of decoder (MPEG4 ...)
- * @param pDecoderInterface (IN) Decoder interface
- * @param pUserData (IN) Pointer on a user data to give to external decoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: xVSS is not in an appropriate state for this function to be called
-******************************************************************************
-*/
-M4OSA_ERR M4xVSS_RegisterExternalVideoDecoder(M4OSA_Context pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface* pDecoderInterface,
- M4OSA_Void* pUserData);
-
-/**
-******************************************************************************
- * M4OSA_ERR M4xVSS_RegisterExternalVideoEncoder(M4OSA_Context pContext,
- * M4VE_EncoderType encoderType,
- * M4VE_Interface* pEncoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video decoder
- * @note
- * @param pContext (IN) xVSS context
- * @param encoderType (IN) Type of encoder (MPEG4 ...)
- * @param pEncoderInterface (IN) Encoder interface
- * @param pUserData (IN) Pointer on a user data to give to external encoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: xVSS is not in an appropriate state for this function to be called
-******************************************************************************
-*/
-M4OSA_ERR M4xVSS_RegisterExternalVideoEncoder(M4OSA_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface* pEncoderInterface,
- M4OSA_Void* pUserData);
-
-/**
******************************************************************************
* prototype M4xVSS_GetVersion(M4_VersionInfo *pVersion)
* @brief This function get the version of the Video Studio 2.1
diff --git a/libvideoeditor/vss/inc/M4xVSS_Internal.h b/libvideoeditor/vss/inc/M4xVSS_Internal.h
index 0f99632..e999867 100755
--- a/libvideoeditor/vss/inc/M4xVSS_Internal.h
+++ b/libvideoeditor/vss/inc/M4xVSS_Internal.h
@@ -479,20 +479,6 @@ typedef struct {
/*UTF Conversion support*/
M4xVSS_UTFConversionContext UTFConversionContext; /*UTF conversion context structure*/
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
- struct
- {
- M4VD_Interface* pDecoderInterface;
- M4OSA_Void* pUserData;
- M4OSA_Bool registered;
- } registeredExternalDecs[M4VD_kVideoType_NB];
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
- struct
- {
- M4VE_Interface* pEncoderInterface;
- M4OSA_Void* pUserData;
- M4OSA_Bool registered;
- } registeredExternalEncs[M4VE_kEncoderType_NB];
} M4xVSS_Context;
/**
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_API.h b/libvideoeditor/vss/mcs/inc/M4MCS_API.h
index 2592fb4..7fb64e8 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_API.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_API.h
@@ -46,9 +46,6 @@
* Common definitions of video editing components */
#include "M4_VideoEditingCommon.h"
-#include "M4VD_HW_API.h"
-#include "M4VE_API.h"
-
/**
* To enable external audio codecs registering*/
#include "M4AD_Common.h"
@@ -259,27 +256,6 @@ typedef enum
M4MCS_kCropBeforeResize = 0x01 /*Input image is cropped (before changing resolution)*/
} M4MCS_SPCrop ;
-/**
- ******************************************************************************
- * enum M4MCS_ExifInfos
- * @brief Still picture specific : The following structure contains all available exif field
- ******************************************************************************
- */
-typedef struct {
- M4OSA_Char* ImageTitle; /* Image title */
- M4OSA_Char* EquipmentManufacturer; /* Image input equipment manufacturer */
- M4OSA_Char* EquipmentModel; /* Image input equipment model */
- M4OSA_Char* Software; /* Software used */
- M4OSA_Char* Artist; /* Artist */
- M4OSA_Char* Copyright; /* Copyright */
- M4OSA_Char* CreationDateTime; /* Creation date and time */
- M4OSA_UInt32 Orientation; /* Orientation of the picture */
- M4OSA_Char* LastChangeDateTime; /* Last Change date and time*/
- M4OSA_UInt32 PixelXDimension; /* Image width*/
- M4OSA_UInt32 PixelYDimension; /* Image Height*/
-} M4MCS_ExifInfos;
-
-/*--- STILL PICTURE ---*/
/**
******************************************************************************
@@ -590,74 +566,6 @@ M4OSA_ERR M4MCS_getExtendedEncodingParams(M4MCS_Context pContext, M4MCS_Encoding
*/
M4OSA_ERR M4MCS_checkParamsAndStart(M4MCS_Context pContext);
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerExternalVideoDecoder(M4MCS_Context pContext,
- * M4VD_VideoType decoderType,
- * M4VD_Interface* pDecoderInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video decoder
- * @note
- * @param pContext (IN) MCS context
- * @param decoderType (IN) Type of decoder (MPEG4 ...)
- * @param pDecoderInterface (IN) Decoder interface
- * @param pUserData (IN) Pointer on a user data to give to external decoder
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: MCS is not in an appropriate state for this function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_registerExternalVideoDecoder(M4MCS_Context pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface* pDecoderInterface,
- M4OSA_Void* pUserData);
-
-M4OSA_ERR M4MCS_registerExternalVideoEncoder(M4MCS_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface* pEncoderInterface,
- M4OSA_Void* pUserData);
-
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_registerExternalAudioDecoder(M4MCS_Context pContext,
- * M4AD_Type decoderType,
- * M4AD_Interface *pDecoderInterface);
- * @brief This function will register a specific external audio decoder.
- * @note According to the decoderType, this function will store in the internal context
- * the decoder interface.
- * @param context (IN/OUT) MCS context.
- * @param decoderType (IN) Audio decoder type
- * @param pDecoderInterface (IN) Audio decoder interface.
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: A parameter is null, or the decoder type is invalid(in DEBUG only)
- ************************************************************************
- */
-M4OSA_ERR M4MCS_registerExternalAudioDecoder(M4MCS_Context pContext,
- M4AD_Type decoderType,
- M4AD_Interface *pDecoderInterface);
-
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerExternalAudioEncoder(M4MCS_Context pContext,
- * M4ENCODER_AudioFormat mediaType,
- * M4ENCODER_AudioGlobalInterface *pEncGlobalInterface)
- * @brief This function will register a specific external audio encoder.
- * @note According to the Mediatype, this function will store in the internal context
- * the encoder interface.
- * @param pContext: (IN) Execution context.
- * @param mediaType: (IN) The media type.
- * @param pEncGlobalInterface: (OUT) the encoder interface functions.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: pContext or pEncGlobalInterface is M4OSA_NULL (debug only)
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_registerExternalAudioEncoder(M4MCS_Context pContext,
- M4ENCODER_AudioFormat MediaType,
- M4ENCODER_AudioGlobalInterface *pEncGlobalInterface);
-
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index 91e3b96..db6d92f 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -10799,299 +10799,3 @@ M4OSA_ERR M4MCS_open_normalMode(M4MCS_Context pContext, M4OSA_Void* pFileIn,
return M4NO_ERROR;
}
-
-M4OSA_ERR M4MCS_registerExternalVideoDecoder( M4MCS_Context pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface *pDecoderInterface,
- M4OSA_Void *pUserData )
-{
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
- M4OSA_ERR err = M4NO_ERROR;
- M4DECODER_VideoInterface *shellInterface;
- M4DECODER_VideoType nativeType;
- M4DECODER_EXTERNAL_UserDataType shellUserData;
-
- switch( decoderType )
- {
- case M4VD_kMpeg4VideoDec:
- case M4VD_kH263VideoDec:
- nativeType = M4DECODER_kVideoTypeMPEG4;
- break;
-
- case M4VD_kH264VideoDec:
- nativeType = M4DECODER_kVideoTypeAVC;
- break;
-
- default:
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoDecoder: unknown decoderType %d",
- decoderType);
- return M4ERR_PARAMETER;
- break;
- }
-
- shellUserData =
- (M4DECODER_EXTERNAL_UserDataType)M4OSA_32bitAlignedMalloc(sizeof(*shellUserData),
- M4MCS,
- (M4OSA_Char *)"userData structure for the external shell decoder");
-
- if( M4OSA_NULL == shellUserData )
- {
- M4OSA_TRACE1_0(
- "M4MCS_registerExternalVideoDecoder:\
- failed to allocate userData structure for the external shell decoder");
- return M4ERR_ALLOC;
- }
-
- shellUserData->externalFuncs = pDecoderInterface;
- shellUserData->externalUserData = pUserData;
-
- err = M4DECODER_EXTERNAL_getInterface(&shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoDecoder:\
- M4DECODER_EXTERNAL_getInterface failed with error 0x%08X",
- err);
- free(shellUserData);
- return err;
- }
-
- err = M4MCS_registerVideoDecoder(pContext, nativeType, shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoDecoder:\
- M4MCS_registerVideoDecoder failed with error 0x%08X",
- err);
- free(shellInterface);
- free(shellUserData);
- return err;
- }
-
- ( (M4MCS_InternalContext
- *)pContext)->m_pVideoDecoderUserDataTable[nativeType] = shellUserData;
-
- return M4NO_ERROR;
-#else
-
- return M4ERR_NOT_IMPLEMENTED;
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-}
-
-M4OSA_ERR M4MCS_registerExternalVideoEncoder( M4MCS_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface *pEncoderInterface,
- M4OSA_Void *pUserData )
-{
-#ifdef M4VSS_ENABLE_EXTERNAL_ENCODERS
-
- M4OSA_ERR err = M4NO_ERROR;
- M4ENCODER_GlobalInterface *shellInterface;
- M4ENCODER_Format nativeType;
-
- switch( encoderType )
- {
- case M4VE_kH263VideoEnc:
- err = M4EGE_H263_getInterfaces(&nativeType, &shellInterface,
- M4ENCODER_OPEN_ADVANCED);
-
- break;
-
- case M4VE_kMpeg4VideoEnc:
- err = M4EGE_MPEG4_getInterfaces(&nativeType, &shellInterface,
- M4ENCODER_OPEN_ADVANCED);
- break;
-
- case M4VE_kH264VideoEnc:
- M4OSA_TRACE1_0(
- "M4MCS_registerExternalVideoEncoder: H264 encoder type not implemented yet");
- return M4ERR_NOT_IMPLEMENTED;
- break;
-
- default:
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoEncoder: unknown encoderType %d",
- encoderType);
- return M4ERR_PARAMETER;
- break;
- }
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoDecoder: M4EGE_getInterface failed with error 0x%08X",
- err);
- return err;
- }
-
- err = M4MCS_registerVideoEncoder(pContext, nativeType, shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalVideoEncoder:\
- M4MCS_registerVideoEncoder failed with error 0x%08X",
- err);
- free(shellInterface);
- return err;
- }
-
- ( (M4MCS_InternalContext
- *)pContext)->pVideoEncoderExternalAPITable[nativeType]
- = pEncoderInterface;
- ( (M4MCS_InternalContext
- *)pContext)->pVideoEncoderUserDataTable[nativeType] = pUserData;
-
- return M4NO_ERROR;
-
-#else
-
- return M4ERR_NOT_IMPLEMENTED;
-
-#endif
-
-}
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_registerExternalAudioDecoder(M4MCS_Context pContext,
- * M4AD_Type decoderType,
- * M4AD_Interface *pDecoderInterface);
- * @brief This function will register a specific external audio decoder.
- * @note According to the decoderType, this function will store in the internal context the
- * decoder interface.
- * @param context (IN/OUT) MCS context.
- * @param decoderType (IN) Audio decoder type
- * @param pDecoderInterface (IN) Audio decoder interface.
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: A parameter is null, or the decoder type is invalid
- * (in DEBUG only)
- ************************************************************************
- */
-M4OSA_ERR M4MCS_registerExternalAudioDecoder( M4MCS_Context pContext,
- M4AD_Type decoderType,
- M4AD_Interface *pDecoderInterface )
-{
- M4MCS_InternalContext *pC = (M4MCS_InternalContext *)pContext;
-
- M4OSA_DEBUG_IF1((M4OSA_NULL == pC), M4ERR_PARAMETER,
- "M4MCS_registerExternalAudioDecoder: invalid context pointer");
- M4OSA_DEBUG_IF1((M4OSA_NULL == pDecoderInterface), M4ERR_PARAMETER,
- "M4MCS_registerExternalAudioDecoder: invalid pointer on decoder interface");
-
- if( M4MCS_kState_CREATED != pC->State )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalAudioDecoder(): Wrong State (%d), returning M4ERR_STATE",
- pC->State);
- return M4ERR_STATE;
- }
-
- if( decoderType >= M4AD_kType_NB )
- {
- M4OSA_DEBUG_IF1(M4OSA_TRUE, M4ERR_PARAMETER,
- "M4MCS_registerExternalAudioDecoder: Invalid audio decoder type");
- return M4ERR_PARAMETER;
- }
-
- if( pC->m_pAudioDecoderFlagTable[decoderType] == M4OSA_TRUE
- && pC->m_pAudioDecoderItTable[decoderType] != M4OSA_NULL )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalAudioDecoder: error parameter: an external decoder of type\
- %i is already registered",
- decoderType);
- return M4ERR_PARAMETER;
- }
-
- if( pC->m_pAudioDecoderItTable[decoderType] != M4OSA_NULL )
- {
- free(pC->m_pAudioDecoderItTable[decoderType]);
- pC->m_pAudioDecoderItTable[decoderType] = M4OSA_NULL;
- }
-
- pC->m_pAudioDecoderItTable[decoderType] = pDecoderInterface;
- pC->m_pAudioDecoderFlagTable[decoderType] =
- M4OSA_TRUE; /* external decoder */
-
- return M4NO_ERROR;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerExternalAudioEncoder(M4MCS_Context pContext,
- * M4ENCODER_AudioFormat mediaType,
- * M4ENCODER_AudioGlobalInterface *pEncGlobalInterface)
- * @brief This function will register a specific external audio encoder.
- * @note According to the Mediatype, this function will store in the internal context the
- * encoder context.
- * @param pContext: (IN) Execution context.
- * @param mediaType: (IN) The media type.
- * @param pEncGlobalInterface: (OUT) the encoder interface functions.
- * @return M4NO_ERROR: there is no error
- * @return M4ERR_PARAMETER: pContext or pEncGlobalInterface is M4OSA_NULL (debug only)
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_registerExternalAudioEncoder( M4MCS_Context pContext,
- M4ENCODER_AudioFormat MediaType,
- M4ENCODER_AudioGlobalInterface *pEncGlobalInterface )
-{
- M4MCS_InternalContext *pC = (M4MCS_InternalContext *)pContext;
-
- /**
- * Check input parameters */
- M4OSA_DEBUG_IF2((pC == M4OSA_NULL), M4ERR_PARAMETER,
- "MCS: context is M4OSA_NULL in M4MCS_registerExternalAudioEncoder");
- M4OSA_DEBUG_IF2((pEncGlobalInterface == M4OSA_NULL), M4ERR_PARAMETER,
- "pEncGlobalInterface is M4OSA_NULL in M4MCS_registerExternalAudioEncoder");
-
- M4OSA_TRACE3_2(
- "MCS: M4MCS_registerExternalAudioEncoder called with pContext=0x%x, \
- pEncGlobalInterface=0x%x",
- pC, pEncGlobalInterface);
-
- if( M4MCS_kState_CREATED != pC->State )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalAudioEncoder(): Wrong State (%d), returning M4ERR_STATE",
- pC->State);
- return M4ERR_STATE;
- }
-
- if( MediaType >= M4ENCODER_kAudio_NB )
- {
- M4OSA_DEBUG_IF1(M4OSA_TRUE, M4ERR_PARAMETER,
- "M4MCS_registerExternalAudioEncoder(): Invalid audio encoder type");
- return M4ERR_PARAMETER;
- }
-
- if( pC->pAudioEncoderFlag[MediaType] == M4OSA_TRUE
- && pC->pAudioEncoderInterface[MediaType] != M4OSA_NULL )
- {
- M4OSA_TRACE1_1(
- "M4MCS_registerExternalAudioEncoder: error parameter:\
- an external encoder of type %i is already registered",
- MediaType);
- return M4ERR_PARAMETER;
- }
-
- if( pC->pAudioEncoderInterface[MediaType] != M4OSA_NULL )
- {
- free(pC->pAudioEncoderInterface[MediaType]);
- pC->pAudioEncoderInterface[MediaType] = M4OSA_NULL;
- }
-
- /*
- * Save encoder interface in context */
- pC->pAudioEncoderInterface[MediaType] = pEncGlobalInterface;
- pC->pAudioEncoderFlag[MediaType] = M4OSA_TRUE; /* external encoder */
-
- return M4NO_ERROR;
-}
-
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c b/libvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c
deleted file mode 100755
index 8c05191..0000000
--- a/libvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *************************************************************************
- * @file M4MCS_Parsing.c
- * @brief MCS implementation (Video Compressor Service)
- * @note This file implements the VOL parsing and timescale 'on the fly' modification
- *************************************************************************
- **/
-
-/**
- ********************************************************************
- * Includes
- ********************************************************************
- */
-
-/* Core headers */
-#include "M4MCS_API.h"
-#include "M4MCS_InternalTypes.h"
-#include "M4VD_Tools.h"
-
-
-#ifdef TIMESCALE_BUG
-
-/*typedef struct
-{
- M4OSA_UInt32 stream_byte;
- M4OSA_UInt32 stream_index;
- M4OSA_MemAddr8 in;
-
-} M4MCS_Bitstream_ctxt;*/
-typedef M4VS_Bitstream_ctxt M4MCS_Bitstream_ctxt;
-
-/*
- ************************************************************************
- * M4OSA_UInt32 M4MCS_GetBitsFromMemory( )
- * @brief
- * @return
- ************************************************************************
- */
-static M4OSA_UInt32 M4MCS_GetBitsFromMemory(
- M4MCS_Bitstream_ctxt* parsingCtxt,
- M4OSA_UInt32 nb_bits)
-{
- return(M4VD_Tools_GetBitsFromMemory((M4VS_Bitstream_ctxt*) parsingCtxt, nb_bits));
-}
-
-/**
- ***********************************************************************
- * M4OSA_ERR M4MCS_WriteBitsToMemory( )
- * @brief
- * @return
- ***********************************************************************
- */
-static M4OSA_ERR M4MCS_WriteBitsToMemory( M4OSA_UInt32 bitsToWrite,
- M4OSA_MemAddr32 dest_bits,
- M4OSA_UInt8 offset,
- M4OSA_UInt8 nb_bits)
-{
- return (M4VD_Tools_WriteBitsToMemory(bitsToWrite,
- dest_bits,
- offset, nb_bits));
-}
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_WriteByteToMemory( )
- * @brief
- * @return
- ************************************************************************
- */
-static M4OSA_ERR M4MCS_WriteByteToMemory( M4OSA_UInt8 BytesToWrite,
- M4OSA_MemAddr8 dest_bytes)
-{
- M4OSA_MemAddr8 addr = dest_bytes;
-
- *addr = BytesToWrite;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * M4OSA_Void M4MCS_intCheckIndex( )
- * @brief :
- * @note : This function can be used to write until 15 bits ...
- * Depending on the bits offset, it increases or not the 8 bits pointer.
- * It must be called if more than 8 bits have to be written not consequently.
- * @return
- ************************************************************************
- */
-static M4OSA_Void M4MCS_intCheckIndex( M4OSA_UInt8 *index,
- M4OSA_UInt32 a,
- M4OSA_MemAddr8* in)
-{
- M4OSA_UInt32 offset = a;
-
- if(offset > 8 && offset <=16)
- {
- offset-=8;
- (*in)++;
- }
- if((*index+offset) >= 8)
- {
- *index = (*index+offset)-8;
- (*in)++;
- }
- else
- {
- *index += offset;
- }
-}
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_intParseVideoDSI( )
- * @brief : This function parses video DSI and changes writer vop time increment resolution
- * @note : It also calculates the number of bits on which the vop_time_increment is coded in
- * the input stream
- * @return
- ************************************************************************
- */
-M4OSA_ERR M4MCS_intParseVideoDSI(M4MCS_InternalContext* pC)
-{
- M4MCS_Bitstream_ctxt parsingCtxt;
- M4OSA_UInt32 code,j;
- M4OSA_MemAddr8 start, in;
- M4OSA_UInt8 i;
- M4OSA_UInt32 time_incr_length, new_time_incr_length;
- M4OSA_UInt8 vol_verid=0, b_hierarchy_type;
-
- /* Fill default values */
- pC->volParsing.video_object_layer_shape = 0;
- pC->volParsing.sprite_enable = 0;
- pC->volParsing.reduced_resolution_vop_enable = 0;
- pC->volParsing.scalability = 0;
- pC->volParsing.enhancement_type = 0;
- pC->volParsing.complexity_estimation_disable = 0;
- pC->volParsing.interlaced = 0;
- pC->volParsing.sprite_warping_points = 0;
- pC->volParsing.sprite_brightness_change = 0;
- pC->volParsing.quant_precision = 5;
-
- parsingCtxt.stream_byte = 0;
- parsingCtxt.stream_index = 8;
- parsingCtxt.in = pC->WriterVideoStreamInfo.Header.pBuf;
-
- start = pC->WriterVideoStreamInfo.Header.pBuf;
-
- while (parsingCtxt.in - start\
- < pC->pReaderVideoStream->m_basicProperties.m_decoderSpecificInfoSize)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if (code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if (code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if (code == 1)
- {
- /* start code found */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if(code == 0xB5) /* Visual object start code */
- {
- /* is object layer identifier */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code == 1)
- {
- /* visual object verid */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 4);
- vol_verid = code;
- /* visual object layer priority */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3);
- }
- else
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 7); /* Realign on byte */
- vol_verid = 1;
- }
- }
- else if ((code > 0x1F) && (code < 0x30))
- { /* find vol start code */
- /* random accessible vol */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
-
- /* video object type indication */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
-
- /* is object layer identifier */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code == 1)
- {
- /* video object layer verid */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 4);
- vol_verid = code;
- /* video object layer priority */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3);
- }
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 4);/* aspect ratio */
- if (code == 15)
- /* par_width and par_height (8+8) */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 16);
- /* vol control parameters */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code == 1)
- {
- /* chroma format + low delay (3+1) */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3);
- /* vbv parameters */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code == 1)
- {
- /* first and latter half bitrate + 2 marker bits
- (15 + 1 + 15 + 1)*/
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 32);
-
- /* first and latter half vbv buffer size + first half
- vbv occupancy
- + marker bits (15+1+3+11+1)*/
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 31);
-
- /* first half vbv occupancy + marker bits (15+1)*/
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 16);
- }
- }
- /* video object layer shape */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 2);
-
- /* Need to save it for vop parsing */
- pC->volParsing.video_object_layer_shape = code;
-
- if (code != 0) return 0; /* only rectangular case supported */
- /* Marker bit */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- /* VOP time increment resolution */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 16);
-
- /* Computes time increment length */
- j = code - 1;
- for (i = 0; (i < 32) && (j != 0); j >>=1)
- {
- i++;
- }
- time_incr_length = (i == 0) ? 1 : i;
- /* Save time increment length and original timescale */
- pC->uiOrigTimescaleLength = time_incr_length;
- pC->uiOrigVideoTimescale = code;
-
- /* Compute new time increment length */
- j = pC->uiVideoTimescale - 1;
- for (i = 0; (i < 32) && (j != 0); j >>=1)
- {
- i++;
- }
- time_incr_length = (i == 0) ? 1 : i;
- /* Save new time increment length */
- pC->uiTimescaleLength = time_incr_length;
-
- /* Write new VOP time increment resolution */
- if(parsingCtxt.stream_index == 0)
- {
- in = parsingCtxt.in - 2;
- }
- else
- {
- in = parsingCtxt.in - 3;
- }
- M4MCS_WriteByteToMemory(pC->uiVideoTimescale, in,
- parsingCtxt.stream_index, 16 );
-
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* Marker bit */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* Fixed VOP rate */
- if (code == 1)
- {
- /* Fixed VOP time increment resolution */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- time_incr_length);
- }
-
- if(pC->volParsing.video_object_layer_shape != 1) /* 1 = Binary */
- {
- if(pC->volParsing.video_object_layer_shape == 0) /* 0 = rectangular */
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* Marker bit */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13);/* Width */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* Marker bit */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13);/* Height */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* Marker bit */
- }
- }
-
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* interlaced */
- pC->volParsing.interlaced = code;
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* OBMC disable */
-
- if(vol_verid == 1)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* sprite enable */
- pC->volParsing.sprite_enable = code;
- }
- else
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 2);/* sprite enable */
- pC->volParsing.sprite_enable = code;
- }
- if ((pC->volParsing.sprite_enable == 1) ||
- (pC->volParsing.sprite_enable == 2))
- /* Sprite static = 1 and Sprite GMC = 2 */
- {
- if (pC->volParsing.sprite_enable != 2)
- {
- /* sprite width */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 13);
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* Marker bit */
- /* sprite height */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 13);
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* Marker bit */
- /* sprite l coordinate */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 13);
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* Marker bit */
- /* sprite top coordinate */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 13);
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* Marker bit */
- }
- /* sprite warping points */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 6);
- pC->volParsing.sprite_warping_points = code;
- /* sprite warping accuracy */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 2);
-
- /* sprite brightness change */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- pC->volParsing.sprite_brightness_change = code;
- if (pC->volParsing.sprite_enable != 2)
- {
- /* low latency sprite enable */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- }
- }
- if ((vol_verid != 1) && (pC->volParsing.video_object_layer_shape != 0))
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* sadct disable */
- }
-
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1); /* not 8 bits */
- if (code)
- { /* quant precision */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 4);
- pC->volParsing.quant_precision = code;
- /* bits per pixel */
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 4);
- }
-
- /* greyscale not supported */
- if(pC->volParsing.video_object_layer_shape == 3)
- {
- /* nogray quant update + composition method + linear composition */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3);
- }
-
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* quant type */
- if (code)
- {
- /* load intra quant mat */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 8);
- i = 1;
- while (i < 64)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 8);
- if (code == 0)
- break;
- i++;
- }
- }
- /* load non intra quant mat */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if (code)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 8);
- i = 1;
- while (i < 64)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 8);
- if (code == 0)
- break;
- i++;
- }
- }
- }
-
- if (vol_verid != 1)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* quarter sample */
- }
- /* complexity estimation disable */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- pC->volParsing.complexity_estimation_disable = code;
- if (!code)
- {
- return M4ERR_NOT_IMPLEMENTED;
- }
-
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* resync marker disable*/
-
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* data partitionned */
- if (code)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);/* reversible VLC */
- }
-
- if (vol_verid != 1)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* newpred */
- if (code)
- {
- return M4ERR_PARAMETER;
- }
- /* reduced resolution vop enable */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- pC->volParsing.reduced_resolution_vop_enable = code;
- }
-
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* scalability */
- pC->volParsing.scalability = code;
- if (code)
- {
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 1);/* hierarchy type */
- b_hierarchy_type = code;
- code = M4MCS_GetBitsFromMemory(
- &parsingCtxt, 4);/* ref layer id */
-
- /* ref sampling direct */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
-
- /* hor sampling factor N */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
-
- /* hor sampling factor M */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
-
- /* vert sampling factor N */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
-
- /* vert sampling factor M */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
-
- /* enhancement type */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- pC->volParsing.enhancement_type = code;
- if ((!b_hierarchy_type) &&
- (pC->volParsing.video_object_layer_shape == 1))
- {
- /* use ref shape */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- /* use ref texture */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- /* shape hor sampling factor N */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
- /* shape hor sampling factor M */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
- /* shape vert sampling factor N */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
- /* shape vert sampling factor M */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 5);
- }
- }
- break;
- }
- }
- else
- {
- if ((code >> 2) == 0x20)
- {
- /* H263 ...-> wrong*/
- break;
- }
- }
- }
- }
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_intChangeAUVideoTimescale( )
- * @brief
- * @return
- ************************************************************************
- */
-M4OSA_ERR M4MCS_intChangeAUVideoTimescale(M4MCS_InternalContext* pC)
-{
- M4MCS_Bitstream_ctxt parsingCtxt;
- M4OSA_UInt32 code;
- M4OSA_MemAddr8 start, in;
- M4OSA_MemAddr32 in_temp;
- M4OSA_UInt8 i, in_index=0; /* in_index is the bit index in the input buffer */
- M4OSA_UInt32 new_time_incr;
- M4OSA_Int32 diff_timescale= 0 ;
- M4OSA_UInt32 stuffing_byte=0;
- M4OSA_UInt8 vopCodingType, vop_fcode_forward, vop_fcode_backward, nb_zeros;
-
- parsingCtxt.stream_byte = 0;
- parsingCtxt.stream_index = 8;
- parsingCtxt.in = pC->ReaderVideoAU.m_dataAddress;
-
- start = pC->ReaderVideoAU.m_dataAddress;
- in = pC->WriterVideoAU.dataAddress;
-
- memset((void *)in, 0, pC->ReaderVideoAU.m_size);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, 0, 8);
- in++;
- if (code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, 0, 8);
- in++;
- if (code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, 0, 8);
- in++;
- if (code == 1)
- {
- /* start code found */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, 0, 8);
- in++;
- if (code == 0xB6)
- { /* find vop start code */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 2); /* VOP coding type */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 2);
- M4MCS_intCheckIndex(&in_index,2,&in);
- vopCodingType = code; /* Save it before needed further in parsing */
- do
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Modulo time base */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- } while(code != 0);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- pC->uiOrigTimescaleLength);
- /* VOP time increment */
-
- /* Calculates new time increment and write it to AU */
- new_time_incr = (pC->uiVideoTimescale * code) /
- pC->uiOrigVideoTimescale;
- M4MCS_WriteByteToMemory(new_time_incr, in,
- in_index, pC->uiTimescaleLength );
- M4MCS_intCheckIndex(&in_index,pC->uiTimescaleLength,
- &in);
-
- /* VOP not coded */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* VOP not coded bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- if(code == 1)
- {
- //break; /* TODO !!! -> Goto stuffing */
- }
- /* newpred ignored */
-
- if((pC->volParsing.video_object_layer_shape != 2) &&
- (vopCodingType == 1 || vopCodingType == 3 &&
- pC->volParsing.sprite_enable == 2))
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* VOP rounding type */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- }
-
- if(pC->volParsing.reduced_resolution_vop_enable &&
- pC->volParsing.video_object_layer_shape == 0 &&
- (vopCodingType == 0 || vopCodingType == 1))
- {
- /* VOP reduced resolution */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- }
-
- if(pC->volParsing.video_object_layer_shape != 0)
- {
- if(pC->volParsing.sprite_enable == 1 &&
- vopCodingType == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13); /* VOP width */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 13);
- M4MCS_intCheckIndex(&in_index,13,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13); /* VOP height */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 13);
- M4MCS_intCheckIndex(&in_index,13,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13); /* VOP horizontal
- mc spatial ref */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 13);
- M4MCS_intCheckIndex(&in_index,13,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 13); /* VOP vertical
- mc spatial ref */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 13);
- M4MCS_intCheckIndex(&in_index,13,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* Marker bit */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- }
- if(pC->volParsing.video_object_layer_shape != 1 &&
- pC->volParsing.scalability &&
- pC->volParsing.enhancement_type)
- {
- /* Background composition */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
-
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- }
- /* Change conv ratio disable */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
-
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* VOP constant alpha */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- if(code)
- {
- /* VOP constant alpha value */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
-
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- }
- }
-
- if(pC->volParsing.video_object_layer_shape != 2)
- {
- if(!pC->volParsing.complexity_estimation_disable)
- {
- return M4ERR_NOT_IMPLEMENTED;
- }
- }
-
- if(pC->volParsing.video_object_layer_shape != 2)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3); /* intra dc vlc thr */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 3);
- M4MCS_intCheckIndex(&in_index,3,&in);
- if(pC->volParsing.interlaced)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* top field first */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1); /* alternate vertical
- scan flag */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- }
- }
-
- if((pC->volParsing.sprite_enable == 1 || pC->volParsing.sprite_enable == 2) &&
- vopCodingType == 3)
- {
- if(pC->volParsing.sprite_warping_points > 0 ||
- (pC->volParsing.sprite_brightness_change))
- {
- return M4ERR_NOT_IMPLEMENTED;
- }
- if(pC->volParsing.sprite_enable == 1)
- {
- return M4ERR_NOT_IMPLEMENTED;
- }
- }
-
- if(pC->volParsing.video_object_layer_shape != 2)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- pC->volParsing.quant_precision); /* vop_quant */
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index,
- pC->volParsing.quant_precision);
- M4MCS_intCheckIndex(&in_index,pC->volParsing.quant_precision,&in);
- if(pC->volParsing.video_object_layer_shape == 3)
- {
- return M4ERR_NOT_IMPLEMENTED;
- }
- if(vopCodingType != 0) /* P-VOP or S-VOP or B-VOP case */
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3); /* vop fcode forward*/
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 3);
- M4MCS_intCheckIndex(&in_index,3,&in);
- vop_fcode_forward = code;
- }
- if(vopCodingType == 2) /* B-VOP */
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 3); /* vop fcode forward*/
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 3);
- M4MCS_intCheckIndex(&in_index,3,&in);
- vop_fcode_backward = code;
- }
-
- }
-
-#if 1
- /* Align on read */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8-(parsingCtxt.stream_index));
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 8-(parsingCtxt.stream_index));
- M4MCS_intCheckIndex(&in_index,8-(parsingCtxt.stream_index),&in);
-
- do
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if(code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- if(code == 0)
- {
- nb_zeros = 0;
- if((vopCodingType == 1 || vopCodingType == 3)
- && vop_fcode_forward > 1) /* P-VOP or S-VOP case */
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- vop_fcode_forward-1);
- nb_zeros = vop_fcode_forward-1;
- }
- else if(vopCodingType == 2 && (vop_fcode_forward > 1 ||
- vop_fcode_backward > 1)) /* B-VOP case */
- {
- if(vop_fcode_forward > vop_fcode_backward)
- {
- if(15+vop_fcode_forward > 17)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- vop_fcode_forward-1);
- }
- else
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- }
- nb_zeros = vop_fcode_forward-1;
- }
- else
- {
- if(15+vop_fcode_backward > 17)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- vop_fcode_backward-1);
- }
- else
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- }
- nb_zeros = vop_fcode_backward-1;
- }
- if(code == 0)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if(code != 1)
- {
- M4MCS_WriteByteToMemory(0, (M4OSA_MemAddr32)in,
- in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- M4MCS_WriteByteToMemory(0, (M4OSA_MemAddr32)in,
- in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
- goto realign;
- }
- else
- {
- M4MCS_intChangeVideoPacketVideoTimescale(pC );
- }
- }
- else
- {
-
- goto realign;
- }
- }
- else /* I-VOP case or P-VOP or S-VOP case with
- vop_fcode_forward = 1 */
- {
- /* Read next bit that must be one */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 1);
- if(code != 1)
- {
- goto realign;
- }
- else
- {
- /* Realign on byte */
-
- /* Write resync marker */
- M4MCS_WriteByteToMemory(0, (M4OSA_MemAddr32)in,
- in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- M4MCS_WriteByteToMemory(0, (M4OSA_MemAddr32)in,
- in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in,
- in_index, 1);
- M4MCS_intCheckIndex(&in_index,1,&in);
-
- /* Change timescale into video packet header */
- M4MCS_intChangeVideoPacketVideoTimescale(pC );
- }
-
- }
- }
- else
- {
- M4MCS_WriteByteToMemory(0, (M4OSA_MemAddr32)in, in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
-realign:
- /* Realign on read */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt,
- 8-(parsingCtxt.stream_index));
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index,
- 8-(parsingCtxt.stream_index));
- M4MCS_intCheckIndex(&in_index,8-(parsingCtxt.stream_index),&in);
- }
- }
- else
- {
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 8);
- M4MCS_intCheckIndex(&in_index,8,&in);
- }
- } while(parsingCtxt.in - pC->ReaderVideoAU.m_dataAddress\
- < pC->ReaderVideoAU.m_size);
-#else
- /* Align on write */
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8-in_index);
- M4MCS_WriteByteToMemory(code, (M4OSA_MemAddr32)in, in_index, 8-in_index);
- M4MCS_intCheckIndex(&in_index,8-in_index,&in);
-
- /* Read 8 bits words, and write them to the output AU
- (write is 8 bits aligned) */
- diff_timescale = pC->uiOrigTimescaleLength - pC->uiTimescaleLength;
- if(diff_timescale > 0)
- {
- while (parsingCtxt.in - start <= pC->ReaderVideoAU.m_size)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- //WritebyteToMemory(code, in);
- *in = code;
- in++;
- }
- }
- else
- {
- while (parsingCtxt.in - start < pC->ReaderVideoAU.m_size)
- {
- code = M4MCS_GetBitsFromMemory(&parsingCtxt, 8);
- //WritebyteToMemory(code, in);
- *in = code;
- in++;
- }
- }
-#endif
- in--;
-
- for(i=0;i<parsingCtxt.stream_index;i++)
- {
- stuffing_byte = stuffing_byte << 1;
- stuffing_byte += 1;
- }
- M4MCS_WriteByteToMemory(stuffing_byte, (M4OSA_MemAddr32)in,
- 8-parsingCtxt.stream_index, parsingCtxt.stream_index);
- pC->WriterVideoAU.size = in + 1 - pC->WriterVideoAU.dataAddress;
- //*in ;
- }
- }
- }
- }
-
- return M4NO_ERROR;
-}
-
-#endif /* TIMESCALE_BUG */
-
diff --git a/libvideoeditor/vss/src/Android.mk b/libvideoeditor/vss/src/Android.mk
index 55a000d..c6fc64a 100755
--- a/libvideoeditor/vss/src/Android.mk
+++ b/libvideoeditor/vss/src/Android.mk
@@ -40,7 +40,6 @@ LOCAL_SRC_FILES:= \
M4VSS3GPP_MediaAndCodecSubscription.c \
M4ChannelCoverter.c \
M4VD_EXTERNAL_BitstreamParser.c \
- M4VD_EXTERNAL_Interface.c \
M4AIR_API.c \
M4READER_Pcm.c \
M4PCMR_CoreReader.c \
diff --git a/libvideoeditor/vss/src/M4ChannelCoverter.c b/libvideoeditor/vss/src/M4ChannelCoverter.c
index eee62d8..5d89820 100755
--- a/libvideoeditor/vss/src/M4ChannelCoverter.c
+++ b/libvideoeditor/vss/src/M4ChannelCoverter.c
@@ -44,7 +44,7 @@ void From2iToMono_16( const short *src,
{
short ii;
long Temp;
- for (ii = n; ii != 0; ii--) {
+ for (ii = n; ii != 0; ii--){
Temp = (long)*(src++);
Temp += (long)*(src++);
*(dst++) = (short)(Temp >>1);
diff --git a/libvideoeditor/vss/src/M4PTO3GPP_API.c b/libvideoeditor/vss/src/M4PTO3GPP_API.c
index e3fe84f..2ce22f6 100755
--- a/libvideoeditor/vss/src/M4PTO3GPP_API.c
+++ b/libvideoeditor/vss/src/M4PTO3GPP_API.c
@@ -242,13 +242,6 @@ M4OSA_ERR M4PTO3GPP_Init( M4PTO3GPP_Context* pContext,
pC->pSavedPlane = M4OSA_NULL;
pC->uiSavedDuration = 0;
- for (i=0; i<M4VE_kEncoderType_NB; i++)
- {
- pC->registeredExternalEncs[i].pEncoderInterface = M4OSA_NULL;
- pC->registeredExternalEncs[i].pUserData = M4OSA_NULL;
- pC->registeredExternalEncs[i].registered = M4OSA_FALSE;
- }
-
M4OSA_TRACE3_0("M4PTO3GPP_Init(): returning M4NO_ERROR");
return M4NO_ERROR;
}
@@ -265,7 +258,7 @@ M4OSA_ERR M4PTO3GPP_Init( M4PTO3GPP_Context* pContext,
* @return M4NO_ERROR: No error
* @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL
* @return M4ERR_STATE: M4PTO3GPP is not in an appropriate state for this function to be
- called
+ called
* @return M4ERR_ALLOC: There is no more available memory
* @return ERR_PTO3GPP_INVALID_VIDEO_FRAME_SIZE_FOR_H263 The output video frame
* size parameter is incompatible with H263 encoding
@@ -317,7 +310,7 @@ M4OSA_ERR M4PTO3GPP_Open(M4PTO3GPP_Context pContext, M4PTO3GPP_Params* pParams)
/**
* Video Format */
- if ((M4VIDEOEDITING_kH263 != pParams->OutputVideoFormat) &&
+ if( (M4VIDEOEDITING_kH263 != pParams->OutputVideoFormat) &&
(M4VIDEOEDITING_kMPEG4 != pParams->OutputVideoFormat) &&
(M4VIDEOEDITING_kMPEG4_EMP != pParams->OutputVideoFormat) &&
(M4VIDEOEDITING_kH264 != pParams->OutputVideoFormat))
@@ -328,7 +321,7 @@ M4OSA_ERR M4PTO3GPP_Open(M4PTO3GPP_Context pContext, M4PTO3GPP_Params* pParams)
/**
* Video Bitrate */
- if (!((M4VIDEOEDITING_k16_KBPS == pParams->OutputVideoBitrate) ||
+ if(!((M4VIDEOEDITING_k16_KBPS == pParams->OutputVideoBitrate) ||
(M4VIDEOEDITING_k24_KBPS == pParams->OutputVideoBitrate) ||
(M4VIDEOEDITING_k32_KBPS == pParams->OutputVideoBitrate) ||
(M4VIDEOEDITING_k48_KBPS == pParams->OutputVideoBitrate) ||
@@ -1263,23 +1256,6 @@ M4OSA_ERR M4PTO3GPP_Ready4Processing(M4PTO3GPP_InternalContext* pC)
{
case M4VIDEOEDITING_kMPEG4_EMP: bActivateEmp = M4OSA_TRUE; /* no break */
case M4VIDEOEDITING_kMPEG4:
- if (pC->registeredExternalEncs[M4VE_kMpeg4VideoEnc].registered)
- {
-#ifdef M4VSS_ENABLE_EXTERNAL_ENCODERS
- pC->m_pEncoderExternalAPI = pC->registeredExternalEncs[M4VE_kMpeg4VideoEnc]
- .pEncoderInterface;
- pC->m_pEncoderUserData = pC->registeredExternalEncs[M4VE_kMpeg4VideoEnc].pUserData;
-
- err = M4EGE_MPEG4_getInterfaces(&encFormat, &pC->m_pEncoderInt,
- M4ENCODER_OPEN_ADVANCED);
-#else
- M4OSA_TRACE1_0("No external MPEG4 encoder available!\
- Did you forget to register one?");
- err = M4ERR_STATE;
-#endif
- }
- else
- {
#ifdef M4VSS_SUPPORT_ENCODER_MPEG4
err = VideoEditorVideoEncoder_getInterface_MPEG4(&encFormat, &pC->m_pEncoderInt,
M4ENCODER_OPEN_ADVANCED);
@@ -1287,26 +1263,8 @@ M4OSA_ERR M4PTO3GPP_Ready4Processing(M4PTO3GPP_InternalContext* pC)
M4OSA_TRACE1_0("No MPEG4 encoder available! Did you forget to register one?");
err = M4ERR_STATE;
#endif /* software MPEG4 encoder available? */
- }
break;
case M4VIDEOEDITING_kH263:
- if (pC->registeredExternalEncs[M4VE_kH263VideoEnc].registered)
- {
-#ifdef M4VSS_ENABLE_EXTERNAL_ENCODERS
- pC->m_pEncoderExternalAPI = pC->registeredExternalEncs[M4VE_kH263VideoEnc]
- .pEncoderInterface;
- pC->m_pEncoderUserData = pC->registeredExternalEncs[M4VE_kH263VideoEnc].pUserData;
-
- err = M4EGE_H263_getInterfaces(&encFormat, &pC->m_pEncoderInt,
- M4ENCODER_OPEN_ADVANCED);
-#else
- M4OSA_TRACE1_0("No external H263 encoder available! Did you forget to register\
- one?");
- err = M4ERR_STATE;
-#endif
- }
- else
- {
#ifdef M4VSS_SUPPORT_ENCODER_MPEG4
err = VideoEditorVideoEncoder_getInterface_H263(&encFormat, &pC->m_pEncoderInt,
M4ENCODER_OPEN_ADVANCED);
@@ -1314,17 +1272,8 @@ M4OSA_ERR M4PTO3GPP_Ready4Processing(M4PTO3GPP_InternalContext* pC)
M4OSA_TRACE1_0("No H263 encoder available! Did you forget to register one?");
err = M4ERR_STATE;
#endif /* software H263 encoder available? */
- }
break;
case M4VIDEOEDITING_kH264:
- if (pC->registeredExternalEncs[M4VE_kH264VideoEnc].registered)
- {
- M4OSA_TRACE1_0("M4PTO3GPP_Ready4Processing: No external H264 encoder available! \
- Did you forget to register one?");
- err = M4ERR_STATE;
- }
- else
- {
#ifdef M4VSS_SUPPORT_ENCODER_AVC
err = VideoEditorVideoEncoder_getInterface_H264(&encFormat, &pC->m_pEncoderInt,
M4ENCODER_OPEN_ADVANCED);
@@ -1333,7 +1282,6 @@ M4OSA_ERR M4PTO3GPP_Ready4Processing(M4PTO3GPP_InternalContext* pC)
Did you forget to register one?");
err = M4ERR_STATE;
#endif /* software H264 encoder available? */
- }
break;
default:
M4OSA_TRACE1_1("M4PTO3GPP_Ready4Processing: unknown format 0x%x returning \
@@ -2020,41 +1968,3 @@ static M4OSA_ERR M4PTO3GPP_writeAmrSilence048Frame(M4WRITER_DataInterface* pWrit
}
-M4OSA_ERR M4PTO3GPP_RegisterExternalVideoEncoder(M4PTO3GPP_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface* pEncoderInterface,
- M4OSA_Void* pUserData)
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4PTO3GPP_InternalContext *pC = (M4PTO3GPP_InternalContext*)(pContext);
-
- switch (encoderType)
- {
- case M4VE_kMpeg4VideoEnc:
- case M4VE_kH263VideoEnc:
- /* OK */
- break;
-
- case M4VE_kH264VideoEnc:
- M4OSA_TRACE1_0("M4PTO3GPP_RegisterExternalVideoEncoder: \
- H264 encoder type not implemented yet");
- return M4ERR_NOT_IMPLEMENTED;
- break;
-
- default:
- M4OSA_TRACE1_1("M4PTO3GPP_RegisterExternalVideoEncoder:\
- unknown encoderType %d", encoderType);
- return M4ERR_PARAMETER;
- break;
- }
-
- pC->registeredExternalEncs[encoderType].pEncoderInterface = pEncoderInterface;
- pC->registeredExternalEncs[encoderType].pUserData = pUserData;
- pC->registeredExternalEncs[encoderType].registered = M4OSA_TRUE;
-
- /* Notice it overwrites any HW encoder that may already have been registered for this type;
- this is normal. */
-
- return M4NO_ERROR;
-}
-
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
index b2e8e6f..c8a8aca 100755
--- a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
+++ b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
@@ -19,7 +19,6 @@
#include "M4OSA_Debug.h"
#include "M4VD_EXTERNAL_Interface.h"
-#include "M4VD_EXTERNAL_Internal.h"
#include "M4VD_Tools.h"
/**
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c
deleted file mode 100755
index 8258eca..0000000
--- a/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- * Copyright (C) 2004-2011 NXP Software
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- ******************************************************************************
- * @file M4VD_EXTERNAL_Interface.c
- * @brief
- * @note
- ******************************************************************************
- */
-
-#include "NXPSW_CompilerSwitches.h"
-
-#include "M4OSA_CoreID.h"
-#include "M4OSA_Types.h"
-#include "M4OSA_Debug.h"
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
-#include "M4OSA_Semaphore.h"
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
-#include "M4VD_EXTERNAL_Interface.h"
-#include "M4VD_EXTERNAL_Internal.h"
-
-/* Warning: the decode thread has finished decoding all the frames */
-#define M4WAR_DECODE_FINISHED M4OSA_ERR_CREATE(M4_WAR,\
- M4DECODER_EXTERNAL, 0x0001)
-/* Warning: the render thread has finished rendering the frame */
-#define M4WAR_RENDER_FINISHED M4OSA_ERR_CREATE(M4_WAR,\
- M4DECODER_EXTERNAL, 0x0002)
-
-#define M4ERR_CHECK(x) if(M4NO_ERROR!=x) return x;
-#define M4ERR_EXIT(x) do { err = x; goto exit_with_error; } while(0)
-
-
-/* ----- shell API ----- */
-
-static M4OSA_ERR M4DECODER_EXTERNAL_create(M4OSA_Context *pVS_Context,
- M4_StreamHandler *pStreamHandler,
- M4READER_DataInterface *pReaderDataInterface,
- M4_AccessUnit* pAccessUnit, M4OSA_Void* pUserData);
-static M4OSA_ERR M4DECODER_EXTERNAL_destroy(M4OSA_Context pVS_Context);
-static M4OSA_ERR M4DECODER_EXTERNAL_getOption(M4OSA_Context pVS_Context, M4OSA_OptionID optionId,
- M4OSA_DataOption* pValue);
-static M4OSA_ERR M4DECODER_EXTERNAL_setOption(M4OSA_Context pVS_Context, M4OSA_OptionID optionId,
- M4OSA_DataOption pValue);
-static M4OSA_ERR M4DECODER_EXTERNAL_decode(M4OSA_Context pVS_Context, M4_MediaTime* pTime,
- M4OSA_Bool bJump);
-static M4OSA_ERR M4DECODER_EXTERNAL_render(M4OSA_Context pVS_Context, M4_MediaTime* pTime,
- M4VIFI_ImagePlane* pOutputPlane,
- M4OSA_Bool bForceRender);
-
-/* ----- Signaling functions ----- */
-
-static M4OSA_ERR M4DECODER_EXTERNAL_signalDecoderOver(M4OSA_Context pVS_Context,
- M4_MediaTime aTime, M4OSA_ERR aUserError);
-static M4OSA_ERR M4DECODER_EXTERNAL_signalRenderOver(M4OSA_Context pVS_Context,
- M4_MediaTime aTime, M4OSA_ERR aUserError);
-
-/* ----- static internal functions ----- */
-
-static M4OSA_ERR M4DECODER_EXTERNAL_Init(void** pVS_Context, M4VD_Interface* p_HWInterface,
- M4_StreamHandler *pStreamHandler);
-static M4OSA_ERR M4DECODER_EXTERNAL_StreamDescriptionInit(M4VD_StreamInfo** ppStreamInfo,
- M4_StreamHandler *pStreamHandler);
-static M4OSA_ERR M4DECODER_EXTERNAL_SetUpReadInput(void* pVS_Context,
- M4READER_DataInterface* pReader,
- M4_AccessUnit* pAccessUnit);
-static M4OSA_ERR M4DECODER_EXTERNAL_GetNextAu(M4VS_VideoDecoder_Context* pStreamContext,
- M4VD_VideoBuffer *nextBuffer,
- M4_MediaTime* nextFrameTime);
-static M4OSA_ERR M4DECODER_EXTERNAL_SynchronousDecode(M4OSA_Context pVS_Context);
-static M4OSA_ERR M4DECODER_EXTERNAL_AsynchronousDecode(M4OSA_Context pVS_Context);
-static M4OSA_ERR M4DECODER_EXTERNAL_AsynchronousRender(M4OSA_Context pVS_Context);
-
-
-/* ___________________________________________________________________ */
-/*| |*/
-/*| |*/
-/*|___________________________________________________________________|*/
-
-/**
- ************************************************************************
- * @brief Retrieves the interface implemented by the decoder
- * @note
- *
- * @param pDecoderInterface: (OUT) address of a pointer that will be set to the interface
- * implemented by this decoder. The interface is a structure
- * allocated by the function and must be unallocated by the
- * caller.
- *
- * @returns : M4NO_ERROR if OK
- * M4ERR_ALLOC if allocation failed
- ************************************************************************
- */
-M4OSA_ERR M4DECODER_EXTERNAL_getInterface(M4DECODER_VideoInterface **pDecoderInterface)
-{
- /* Allocates memory for the decoder shell pointer to function */
- *pDecoderInterface =
- (M4DECODER_VideoInterface*)M4OSA_32bitAlignedMalloc( sizeof(M4DECODER_VideoInterface),
- M4DECODER_EXTERNAL, (M4OSA_Char *)"M4DECODER_VideoInterface" );
- if (M4OSA_NULL == *pDecoderInterface)
- {
- M4OSA_TRACE1_0("M4DECODER_EXTERNAL_getInterface:\
- unable to allocate M4DECODER_VideoInterface, returning M4ERR_ALLOC");
- return M4ERR_ALLOC;
- }
-
- (*pDecoderInterface)->m_pFctCreate = M4DECODER_EXTERNAL_create;
- (*pDecoderInterface)->m_pFctDestroy = M4DECODER_EXTERNAL_destroy;
- (*pDecoderInterface)->m_pFctGetOption = (M4DECODER_getOption_fct*)M4DECODER_EXTERNAL_getOption;
- (*pDecoderInterface)->m_pFctSetOption = M4DECODER_EXTERNAL_setOption;
- (*pDecoderInterface)->m_pFctDecode = M4DECODER_EXTERNAL_decode;
- (*pDecoderInterface)->m_pFctRender = M4DECODER_EXTERNAL_render;
-
- return M4NO_ERROR;
-}
-
-
-/* ___________________________________________________________________ */
-/*| |*/
-/*| shell API |*/
-/*|___________________________________________________________________|*/
-
-/**
- ************************************************************************
- * @brief Creates the external video decoder
- * @note This function creates internal video decoder context and
- * initializes it.
- *
- * @param pVS_Context (OUT) Context of the video hw shell
- * @param pStreamHandler (IN) Pointer to a video stream description
- * @param pReaderDataInterface: (IN) Pointer to the M4READER_DataInterface
- * structure that must be used by the
- * decoder to read data from the stream
- * @param pAccessUnit (IN) Pointer to an access unit (allocated
- * by the caller) where the decoded data
- * are stored
- * @param pExternalAPI (IN) Interface of the client video decoder
- * @param pUserData (IN) User data of the external video decoder
- *
- * @return M4NO_ERROR There is no error
- * @return M4ERR_ALLOC a memory allocation has failed
- * @return M4ERR_PARAMETER at least one parameter is not properly set (in DEBUG only)
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_create(M4OSA_Context *pVS_Context,
- M4_StreamHandler *pStreamHandler,
- M4READER_DataInterface *pReaderDataInterface,
- M4_AccessUnit* pAccessUnit, M4OSA_Void* pUserData)
-{
- M4VD_VideoType videoDecoderKind;
- M4VD_StreamInfo* pStreamInfo;
- M4VD_OutputFormat outputFormat;
-
- M4VS_VideoDecoder_Context* pStreamContext;
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_create");
-
- /* Video Shell Creation */
- err = M4DECODER_EXTERNAL_Init(pVS_Context,
- ((M4DECODER_EXTERNAL_UserDataType)pUserData)->externalFuncs, pStreamHandler);
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create :\
- M4VD_EXTERNAL_Init RETURNS THE ERROR CODE = 0x%x", err);
- return err;
- }
-
- err = M4DECODER_EXTERNAL_SetUpReadInput(*pVS_Context, pReaderDataInterface, pAccessUnit);
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create :\
- M4VD_EXTERNAL_SetUpReadInput RETURNS THE ERROR CODE = 0x%x", err);
- return err;
- }
-
- pStreamContext = (M4VS_VideoDecoder_Context*)(*pVS_Context);
-
- /* Stream Description init */
- err = M4DECODER_EXTERNAL_StreamDescriptionInit(&pStreamInfo, pStreamHandler);
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create :\
- M4VD_EXTERNAL_StreamDescriptionInit RETURNS THE ERROR CODE = 0x%x", err);
- return err;
- }
-
- pStreamContext->m_pStreamInfo = pStreamInfo;
-
- /* HW context creation */
- err = pStreamContext->m_VD_Interface->m_pFctInitVideoDecoder(&(pStreamContext->m_VD_Context),
- &(pStreamContext->m_VD_SignalingInterface));
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create : m_pFctInitVideoDecoder() error 0x%x", err);
- return err;
- }
-
- /* HW decoder creation */
- switch(pStreamHandler->m_streamType)
- {
- case M4DA_StreamTypeVideoH263 :
- videoDecoderKind = M4VD_kH263VideoDec;
- break;
-
- default :
- case M4DA_StreamTypeVideoMpeg4 :
- videoDecoderKind = M4VD_kMpeg4VideoDec;
- break;
- }
-
- err = pStreamContext->m_VD_Interface->m_pFctOpenDecoder(pStreamContext->m_VD_Context,
- videoDecoderKind, pStreamContext->m_pStreamInfo, &outputFormat,
- ((M4DECODER_EXTERNAL_UserDataType)pUserData)->externalUserData);
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create : m_pFctOpenDecoder() error 0x%x", err);
- return err;
- }
-
- /* Parse the VOL header */
- err = M4DECODER_EXTERNAL_ParseVideoDSI((M4OSA_UInt8 *)pStreamContext->m_pStreamInfo->\
- decoderConfiguration.pBuffer,
- pStreamContext->m_pStreamInfo->\
- decoderConfiguration.aSize,
- &pStreamContext->m_Dci, &pStreamContext->m_VideoSize);
-
- if (err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_create :\
- M4DECODER_EXTERNAL_ParseVideoDSI() error 0x%x", err);
- return err;
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief destroy the instance of the decoder
- * @note after this call the context is invalid
- *
- * @param pVS_Context: (IN) Context of the decoder
- *
- * @return M4NO_ERROR There is no error
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_destroy(M4OSA_Context pVS_Context)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_destroy");
-
- if(M4OSA_NULL != pStreamContext)
- {
- /* Call external API destroy function */
- pStreamContext->m_VD_Interface->m_pFctClose(pStreamContext->m_VD_Context);
-
- /* Destroy context */
- pStreamContext->m_VD_Interface->m_pFctCleanUp(pStreamContext->m_VD_Context);
-
- if(M4OSA_NULL != pStreamContext->m_pStreamInfo)
- {
- free(pStreamContext->m_pStreamInfo);
- pStreamContext->m_pStreamInfo = M4OSA_NULL;
- }
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- if (M4OSA_NULL != pStreamContext->m_SemSync)
- {
- M4OSA_semaphoreClose(pStreamContext->m_SemSync);
- }
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
- free(pStreamContext);
- pStreamContext = M4OSA_NULL;
- }
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief Get an option value from the decoder
- * @note It allows the caller to retrieve a property value:
- * - the size (width x height) of the image
- * - the DSI properties
- *
- * @param pVS_Context: (IN) Context of the decoder
- * @param optionId: (IN) indicates the option to set
- * @param pValue: (IN/OUT) pointer to structure or value (allocated by user) where option
- * is stored
- * @return M4NO_ERROR there is no error
- * @return M4ERR_PARAMETER The context is invalid (in DEBUG only)
- * @return M4ERR_BAD_OPTION_ID when the option ID is not a valid one
- * @return M4ERR_STATE State automaton is not applied
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_getOption(M4OSA_Context pVS_Context, M4OSA_OptionID optionId,
- M4OSA_DataOption *pValue)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_getOption");
-
- switch (optionId)
- {
- case M4DECODER_kOptionID_VideoSize:
- *((M4DECODER_VideoSize*)pValue) = pStreamContext->m_VideoSize;
- err = M4NO_ERROR;
- break;
-
- case M4DECODER_MPEG4_kOptionID_DecoderConfigInfo:
- *((M4DECODER_MPEG4_DecoderConfigInfo*)pValue) = pStreamContext->m_Dci;
- err = M4NO_ERROR;
- break;
-
- default:
- err = pStreamContext->m_VD_Interface->m_pFctGetOption(pStreamContext->m_VD_Context,
- optionId, pValue);
- break;
- }
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief set en option value of the decoder
- * @note It allows the caller to set a property value:
- * - Nothing implemented at this time
- *
- * @param pVS_Context: (IN) Context of the external video decoder shell
- * @param optionId: (IN) Identifier indicating the option to set
- * @param pValue: (IN) Pointer to structure or value (allocated by user) where
- * option is stored
- * @return M4NO_ERROR There is no error
- * @return M4ERR_BAD_OPTION_ID The option ID is not a valid one
- * @return M4ERR_STATE State automaton is not applied
- * @return M4ERR_PARAMETER The option parameter is invalid
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_setOption(M4OSA_Context pVS_Context, M4OSA_OptionID optionId,
- M4OSA_DataOption pValue)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
- M4OSA_ERR err;
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_setOption");
-
- switch (optionId)
- {
- case M4DECODER_kOptionID_OutputFilter:
- {
- M4DECODER_OutputFilter* pOutputFilter = (M4DECODER_OutputFilter*) pValue;
- err =
- pStreamContext->m_VD_Interface->m_pFctSetOutputFilter(pStreamContext->m_VD_Context,
- (M4VIFI_PlanConverterFunctionType*)pOutputFilter->m_pFilterFunction,
- pOutputFilter->m_pFilterUserData);
- }
- break;
-
- case M4DECODER_kOptionID_DeblockingFilter:
- err = M4NO_ERROR;
- break;
-
- default:
- err = pStreamContext->m_VD_Interface->m_pFctSetOption(pStreamContext->m_VD_Context,
- optionId, pValue);
- break;
- }
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief Decode video Access Units up to a target time
- * @note Parse and decode the video until it can output a decoded image for which
- * the composition time is equal or greater to the passed targeted time
- * The data are read from the reader data interface passed to M4DECODER_EXTERNAL_create.
- * If threaded mode, waits until previous decoding is over,
- * and fill decoding parameters used by the decoding thread.
- *
- * @param pVS_Context:(IN) Context of the external video decoder shell
- * @param pTime: (IN/OUT) IN: Time to decode up to (in milli secondes)
- * OUT:Time of the last decoded frame (in ms)
- * @param bJump: (IN) 0 if no jump occured just before this call
- * 1 if a a jump has just been made
- *
- * @return M4NO_ERROR there is no error
- * @return M4ERR_PARAMETER at least one parameter is not properly set
- * @return M4WAR_NO_MORE_AU there is no more access unit to decode (end of stream)
- * @return M4WAR_VIDEORENDERER_NO_NEW_FRAME No frame to render
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_decode(M4OSA_Context pVS_Context, M4_MediaTime* pTime,
- M4OSA_Bool bJump)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_TRACE2_2("M4DECODER_EXTERNAL_decode : up to %lf bjump = 0x%x", *pTime, bJump);
-
- pStreamContext->m_DecodeUpToCts = *pTime;
- pStreamContext->m_bJump = bJump;
- if (bJump)
- {
- pStreamContext->m_CurrentDecodeCts = -1.0;
- pStreamContext->m_CurrentRenderCts = -1.0;
- }
-
- if(pStreamContext->m_DecodeUpToCts < pStreamContext->m_nextAUCts &&
- pStreamContext->m_CurrentRenderCts > pStreamContext->m_DecodeUpToCts)
- {
- /* It means that we do not need to launch another predecode, as we will reuse
- the previously decoded frame*/
- /* a warning is returned to the service to warn it about that .*/
- /* In that case, the service MUST NOT call render function, and must keep the
- previous frame */
- /* if necessary (i.e force render case)*/
- M4OSA_TRACE2_0("No decode is needed, same frame reused");
- return M4WAR_VIDEORENDERER_NO_NEW_FRAME;
- }
-
- /* If render has not been called for frame n, it means that n+1 frame decoding has
- not been launched
- -> do not wait for its decoding completion ...*/
- if(pStreamContext->m_bIsWaitNextDecode == M4OSA_TRUE)
- {
- /* wait for decode n+1 to complete */
- //M4semvalue--;
- //printf("Semaphore wait: %d\n", M4semvalue);
- pStreamContext->m_bIsWaitNextDecode = M4OSA_FALSE;
- M4OSA_semaphoreWait(pStreamContext->m_SemSync, M4OSA_WAIT_FOREVER);
- }
- if(pStreamContext->m_CurrentDecodeCts >= *pTime)
- {
- /* If we are not in this condition, it means that we ask for a frame after the
- "predecoded" frame */
- *pTime = pStreamContext->m_CurrentDecodeCts;
- return M4NO_ERROR;
- }
-
- pStreamContext->m_NbDecodedFrames = 0;
- pStreamContext->m_uiDecodeError = M4NO_ERROR;
- pStreamContext->m_bDataDecodePending = M4OSA_TRUE;
- pStreamContext->m_uiDecodeError = M4NO_ERROR;
-
- /* Launch DecodeUpTo process in synchronous mode */
- while(pStreamContext->m_uiDecodeError == M4NO_ERROR)
- {
- M4DECODER_EXTERNAL_SynchronousDecode(pVS_Context);
- /* return code is ignored, it is used only in M4OSA_Thread api */
- }
-
- *pTime = pStreamContext->m_CurrentDecodeCts;
-
- if ( (M4WAR_DECODE_FINISHED == pStreamContext->m_uiDecodeError)
- || (M4WAR_VIDEORENDERER_NO_NEW_FRAME == pStreamContext->m_uiDecodeError) )
- {
- pStreamContext->m_uiDecodeError = M4NO_ERROR;
- }
-
- return pStreamContext->m_uiDecodeError;
-}
-
-/**
- ************************************************************************
- * @brief Renders the video at the specified time.
- * @note If threaded mode, this function unlock the decoding thread,
- * which also call the external rendering function.
- * Else, just call external rendering function, and waits for its
- * completion.
- *
- * @param pVS_Context: (IN) Context of the video decoder shell
- * @param pTime: (IN/OUT) IN: Time to render to (in milli secondes)
- * OUT:Time of the effectively rendered frame (in ms)
- * @param pOutputPlane:(OUT) Output plane filled with decoded data (converted)
- * If NULL, the rendering is made by the external
- * component.
- * @param bForceRender:(IN) 1 if the image must be rendered even it has already been
- * 0 if not (in which case the function can return
- * M4WAR_VIDEORENDERER_NO_NEW_FRAME)
- * @return M4NO_ERROR There is no error
- * @return M4ERR_PARAMETER At least one parameter is not properly set
- * @return M4ERR_STATE State automaton is not applied
- * @return M4ERR_ALLOC There is no more available memory
- * @return M4WAR_VIDEORENDERER_NO_NEW_FRAME If the frame to render has already been rendered
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_render(M4OSA_Context pVS_Context, M4_MediaTime* pTime,
- M4VIFI_ImagePlane* pOutputPlane,
- M4OSA_Bool bForceRender)
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_TRACE2_2("M4DECODER_EXTERNAL_render : pTime = %lf, forceRender: %d ", *pTime,
- bForceRender);
-
- pStreamContext->m_TargetRenderCts = *pTime;
- pStreamContext->m_pOutputPlane = pOutputPlane;
- pStreamContext->m_bForceRender = bForceRender;
- pStreamContext->m_uiRenderError = M4NO_ERROR;
- pStreamContext->m_bDataRenderPending = M4OSA_TRUE;
-
- /* Launch Render process in synchronous mode */
- while(pStreamContext->m_uiRenderError == M4NO_ERROR)
- {
- M4DECODER_EXTERNAL_AsynchronousRender(pVS_Context);
- /* return code is ignored, it is used only in M4OSA_Thread */
- }
-
-
- *pTime = pStreamContext->m_CurrentRenderCts;
-
-
- if (M4WAR_RENDER_FINISHED == pStreamContext->m_uiRenderError)
- {
- pStreamContext->m_uiRenderError = M4NO_ERROR;
- }
-
- return pStreamContext->m_uiRenderError;
-}
-
-
-/* ___________________________________________________________________ */
-/*| |*/
-/*| Signaling functions |*/
-/*|___________________________________________________________________|*/
-
-/**
- ************************************************************************
- * @brief Called by the HW video decoder to signal that a decoding is
- * over
- * @note The function gets another AU in the internal AU buffer, and
- * launches the decoding.
- * If no more AU are available, the M4DECODER_EXTERNAL_decode
- * (or M4DECODER_EXTERNAL_render if threaded) function is unlocked
- *
- * @param pVS_Context: (IN) context of the video hw shell
- * @param aTime: (IN) time of the decoded frame
- * @param aUserError (IN) error code returned to the VPS
- *
- * @return M4NO_ERROR There is no error
- * @return M4ERR_HW_DECODER_xxx A fatal error occured
- * @return M4ERR_PARAMETER At least one parameter is NULL
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_signalDecoderOver(M4OSA_Context pVS_Context,
- M4_MediaTime aTime, M4OSA_ERR aUserError)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_TRACE2_1("M4DECODER_EXTERNAL_signalDecoderOver : aTime = %lf", aTime);
-
- pStreamContext->m_NbDecodedFrames++;
- pStreamContext->m_uiDecodeError = aUserError;
- pStreamContext->m_CurrentDecodeCts = aTime;
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- /* give control back to stepDecode */
- //M4semvalue++;
- //printf("Semaphore post: %d\n", M4semvalue);
- M4OSA_semaphorePost(pStreamContext->m_SemSync);
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief Called by the HW video renderer to signal that a rendering is
- * over
- * @note The function just post a semaphore to unblock
- * M4DECODER_EXTERNAL_render function
- *
- * @param pVS_Context: (IN) context of the video hw shell
- * @param aTime: (IN) time of the decoded frame
- * @param aUserError (IN) error code returned to the VPS
- *
- * @return M4NO_ERROR There is no error
- * @return M4ERR_HW_DECODER_xxx A fatal error occured
- * @return M4ERR_PARAMETER At least one parameter is NULL
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_signalRenderOver(M4OSA_Context pVS_Context,
- M4_MediaTime aTime, M4OSA_ERR aUserError)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_TRACE3_1("M4DECODER_EXTERNAL_signalRenderOver : aTime = %lf", aTime);
-
- pStreamContext->m_uiRenderError = aUserError;
- pStreamContext->m_CurrentRenderCts = aTime;
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- /* give control back to stepRender */
- //M4semvalue++;
- //printf("Semaphore post: %d\n", M4semvalue);
- M4OSA_semaphorePost(pStreamContext->m_SemSync);
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
- return M4NO_ERROR;
-}
-
-
-/* ___________________________________________________________________ */
-/*| |*/
-/*| Internals |*/
-/*|___________________________________________________________________|*/
-
-/**
- ************************************************************************
- * @brief Initializes the video decoder shell/handler
- * @note allocates an execution context
- *
- * @param pVS_Context: (OUT) Output context allocated
- * @param p_HWInterface: (IN) Pointer on the set of external HW codec functions
- * @param pStreamHandler: (IN) Pointer to a video stream description
- *
- * @return M4NO_ERROR There is no error
- * @return M4ERR_ALLOC There is no more available memory
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_Init(M4OSA_Context* pVS_Context,
- M4VD_Interface* p_HWInterface,
- M4_StreamHandler *pStreamHandler)
-{
- M4VS_VideoDecoder_Context* pStreamContext;
-
- M4OSA_ERR err = M4NO_ERROR;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_Init");
-
- /* Allocate the internal context */
- *pVS_Context = M4OSA_NULL;
-
- pStreamContext = (M4VS_VideoDecoder_Context*)M4OSA_32bitAlignedMalloc(sizeof(M4VS_VideoDecoder_Context),
- M4DECODER_EXTERNAL,(M4OSA_Char *) "M4VS_VideoDecoder_Context");
- if (M4OSA_NULL == pStreamContext)
- {
- M4OSA_TRACE1_0("M4DECODER_EXTERNAL_Init : error, cannot allocate context !");
- return M4ERR_ALLOC;
- }
-
- /* Reset internal context structure */
- *pVS_Context = pStreamContext;
-
- /* --- READER --- */
- pStreamContext->m_pReader = M4OSA_NULL;
- pStreamContext->m_pNextAccessUnitToDecode = M4OSA_NULL;
- pStreamContext->m_bJump = M4OSA_FALSE;
- pStreamContext->m_nextAUCts = -1;
-
- /* --- DECODER --- */
- pStreamContext->m_DecodeUpToCts = -1;
- pStreamContext->m_CurrentDecodeCts = -1;
- pStreamContext->m_NbDecodedFrames = 0;
- pStreamContext->m_uiDecodeError = M4NO_ERROR;
- pStreamContext->m_bDataDecodePending = M4OSA_FALSE;
- pStreamContext->m_PreviousDecodeCts = 0;
- pStreamContext->m_bIsWaitNextDecode = M4OSA_FALSE;
-
- /* --- RENDER --- */
- pStreamContext->m_TargetRenderCts = -1;
- pStreamContext->m_CurrentRenderCts = -1;
- pStreamContext->m_uiRenderError = M4NO_ERROR;
- pStreamContext->m_bForceRender = M4OSA_TRUE;
- pStreamContext->m_bDataRenderPending = M4OSA_FALSE;
-
- /* --- STREAM PARAMS --- */
- pStreamContext->m_pVideoStreamhandler = (M4_VideoStreamHandler*)pStreamHandler;
- pStreamContext->m_pStreamInfo = M4OSA_NULL;
- pStreamContext->m_pOutputPlane = M4OSA_NULL;
-
- /* --- VD API --- */
- pStreamContext->m_VD_Interface = p_HWInterface;
- pStreamContext->m_VD_Context = M4OSA_NULL;
-
- pStreamContext->m_VD_SignalingInterface.m_pSignalTarget = pStreamContext;
- pStreamContext->m_VD_SignalingInterface.m_pFctSignalDecoderOver =
- M4DECODER_EXTERNAL_signalDecoderOver;
- pStreamContext->m_VD_SignalingInterface.m_pFctSignalRenderOver =
- M4DECODER_EXTERNAL_signalRenderOver;
-
- /* --- THREAD STUFF --- */
-
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- pStreamContext->m_SemSync = M4OSA_NULL;
- //M4semvalue=0;
- err = M4OSA_semaphoreOpen(&(pStreamContext->m_SemSync), 0);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_Init: can't open sync semaphore (err 0x%08X)", err);
- return err;
- }
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief Fills the stream info structure
- * @note This function is called at decoder's creation time,
- * allocates and fills video info structure
- *
- * @param ppStreamInfo (OUT) Video info structure
- * @param pStreamHandler (IN) Pointer to a video stream description
- *
- * @return M4ERR_ALLOC Memory allocation error
- * @return M4NO_ERROR There is no error
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_StreamDescriptionInit(M4VD_StreamInfo** ppStreamInfo,
- M4_StreamHandler *pStreamHandler)
-{
- M4_VideoStreamHandler* pVideoStreamHandler = M4OSA_NULL;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_StreamDescriptionInit");
-
- pVideoStreamHandler = (M4_VideoStreamHandler*)pStreamHandler;
-
- /* M4VD_StreamInfo allocation */
- *ppStreamInfo = (M4VD_StreamInfo*)M4OSA_32bitAlignedMalloc(sizeof(M4VD_StreamInfo),
- M4DECODER_EXTERNAL, (M4OSA_Char *)"M4VD_StreamInfo");
- if(M4OSA_NULL == *ppStreamInfo)
- {
- return M4ERR_ALLOC;
- }
-
- /* init values */
- (*ppStreamInfo)->anImageSize.aWidth = pVideoStreamHandler->m_videoWidth;
- (*ppStreamInfo)->anImageSize.aHeight = pVideoStreamHandler->m_videoHeight;
-
- (*ppStreamInfo)->decoderConfiguration.pBuffer =
- (M4OSA_MemAddr8)pStreamHandler->m_pDecoderSpecificInfo;
- (*ppStreamInfo)->decoderConfiguration.aSize = pStreamHandler->m_decoderSpecificInfoSize;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief Initializes current AU parameters
- * @note It is called at decoder's creation time to initialize
- * current decoder's AU.
- *
- * @param pVS_Context (IN) Context of the video decoder shell
- * @param pReader (IN) Reader interface
- * @param pAccessUnit (IN) Access Unit structure used bu decoder
- *
- * @return
- * @return
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_SetUpReadInput(M4OSA_Context pVS_Context,
- M4READER_DataInterface* pReader,
- M4_AccessUnit* pAccessUnit)
-{
- M4VS_VideoDecoder_Context* pStreamContext=(M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_SetUpReadInput");
-
- M4OSA_DEBUG_IF1((M4OSA_NULL == pStreamContext), M4ERR_PARAMETER,
- "M4DECODER_EXTERNAL_SetUpReadInput: invalid context pointer");
- M4OSA_DEBUG_IF1((M4OSA_NULL == pReader), M4ERR_PARAMETER,
- "M4DECODER_EXTERNAL_SetUpReadInput: invalid pReader pointer");
- M4OSA_DEBUG_IF1((M4OSA_NULL == pAccessUnit), M4ERR_PARAMETER,
- "M4DECODER_EXTERNAL_SetUpReadInput: invalid pAccessUnit pointer");
-
- pStreamContext->m_pReader = pReader;
- pStreamContext->m_pNextAccessUnitToDecode = pAccessUnit;
-
- pAccessUnit->m_streamID = 0;
- pAccessUnit->m_size = 0;
- pAccessUnit->m_CTS = 0;
- pAccessUnit->m_DTS = 0;
- pAccessUnit->m_attribute = 0;
-
- return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief Gets the next AU from internal AU buffer
- * @note This function is necessary to be able to have a decodeUpTo
- * interface with the VPS.
- * The AU are read from file by M4DECODER_EXTERNAL_decode function
- * and stored into a buffer. This function is called internally
- * to get these stored AU.
- *
- * @param pStreamContext: (IN) context of the video hw shell
- * @param nextFrameTime: (IN/OUT) time of the AU
- *
- * @return M4NO_ERROR There is no error
- * @return M4WAR_NO_MORE_AU No more AU in internal buffer
- * @return M4ERR_PARAMETER One invalid parameter
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_GetNextAu(M4VS_VideoDecoder_Context* pStreamContext,
- M4VD_VideoBuffer *nextBuffer,
- M4_MediaTime* nextFrameTime)
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4_AccessUnit* pAccessUnit;
-
- M4OSA_TRACE3_0("M4DECODER_EXTERNAL_GetNextAu");
-
- /* Check context is valid */
- if(M4OSA_NULL == pStreamContext)
- {
- M4OSA_TRACE1_0("M4DECODER_EXTERNAL_GetNextAu : error pStreamContext is NULL");
- return M4ERR_PARAMETER;
- }
-
- /* Read the AU */
- pAccessUnit = pStreamContext->m_pNextAccessUnitToDecode;
-
- err = pStreamContext->m_pReader->m_pFctGetNextAu(pStreamContext->m_pReader->m_readerContext,
- (M4_StreamHandler*)pStreamContext->m_pVideoStreamhandler, pAccessUnit);
-
- if((err == M4WAR_NO_DATA_YET) || (err == M4WAR_NO_MORE_AU))
- {
- M4OSA_TRACE2_1("M4DECODER_EXTERNAL_GetNextAu : no data avalaible 0x%x", err);
- }
- else if(err != M4NO_ERROR)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_GetNextAu : filesystem error 0x%x", err);
-
- *nextFrameTime = 0;
- nextBuffer->pBuffer = M4OSA_NULL;
- nextBuffer->bufferSize = 0;
-
- return err;
- }
-
- /* Fill buffer */
- *nextFrameTime = pAccessUnit->m_CTS;
- nextBuffer->pBuffer = (M4OSA_MemAddr32)pAccessUnit->m_dataAddress;
- nextBuffer->bufferSize = pAccessUnit->m_size;
-
- M4OSA_TRACE3_1("M4DECODER_EXTERNAL_GetNextAu: AU obtained, time is %f", *nextFrameTime);
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief
- * @note
- *
- * @param pVS_Context: (IN) Context of the video hw shell
- *
- * @return M4NO_ERROR There is no error
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_SynchronousDecode(M4OSA_Context pVS_Context)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_ERR err = M4NO_ERROR;
- M4VD_VideoBuffer nextBuffer;
-
-
- /* ----- decode process ----- */
-
- if(M4OSA_TRUE == pStreamContext->m_bDataDecodePending)
- {
- /* Targeted time is reached */
- if( pStreamContext->m_CurrentDecodeCts >= pStreamContext->m_DecodeUpToCts )
- {
- M4OSA_TRACE2_0("M4DECODER_EXTERNAL_SynchronousDecode :\
- skip decode because synchronisation");
-
- if(pStreamContext->m_NbDecodedFrames > 0)
- {
- pStreamContext->m_uiDecodeError = M4WAR_DECODE_FINISHED;
- }
- else
- {
- pStreamContext->m_uiDecodeError = M4WAR_VIDEORENDERER_NO_NEW_FRAME;
- }
-
- M4ERR_EXIT(M4NO_ERROR);
- }
-
- pStreamContext->m_PreviousDecodeCts = pStreamContext->m_CurrentDecodeCts;
-
- /* Get the next AU */
- pStreamContext->m_uiDecodeError = M4DECODER_EXTERNAL_GetNextAu(pStreamContext,
- &nextBuffer, &pStreamContext->m_CurrentDecodeCts);
-
- if( M4NO_ERROR != pStreamContext->m_uiDecodeError )
- {
- if ( M4WAR_NO_MORE_AU != pStreamContext->m_uiDecodeError)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_SynchronousDecode :\
- M4DECODER_EXTERNAL_GetNextAu error 0x%x", pStreamContext->m_uiDecodeError);
- }
- M4ERR_EXIT(pStreamContext->m_uiDecodeError);
- }
-
- /* Decode the AU */
- if(nextBuffer.bufferSize > 0)
- {
- pStreamContext->m_uiDecodeError =
- pStreamContext->m_VD_Interface->m_pFctStepDecode(pStreamContext->m_VD_Context,
- &nextBuffer, pStreamContext->m_CurrentDecodeCts);
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- if ( (M4NO_ERROR == pStreamContext->m_uiDecodeError)
- /*|| (M4WAR_IO_PENDING == pStreamContext->m_uiDecodeError)*/ )
- {
- /* wait for decode to complete */
- //M4semvalue--;
- //printf("Semaphore wait 2: %d\n", M4semvalue);
- M4OSA_semaphoreWait(pStreamContext->m_SemSync, M4OSA_WAIT_FOREVER);
- /* by now the actual m_uiDecodeError has been set by signalDecode */
- }
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
- if(M4NO_ERROR != pStreamContext->m_uiDecodeError)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_SynchronousDecode : HW decoder error 0x%x",
- pStreamContext->m_uiDecodeError);
- M4ERR_EXIT(M4NO_ERROR);
- }
- }
- else
- {
- M4ERR_EXIT(M4NO_ERROR);
- }
- }
-
- return M4NO_ERROR;
-
-
-/* ----- Release resources if an error occured */
-exit_with_error:
-
- /* Abort decoding */
- pStreamContext->m_bDataDecodePending = M4OSA_FALSE;
-
- if((M4NO_ERROR == pStreamContext->m_uiDecodeError) && (M4NO_ERROR != err))
- {
- pStreamContext->m_uiDecodeError = err;
- }
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief
- * @note
- *
- * @param pVS_Context: (IN) Context of the video hw shell
- *
- * @return M4NO_ERROR There is no error
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_AsynchronousDecode(M4OSA_Context pVS_Context)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_ERR err = M4NO_ERROR;
- M4VD_VideoBuffer nextBuffer;
-
-
- /* ----- decode process ----- */
-
- if(M4OSA_TRUE == pStreamContext->m_bDataDecodePending)
- {
- pStreamContext->m_PreviousDecodeCts = pStreamContext->m_CurrentDecodeCts;
-
- /* Get the next AU */
- pStreamContext->m_uiDecodeError = M4DECODER_EXTERNAL_GetNextAu(pStreamContext,
- &nextBuffer, &pStreamContext->m_nextAUCts);
-
- if( M4NO_ERROR != pStreamContext->m_uiDecodeError )
- {
- if ( M4WAR_NO_MORE_AU != pStreamContext->m_uiDecodeError)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_AsynchronousDecode :\
- M4DECODER_EXTERNAL_GetNextAu error 0x%x", pStreamContext->m_uiDecodeError);
- }
- //M4semvalue++;
- //printf("Semaphore post: %d\n", M4semvalue);
- //M4OSA_semaphorePost(pStreamContext->m_SemSync);
- M4ERR_EXIT(pStreamContext->m_uiDecodeError);
- }
-
- /* Decode the AU if needed */
- if(nextBuffer.bufferSize > 0)
- {
- pStreamContext->m_uiDecodeError =
- pStreamContext->m_VD_Interface->m_pFctStepDecode(pStreamContext->m_VD_Context,
- &nextBuffer, pStreamContext->m_nextAUCts\
- /*pStreamContext->m_CurrentDecodeCts*/);
- if(M4NO_ERROR != pStreamContext->m_uiDecodeError)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_AsynchronousDecode : HW decoder error 0x%x",
- pStreamContext->m_uiDecodeError);
- M4ERR_EXIT(M4NO_ERROR);
- }
- pStreamContext->m_bIsWaitNextDecode = M4OSA_TRUE;
- }
- else
- {
- M4ERR_EXIT(M4NO_ERROR);
- }
- }
-
- return M4NO_ERROR;
-
-
-/* ----- Release resources if an error occured */
-exit_with_error:
-
- /* Abort decoding */
- pStreamContext->m_bDataDecodePending = M4OSA_FALSE;
-
- if((M4NO_ERROR == pStreamContext->m_uiDecodeError) && (M4NO_ERROR != err))
- {
- pStreamContext->m_uiDecodeError = err;
- }
-
- return err;
-}
-
-/**
- ************************************************************************
- * @brief
- * @note
- *
- * @param pVS_Context: (IN) Context of the video hw shell
- *
- * @return M4NO_ERROR There is no error
- ************************************************************************
- */
-static M4OSA_ERR M4DECODER_EXTERNAL_AsynchronousRender(M4OSA_Context pVS_Context)
-{
- M4VS_VideoDecoder_Context* pStreamContext = (M4VS_VideoDecoder_Context*)pVS_Context;
-
- M4OSA_ERR err = M4NO_ERROR;
-
-
- /* ----- Render one frame ----- */
-
- if(M4OSA_TRUE == pStreamContext->m_bDataRenderPending)
- {
- /* Render the frame */
- pStreamContext->m_CurrentRenderCts = pStreamContext->m_CurrentDecodeCts;
-
- pStreamContext->m_uiRenderError =
- pStreamContext->m_VD_Interface->m_pFctStepRender(pStreamContext->m_VD_Context,
- pStreamContext->m_pOutputPlane, pStreamContext->m_CurrentRenderCts);
-#ifndef M4DECODER_EXTERNAL_SYNC_EXT_DECODE
- if ( (M4NO_ERROR == pStreamContext->m_uiRenderError)
- /* || (M4WAR_IO_PENDING == pStreamContext->m_uiRenderError) */ )
- {
- /* wait for render to complete */
- //M4semvalue--;
- //printf("Semaphore wait: %d\n", M4semvalue);
- M4OSA_semaphoreWait(pStreamContext->m_SemSync, M4OSA_WAIT_FOREVER);
- /* by now the actual m_uiRenderError has been set by signalRender */
- }
-#endif /* not M4DECODER_EXTERNAL_SYNC_EXT_DECODE */
- if(M4NO_ERROR != pStreamContext->m_uiRenderError)
- {
- M4OSA_TRACE1_1("M4DECODER_EXTERNAL_AsynchronousRender : HW render error 0x%x", err);
- pStreamContext->m_bDataRenderPending = M4OSA_FALSE;
-
- return M4NO_ERROR;
- }
-
- /* Launch in asynchronous mode the predecoding of the next frame */
- pStreamContext->m_NbDecodedFrames = 0;
- pStreamContext->m_uiDecodeError = M4NO_ERROR;
- pStreamContext->m_bDataDecodePending = M4OSA_TRUE;
- M4DECODER_EXTERNAL_AsynchronousDecode(pVS_Context);
-
- pStreamContext->m_uiRenderError = M4WAR_RENDER_FINISHED;
- }
-
- return M4NO_ERROR;
-
-
-/* ----- Release resources if an error occured */
-exit_with_error:
-
- /* Abort the rendering */
- pStreamContext->m_bDataRenderPending = M4OSA_FALSE;
-
- if((M4NO_ERROR == pStreamContext->m_uiRenderError) && (M4NO_ERROR != err))
- {
- pStreamContext->m_uiRenderError = err;
- }
-
-
- return err;
-}
-
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
index 6311cd6..d9b6eb5 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
@@ -1817,87 +1817,6 @@ M4OSA_ERR M4VSS3GPP_intClipCleanUp( M4VSS3GPP_ClipContext *pClipCtxt )
return err;
}
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
-M4OSA_ERR
-M4VSS3GPP_intClipRegisterExternalVideoDecoder( M4VSS3GPP_ClipContext *pClipCtxt,
- M4VD_VideoType decoderType,
- M4VD_Interface *pDecoderInterface,
- M4OSA_Void *pUserData )
-{
- M4OSA_ERR err = M4NO_ERROR;
- M4DECODER_VideoInterface *shellInterface;
- M4DECODER_VideoType nativeType;
- M4DECODER_EXTERNAL_UserDataType shellUserData;
-
- switch( decoderType )
- {
- case M4VD_kMpeg4VideoDec:
- case M4VD_kH263VideoDec:
- nativeType = M4DECODER_kVideoTypeMPEG4;
- break;
-
- case M4VD_kH264VideoDec:
- nativeType = M4DECODER_kVideoTypeAVC;
- break;
-
- default:
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intClipRegisterExternalVideoDecoder: unknown decoderType %d",
- decoderType);
- return M4ERR_PARAMETER;
- break;
- }
-
- shellUserData =
- (M4DECODER_EXTERNAL_UserDataType)M4OSA_32bitAlignedMalloc(sizeof(*shellUserData),
- M4VSS3GPP, (M4OSA_Char *)"userData structure for the external shell decoder");
-
- if( M4OSA_NULL == shellUserData )
- {
- M4OSA_TRACE1_0(
- "M4VSS3GPP_intClipRegisterExternalVideoDecoder:\
- failed to allocate userData structure for the external shell decoder");
- return M4ERR_ALLOC;
- }
-
- shellUserData->externalFuncs = pDecoderInterface;
- shellUserData->externalUserData = pUserData;
-
- err = M4DECODER_EXTERNAL_getInterface(&shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intClipRegisterExternalVideoDecoder:\
- M4DECODER_EXTERNAL_getInterface failed with error 0x%08X",
- err);
- free(shellUserData);
- return err;
- }
-
- err = M4VSS3GPP_registerVideoDecoder(&(pClipCtxt->ShellAPI), nativeType,
- shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intClipRegisterExternalVideoDecoder:\
- M4VSS3GPP_registerVideoDecoder failed with error 0x%08X",
- err);
- free(shellInterface);
- free(shellUserData);
- return err;
- }
-
- pClipCtxt->ShellAPI.m_pVideoDecoderUserDataTable[nativeType] =
- shellUserData;
-
- return M4NO_ERROR;
-}
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
/**
******************************************************************************
* M4OSA_UInt32 M4VSS3GPP_intGetFrameSize_AMRNB()
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
index e778b52..efdda9b 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
@@ -190,24 +190,6 @@ M4OSA_ERR M4VSS3GPP_editInit( M4VSS3GPP_EditContext *pContext,
pC->pOsaFileReadPtr = pFileReadPtrFct;
pC->pOsaFileWritPtr = pFileWritePtrFct;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
- for ( i = 0; i < M4VD_kVideoType_NB; i++ )
- {
- pC->registeredExternalDecs[i].pDecoderInterface = M4OSA_NULL;
- pC->registeredExternalDecs[i].pUserData = M4OSA_NULL;
- pC->registeredExternalDecs[i].registered = M4OSA_FALSE;
- }
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-#ifdef M4VSS_SUPPORT_OMX_CODECS
-
- for ( i = 0; i < M4VSS3GPP_kCodecType_NB; i++ )
- {
- pC->m_codecInterface[i] = M4OSA_NULL;
- }
- pC->pOMXUserData = M4OSA_NULL;
-#endif /* M4VSS_SUPPORT_OMX_CODECS */
/*
* Reset pointers for media and codecs interfaces */
@@ -1659,119 +1641,6 @@ M4OSA_ERR M4VSS3GPP_editCleanUp( M4VSS3GPP_EditContext pContext )
return M4NO_ERROR;
}
-M4OSA_ERR
-M4VSS3GPP_editRegisterExternalVideoDecoder( M4VSS3GPP_EditContext pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface *pDecoderInterface,
- M4OSA_Void *pUserData )
-{
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
- M4VSS3GPP_InternalEditContext *pC =
- (M4VSS3GPP_InternalEditContext *)pContext;
- /* Here the situation is a bit special: we need to record the registrations that are made,
- so that we can replay them for each clip we create. */
-
- if( decoderType >= M4VD_kVideoType_NB )
- {
- return M4ERR_PARAMETER;
- }
-
- pC->registeredExternalDecs[decoderType].pDecoderInterface
- = pDecoderInterface;
- pC->registeredExternalDecs[decoderType].pUserData = pUserData;
- pC->registeredExternalDecs[decoderType].registered = M4OSA_TRUE;
-
- /* Notice it overwrites any HW decoder that may already have been registered for this type;
- this is normal.*/
-
- return M4NO_ERROR;
-
-#else
-
- return M4ERR_NOT_IMPLEMENTED;
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-}
-
-M4OSA_ERR
-M4VSS3GPP_editRegisterExternalVideoEncoder( M4VSS3GPP_EditContext pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface *pEncoderInterface,
- M4OSA_Void *pUserData )
-{
-#ifdef M4VSS_ENABLE_EXTERNAL_ENCODERS
-
- M4VSS3GPP_InternalEditContext *pC =
- (M4VSS3GPP_InternalEditContext *)pContext;
- M4OSA_ERR err = M4NO_ERROR;
- M4ENCODER_GlobalInterface *shellInterface;
- M4ENCODER_Format nativeType;
-
- switch( encoderType )
- {
- case M4VE_kH263VideoEnc:
- err = M4EGE_H263_getInterfaces(&nativeType, &shellInterface,
- M4ENCODER_OPEN_ADVANCED);
-
- break;
-
- case M4VE_kMpeg4VideoEnc:
- err = M4EGE_MPEG4_getInterfaces(&nativeType, &shellInterface,
- M4ENCODER_OPEN_ADVANCED);
- break;
-
- case M4VE_kH264VideoEnc:
- M4OSA_TRACE1_0(
- "M4VSS3GPP_editRegisterExternalVideoEncoder:\
- H264 encoder type not implemented yet");
- return M4ERR_NOT_IMPLEMENTED;
- break;
-
- default:
- M4OSA_TRACE1_1(
- "M4VSS3GPP_editRegisterExternalVideoEncoder: unknown encoderType %d",
- encoderType);
- return M4ERR_PARAMETER;
- break;
- }
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_editRegisterExternalVideoEncoder:\
- M4EGE_getInterface failed with error 0x%08X",
- err);
- return err;
- }
-
- err = M4VSS3GPP_registerVideoEncoder(&(pC->ShellAPI), nativeType,
- shellInterface);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_editRegisterExternalVideoEncoder:\
- M4VSS3GPP_registerVideoEncoder failed with error 0x%08X",
- err);
- free(shellInterface);
- return err;
- }
-
- pC->ShellAPI.pVideoEncoderExternalAPITable[nativeType] = pEncoderInterface;
- pC->ShellAPI.pVideoEncoderUserDataTable[nativeType] = pUserData;
-
- return M4NO_ERROR;
-
-#else
-
- return M4ERR_NOT_IMPLEMENTED;
-
-#endif
-
-}
-
#ifdef WIN32
/**
******************************************************************************
@@ -3303,49 +3172,6 @@ M4OSA_ERR M4VSS3GPP_intOpenClip( M4VSS3GPP_InternalEditContext *pC,
* Set shortcut */
pClip = *hClip;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
- /* replay recorded external decoder registrations on the clip */
-
- for ( i = 0; i < M4VD_kVideoType_NB; i++ )
- {
- if( pC->registeredExternalDecs[i].registered )
- {
- err = M4VSS3GPP_intClipRegisterExternalVideoDecoder(pClip, i,
- pC->registeredExternalDecs[i].pDecoderInterface,
- pC->registeredExternalDecs[i].pUserData);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intOpenClip:\
- M4VSS3GPP_intClipRegisterExternalVideoDecoder() returns 0x%x!",
- err);
- M4VSS3GPP_intClipCleanUp(pClip);
- return err;
- }
- }
- }
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-#ifdef M4VSS_SUPPORT_OMX_CODECS
-
- M4OSA_TRACE3_1("M4VSS3GPP_intOpenClip: pClip->ShellAPI = 0x%x",
- &pClip->ShellAPI);
- err = M4VSS3GPP_intSubscribeExternalCodecs((M4VSS3GPP_EditContext *)pC,
- (M4OSA_Context) &pClip->ShellAPI);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intOpenClip: M4VSS3GPP_intSubscribeExternalCodecs returned err 0x%x",
- err);
- }
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intOpenClip: M4VSS3GPP_intSubscribeExternalCodecs returned 0x%x",
- err);
-#endif /* M4VSS_SUPPORT_OMX_CODECS */
-
err = M4VSS3GPP_intClipOpen(pClip, pClipSettings, M4OSA_FALSE, M4OSA_FALSE,
M4OSA_FALSE);
@@ -3595,431 +3421,3 @@ static M4OSA_Void M4VSS3GPP_intComputeOutputAverageVideoBitrate(
pC->ewc.uiVideoBitrate = ( total_bitsum / total_duration) * 1000;
}
-#ifdef M4VSS_SUPPORT_OMX_CODECS
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_editRegisterExternalCodec(M4VSS3GPP_EditContext pContext,
- * M4VSS3GPP_codecType codecType,
- * M4OSA_Context pCodecInterface,
- * M4OSA_Void* pUserData)
- * @brief Registers an external Video/Audio codec with VSS3GPP
- * @note This is much different from the other external codec registration API to cope
- * up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @param codecType (IN) Type of codec (MPEG4 ...)
- * @param pCodecInterface (IN) Codec interface
- * @param pUserData (IN) Pointer on a user data to give to external codec
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for
- * this function to be called
- ******************************************************************************
- */
-
-M4OSA_ERR M4VSS3GPP_editRegisterExternalCodec( M4VSS3GPP_EditContext pContext,
- M4VSS3GPP_codecType codecType,
- M4OSA_Context pCodecInterface,
- M4OSA_Void *pUserData )
-{
- M4VSS3GPP_InternalEditContext *pC =
- (M4VSS3GPP_InternalEditContext *)pContext;
- M4OSA_ERR err = M4NO_ERROR;
-
- if( ( M4OSA_NULL == pContext) || (M4OSA_NULL == pCodecInterface) )
- {
- M4OSA_TRACE1_2(
- "M4VSS3GPP_editRegisterExternalCodec: NULL input parameter; pContext=0x%x,\
- pCodecInterface=0x%x",
- pContext, pCodecInterface);
- return M4ERR_PARAMETER;
- }
-
- if( codecType >= M4VSS3GPP_kCodecType_NB )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_editRegisterExternalCodec: invalid codec Type; codecType=0x%x",
- codecType);
- return M4ERR_PARAMETER;
- }
-
- pC->m_codecInterface[codecType] = pCodecInterface;
- pC->pOMXUserData = pUserData;
-
- M4OSA_TRACE3_2(
- "M4VSS3GPP_editRegisterExternalCodec: pC->m_codecInterface[%d] = 0x%x",
- codecType, pCodecInterface);
- M4OSA_TRACE3_1(
- "M4VSS3GPP_editRegisterExternalCodec: pC->pOMXUserDatat = 0x%x",
- pUserData);
-
- return M4NO_ERROR;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_editSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext)
- * @brief Subscribes to previously registered external Video/Audio codec
- * @note This is much different from the other external codec registration API to cope
- * up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for
- * this function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4VSS3GPP_editSubscribeExternalCodecs(
- M4VSS3GPP_EditContext pContext )
-{
- M4VSS3GPP_InternalEditContext *pC =
- (M4VSS3GPP_InternalEditContext *)pContext;
- M4OSA_ERR err = M4NO_ERROR;
-
- if( M4OSA_NULL == pContext )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_editSubscribeExternalCodecs: NULL input parameter; pContext=0x%x",
- pContext);
- return M4ERR_PARAMETER;
- }
-
- M4OSA_TRACE3_1(
- "M4VSS3GPP_editSubscribeExternalCodecs: &pC->ShellAPI = 0x%x",
- &pC->ShellAPI);
- err = M4VSS3GPP_intSubscribeExternalCodecs(pContext,
- (M4OSA_Context) &pC->ShellAPI);
- M4OSA_TRACE3_1(
- "M4VSS3GPP_editSubscribeExternalCodecs:\
- M4VSS3GPP_intSubscribeExternalCodecs returns 0x%x",
- err);
- return err;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4VSS3GPP_intSubscribeExternalCodecs(M4VSS3GPP_EditContext pContext,
- * M4OSA_Context pShellCtxt)
- * @brief Subscribes to previously registered external Video/Audio codec
- * @note This is much different from the other external codec registration API to cope
- * up with specific requirement of OMX codec implementation.
- *
- * @param pContext (IN) VSS3GPP context
- * @param pShellContext (IN) Media Codec shell context
- * @return M4NO_ERROR: No error
- * @return M4ERR_PARAMETER: At least one parameter is M4OSA_NULL (debug only)
- * @return M4ERR_STATE: VSS3GPP is not in an appropriate state for
- * this function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4VSS3GPP_intSubscribeExternalCodecs( M4VSS3GPP_EditContext pContext,
- M4OSA_Context pShellCtxt )
-{
- M4VSS3GPP_InternalEditContext *pC =
- (M4VSS3GPP_InternalEditContext *)pContext;
- M4VSS3GPP_MediaAndCodecCtxt *pShellContext =
- (M4VSS3GPP_MediaAndCodecCtxt *)pShellCtxt;
- M4OSA_ERR err = M4NO_ERROR;
-
- if( ( M4OSA_NULL == pContext) || (M4OSA_NULL == pShellContext) )
- {
- M4OSA_TRACE1_2(
- "M4VSS3GPP_intSubscribeExternalCodecs: NULL input parameter; pContext=0x%x,\
- pShellContext=0x%x",
- pContext, pShellContext);
- return M4ERR_PARAMETER;
- }
-
- M4OSA_TRACE3_1("M4VSS3GPP_intSubscribeExternalCodecs: pShellContext=0x%x",
- pShellContext);
-
-#ifdef M4VSS_SUPPORT_VIDEC_3GP
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kVideoDecMPEG4] )
- {
- err = M4VSS3GPP_registerVideoDecoder(pShellContext,
- M4DECODER_kVideoTypeMPEG4, (M4DECODER_VideoInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoDecMPEG4]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoDecoder(Mpeg4) returned err 0x%x",
- err);
- return err;
- }
- /** Provide the application user data back to the interface functions. **
- **/
- pShellContext->m_pVideoDecoderUserDataTable[M4DECODER_kVideoTypeMPEG4] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoDecoder(Mpeg4) OK: 0x%x",
- (M4DECODER_VideoInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoDecMPEG4]);
- }
-
-#endif /* M4VSS_SUPPORT_VIDEC_3GP */
-
-#ifdef M4VSS_SUPPORT_VIDEO_AVC
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kVideoDecH264] )
- {
- err = M4VSS3GPP_registerVideoDecoder(pShellContext,
- M4DECODER_kVideoTypeAVC, (M4DECODER_VideoInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoDecH264]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoDecoder(AVC) returned err 0x%x",
- err);
- return err;
- }
- /** Provide the application user data back to the interface functions. **
- **/
- pShellContext->m_pVideoDecoderUserDataTable[M4DECODER_kVideoTypeAVC] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerVideoDecoder(H264) OK: 0x%x",
- (M4DECODER_VideoInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoDecH264]);
- }
-
-#endif /* M4VSS_SUPPORT_VIDEO_AVC*/
-
-#ifdef M4VSS_SUPPORT_ENCODER_MPEG4
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kVideoEncMPEG4] )
- {
- err = M4VSS3GPP_registerVideoEncoder(pShellContext, M4ENCODER_kMPEG4,
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncMPEG4]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoEncoder(Mpeg4) returned err 0x%x",
- err);
- return err;
- }
- /** Provide the application user data back to the interface functions. **
- **/
- pShellContext->pVideoEncoderUserDataTable[M4ENCODER_kMPEG4] =
- pC->pOMXUserData;
- pShellContext->pVideoEncoderExternalAPITable[M4ENCODER_kMPEG4] =
- pC->m_codecInterface[M4VSS3GPP_kVideoEncMPEG4];
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoEncoder(Mpeg4) OK: 0x%x",
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncMPEG4]);
- }
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kVideoEncH263] )
- {
- err = M4VSS3GPP_registerVideoEncoder(pShellContext, M4ENCODER_kH263,
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncH263]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoEncoder(H263) returned err 0x%x",
- err);
- return err;
- }
- /** Provide the application user data back to the interface functions. **
- **/
- pShellContext->pVideoEncoderUserDataTable[M4ENCODER_kH263] =
- pC->pOMXUserData;
- pShellContext->pVideoEncoderExternalAPITable[M4ENCODER_kH263] =
- pC->m_codecInterface[M4VSS3GPP_kVideoEncH263];
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerVideoEncoder(H263) OK: 0x%x",
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncH263]);
- }
-
-#endif /* M4VSS_SUPPORT_ENCODER_MPEG4 */
-
-#ifdef M4VSS_SUPPORT_ENCODER_AVC
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kVideoEncH264] )
- {
- err = M4VSS3GPP_registerVideoEncoder(pShellContext, M4ENCODER_kH264,
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncH264]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerVideoEncoder(H264) returned err 0x%x",
- err);
- return err;
- }
- /** Provide the application user data back to the interface functions. **
- **/
- pShellContext->pVideoEncoderUserDataTable[M4ENCODER_kH264] =
- pC->pOMXUserData;
- pShellContext->pVideoEncoderExternalAPITable[M4ENCODER_kH264] =
- pC->m_codecInterface[M4VSS3GPP_kVideoEncH264];
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerVideoEncoder(H264) OK: 0x%x",
- (M4ENCODER_GlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kVideoEncH264]);
- }
-
-#endif /* M4VSS_SUPPORT_ENCODER_AVC */
-
-#ifdef M4VSS_SUPPORT_AUDEC_AAC
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kAudioDecAAC] )
- {
- err = M4VSS3GPP_registerAudioDecoder(pShellContext, M4AD_kTypeAAC,
- (M4AD_Interface *)pC->m_codecInterface[M4VSS3GPP_kAudioDecAAC]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioDecoder(AAC) returned err 0x%x",
- err);
- return err;
- }
- pShellContext->pAudioDecoderUserDataTable[M4AD_kTypeAAC] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerAudioDecoder(AAC) OK: 0x%x",
- (M4AD_Interface *)pC->m_codecInterface[M4VSS3GPP_kAudioDecAAC]);
- }
-
-#endif /* M4VSS_SUPPORT_AUDEC_AAC*/
-
-#ifdef M4VSS_SUPPORT_AUDEC_AMRNB
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kAudioDecAMRNB] )
- {
- err = M4VSS3GPP_registerAudioDecoder(pShellContext, M4AD_kTypeAMRNB,
- (M4AD_Interface
- *)pC->m_codecInterface[M4VSS3GPP_kAudioDecAMRNB]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioDecoder(AMRNB) returned err 0x%x",
- err);
- return err;
- }
- pShellContext->pAudioDecoderUserDataTable[M4AD_kTypeAMRNB] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioDecoder(AMRNB) OK: 0x%x",
- (M4AD_Interface *)pC->m_codecInterface[M4VSS3GPP_kAudioDecAMRNB]);
- }
-
-#endif /* M4VSS_SUPPORT_AUDEC_AMRNB*/
-
-#ifdef M4VSS_SUPPORT_AUDEC_MP3
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kAudioDecMP3] )
- {
- err = M4VSS3GPP_registerAudioDecoder(pShellContext, M4AD_kTypeMP3,
- (M4AD_Interface *)pC->m_codecInterface[M4VSS3GPP_kAudioDecMP3]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioDecoder(MP3) returned err 0x%x",
- err);
- return err;
- }
- pShellContext->pAudioDecoderUserDataTable[M4AD_kTypeMP3] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerAudioDecoder(MP3) OK: 0x%x",
- (M4AD_Interface *)pC->m_codecInterface[M4VSS3GPP_kAudioDecMP3]);
- }
-
-#endif /* M4VSS_SUPPORT_AUDEC_MP3*/
-
-#ifdef M4VSS_SUPPORT_ENCODER_AAC
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kAudioEncAAC] )
- {
- err = M4VSS3GPP_registerAudioEncoder(pShellContext, M4ENCODER_kAAC,
- (M4ENCODER_AudioGlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kAudioEncAAC]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioEncoder(AAC) returned err 0x%x",
- err);
- return err;
- }
- pShellContext->pAudioEncoderUserDataTable[M4ENCODER_kAAC] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs: M4VSS3GPP_registerAudioEncoder(AAC) OK: 0x%x",
- (M4ENCODER_AudioGlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kAudioEncAAC]);
- }
-
-#endif /* M4VSS_SUPPORT_ENCODER_AAC*/
-
-#ifdef M4VSS_SUPPORT_ENCODER_AMR
-
- if( M4OSA_NULL != pC->m_codecInterface[M4VSS3GPP_kAudioEncAMRNB] )
- {
- err = M4VSS3GPP_registerAudioEncoder(pShellContext, M4ENCODER_kAMRNB,
- (M4ENCODER_AudioGlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kAudioEncAMRNB]);
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioEncoder(AMRNB) returned err 0x%x",
- err);
- return err;
- }
- pShellContext->pAudioEncoderUserDataTable[M4ENCODER_kAMRNB] =
- pC->pOMXUserData;
- M4OSA_TRACE3_1(
- "M4VSS3GPP_intSubscribeExternalCodecs:\
- M4VSS3GPP_registerAudioEncoder(AMRNB) OK: 0x%x",
- (M4ENCODER_AudioGlobalInterface
- *)pC->m_codecInterface[M4VSS3GPP_kAudioEncAMRNB]);
- }
-
-#endif /* M4VSS_SUPPORT_ENCODER_AMR*/
-
- if( M4OSA_NULL != pC->pOMXUserData )
- {
- /* If external OMX codecs are already registered with VSS3GPP internal context
- * and are being subscribed by application, *
- * then set boolean to prevent unregistration of external codec interfaces. *
- * This is to prevent external codec interfaces from being reset
- during VSS3GPP step function. *
- * External OMX codecs are registered only once by application.
- So pointers should remain valid*
- * throughout life cycle of the application */
-
- pShellContext->bAllowFreeingOMXCodecInterface = M4OSA_FALSE;
- }
-
- return M4NO_ERROR;
-}
-#endif /* M4VSS_SUPPORT_OMX_CODECS */
diff --git a/libvideoeditor/vss/src/M4xVSS_API.c b/libvideoeditor/vss/src/M4xVSS_API.c
index 8750fec..e99cfe5 100755
--- a/libvideoeditor/vss/src/M4xVSS_API.c
+++ b/libvideoeditor/vss/src/M4xVSS_API.c
@@ -30,7 +30,6 @@
#include "M4OSA_Debug.h"
#include "M4OSA_FileReader.h"
#include "M4OSA_FileWriter.h"
-#include "M4OSA_FileExtra.h"
#include "M4OSA_CoreID.h"
#include "M4OSA_CharStar.h"
// StageFright encoders require %16 resolution
@@ -218,23 +217,6 @@ M4OSA_ERR M4xVSS_Init( M4OSA_Context *pContext, M4xVSS_InitParams *pParams )
/*FB: initialize to avoid crash when error during the editing*/
xVSS_context->pCurrentEditSettings = M4OSA_NULL;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
- for ( i = 0; i < M4VD_kVideoType_NB; i++ )
- {
- xVSS_context->registeredExternalDecs[i].pDecoderInterface = M4OSA_NULL;
- xVSS_context->registeredExternalDecs[i].pUserData = M4OSA_NULL;
- xVSS_context->registeredExternalDecs[i].registered = M4OSA_FALSE;
- }
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
- for ( i = 0; i < M4VE_kEncoderType_NB; i++ )
- {
- xVSS_context->registeredExternalEncs[i].pEncoderInterface = M4OSA_NULL;
- xVSS_context->registeredExternalEncs[i].pUserData = M4OSA_NULL;
- xVSS_context->registeredExternalEncs[i].registered = M4OSA_FALSE;
- }
-
/* Initialize state if all initializations are corrects */
xVSS_context->m_state = M4xVSS_kStateInitialized;
@@ -6101,65 +6083,6 @@ M4OSA_ERR M4xVSS_CleanUp( M4OSA_Context pContext )
return M4NO_ERROR;
}
-M4OSA_ERR M4xVSS_RegisterExternalVideoDecoder( M4OSA_Context pContext,
- M4VD_VideoType decoderType,
- M4VD_Interface *pDecoderInterface,
- M4OSA_Void *pUserData )
-{
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-
- M4xVSS_Context *xVSS_context = (M4xVSS_Context *)pContext;
- /* Here the situation is a bit special: we need to record the registrations that are made,
- so that we can replay them for each clip we create. */
-
- if( decoderType >= M4VD_kVideoType_NB )
- {
- return M4ERR_PARAMETER;
- }
-
- xVSS_context->registeredExternalDecs[decoderType].pDecoderInterface =
- pDecoderInterface;
- xVSS_context->registeredExternalDecs[decoderType].pUserData = pUserData;
- xVSS_context->registeredExternalDecs[decoderType].registered = M4OSA_TRUE;
-
- /* Notice it overwrites any HW decoder that may already have been registered for this type;
- this is normal.*/
-
- return M4NO_ERROR;
-
-#else
-
- return M4ERR_NOT_IMPLEMENTED;
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
-}
-
-M4OSA_ERR M4xVSS_RegisterExternalVideoEncoder( M4OSA_Context pContext,
- M4VE_EncoderType encoderType,
- M4VE_Interface *pEncoderInterface,
- M4OSA_Void *pUserData )
-{
- M4xVSS_Context *xVSS_context = (M4xVSS_Context *)pContext;
- /* Here the situation is a bit special: we need to record the registrations that are made,
- so that we can replay them for each clip we create. */
-
- if( encoderType >= M4VE_kEncoderType_NB )
- {
- return M4ERR_PARAMETER;
- }
-
- xVSS_context->registeredExternalEncs[encoderType].pEncoderInterface =
- pEncoderInterface;
- xVSS_context->registeredExternalEncs[encoderType].pUserData = pUserData;
- xVSS_context->registeredExternalEncs[encoderType].registered = M4OSA_TRUE;
-
- /* Notice it overwrites any HW encoder that may already have been registered for this type;
- this is normal.*/
-
- return M4NO_ERROR;
-}
-
/**
******************************************************************************
* prototype M4xVSS_GetVersion(M4_VersionInfo *pVersion)
diff --git a/libvideoeditor/vss/src/M4xVSS_internal.c b/libvideoeditor/vss/src/M4xVSS_internal.c
index e7e2dfd..391c945 100755
--- a/libvideoeditor/vss/src/M4xVSS_internal.c
+++ b/libvideoeditor/vss/src/M4xVSS_internal.c
@@ -23,7 +23,6 @@
*/
#include "M4OSA_Debug.h"
#include "M4OSA_CharStar.h"
-#include "M4OSA_FileExtra.h"
#include "NXPSW_CompilerSwitches.h"
@@ -94,44 +93,6 @@ M4OSA_ERR M4xVSS_internalStartTranscoding(M4OSA_Context pContext)
return err;
}
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
- /* replay recorded external decoder registrations on the MCS */
- for (i=0; i<M4VD_kVideoType_NB; i++)
- {
- if (xVSS_context->registeredExternalDecs[i].registered)
- {
- err = M4MCS_registerExternalVideoDecoder(mcs_context, i,
- xVSS_context->registeredExternalDecs[i].pDecoderInterface,
- xVSS_context->registeredExternalDecs[i].pUserData);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4xVSS_internalStartTranscoding:\
- M4MCS_registerExternalVideoDecoder() returns 0x%x!", err);
- M4MCS_abort(mcs_context);
- return err;
- }
- }
- }
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
- /* replay recorded external encoder registrations on the MCS */
- for (i=0; i<M4VE_kEncoderType_NB; i++)
- {
- if (xVSS_context->registeredExternalEncs[i].registered)
- {
- err = M4MCS_registerExternalVideoEncoder(mcs_context, i,
- xVSS_context->registeredExternalEncs[i].pEncoderInterface,
- xVSS_context->registeredExternalEncs[i].pUserData);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4xVSS_internalStartTranscoding:\
- M4MCS_registerExternalVideoEncoder() returns 0x%x!", err);
- M4MCS_abort(mcs_context);
- return err;
- }
- }
- }
-
err = M4MCS_open(mcs_context, xVSS_context->pMCScurrentParams->pFileIn,
xVSS_context->pMCScurrentParams->InputFileType,
xVSS_context->pMCScurrentParams->pFileOut,
@@ -1550,24 +1511,6 @@ M4OSA_ERR M4xVSS_internalStartConvertPictureTo3gp(M4OSA_Context pContext)
return err;
}
- /* replay recorded external encoder registrations on the PTO3GPP */
- for (i=0; i<M4VE_kEncoderType_NB; i++)
- {
- if (xVSS_context->registeredExternalEncs[i].registered)
- {
- err = M4PTO3GPP_RegisterExternalVideoEncoder(pM4PTO3GPP_Ctxt, i,
- xVSS_context->registeredExternalEncs[i].pEncoderInterface,
- xVSS_context->registeredExternalEncs[i].pUserData);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4xVSS_internalGenerateEditedFile:\
- M4PTO3GPP_registerExternalVideoEncoder() returns 0x%x!", err);
- M4PTO3GPP_CleanUp(pM4PTO3GPP_Ctxt);
- return err;
- }
- }
- }
-
pCallBackCtxt = (M4xVSS_PictureCallbackCtxt*)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_PictureCallbackCtxt),
M4VS,(M4OSA_Char *) "Pto3gpp callback struct");
if(pCallBackCtxt == M4OSA_NULL)
@@ -2406,44 +2349,6 @@ M4OSA_ERR M4xVSS_internalGenerateEditedFile(M4OSA_Context pContext)
return err;
}
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
- /* replay recorded external decoder registrations on the VSS3GPP */
- for (i=0; i<M4VD_kVideoType_NB; i++)
- {
- if (xVSS_context->registeredExternalDecs[i].registered)
- {
- err = M4VSS3GPP_editRegisterExternalVideoDecoder(pVssCtxt, i,
- xVSS_context->registeredExternalDecs[i].pDecoderInterface,
- xVSS_context->registeredExternalDecs[i].pUserData);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4xVSS_internalGenerateEditedFile: \
- M4VSS3GPP_editRegisterExternalVideoDecoder() returns 0x%x!", err);
- M4VSS3GPP_editCleanUp(pVssCtxt);
- return err;
- }
- }
- }
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
-
- /* replay recorded external encoder registrations on the VSS3GPP */
- for (i=0; i<M4VE_kEncoderType_NB; i++)
- {
- if (xVSS_context->registeredExternalEncs[i].registered)
- {
- err = M4VSS3GPP_editRegisterExternalVideoEncoder(pVssCtxt, i,
- xVSS_context->registeredExternalEncs[i].pEncoderInterface,
- xVSS_context->registeredExternalEncs[i].pUserData);
- if (M4NO_ERROR != err)
- {
- M4OSA_TRACE1_1("M4xVSS_internalGenerateEditedFile:\
- M4VSS3GPP_editRegisterExternalVideoEncoder() returns 0x%x!", err);
- M4VSS3GPP_editCleanUp(pVssCtxt);
- return err;
- }
- }
- }
-
/* In case of MMS use case, we fill directly into the VSS context the targeted bitrate */
if(xVSS_context->targetedBitrate != 0)
{