Reconcile with honeycomb-release

Change-Id: Ibbe91b2c58ef41c449cb4b125b4b6e4034a71ed5
diff --git a/libvideoeditor/lvpp/Android.mk b/libvideoeditor/lvpp/Android.mk
index 37b8511..8b5a6f5 100755
--- a/libvideoeditor/lvpp/Android.mk
+++ b/libvideoeditor/lvpp/Android.mk
@@ -35,6 +35,8 @@
     DummyAudioSource.cpp \

     DummyVideoSource.cpp \

     VideoEditorBGAudioProcessing.cpp \

+    AudioPlayerBase.cpp \

+    PreviewPlayerBase.cpp \

     PreviewRenderer.cpp

 

 LOCAL_MODULE_TAGS := optional

@@ -50,10 +52,11 @@
     libutils           \

     libcutils          \

     libmedia           \

+    libdrmframework    \

     libstagefright  \

     libstagefright_omx  \

     libstagefright_foundation \

-    libsurfaceflinger_client \

+    libgui \

     libaudioflinger \

     libui

 

@@ -98,11 +101,6 @@
     -DUSE_STAGEFRIGHT_READERS \

     -DUSE_STAGEFRIGHT_3GPP_READER

 

-

-# Don't prelink this library.  For more efficient code, you may want

-# to add this library to the prelink map and set this to true.

-LOCAL_PRELINK_MODULE := false

-

 include $(BUILD_SHARED_LIBRARY)

 

 #include $(call all-makefiles-under,$(LOCAL_PATH))

diff --git a/libvideoeditor/lvpp/AudioPlayerBase.cpp b/libvideoeditor/lvpp/AudioPlayerBase.cpp
new file mode 100644
index 0000000..26c6a63
--- /dev/null
+++ b/libvideoeditor/lvpp/AudioPlayerBase.cpp
@@ -0,0 +1,510 @@
+/*
+ * 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.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "AudioPlayerBase"
+#include <utils/Log.h>
+
+#include <binder/IPCThreadState.h>
+#include <media/AudioTrack.h>
+#include <media/stagefright/MediaDebug.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+
+#include "AudioPlayerBase.h"
+#include "PreviewPlayerBase.h"
+
+namespace android {
+
+AudioPlayerBase::AudioPlayerBase(
+        const sp<MediaPlayerBase::AudioSink> &audioSink,
+        PreviewPlayerBase *observer)
+    : mAudioTrack(NULL),
+      mInputBuffer(NULL),
+      mSampleRate(0),
+      mLatencyUs(0),
+      mFrameSize(0),
+      mNumFramesPlayed(0),
+      mPositionTimeMediaUs(-1),
+      mPositionTimeRealUs(-1),
+      mSeeking(false),
+      mReachedEOS(false),
+      mFinalStatus(OK),
+      mStarted(false),
+      mIsFirstBuffer(false),
+      mFirstBufferResult(OK),
+      mFirstBuffer(NULL),
+      mAudioSink(audioSink),
+      mObserver(observer) {
+}
+
+AudioPlayerBase::~AudioPlayerBase() {
+    if (mStarted) {
+        reset();
+    }
+}
+
+void AudioPlayerBase::setSource(const sp<MediaSource> &source) {
+    CHECK_EQ(mSource, NULL);
+    mSource = source;
+}
+
+status_t AudioPlayerBase::start(bool sourceAlreadyStarted) {
+    CHECK(!mStarted);
+    CHECK(mSource != NULL);
+
+    status_t err;
+    if (!sourceAlreadyStarted) {
+        err = mSource->start();
+
+        if (err != OK) {
+            return err;
+        }
+    }
+
+    // We allow an optional INFO_FORMAT_CHANGED at the very beginning
+    // of playback, if there is one, getFormat below will retrieve the
+    // updated format, if there isn't, we'll stash away the valid buffer
+    // of data to be used on the first audio callback.
+
+    CHECK(mFirstBuffer == NULL);
+
+    mFirstBufferResult = mSource->read(&mFirstBuffer);
+    if (mFirstBufferResult == INFO_FORMAT_CHANGED) {
+        LOGV("INFO_FORMAT_CHANGED!!!");
+
+        CHECK(mFirstBuffer == NULL);
+        mFirstBufferResult = OK;
+        mIsFirstBuffer = false;
+    } else {
+        mIsFirstBuffer = true;
+    }
+
+    sp<MetaData> format = mSource->getFormat();
+    const char *mime;
+    bool success = format->findCString(kKeyMIMEType, &mime);
+    CHECK(success);
+    CHECK(!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW));
+
+    success = format->findInt32(kKeySampleRate, &mSampleRate);
+    CHECK(success);
+
+    int32_t numChannels;
+    success = format->findInt32(kKeyChannelCount, &numChannels);
+    CHECK(success);
+
+    if (mAudioSink.get() != NULL) {
+        status_t err = mAudioSink->open(
+                mSampleRate, numChannels, AUDIO_FORMAT_PCM_16_BIT,
+                DEFAULT_AUDIOSINK_BUFFERCOUNT,
+                &AudioPlayerBase::AudioSinkCallback, this);
+        if (err != OK) {
+            if (mFirstBuffer != NULL) {
+                mFirstBuffer->release();
+                mFirstBuffer = NULL;
+            }
+
+            if (!sourceAlreadyStarted) {
+                mSource->stop();
+            }
+
+            return err;
+        }
+
+        mLatencyUs = (int64_t)mAudioSink->latency() * 1000;
+        mFrameSize = mAudioSink->frameSize();
+
+        mAudioSink->start();
+    } else {
+        mAudioTrack = new AudioTrack(
+                AUDIO_STREAM_MUSIC, mSampleRate, AUDIO_FORMAT_PCM_16_BIT,
+                (numChannels == 2)
+                    ? AUDIO_CHANNEL_OUT_STEREO
+                    : AUDIO_CHANNEL_OUT_MONO,
+                0, 0, &AudioCallback, this, 0);
+
+        if ((err = mAudioTrack->initCheck()) != OK) {
+            delete mAudioTrack;
+            mAudioTrack = NULL;
+
+            if (mFirstBuffer != NULL) {
+                mFirstBuffer->release();
+                mFirstBuffer = NULL;
+            }
+
+            if (!sourceAlreadyStarted) {
+                mSource->stop();
+            }
+
+            return err;
+        }
+
+        mLatencyUs = (int64_t)mAudioTrack->latency() * 1000;
+        mFrameSize = mAudioTrack->frameSize();
+
+        mAudioTrack->start();
+    }
+
+    mStarted = true;
+
+    return OK;
+}
+
+void AudioPlayerBase::pause(bool playPendingSamples) {
+    CHECK(mStarted);
+
+    if (playPendingSamples) {
+        if (mAudioSink.get() != NULL) {
+            mAudioSink->stop();
+        } else {
+            mAudioTrack->stop();
+        }
+    } else {
+        if (mAudioSink.get() != NULL) {
+            mAudioSink->pause();
+        } else {
+            mAudioTrack->pause();
+        }
+    }
+}
+
+void AudioPlayerBase::resume() {
+    CHECK(mStarted);
+
+    if (mAudioSink.get() != NULL) {
+        mAudioSink->start();
+    } else {
+        mAudioTrack->start();
+    }
+}
+
+void AudioPlayerBase::reset() {
+    CHECK(mStarted);
+
+    if (mAudioSink.get() != NULL) {
+        mAudioSink->stop();
+        mAudioSink->close();
+    } else {
+        mAudioTrack->stop();
+
+        delete mAudioTrack;
+        mAudioTrack = NULL;
+    }
+
+    // Make sure to release any buffer we hold onto so that the
+    // source is able to stop().
+
+    if (mFirstBuffer != NULL) {
+        mFirstBuffer->release();
+        mFirstBuffer = NULL;
+    }
+
+    if (mInputBuffer != NULL) {
+        LOGV("AudioPlayerBase releasing input buffer.");
+
+        mInputBuffer->release();
+        mInputBuffer = NULL;
+    }
+
+    mSource->stop();
+
+    // The following hack is necessary to ensure that the OMX
+    // component is completely released by the time we may try
+    // to instantiate it again.
+    wp<MediaSource> tmp = mSource;
+    mSource.clear();
+    while (tmp.promote() != NULL) {
+        usleep(1000);
+    }
+    IPCThreadState::self()->flushCommands();
+
+    mNumFramesPlayed = 0;
+    mPositionTimeMediaUs = -1;
+    mPositionTimeRealUs = -1;
+    mSeeking = false;
+    mReachedEOS = false;
+    mFinalStatus = OK;
+    mStarted = false;
+}
+
+// static
+void AudioPlayerBase::AudioCallback(int event, void *user, void *info) {
+    static_cast<AudioPlayerBase *>(user)->AudioCallback(event, info);
+}
+
+bool AudioPlayerBase::isSeeking() {
+    Mutex::Autolock autoLock(mLock);
+    return mSeeking;
+}
+
+bool AudioPlayerBase::reachedEOS(status_t *finalStatus) {
+    *finalStatus = OK;
+
+    Mutex::Autolock autoLock(mLock);
+    *finalStatus = mFinalStatus;
+    return mReachedEOS;
+}
+
+// static
+size_t AudioPlayerBase::AudioSinkCallback(
+        MediaPlayerBase::AudioSink *audioSink,
+        void *buffer, size_t size, void *cookie) {
+    AudioPlayerBase *me = (AudioPlayerBase *)cookie;
+
+    return me->fillBuffer(buffer, size);
+}
+
+void AudioPlayerBase::AudioCallback(int event, void *info) {
+    if (event != AudioTrack::EVENT_MORE_DATA) {
+        return;
+    }
+
+    AudioTrack::Buffer *buffer = (AudioTrack::Buffer *)info;
+    size_t numBytesWritten = fillBuffer(buffer->raw, buffer->size);
+
+    buffer->size = numBytesWritten;
+}
+
+uint32_t AudioPlayerBase::getNumFramesPendingPlayout() const {
+    uint32_t numFramesPlayedOut;
+    status_t err;
+
+    if (mAudioSink != NULL) {
+        err = mAudioSink->getPosition(&numFramesPlayedOut);
+    } else {
+        err = mAudioTrack->getPosition(&numFramesPlayedOut);
+    }
+
+    if (err != OK || mNumFramesPlayed < numFramesPlayedOut) {
+        return 0;
+    }
+
+    // mNumFramesPlayed is the number of frames submitted
+    // to the audio sink for playback, but not all of them
+    // may have played out by now.
+    return mNumFramesPlayed - numFramesPlayedOut;
+}
+
+size_t AudioPlayerBase::fillBuffer(void *data, size_t size) {
+    if (mNumFramesPlayed == 0) {
+        LOGV("AudioCallback");
+    }
+
+    if (mReachedEOS) {
+        return 0;
+    }
+
+    bool postSeekComplete = false;
+    bool postEOS = false;
+    int64_t postEOSDelayUs = 0;
+
+    size_t size_done = 0;
+    size_t size_remaining = size;
+    while (size_remaining > 0) {
+        MediaSource::ReadOptions options;
+
+        {
+            Mutex::Autolock autoLock(mLock);
+
+            if (mSeeking) {
+                if (mIsFirstBuffer) {
+                    if (mFirstBuffer != NULL) {
+                        mFirstBuffer->release();
+                        mFirstBuffer = NULL;
+                    }
+                    mIsFirstBuffer = false;
+                }
+
+                options.setSeekTo(mSeekTimeUs);
+
+                if (mInputBuffer != NULL) {
+                    mInputBuffer->release();
+                    mInputBuffer = NULL;
+                }
+
+                mSeeking = false;
+                if (mObserver) {
+                    postSeekComplete = true;
+                }
+            }
+        }
+
+        if (mInputBuffer == NULL) {
+            status_t err;
+
+            if (mIsFirstBuffer) {
+                mInputBuffer = mFirstBuffer;
+                mFirstBuffer = NULL;
+                err = mFirstBufferResult;
+
+                mIsFirstBuffer = false;
+            } else {
+                err = mSource->read(&mInputBuffer, &options);
+            }
+
+            CHECK((err == OK && mInputBuffer != NULL)
+                   || (err != OK && mInputBuffer == NULL));
+
+            Mutex::Autolock autoLock(mLock);
+
+            if (err != OK) {
+                if (mObserver && !mReachedEOS) {
+                    // We don't want to post EOS right away but only
+                    // after all frames have actually been played out.
+
+                    // These are the number of frames submitted to the
+                    // AudioTrack that you haven't heard yet.
+                    uint32_t numFramesPendingPlayout =
+                        getNumFramesPendingPlayout();
+
+                    // These are the number of frames we're going to
+                    // submit to the AudioTrack by returning from this
+                    // callback.
+                    uint32_t numAdditionalFrames = size_done / mFrameSize;
+
+                    numFramesPendingPlayout += numAdditionalFrames;
+
+                    int64_t timeToCompletionUs =
+                        (1000000ll * numFramesPendingPlayout) / mSampleRate;
+
+                    LOGV("total number of frames played: %lld (%lld us)",
+                            (mNumFramesPlayed + numAdditionalFrames),
+                            1000000ll * (mNumFramesPlayed + numAdditionalFrames)
+                                / mSampleRate);
+
+                    LOGV("%d frames left to play, %lld us (%.2f secs)",
+                         numFramesPendingPlayout,
+                         timeToCompletionUs, timeToCompletionUs / 1E6);
+
+                    postEOS = true;
+                    postEOSDelayUs = timeToCompletionUs + mLatencyUs;
+                }
+
+                mReachedEOS = true;
+                mFinalStatus = err;
+                break;
+            }
+
+            CHECK(mInputBuffer->meta_data()->findInt64(
+                        kKeyTime, &mPositionTimeMediaUs));
+
+            mPositionTimeRealUs =
+                ((mNumFramesPlayed + size_done / mFrameSize) * 1000000)
+                    / mSampleRate;
+
+            LOGV("buffer->size() = %d, "
+                 "mPositionTimeMediaUs=%.2f mPositionTimeRealUs=%.2f",
+                 mInputBuffer->range_length(),
+                 mPositionTimeMediaUs / 1E6, mPositionTimeRealUs / 1E6);
+        }
+
+        if (mInputBuffer->range_length() == 0) {
+            mInputBuffer->release();
+            mInputBuffer = NULL;
+
+            continue;
+        }
+
+        size_t copy = size_remaining;
+        if (copy > mInputBuffer->range_length()) {
+            copy = mInputBuffer->range_length();
+        }
+
+        memcpy((char *)data + size_done,
+               (const char *)mInputBuffer->data() + mInputBuffer->range_offset(),
+               copy);
+
+        mInputBuffer->set_range(mInputBuffer->range_offset() + copy,
+                                mInputBuffer->range_length() - copy);
+
+        size_done += copy;
+        size_remaining -= copy;
+    }
+
+    {
+        Mutex::Autolock autoLock(mLock);
+        mNumFramesPlayed += size_done / mFrameSize;
+    }
+
+    if (postEOS) {
+        mObserver->postAudioEOS(postEOSDelayUs);
+    }
+
+    if (postSeekComplete) {
+        mObserver->postAudioSeekComplete();
+    }
+
+    return size_done;
+}
+
+int64_t AudioPlayerBase::getRealTimeUs() {
+    Mutex::Autolock autoLock(mLock);
+    return getRealTimeUsLocked();
+}
+
+int64_t AudioPlayerBase::getRealTimeUsLocked() const {
+    return -mLatencyUs + (mNumFramesPlayed * 1000000) / mSampleRate;
+}
+
+int64_t AudioPlayerBase::getMediaTimeUs() {
+    Mutex::Autolock autoLock(mLock);
+
+    if (mPositionTimeMediaUs < 0 || mPositionTimeRealUs < 0) {
+        if (mSeeking) {
+            return mSeekTimeUs;
+        }
+
+        return 0;
+    }
+
+    int64_t realTimeOffset = getRealTimeUsLocked() - mPositionTimeRealUs;
+    if (realTimeOffset < 0) {
+        realTimeOffset = 0;
+    }
+
+    return mPositionTimeMediaUs + realTimeOffset;
+}
+
+bool AudioPlayerBase::getMediaTimeMapping(
+        int64_t *realtime_us, int64_t *mediatime_us) {
+    Mutex::Autolock autoLock(mLock);
+
+    *realtime_us = mPositionTimeRealUs;
+    *mediatime_us = mPositionTimeMediaUs;
+
+    return mPositionTimeRealUs != -1 && mPositionTimeMediaUs != -1;
+}
+
+status_t AudioPlayerBase::seekTo(int64_t time_us) {
+    Mutex::Autolock autoLock(mLock);
+
+    mSeeking = true;
+    mPositionTimeRealUs = mPositionTimeMediaUs = -1;
+    mReachedEOS = false;
+    mSeekTimeUs = time_us;
+
+    if (mAudioSink != NULL) {
+        mAudioSink->flush();
+    } else {
+        mAudioTrack->flush();
+    }
+
+    return OK;
+}
+
+}
diff --git a/libvideoeditor/lvpp/AudioPlayerBase.h b/libvideoeditor/lvpp/AudioPlayerBase.h
new file mode 100644
index 0000000..31b9fa2
--- /dev/null
+++ b/libvideoeditor/lvpp/AudioPlayerBase.h
@@ -0,0 +1,119 @@
+/*
+ * 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 AUDIO_PLAYER_BASE_H_
+
+#define AUDIO_PLAYER_BASE_H_
+
+#include <media/MediaPlayerInterface.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/TimeSource.h>
+#include <utils/threads.h>
+
+namespace android {
+
+class MediaSource;
+class AudioTrack;
+class PreviewPlayerBase;
+
+class AudioPlayerBase : public TimeSource {
+public:
+    enum {
+        REACHED_EOS,
+        SEEK_COMPLETE
+    };
+
+    AudioPlayerBase(const sp<MediaPlayerBase::AudioSink> &audioSink,
+                PreviewPlayerBase *audioObserver = NULL);
+
+    virtual ~AudioPlayerBase();
+
+    // Caller retains ownership of "source".
+    void setSource(const sp<MediaSource> &source);
+
+    // Return time in us.
+    virtual int64_t getRealTimeUs();
+
+    status_t start(bool sourceAlreadyStarted = false);
+
+    void pause(bool playPendingSamples = false);
+    void resume();
+
+    // Returns the timestamp of the last buffer played (in us).
+    int64_t getMediaTimeUs();
+
+    // Returns true iff a mapping is established, i.e. the AudioPlayerBase
+    // has played at least one frame of audio.
+    bool getMediaTimeMapping(int64_t *realtime_us, int64_t *mediatime_us);
+
+    status_t seekTo(int64_t time_us);
+
+    bool isSeeking();
+    bool reachedEOS(status_t *finalStatus);
+
+private:
+    friend class VideoEditorAudioPlayer;
+    sp<MediaSource> mSource;
+    AudioTrack *mAudioTrack;
+
+    MediaBuffer *mInputBuffer;
+
+    int mSampleRate;
+    int64_t mLatencyUs;
+    size_t mFrameSize;
+
+    Mutex mLock;
+    int64_t mNumFramesPlayed;
+
+    int64_t mPositionTimeMediaUs;
+    int64_t mPositionTimeRealUs;
+
+    bool mSeeking;
+    bool mReachedEOS;
+    status_t mFinalStatus;
+    int64_t mSeekTimeUs;
+
+    bool mStarted;
+
+    bool mIsFirstBuffer;
+    status_t mFirstBufferResult;
+    MediaBuffer *mFirstBuffer;
+
+    sp<MediaPlayerBase::AudioSink> mAudioSink;
+    PreviewPlayerBase *mObserver;
+
+    static void AudioCallback(int event, void *user, void *info);
+    void AudioCallback(int event, void *info);
+
+    static size_t AudioSinkCallback(
+            MediaPlayerBase::AudioSink *audioSink,
+            void *data, size_t size, void *me);
+
+    size_t fillBuffer(void *data, size_t size);
+
+    int64_t getRealTimeUsLocked() const;
+
+    void reset();
+
+    uint32_t getNumFramesPendingPlayout() const;
+
+    AudioPlayerBase(const AudioPlayerBase &);
+    AudioPlayerBase &operator=(const AudioPlayerBase &);
+};
+
+}  // namespace android
+
+#endif  // AUDIO_PLAYER_BASE_H_
diff --git a/libvideoeditor/lvpp/DummyAudioSource.cpp b/libvideoeditor/lvpp/DummyAudioSource.cpp
index 04f8dc9..8273a40 100755
--- a/libvideoeditor/lvpp/DummyAudioSource.cpp
+++ b/libvideoeditor/lvpp/DummyAudioSource.cpp
@@ -76,9 +76,10 @@
     mSamplingRate(samplingRate),
     mChannelCount(channelCount),
     mFrameDurationUs(frameDurationUs),
+    mNumberOfSamplePerFrame(0),
     mAudioDurationUs(audioDurationUs),
     mTimeStampUs(0) ,
-    mNumberOfSamplePerFrame(0),
+
     mBufferGroup(NULL){
     LOG2("DummyAudioSource::DummyAudioSource constructor START");
     /* Do nothing here? */
@@ -97,7 +98,12 @@
     LOG2("DummyAudioSource::~DummyAudioSource");
 }
 
-
+void DummyAudioSource::setDuration (int64_t audioDurationUs) {
+    Mutex::Autolock autoLock(mLock);
+    LOG2("SetDuration %lld", mAudioDurationUs);
+    mAudioDurationUs += audioDurationUs;
+    LOG2("SetDuration %lld", mAudioDurationUs);
+}
 
 status_t DummyAudioSource::start(MetaData *params) {
     status_t err = OK;
@@ -143,7 +149,7 @@
     meta->setInt32(kKeySampleRate, mSamplingRate);
     meta->setInt64(kKeyDuration, mFrameDurationUs);
 
-     meta->setCString(kKeyDecoderComponent, "DummyAudioSource");
+    meta->setCString(kKeyDecoderComponent, "DummyAudioSource");
 
     return meta;
 }
@@ -152,18 +158,20 @@
     status_t err            = OK;
     //LOG2("DummyAudioSource::read START");
     MediaBuffer *buffer;
-    int32_t byteCount;
     int64_t seekTimeUs;
     ReadOptions::SeekMode mode;
 
     if (options && options->getSeekTo(&seekTimeUs, &mode)) {
         CHECK(seekTimeUs >= 0);
         mTimeStampUs = seekTimeUs;
-     }
-
-    if (mTimeStampUs >= mAudioDurationUs) {
-        *out = NULL;
-        return ERROR_END_OF_STREAM;
+    }
+    {
+        Mutex::Autolock autoLock(mLock);
+        if (mTimeStampUs >= mAudioDurationUs) {
+            *out = NULL;
+            LOGI("EOS reached");
+            return ERROR_END_OF_STREAM;
+        }
     }
 
     err = mBufferGroup->acquire_buffer(&buffer);
@@ -171,13 +179,8 @@
         return err;
     }
 
-    uint8_t *inputPtr =
-    ( uint8_t *)buffer->data() + buffer->range_offset();
-
-    //TODO: replace with memset
-    for (byteCount = 0; byteCount < (mNumberOfSamplePerFrame << 1); byteCount++) {
-        inputPtr[byteCount] = 0;
-    }
+    memset((uint8_t *) buffer->data() + buffer->range_offset(),
+            0, mNumberOfSamplePerFrame << 1);
 
     buffer->set_range(buffer->range_offset(), (mNumberOfSamplePerFrame << 1));
 
diff --git a/libvideoeditor/lvpp/DummyAudioSource.h b/libvideoeditor/lvpp/DummyAudioSource.h
index a562bc1..bb3f4a2 100755
--- a/libvideoeditor/lvpp/DummyAudioSource.h
+++ b/libvideoeditor/lvpp/DummyAudioSource.h
@@ -45,8 +45,9 @@
     virtual status_t start(MetaData *params = NULL);

     virtual status_t stop();

     virtual sp<MetaData> getFormat();

-    virtual status_t read (MediaBuffer **buffer, 

+    virtual status_t read (MediaBuffer **buffer,

                             const MediaSource::ReadOptions *options = NULL);

+    void setDuration (int64_t audioDurationUs);

 

 protected:

     DummyAudioSource (int32_t samplingRate,

@@ -62,7 +63,8 @@
     int32_t mNumberOfSamplePerFrame;

     int64_t mAudioDurationUs;

     int64_t mTimeStampUs;

-    int32_t mNbBuffer;

+    Mutex mLock;

+

     MediaBufferGroup *mBufferGroup;

 

     DummyAudioSource(const DummyAudioSource &);

diff --git a/libvideoeditor/lvpp/DummyVideoSource.cpp b/libvideoeditor/lvpp/DummyVideoSource.cpp
index 58487b2..8081660 100755
--- a/libvideoeditor/lvpp/DummyVideoSource.cpp
+++ b/libvideoeditor/lvpp/DummyVideoSource.cpp
@@ -96,7 +96,7 @@
 

     LOG2("DummyVideoSource::stop START");

     if (mImageBuffer != NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mImageBuffer);

+        free(mImageBuffer);

         mImageBuffer = NULL;

     }

     LOG2("DummyVideoSource::stop END");

@@ -136,7 +136,7 @@
         M4OSA_clockGetTime(&mImagePlayStartTime, 1000); //1000 time scale for time in ms

     }

 

-    if ((mImageSeekTime == mImageClipDuration) || (mFrameTimeUs == mImageClipDuration)) {

+    if ((mImageSeekTime == mImageClipDuration) || (mFrameTimeUs == (int64_t)mImageClipDuration)) {

         LOG2("DummyVideoSource::read() End of stream reached; return NULL buffer");

         *out = NULL;

         return ERROR_END_OF_STREAM;

diff --git a/libvideoeditor/lvpp/DummyVideoSource.h b/libvideoeditor/lvpp/DummyVideoSource.h
index 6fcc0a9..686e637 100755
--- a/libvideoeditor/lvpp/DummyVideoSource.h
+++ b/libvideoeditor/lvpp/DummyVideoSource.h
@@ -21,7 +21,6 @@
 

 #include <utils/RefBase.h>

 #include <utils/threads.h>

-#include <media/stagefright/MediaBufferGroup.h>

 #include <media/stagefright/MediaSource.h>

 #include <media/stagefright/DataSource.h>

 #include "OMX_IVCommon.h"

@@ -36,7 +35,6 @@
 

 class  MediaBuffer;

 class  MetaData;

-struct MediaBufferGroup;

 

 struct DummyVideoSource : public MediaSource {

 

@@ -63,7 +61,6 @@
     uint64_t mImageClipDuration;

     const char *mUri;

     int64_t mFrameTimeUs;

-    MediaBufferGroup *mBufferGroup;

     bool mIsFirstImageFrame;

     void *mImageBuffer;

     M4OSA_Time mImagePlayStartTime;

diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp
old mode 100644
new mode 100755
index f26a18c..8c9ef10
--- a/libvideoeditor/lvpp/PreviewPlayer.cpp
+++ b/libvideoeditor/lvpp/PreviewPlayer.cpp
@@ -27,7 +27,6 @@
 #include "DummyAudioSource.h"
 #include "DummyVideoSource.h"
 #include "VideoEditorSRC.h"
-#include "include/LiveSession.h"
 #include "include/NuCachedSource2.h"
 #include "include/ThrottledSource.h"
 
@@ -171,17 +170,18 @@
 }
 
 PreviewPlayer::PreviewPlayer()
-    : AwesomePlayer(),
-      mFrameRGBBuffer(NULL),
-      mFrameYUVBuffer(NULL),
+    : PreviewPlayerBase(),
+      mCurrFramingEffectIndex(0)   ,
       mReportedWidth(0),
       mReportedHeight(0),
-      mCurrFramingEffectIndex(0) {
+      mFrameRGBBuffer(NULL),
+      mFrameYUVBuffer(NULL){
 
     mVideoRenderer = NULL;
     mLastVideoBuffer = NULL;
     mSuspensionState = NULL;
     mEffectsSettings = NULL;
+    mVeAudioPlayer = NULL;
     mAudioMixStoryBoardTS = 0;
     mCurrentMediaBeginCutTime = 0;
     mCurrentMediaVolumeValue = 0;
@@ -192,17 +192,17 @@
     mProgressCbInterval = 0;
     mNumberDecVideoFrames = 0;
     mOverlayUpdateEventPosted = false;
-    mVeAudioPlayer = NULL;
+    mIsChangeSourceRequired = true;
 
     mVideoEvent = new PreviewPlayerEvent(this, &PreviewPlayer::onVideoEvent);
     mVideoEventPending = false;
     mStreamDoneEvent = new PreviewPlayerEvent(this,
-         &AwesomePlayer::onStreamDone);
+         &PreviewPlayer::onStreamDone);
 
     mStreamDoneEventPending = false;
 
     mCheckAudioStatusEvent = new PreviewPlayerEvent(
-        this, &AwesomePlayer::onCheckAudioStatus);
+        this, &PreviewPlayerBase::onCheckAudioStatus);
 
     mAudioStatusEventPending = false;
 
@@ -230,7 +230,7 @@
     reset();
 
     if(mResizedVideoBuffer != NULL) {
-        M4OSA_free((M4OSA_MemAddr32)(mResizedVideoBuffer->data()));
+        free((mResizedVideoBuffer->data()));
         mResizedVideoBuffer = NULL;
     }
 
@@ -313,7 +313,7 @@
         LOGV("PreviewPlayer: setDataSource_l Dummyaudiocreation started");
 
         mAudioTrack = DummyAudioSource::Create(32000, 2, 20000,
-                                              ((mPlayEndTimeMsec)*1000));
+                                              ((mPlayEndTimeMsec)*1000LL));
         LOGV("PreviewPlayer: setDataSource_l Dummyauiosource created");
         if(mAudioTrack != NULL) {
             haveAudio = true;
@@ -333,7 +333,7 @@
     LOGV("PreviewPlayer: setDataSource_l_jpg started");
 
     mAudioSource = DummyAudioSource::Create(32000, 2, 20000,
-                                          ((mPlayEndTimeMsec)*1000));
+                                          ((mPlayEndTimeMsec)*1000LL));
     LOGV("PreviewPlayer: setDataSource_l_jpg Dummyaudiosource created");
     if(mAudioSource != NULL) {
         setAudioSource(mAudioSource);
@@ -345,7 +345,7 @@
         return err;
     }
 
-    mDurationUs = (mPlayEndTimeMsec - mPlayBeginTimeMsec)*1000;
+    mDurationUs = (mPlayEndTimeMsec - mPlayBeginTimeMsec)*1000LL;
 
     mVideoSource = DummyVideoSource::Create(mVideoWidth, mVideoHeight,
                                             mDurationUs, mUri);
@@ -397,7 +397,10 @@
 
     mTimeSource = NULL;
 
-    delete mAudioPlayer;
+    //Single audio player instance used
+    //So donot delete it here
+    //It is deleted from PreviewController class
+    //delete mAudioPlayer;
     mAudioPlayer = NULL;
 
     if (mLastVideoBuffer) {
@@ -447,23 +450,11 @@
     mIsVideoSourceJpg = false;
     mFrameRGBBuffer = NULL;
     if(mFrameYUVBuffer != NULL) {
-        M4OSA_free((M4OSA_MemAddr32)mFrameYUVBuffer);
+        free(mFrameYUVBuffer);
         mFrameYUVBuffer = NULL;
     }
 }
 
-void PreviewPlayer::partial_reset_l() {
-
-    if (mLastVideoBuffer) {
-        mLastVideoBuffer->release();
-        mLastVideoBuffer = NULL;
-    }
-
-    /* call base struct */
-    AwesomePlayer::partial_reset_l();
-
-}
-
 status_t PreviewPlayer::play() {
     Mutex::Autolock autoLock(mLock);
 
@@ -472,8 +463,154 @@
     return play_l();
 }
 
+status_t PreviewPlayer::startAudioPlayer_l() {
+    CHECK(!(mFlags & AUDIO_RUNNING));
+
+    if (mAudioSource == NULL || mAudioPlayer == NULL) {
+        return OK;
+    }
+
+    if (!(mFlags & AUDIOPLAYER_STARTED)) {
+        mFlags |= AUDIOPLAYER_STARTED;
+
+        // We've already started the MediaSource in order to enable
+        // the prefetcher to read its data.
+        status_t err = mVeAudioPlayer->start(
+                true /* sourceAlreadyStarted */);
+
+        if (err != OK) {
+            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
+            return err;
+        }
+    } else {
+        mVeAudioPlayer->resume();
+    }
+
+    mFlags |= AUDIO_RUNNING;
+
+    mWatchForAudioEOS = true;
+
+    return OK;
+}
+
+status_t PreviewPlayer::setAudioPlayer(AudioPlayerBase *audioPlayer) {
+    Mutex::Autolock autoLock(mLock);
+    CHECK(!(mFlags & PLAYING));
+    mAudioPlayer = audioPlayer;
+
+    LOGV("SetAudioPlayer");
+    mIsChangeSourceRequired = true;
+    mVeAudioPlayer =
+            (VideoEditorAudioPlayer*)mAudioPlayer;
+
+    // check if the new and old source are dummy
+    sp<MediaSource> anAudioSource = mVeAudioPlayer->getSource();
+    if (anAudioSource == NULL) {
+        // Audio player does not have any source set.
+        LOGV("setAudioPlayer: Audio player does not have any source set");
+        return OK;
+    }
+
+    // If new video source is not dummy, then always change source
+    // Else audio player continues using old audio source and there are
+    // frame drops to maintain AV sync
+    sp<MetaData> meta;
+    if (mVideoSource != NULL) {
+        meta = mVideoSource->getFormat();
+        const char *pVidSrcType;
+        if (meta->findCString(kKeyDecoderComponent, &pVidSrcType)) {
+            if (strcmp(pVidSrcType, "DummyVideoSource") != 0) {
+                LOGV(" Video clip with silent audio; need to change source");
+                return OK;
+            }
+        }
+    }
+
+    const char *pSrcType1;
+    const char *pSrcType2;
+    meta = anAudioSource->getFormat();
+
+    if (meta->findCString(kKeyDecoderComponent, &pSrcType1)) {
+        if (strcmp(pSrcType1, "DummyAudioSource") == 0) {
+            meta = mAudioSource->getFormat();
+            if (meta->findCString(kKeyDecoderComponent, &pSrcType2)) {
+                if (strcmp(pSrcType2, "DummyAudioSource") == 0) {
+                    mIsChangeSourceRequired = false;
+                    // Just set the new play duration for the existing source
+                    MediaSource *pMediaSrc = anAudioSource.get();
+                    DummyAudioSource *pDummyAudioSource = (DummyAudioSource*)pMediaSrc;
+                    //Increment the duration of audio source
+                    pDummyAudioSource->setDuration(
+                        (int64_t)((mPlayEndTimeMsec)*1000LL));
+
+                    // Stop the new audio source
+                    // since we continue using old source
+                    LOGV("setAudioPlayer: stop new audio source");
+                    mAudioSource->stop();
+                }
+            }
+        }
+    }
+
+    return OK;
+}
+
+void PreviewPlayer::onStreamDone() {
+    // Posted whenever any stream finishes playing.
+
+    Mutex::Autolock autoLock(mLock);
+    if (!mStreamDoneEventPending) {
+        return;
+    }
+    mStreamDoneEventPending = false;
+
+    if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
+        LOGV("MEDIA_ERROR %d", mStreamDoneStatus);
+
+        notifyListener_l(
+                MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
+
+        pause_l(true /* at eos */);
+
+        mFlags |= AT_EOS;
+        return;
+    }
+
+    const bool allDone =
+        (mVideoSource == NULL || (mFlags & VIDEO_AT_EOS))
+            && (mAudioSource == NULL || (mFlags & AUDIO_AT_EOS));
+
+    if (!allDone) {
+        return;
+    }
+
+    if (mFlags & (LOOPING | AUTO_LOOPING)) {
+        seekTo_l(0);
+
+        if (mVideoSource != NULL) {
+            postVideoEvent_l();
+        }
+    } else {
+        LOGV("MEDIA_PLAYBACK_COMPLETE");
+        //pause before sending event
+        pause_l(true /* at eos */);
+
+        //This lock is used to syncronize onStreamDone() in PreviewPlayer and
+        //stopPreview() in PreviewController
+        Mutex::Autolock autoLock(mLockControl);
+        notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
+
+        mFlags |= AT_EOS;
+        LOGV("onStreamDone end");
+        return;
+    }
+}
+
+
 status_t PreviewPlayer::play_l() {
 
+    mFlags &= ~SEEK_PREVIEW;
+
     if (mFlags & PLAYING) {
         return OK;
     }
@@ -512,26 +649,75 @@
                  mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
                  mCurrentMediaVolumeValue);
 
-                mTimeSource = mVeAudioPlayer;
+                 mFlags |= AUDIOPLAYER_STARTED;
+                // We've already started the MediaSource in order to enable
+                // the prefetcher to read its data.
+                status_t err = mVeAudioPlayer->start(
+                        true /* sourceAlreadyStarted */);
 
+                if (err != OK) {
+                    //delete mAudioPlayer;
+                    mAudioPlayer = NULL;
+
+                    mFlags &= ~(PLAYING | FIRST_FRAME);
+                    return err;
+                }
+
+                mTimeSource = mVeAudioPlayer;
+                mFlags |= AUDIO_RUNNING;
                 deferredAudioSeek = true;
                 mWatchForAudioSeekComplete = false;
                 mWatchForAudioEOS = true;
             }
-        }
+        } else {
+            mVeAudioPlayer = (VideoEditorAudioPlayer*)mAudioPlayer;
+            bool isAudioPlayerStarted = mVeAudioPlayer->isStarted();
 
-        CHECK(!(mFlags & AUDIO_RUNNING));
+            if (mIsChangeSourceRequired == true) {
+                LOGV("play_l: Change audio source required");
 
-        if (mVideoSource == NULL) {
-            status_t err = startAudioPlayer_l();
+                if (isAudioPlayerStarted == true) {
+                    mVeAudioPlayer->pause();
+                }
 
-            if (err != OK) {
-                delete mAudioPlayer;
-                mAudioPlayer = NULL;
-                mVeAudioPlayer = NULL;
-                mFlags &= ~(PLAYING | FIRST_FRAME);
-                return err;
+                mVeAudioPlayer->setSource(mAudioSource);
+                mVeAudioPlayer->setObserver(this);
+
+                mVeAudioPlayer->setAudioMixSettings(
+                 mPreviewPlayerAudioMixSettings);
+
+                mVeAudioPlayer->setAudioMixStoryBoardSkimTimeStamp(
+                    mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
+                    mCurrentMediaVolumeValue);
+
+                if (isAudioPlayerStarted == true) {
+                    mVeAudioPlayer->resume();
+                } else {
+                    status_t err = OK;
+                    err = mVeAudioPlayer->start(true);
+                    if (err != OK) {
+                        mAudioPlayer = NULL;
+                        mVeAudioPlayer = NULL;
+
+                        mFlags &= ~(PLAYING | FIRST_FRAME);
+                        return err;
+                    }
+                }
+            } else {
+                LOGV("play_l: No Source change required");
+                mVeAudioPlayer->setAudioMixStoryBoardSkimTimeStamp(
+                    mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime,
+                    mCurrentMediaVolumeValue);
+
+                mVeAudioPlayer->resume();
             }
+
+            mFlags |= AUDIOPLAYER_STARTED;
+            mFlags |= AUDIO_RUNNING;
+            mTimeSource = mVeAudioPlayer;
+            deferredAudioSeek = true;
+            mWatchForAudioSeekComplete = false;
+            mWatchForAudioEOS = true;
         }
     }
 
@@ -546,6 +732,7 @@
         MediaBuffer *aLocalBuffer;
         options.setSeekTo(mSeekTimeUs);
         mVideoSource->read(&aLocalBuffer, &options);
+        aLocalBuffer->release();
     }
 
     if (mVideoSource != NULL) {
@@ -568,38 +755,9 @@
     return OK;
 }
 
-status_t PreviewPlayer::startAudioPlayer_l() {
-    CHECK(!(mFlags & AUDIO_RUNNING));
-
-    if (mAudioSource == NULL || mAudioPlayer == NULL) {
-        return OK;
-    }
-
-    if (!(mFlags & AUDIOPLAYER_STARTED)) {
-        mFlags |= AUDIOPLAYER_STARTED;
-
-        // We've already started the MediaSource in order to enable
-        // the prefetcher to read its data.
-        status_t err = mVeAudioPlayer->start(
-                true /* sourceAlreadyStarted */);
-
-        if (err != OK) {
-            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
-            return err;
-        }
-    } else {
-        mVeAudioPlayer->resume();
-    }
-
-    mFlags |= AUDIO_RUNNING;
-
-    mWatchForAudioEOS = true;
-
-    return OK;
-}
 
 status_t PreviewPlayer::initRenderer_l() {
-    if (mSurface != NULL || mISurface != NULL) {
+    if (mSurface != NULL) {
         sp<MetaData> meta = mVideoSource->getFormat();
 
         int32_t format;
@@ -638,12 +796,6 @@
 }
 
 
-void PreviewPlayer::setISurface(const sp<ISurface> &isurface) {
-    Mutex::Autolock autoLock(mLock);
-    mISurface = isurface;
-}
-
-
 status_t PreviewPlayer::seekTo(int64_t timeUs) {
 
     if ((mExtractorFlags & MediaExtractor::CAN_SEEK) || (mIsVideoSourceJpg)) {
@@ -764,6 +916,11 @@
     }
     mVideoEventPending = false;
 
+    if (mFlags & SEEK_PREVIEW) {
+        mFlags &= ~SEEK_PREVIEW;
+        return;
+    }
+
     TimeSource *ts_st =  &mSystemTimeSource;
     int64_t timeStartUs = ts_st->getRealTimeUs();
 
@@ -774,7 +931,7 @@
         }
 
 
-        if(mSeeking == SEEK && mAudioSource != NULL) {
+        if(mAudioSource != NULL) {
 
             // We're going to seek the video source first, followed by
             // the audio source.
@@ -799,10 +956,7 @@
                                                       mSeekTimeUs / 1E6);
 
             options.setSeekTo(
-                    mSeekTimeUs,
-                    mSeeking == SEEK_VIDEO_ONLY
-                        ? MediaSource::ReadOptions::SEEK_NEXT_SYNC
-                        : MediaSource::ReadOptions::SEEK_CLOSEST);
+                    mSeekTimeUs, MediaSource::ReadOptions::SEEK_CLOSEST);
         }
         for (;;) {
             status_t err = mVideoSource->read(&mVideoBuffer, &options);
@@ -821,8 +975,9 @@
                     if (mVideoRenderer != NULL) {
                         mVideoRendererIsPreview = false;
                         err = initRenderer_l();
-                           if ( err != OK )
-                        postStreamDoneEvent_l(err); // santosh
+                        if (err != OK) {
+                            postStreamDoneEvent_l(err);
+                        }
 
                     }
                     continue;
@@ -835,11 +990,11 @@
                 finishSeekIfNecessary(-1);
                 LOGV("PreviewPlayer: onVideoEvent EOS reached.");
                 mFlags |= VIDEO_AT_EOS;
-                if (mOverlayUpdateEventPosted) {
-                    mOverlayUpdateEventPosted = false;
-                    postOverlayUpdateEvent_l();
-                }
+                mFlags |= AUDIO_AT_EOS;
+                mOverlayUpdateEventPosted = false;
                 postStreamDoneEvent_l(err);
+                // Set the last decoded timestamp to duration
+                mDecodedVideoTs = (mPlayEndTimeMsec*1000LL);
                 return;
             }
 
@@ -855,14 +1010,23 @@
             int64_t videoTimeUs;
             CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &videoTimeUs));
 
-            if((videoTimeUs/1000) < mPlayBeginTimeMsec) {
-                // Frames are before begin cut time
-                // Donot render
-                mVideoBuffer->release();
-                mVideoBuffer = NULL;
-                continue;
+            if (mSeeking != NO_SEEK) {
+                if (videoTimeUs < mSeekTimeUs) {
+                    // buffers are before seek time
+                    // ignore them
+                    mVideoBuffer->release();
+                    mVideoBuffer = NULL;
+                    continue;
+                }
+            } else {
+                if((videoTimeUs/1000) < mPlayBeginTimeMsec) {
+                    // Frames are before begin cut time
+                    // Donot render
+                    mVideoBuffer->release();
+                    mVideoBuffer = NULL;
+                    continue;
+                }
             }
-
             break;
         }
     }
@@ -877,10 +1041,9 @@
         mVideoTimeUs = timeUs;
     }
 
-    mDecodedVideoTs = timeUs;
 
     if(!mStartNextPlayer) {
-        int64_t playbackTimeRemaining = (mPlayEndTimeMsec*1000) - timeUs;
+        int64_t playbackTimeRemaining = (mPlayEndTimeMsec*1000LL) - timeUs;
         if(playbackTimeRemaining <= 1500000) {
             //When less than 1.5 sec of playback left
             // send notification to start next player
@@ -892,11 +1055,10 @@
 
     SeekType wasSeeking = mSeeking;
     finishSeekIfNecessary(timeUs);
-
-    if (mAudioPlayer != NULL && !(mFlags & AUDIO_RUNNING)) {
+    if (mAudioPlayer != NULL && !(mFlags & (AUDIO_RUNNING))) {
         status_t err = startAudioPlayer_l();
         if (err != OK) {
-            LOGE("Startung the audio player failed w/ err %d", err);
+            LOGE("Starting the audio player failed w/ err %d", err);
             return;
         }
     }
@@ -926,63 +1088,40 @@
 
         int64_t latenessUs = nowUs - timeUs;
 
+        if (wasSeeking != NO_SEEK) {
+            // Let's display the first frame after seeking right away.
+            latenessUs = 0;
+        }
         LOGV("Audio time stamp = %lld and video time stamp = %lld",
                                             ts->getRealTimeUs(),timeUs);
+        if (latenessUs > 40000) {
+            // We're more than 40ms late.
 
-        if (wasSeeking == SEEK_VIDEO_ONLY) {
-            if (latenessUs > 0) {
-                LOGV("after SEEK_VIDEO_ONLY we're late by %.2f secs", latenessUs / 1E6);
-            }
-        }
-        if (wasSeeking == NO_SEEK) {
-
-            if (latenessUs > 500000ll
-                && mRTSPController == NULL
-                && mAudioPlayer != NULL
-                && mAudioPlayer->getMediaTimeMapping(
-                    &realTimeUs, &mediaTimeUs)) {
-                LOGV("we're much too late (%.2f secs), video skipping ahead",
-                 latenessUs / 1E6);
-
-                mVideoBuffer->release();
-                mVideoBuffer = NULL;
-
-                mSeeking = SEEK_VIDEO_ONLY;
-                mSeekTimeUs = mediaTimeUs;
-
-                postVideoEvent_l();
-                return;
-            }
-
-            if (latenessUs > 40000) {
-                // We're more than 40ms late.
-
-                LOGV("LV PLAYER we're late by %lld us (%.2f secs)",
+            LOGV("LV PLAYER we're late by %lld us (%.2f secs)",
                                            latenessUs, latenessUs / 1E6);
 
-                mVideoBuffer->release();
-                mVideoBuffer = NULL;
-                postVideoEvent_l(0);
-                return;
-            }
-
-            if (latenessUs < -25000) {
-                // We're more than 25ms early.
-                LOGV("We're more than 25ms early, lateness %lld", latenessUs);
-
-                postVideoEvent_l(25000);
-                return;
-            }
+            mVideoBuffer->release();
+            mVideoBuffer = NULL;
+            postVideoEvent_l(0);
+            return;
         }
 
+        if (latenessUs < -25000) {
+            // We're more than 25ms early.
+            LOGV("We're more than 25ms early, lateness %lld", latenessUs);
+
+            postVideoEvent_l(25000);
+            return;
+        }
     }
 
     if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
         mVideoRendererIsPreview = false;
 
         status_t err = initRenderer_l();
-        if ( err != OK )
-        postStreamDoneEvent_l(err); // santosh
+        if (err != OK) {
+            postStreamDoneEvent_l(err);
+        }
     }
 
     // If timestamp exceeds endCutTime of clip, donot render
@@ -996,13 +1135,14 @@
         mFlags |= VIDEO_AT_EOS;
         mFlags |= AUDIO_AT_EOS;
         LOGV("PreviewPlayer: onVideoEvent timeUs > mPlayEndTime; send EOS..");
-        if (mOverlayUpdateEventPosted) {
-            mOverlayUpdateEventPosted = false;
-            postOverlayUpdateEvent_l();
-        }
+        mOverlayUpdateEventPosted = false;
+        // Set the last decoded timestamp to duration
+        mDecodedVideoTs = (mPlayEndTimeMsec*1000LL);
         postStreamDoneEvent_l(ERROR_END_OF_STREAM);
         return;
     }
+    // Capture the frame timestamp to be rendered
+    mDecodedVideoTs = timeUs;
 
     // Post processing to apply video effects
     for(i=0;i<mNumberEffects;i++) {
@@ -1020,7 +1160,6 @@
             ((mEffectsSettings[i].uiStartTime+mEffectsSettings[i].uiDuration) >=
              (((timeUs+mDecVideoTsStoryBoard)/1000)-mPlayBeginTimeMsec))
               && (mEffectsSettings[i].uiDuration != 0)) {
-
             setVideoPostProcessingNode(
              mEffectsSettings[i].VideoEffectType, TRUE);
         }
@@ -1034,14 +1173,13 @@
     if (mCurrentVideoEffect & VIDEO_EFFECT_FRAMING) {
         mCurrentVideoEffect &= ~VIDEO_EFFECT_FRAMING; //never apply framing here.
         if (!mOverlayUpdateEventPosted) {
-
             // Find the effect in effectSettings array
-            int index;
+            M4OSA_UInt32 index;
             for (index = 0; index < mNumberEffects; index++) {
                 M4OSA_UInt32 timeMs = mDecodedVideoTs/1000;
                 M4OSA_UInt32 timeOffset = mDecVideoTsStoryBoard/1000;
                 if(mEffectsSettings[index].VideoEffectType ==
-                    M4xVSS_kVideoEffectType_Framing) {
+                    (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Framing) {
                     if (((mEffectsSettings[index].uiStartTime + 1) <=
                         timeMs + timeOffset - mPlayBeginTimeMsec) &&
                         ((mEffectsSettings[index].uiStartTime - 1 +
@@ -1117,13 +1255,17 @@
         LOGV("PreviewPlayer: onVideoEvent EOS.");
         mFlags |= VIDEO_AT_EOS;
         mFlags |= AUDIO_AT_EOS;
-        if (mOverlayUpdateEventPosted) {
-            mOverlayUpdateEventPosted = false;
-            postOverlayUpdateEvent_l();
-        }
+        mOverlayUpdateEventPosted = false;
+        // Set the last decoded timestamp to duration
+        mDecodedVideoTs = (mPlayEndTimeMsec*1000LL);
         postStreamDoneEvent_l(ERROR_END_OF_STREAM);
     }
     else {
+        if ((wasSeeking != NO_SEEK) && (mFlags & SEEK_PREVIEW)) {
+            mFlags &= ~SEEK_PREVIEW;
+            return;
+        }
+
         if(!mIsVideoSourceJpg) {
             postVideoEvent_l(0);
         }
@@ -1348,6 +1490,16 @@
     return OK;
 }
 
+void PreviewPlayer::acquireLock() {
+    LOGV("acquireLock");
+    mLockControl.lock();
+}
+
+void PreviewPlayer::releaseLock() {
+    LOGV("releaseLock");
+    mLockControl.unlock();
+}
+
 status_t PreviewPlayer::resume() {
     LOGV("resume");
     Mutex::Autolock autoLock(mLock);
@@ -1361,13 +1513,13 @@
 
     status_t err;
     if (state->mFileSource != NULL) {
-        err = AwesomePlayer::setDataSource_l(state->mFileSource);
+        err = PreviewPlayerBase::setDataSource_l(state->mFileSource);
 
         if (err == OK) {
             mFileSource = state->mFileSource;
         }
     } else {
-        err = AwesomePlayer::setDataSource_l(state->mUri, &state->mUriHeaders);
+        err = PreviewPlayerBase::setDataSource_l(state->mUri, &state->mUriHeaders);
     }
 
     if (err != OK) {
@@ -1381,7 +1533,7 @@
 
     mFlags = state->mFlags & (AUTO_LOOPING | LOOPING | AT_EOS);
 
-    if (state->mLastVideoFrame && (mSurface != NULL || mISurface != NULL)) {
+    if (state->mLastVideoFrame && (mSurface != NULL)) {
         mVideoRenderer =
             PreviewLocalRenderer::initPreviewLocalRenderer(
                     true,  // previewOnly
@@ -1461,7 +1613,7 @@
 status_t PreviewPlayer::setStoryboardStartTime(uint32_t msec) {
 
     mStoryboardStartTimeMsec = msec;
-    mDecVideoTsStoryBoard = mStoryboardStartTimeMsec*1000;
+    mDecVideoTsStoryBoard = mStoryboardStartTimeMsec*1000LL;
     return OK;
 }
 
@@ -1606,7 +1758,7 @@
 
     if(err != M4NO_ERROR)
     {
-        LOGE("doMediaRendering: applyRenderingMode returned err=0x%x", err);
+        LOGE("doMediaRendering: applyRenderingMode returned err=0x%x", (int)err);
         return err;
     }
     mVideoResizedOrCropped = true;
@@ -1616,7 +1768,7 @@
 
 status_t PreviewPlayer::resetJniCallbackTimeStamp() {
 
-    mDecVideoTsStoryBoard = mStoryboardStartTimeMsec*1000;
+    mDecVideoTsStoryBoard = mStoryboardStartTimeMsec*1000LL;
     return OK;
 }
 
@@ -1840,13 +1992,15 @@
                     if (mVideoRenderer != NULL) {
                         mVideoRendererIsPreview = false;
                         err = initRenderer_l();
-                        if ( err != OK )
-                                postStreamDoneEvent_l(err); // santosh
+                        if (err != OK) {
+                            postStreamDoneEvent_l(err);
+                        }
                     }
                     continue;
                 }
                 LOGV("PreviewPlayer: onVideoEvent EOS reached.");
                 mFlags |= VIDEO_AT_EOS;
+                mFlags |= AUDIO_AT_EOS;
                 postStreamDoneEvent_l(err);
                 return OK;
             }
@@ -1862,15 +2016,23 @@
 
             int64_t videoTimeUs;
             CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &videoTimeUs));
-
-            if((videoTimeUs/1000) < mPlayBeginTimeMsec) {
-                // buffers are before begin cut time
-                // ignore them
-                mVideoBuffer->release();
-                mVideoBuffer = NULL;
-                continue;
+            if (mSeeking != NO_SEEK) {
+                if (videoTimeUs < mSeekTimeUs) {
+                    // buffers are before seek time
+                    // ignore them
+                    mVideoBuffer->release();
+                    mVideoBuffer = NULL;
+                    continue;
+                }
+            } else {
+                if((videoTimeUs/1000) < mPlayBeginTimeMsec) {
+                    // buffers are before begin cut time
+                    // ignore them
+                    mVideoBuffer->release();
+                    mVideoBuffer = NULL;
+                    continue;
+                }
             }
-
             break;
         }
     }
@@ -1889,4 +2051,9 @@
 
 }
 
+status_t PreviewPlayer::getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs) {
+    *lastRenderedTimeMs = (((mDecodedVideoTs+mDecVideoTsStoryBoard)/1000)-mPlayBeginTimeMsec);
+    return OK;
+}
+
 }  // namespace android
diff --git a/libvideoeditor/lvpp/PreviewPlayer.h b/libvideoeditor/lvpp/PreviewPlayer.h
old mode 100644
new mode 100755
index 5382698..b793639
--- a/libvideoeditor/lvpp/PreviewPlayer.h
+++ b/libvideoeditor/lvpp/PreviewPlayer.h
@@ -28,12 +28,12 @@
 #include <media/stagefright/OMXClient.h>
 #include <media/stagefright/TimeSource.h>
 #include <utils/threads.h>
-#include <AwesomePlayer.h>
+#include "PreviewPlayerBase.h"
 #include "VideoEditorPreviewController.h"
 
 namespace android {
 
-struct AudioPlayer;
+struct AudioPlayerBase;
 struct DataSource;
 struct MediaBuffer;
 struct MediaExtractor;
@@ -51,7 +51,7 @@
     PreviewPlayerRenderer &operator=(const PreviewPlayerRenderer &);
 };
 
-struct PreviewPlayer : public AwesomePlayer {
+struct PreviewPlayer : public PreviewPlayerBase {
     PreviewPlayer();
     ~PreviewPlayer();
 
@@ -60,14 +60,14 @@
 
     status_t play();
 
-    void setISurface(const sp<ISurface> &isurface);
-
     status_t seekTo(int64_t timeUs);
 
     status_t getVideoDimensions(int32_t *width, int32_t *height) const;
 
     status_t suspend();
     status_t resume();
+    void acquireLock();
+    void releaseLock();
 
     status_t prepare();
     status_t setDataSource(
@@ -92,7 +92,8 @@
     status_t resetJniCallbackTimeStamp();
     status_t setImageClipProperties(uint32_t width, uint32_t height);
     status_t readFirstVideoFrame();
-
+    status_t getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs);
+    status_t setAudioPlayer(AudioPlayerBase *audioPlayer);
 
 private:
     friend struct PreviewPlayerEvent;
@@ -111,24 +112,23 @@
         AUTO_LOOPING        = 1024,
     };
 
-    sp<ISurface> mISurface;
-
     void cancelPlayerEvents(bool keepBufferingGoing = false);
     status_t setDataSource_l(const sp<MediaExtractor> &extractor);
     status_t setDataSource_l(
         const char *uri, const KeyedVector<String8, String8> *headers);
     void reset_l();
-    void partial_reset_l();
     status_t play_l();
     status_t initRenderer_l();
     status_t initAudioDecoder();
     status_t initVideoDecoder(uint32_t flags = 0);
     void onVideoEvent();
+    void onStreamDone();
     status_t finishSetDataSource_l();
     static bool ContinuePreparation(void *cookie);
     void onPrepareAsyncEvent();
     void finishAsyncPrepare_l();
     status_t startAudioPlayer_l();
+    bool mIsChangeSourceRequired;
 
     sp<PreviewPlayerRenderer> mVideoRenderer;
 
@@ -200,10 +200,10 @@
     bool mIsFiftiesEffectStarted;
     int64_t mImageFrameTimeUs;
     bool mStartNextPlayer;
+    mutable Mutex mLockControl;
 
     M4VIFI_UInt8*  mFrameRGBBuffer;
     M4VIFI_UInt8*  mFrameYUVBuffer;
-    VideoEditorAudioPlayer *mVeAudioPlayer;
 
     void setVideoPostProcessingNode(
                     M4VSS3GPP_VideoEffectType type, M4OSA_Bool enable);
@@ -220,6 +220,8 @@
     status_t prepare_l();
     status_t prepareAsync_l();
 
+    VideoEditorAudioPlayer  *mVeAudioPlayer;
+
     PreviewPlayer(const PreviewPlayer &);
     PreviewPlayer &operator=(const PreviewPlayer &);
 };
diff --git a/libvideoeditor/lvpp/PreviewPlayerBase.cpp b/libvideoeditor/lvpp/PreviewPlayerBase.cpp
new file mode 100644
index 0000000..62b8a72
--- /dev/null
+++ b/libvideoeditor/lvpp/PreviewPlayerBase.cpp
@@ -0,0 +1,1915 @@
+/*
+ * 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.
+ */
+
+#undef DEBUG_HDCP
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "PreviewPlayerBase"
+#include <utils/Log.h>
+
+#include <dlfcn.h>
+
+#include "include/ARTSPController.h"
+#include "PreviewPlayerBase.h"
+#include "AudioPlayerBase.h"
+#include "include/SoftwareRenderer.h"
+#include "include/NuCachedSource2.h"
+#include "include/ThrottledSource.h"
+#include "include/MPEG2TSExtractor.h"
+
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+#include <media/IMediaPlayerService.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/FileSource.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaExtractor.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+#include <media/stagefright/OMXCodec.h>
+
+#include <surfaceflinger/Surface.h>
+#include <gui/ISurfaceTexture.h>
+#include <gui/SurfaceTextureClient.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/foundation/AMessage.h>
+
+#include <cutils/properties.h>
+
+#define USE_SURFACE_ALLOC 1
+
+namespace android {
+
+static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
+static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
+static int64_t kHighWaterMarkRTSPUs = 4000000ll;  // 4secs
+static const size_t kLowWaterMarkBytes = 40000;
+static const size_t kHighWaterMarkBytes = 200000;
+
+struct AwesomeEvent : public TimedEventQueue::Event {
+    AwesomeEvent(
+            PreviewPlayerBase *player,
+            void (PreviewPlayerBase::*method)())
+        : mPlayer(player),
+          mMethod(method) {
+    }
+
+protected:
+    virtual ~AwesomeEvent() {}
+
+    virtual void fire(TimedEventQueue *queue, int64_t /* now_us */) {
+        (mPlayer->*mMethod)();
+    }
+
+private:
+    PreviewPlayerBase *mPlayer;
+    void (PreviewPlayerBase::*mMethod)();
+
+    AwesomeEvent(const AwesomeEvent &);
+    AwesomeEvent &operator=(const AwesomeEvent &);
+};
+
+struct AwesomeLocalRenderer : public AwesomeRenderer {
+    AwesomeLocalRenderer(
+            const sp<ANativeWindow> &nativeWindow, const sp<MetaData> &meta)
+        : mTarget(new SoftwareRenderer(nativeWindow, meta)) {
+    }
+
+    virtual void render(MediaBuffer *buffer) {
+        render((const uint8_t *)buffer->data() + buffer->range_offset(),
+               buffer->range_length());
+    }
+
+    void render(const void *data, size_t size) {
+        mTarget->render(data, size, NULL);
+    }
+
+protected:
+    virtual ~AwesomeLocalRenderer() {
+        delete mTarget;
+        mTarget = NULL;
+    }
+
+private:
+    SoftwareRenderer *mTarget;
+
+    AwesomeLocalRenderer(const AwesomeLocalRenderer &);
+    AwesomeLocalRenderer &operator=(const AwesomeLocalRenderer &);;
+};
+
+struct AwesomeNativeWindowRenderer : public AwesomeRenderer {
+    AwesomeNativeWindowRenderer(
+            const sp<ANativeWindow> &nativeWindow,
+            int32_t rotationDegrees)
+        : mNativeWindow(nativeWindow) {
+        applyRotation(rotationDegrees);
+    }
+
+    virtual void render(MediaBuffer *buffer) {
+        status_t err = mNativeWindow->queueBuffer(
+                mNativeWindow.get(), buffer->graphicBuffer().get());
+        if (err != 0) {
+            LOGE("queueBuffer failed with error %s (%d)", strerror(-err),
+                    -err);
+            return;
+        }
+
+        sp<MetaData> metaData = buffer->meta_data();
+        metaData->setInt32(kKeyRendered, 1);
+    }
+
+protected:
+    virtual ~AwesomeNativeWindowRenderer() {}
+
+private:
+    sp<ANativeWindow> mNativeWindow;
+
+    void applyRotation(int32_t rotationDegrees) {
+        uint32_t transform;
+        switch (rotationDegrees) {
+            case 0: transform = 0; break;
+            case 90: transform = HAL_TRANSFORM_ROT_90; break;
+            case 180: transform = HAL_TRANSFORM_ROT_180; break;
+            case 270: transform = HAL_TRANSFORM_ROT_270; break;
+            default: transform = 0; break;
+        }
+
+        if (transform) {
+            CHECK_EQ(0, native_window_set_buffers_transform(
+                        mNativeWindow.get(), transform));
+        }
+    }
+
+    AwesomeNativeWindowRenderer(const AwesomeNativeWindowRenderer &);
+    AwesomeNativeWindowRenderer &operator=(
+            const AwesomeNativeWindowRenderer &);
+};
+
+// To collect the decoder usage
+void addBatteryData(uint32_t params) {
+    sp<IBinder> binder =
+        defaultServiceManager()->getService(String16("media.player"));
+    sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
+    CHECK(service.get() != NULL);
+
+    service->addBatteryData(params);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PreviewPlayerBase::PreviewPlayerBase()
+    : mQueueStarted(false),
+      mTimeSource(NULL),
+      mVideoRendererIsPreview(false),
+      mAudioPlayer(NULL),
+      mDisplayWidth(0),
+      mDisplayHeight(0),
+      mFlags(0),
+      mExtractorFlags(0),
+      mVideoBuffer(NULL),
+      mDecryptHandle(NULL),
+      mLastVideoTimeUs(-1) {
+    CHECK_EQ(mClient.connect(), (status_t)OK);
+
+    DataSource::RegisterDefaultSniffers();
+
+    mVideoEvent = new AwesomeEvent(this, &PreviewPlayerBase::onVideoEvent);
+    mVideoEventPending = false;
+    mStreamDoneEvent = new AwesomeEvent(this, &PreviewPlayerBase::onStreamDone);
+    mStreamDoneEventPending = false;
+    mBufferingEvent = new AwesomeEvent(this, &PreviewPlayerBase::onBufferingUpdate);
+    mBufferingEventPending = false;
+    mVideoLagEvent = new AwesomeEvent(this, &PreviewPlayerBase::onVideoLagUpdate);
+    mVideoEventPending = false;
+
+    mCheckAudioStatusEvent = new AwesomeEvent(
+            this, &PreviewPlayerBase::onCheckAudioStatus);
+
+    mAudioStatusEventPending = false;
+
+    reset();
+}
+
+PreviewPlayerBase::~PreviewPlayerBase() {
+    if (mQueueStarted) {
+        mQueue.stop();
+    }
+
+    reset();
+
+    mClient.disconnect();
+}
+
+void PreviewPlayerBase::cancelPlayerEvents(bool keepBufferingGoing) {
+    mQueue.cancelEvent(mVideoEvent->eventID());
+    mVideoEventPending = false;
+    mQueue.cancelEvent(mStreamDoneEvent->eventID());
+    mStreamDoneEventPending = false;
+    mQueue.cancelEvent(mCheckAudioStatusEvent->eventID());
+    mAudioStatusEventPending = false;
+    mQueue.cancelEvent(mVideoLagEvent->eventID());
+    mVideoLagEventPending = false;
+
+    if (!keepBufferingGoing) {
+        mQueue.cancelEvent(mBufferingEvent->eventID());
+        mBufferingEventPending = false;
+    }
+}
+
+void PreviewPlayerBase::setListener(const wp<MediaPlayerBase> &listener) {
+    Mutex::Autolock autoLock(mLock);
+    mListener = listener;
+}
+
+status_t PreviewPlayerBase::setDataSource(
+        const char *uri, const KeyedVector<String8, String8> *headers) {
+    Mutex::Autolock autoLock(mLock);
+    return setDataSource_l(uri, headers);
+}
+
+status_t PreviewPlayerBase::setDataSource_l(
+        const char *uri, const KeyedVector<String8, String8> *headers) {
+    reset_l();
+
+    mUri = uri;
+
+    if (headers) {
+        mUriHeaders = *headers;
+
+        ssize_t index = mUriHeaders.indexOfKey(String8("x-hide-urls-from-log"));
+        if (index >= 0) {
+            // Browser is in "incognito" mode, suppress logging URLs.
+
+            // This isn't something that should be passed to the server.
+            mUriHeaders.removeItemsAt(index);
+
+            mFlags |= INCOGNITO;
+        }
+    }
+
+    if (!(mFlags & INCOGNITO)) {
+        LOGI("setDataSource_l('%s')", mUri.string());
+    } else {
+        LOGI("setDataSource_l(URL suppressed)");
+    }
+
+    // The actual work will be done during preparation in the call to
+    // ::finishSetDataSource_l to avoid blocking the calling thread in
+    // setDataSource for any significant time.
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::setDataSource(
+        int fd, int64_t offset, int64_t length) {
+    Mutex::Autolock autoLock(mLock);
+
+    reset_l();
+
+    sp<DataSource> dataSource = new FileSource(fd, offset, length);
+
+    status_t err = dataSource->initCheck();
+
+    if (err != OK) {
+        return err;
+    }
+
+    mFileSource = dataSource;
+
+    return setDataSource_l(dataSource);
+}
+
+status_t PreviewPlayerBase::setDataSource(const sp<IStreamSource> &source) {
+    return INVALID_OPERATION;
+}
+
+status_t PreviewPlayerBase::setDataSource_l(
+        const sp<DataSource> &dataSource) {
+    sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
+
+    if (extractor == NULL) {
+        return UNKNOWN_ERROR;
+    }
+
+    dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
+    if (mDecryptHandle != NULL) {
+        CHECK(mDrmManagerClient);
+        if (RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
+            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
+        }
+    }
+
+    return setDataSource_l(extractor);
+}
+
+status_t PreviewPlayerBase::setDataSource_l(const sp<MediaExtractor> &extractor) {
+    // Attempt to approximate overall stream bitrate by summing all
+    // tracks' individual bitrates, if not all of them advertise bitrate,
+    // we have to fail.
+
+    int64_t totalBitRate = 0;
+
+    for (size_t i = 0; i < extractor->countTracks(); ++i) {
+        sp<MetaData> meta = extractor->getTrackMetaData(i);
+
+        int32_t bitrate;
+        if (!meta->findInt32(kKeyBitRate, &bitrate)) {
+            totalBitRate = -1;
+            break;
+        }
+
+        totalBitRate += bitrate;
+    }
+
+    mBitrate = totalBitRate;
+
+    LOGV("mBitrate = %lld bits/sec", mBitrate);
+
+    bool haveAudio = false;
+    bool haveVideo = false;
+    for (size_t i = 0; i < extractor->countTracks(); ++i) {
+        sp<MetaData> meta = extractor->getTrackMetaData(i);
+
+        const char *mime;
+        CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+        if (!haveVideo && !strncasecmp(mime, "video/", 6)) {
+            setVideoSource(extractor->getTrack(i));
+            haveVideo = true;
+
+            // Set the presentation/display size
+            int32_t displayWidth, displayHeight;
+            bool success = meta->findInt32(kKeyDisplayWidth, &displayWidth);
+            if (success) {
+                success = meta->findInt32(kKeyDisplayHeight, &displayHeight);
+            }
+            if (success) {
+                mDisplayWidth = displayWidth;
+                mDisplayHeight = displayHeight;
+            }
+
+        } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) {
+            setAudioSource(extractor->getTrack(i));
+            haveAudio = true;
+
+            if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
+                // Only do this for vorbis audio, none of the other audio
+                // formats even support this ringtone specific hack and
+                // retrieving the metadata on some extractors may turn out
+                // to be very expensive.
+                sp<MetaData> fileMeta = extractor->getMetaData();
+                int32_t loop;
+                if (fileMeta != NULL
+                        && fileMeta->findInt32(kKeyAutoLoop, &loop) && loop != 0) {
+                    mFlags |= AUTO_LOOPING;
+                }
+            }
+        }
+
+        if (haveAudio && haveVideo) {
+            break;
+        }
+    }
+
+    if (!haveAudio && !haveVideo) {
+        return UNKNOWN_ERROR;
+    }
+
+    mExtractorFlags = extractor->flags();
+
+    return OK;
+}
+
+void PreviewPlayerBase::reset() {
+    Mutex::Autolock autoLock(mLock);
+    reset_l();
+}
+
+void PreviewPlayerBase::reset_l() {
+    mDisplayWidth = 0;
+    mDisplayHeight = 0;
+
+    if (mDecryptHandle != NULL) {
+            mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                    Playback::STOP, 0);
+            mDecryptHandle = NULL;
+            mDrmManagerClient = NULL;
+    }
+
+    if (mFlags & PLAYING) {
+        uint32_t params = IMediaPlayerService::kBatteryDataTrackDecoder;
+        if ((mAudioSource != NULL) && (mAudioSource != mAudioTrack)) {
+            params |= IMediaPlayerService::kBatteryDataTrackAudio;
+        }
+        if (mVideoSource != NULL) {
+            params |= IMediaPlayerService::kBatteryDataTrackVideo;
+        }
+        addBatteryData(params);
+    }
+
+    if (mFlags & PREPARING) {
+        mFlags |= PREPARE_CANCELLED;
+        if (mConnectingDataSource != NULL) {
+            LOGI("interrupting the connection process");
+            mConnectingDataSource->disconnect();
+        } else if (mConnectingRTSPController != NULL) {
+            LOGI("interrupting the connection process");
+            mConnectingRTSPController->disconnect();
+        }
+
+        if (mFlags & PREPARING_CONNECTED) {
+            // We are basically done preparing, we're just buffering
+            // enough data to start playback, we can safely interrupt that.
+            finishAsyncPrepare_l();
+        }
+    }
+
+    while (mFlags & PREPARING) {
+        mPreparedCondition.wait(mLock);
+    }
+
+    cancelPlayerEvents();
+
+    mCachedSource.clear();
+    mAudioTrack.clear();
+    mVideoTrack.clear();
+
+    // Shutdown audio first, so that the respone to the reset request
+    // appears to happen instantaneously as far as the user is concerned
+    // If we did this later, audio would continue playing while we
+    // shutdown the video-related resources and the player appear to
+    // not be as responsive to a reset request.
+    if (mAudioPlayer == NULL && mAudioSource != NULL) {
+        // If we had an audio player, it would have effectively
+        // taken possession of the audio source and stopped it when
+        // _it_ is stopped. Otherwise this is still our responsibility.
+        mAudioSource->stop();
+    }
+    mAudioSource.clear();
+
+    mTimeSource = NULL;
+
+    delete mAudioPlayer;
+    mAudioPlayer = NULL;
+
+    mVideoRenderer.clear();
+
+    if (mRTSPController != NULL) {
+        mRTSPController->disconnect();
+        mRTSPController.clear();
+    }
+
+    if (mVideoSource != NULL) {
+        shutdownVideoDecoder_l();
+    }
+
+    mDurationUs = -1;
+    mFlags = 0;
+    mExtractorFlags = 0;
+    mTimeSourceDeltaUs = 0;
+    mVideoTimeUs = 0;
+
+    mSeeking = NO_SEEK;
+    mSeekNotificationSent = false;
+    mSeekTimeUs = 0;
+
+    mUri.setTo("");
+    mUriHeaders.clear();
+
+    mFileSource.clear();
+
+    mBitrate = -1;
+    mLastVideoTimeUs = -1;
+}
+
+void PreviewPlayerBase::notifyListener_l(int msg, int ext1, int ext2) {
+    if (mListener != NULL) {
+        sp<MediaPlayerBase> listener = mListener.promote();
+
+        if (listener != NULL) {
+            listener->sendEvent(msg, ext1, ext2);
+        }
+    }
+}
+
+bool PreviewPlayerBase::getBitrate(int64_t *bitrate) {
+    off64_t size;
+    if (mDurationUs >= 0 && mCachedSource != NULL
+            && mCachedSource->getSize(&size) == OK) {
+        *bitrate = size * 8000000ll / mDurationUs;  // in bits/sec
+        return true;
+    }
+
+    if (mBitrate >= 0) {
+        *bitrate = mBitrate;
+        return true;
+    }
+
+    *bitrate = 0;
+
+    return false;
+}
+
+// Returns true iff cached duration is available/applicable.
+bool PreviewPlayerBase::getCachedDuration_l(int64_t *durationUs, bool *eos) {
+    int64_t bitrate;
+
+    if (mRTSPController != NULL) {
+        *durationUs = mRTSPController->getQueueDurationUs(eos);
+        return true;
+    } else if (mCachedSource != NULL && getBitrate(&bitrate)) {
+        status_t finalStatus;
+        size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus);
+        *durationUs = cachedDataRemaining * 8000000ll / bitrate;
+        *eos = (finalStatus != OK);
+        return true;
+    }
+
+    return false;
+}
+
+void PreviewPlayerBase::ensureCacheIsFetching_l() {
+    if (mCachedSource != NULL) {
+        mCachedSource->resumeFetchingIfNecessary();
+    }
+}
+
+void PreviewPlayerBase::onVideoLagUpdate() {
+    Mutex::Autolock autoLock(mLock);
+    if (!mVideoLagEventPending) {
+        return;
+    }
+    mVideoLagEventPending = false;
+
+    int64_t audioTimeUs = mAudioPlayer->getMediaTimeUs();
+    int64_t videoLateByUs = audioTimeUs - mVideoTimeUs;
+
+    if (!(mFlags & VIDEO_AT_EOS) && videoLateByUs > 300000ll) {
+        LOGV("video late by %lld ms.", videoLateByUs / 1000ll);
+
+        notifyListener_l(
+                MEDIA_INFO,
+                MEDIA_INFO_VIDEO_TRACK_LAGGING,
+                videoLateByUs / 1000ll);
+    }
+
+    postVideoLagEvent_l();
+}
+
+void PreviewPlayerBase::onBufferingUpdate() {
+    Mutex::Autolock autoLock(mLock);
+    if (!mBufferingEventPending) {
+        return;
+    }
+    mBufferingEventPending = false;
+
+    if (mCachedSource != NULL) {
+        status_t finalStatus;
+        size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus);
+        bool eos = (finalStatus != OK);
+
+        if (eos) {
+            if (finalStatus == ERROR_END_OF_STREAM) {
+                notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
+            }
+            if (mFlags & PREPARING) {
+                LOGV("cache has reached EOS, prepare is done.");
+                finishAsyncPrepare_l();
+            }
+        } else {
+            int64_t bitrate;
+            if (getBitrate(&bitrate)) {
+                size_t cachedSize = mCachedSource->cachedSize();
+                int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;
+
+                int percentage = 100.0 * (double)cachedDurationUs / mDurationUs;
+                if (percentage > 100) {
+                    percentage = 100;
+                }
+
+                notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage);
+            } else {
+                // We don't know the bitrate of the stream, use absolute size
+                // limits to maintain the cache.
+
+                if ((mFlags & PLAYING) && !eos
+                        && (cachedDataRemaining < kLowWaterMarkBytes)) {
+                    LOGI("cache is running low (< %d) , pausing.",
+                         kLowWaterMarkBytes);
+                    mFlags |= CACHE_UNDERRUN;
+                    pause_l();
+                    ensureCacheIsFetching_l();
+                    notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
+                } else if (eos || cachedDataRemaining > kHighWaterMarkBytes) {
+                    if (mFlags & CACHE_UNDERRUN) {
+                        LOGI("cache has filled up (> %d), resuming.",
+                             kHighWaterMarkBytes);
+                        mFlags &= ~CACHE_UNDERRUN;
+                        play_l();
+                        notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
+                    } else if (mFlags & PREPARING) {
+                        LOGV("cache has filled up (> %d), prepare is done",
+                             kHighWaterMarkBytes);
+                        finishAsyncPrepare_l();
+                    }
+                }
+            }
+        }
+    }
+
+    int64_t cachedDurationUs;
+    bool eos;
+    if (getCachedDuration_l(&cachedDurationUs, &eos)) {
+        LOGV("cachedDurationUs = %.2f secs, eos=%d",
+             cachedDurationUs / 1E6, eos);
+
+        int64_t highWaterMarkUs =
+            (mRTSPController != NULL) ? kHighWaterMarkRTSPUs : kHighWaterMarkUs;
+
+        if ((mFlags & PLAYING) && !eos
+                && (cachedDurationUs < kLowWaterMarkUs)) {
+            LOGI("cache is running low (%.2f secs) , pausing.",
+                 cachedDurationUs / 1E6);
+            mFlags |= CACHE_UNDERRUN;
+            pause_l();
+            ensureCacheIsFetching_l();
+            notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
+        } else if (eos || cachedDurationUs > highWaterMarkUs) {
+            if (mFlags & CACHE_UNDERRUN) {
+                LOGI("cache has filled up (%.2f secs), resuming.",
+                     cachedDurationUs / 1E6);
+                mFlags &= ~CACHE_UNDERRUN;
+                play_l();
+                notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
+            } else if (mFlags & PREPARING) {
+                LOGV("cache has filled up (%.2f secs), prepare is done",
+                     cachedDurationUs / 1E6);
+                finishAsyncPrepare_l();
+            }
+        }
+    }
+
+    postBufferingEvent_l();
+}
+
+void PreviewPlayerBase::onStreamDone() {
+    // Posted whenever any stream finishes playing.
+
+    Mutex::Autolock autoLock(mLock);
+    if (!mStreamDoneEventPending) {
+        return;
+    }
+    mStreamDoneEventPending = false;
+
+    if (mStreamDoneStatus != ERROR_END_OF_STREAM) {
+        LOGV("MEDIA_ERROR %d", mStreamDoneStatus);
+
+        notifyListener_l(
+                MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
+
+        pause_l(true /* at eos */);
+
+        mFlags |= AT_EOS;
+        return;
+    }
+
+    const bool allDone =
+        (mVideoSource == NULL || (mFlags & VIDEO_AT_EOS))
+            && (mAudioSource == NULL || (mFlags & AUDIO_AT_EOS));
+
+    if (!allDone) {
+        return;
+    }
+
+    if (mFlags & (LOOPING | AUTO_LOOPING)) {
+        seekTo_l(0);
+
+        if (mVideoSource != NULL) {
+            postVideoEvent_l();
+        }
+    } else {
+        LOGV("MEDIA_PLAYBACK_COMPLETE");
+        notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
+
+        pause_l(true /* at eos */);
+
+        mFlags |= AT_EOS;
+    }
+}
+
+status_t PreviewPlayerBase::play() {
+    Mutex::Autolock autoLock(mLock);
+
+    mFlags &= ~CACHE_UNDERRUN;
+
+    return play_l();
+}
+
+status_t PreviewPlayerBase::play_l() {
+    mFlags &= ~SEEK_PREVIEW;
+
+    if (mFlags & PLAYING) {
+        return OK;
+    }
+
+    if (!(mFlags & PREPARED)) {
+        status_t err = prepare_l();
+
+        if (err != OK) {
+            return err;
+        }
+    }
+
+    mFlags |= PLAYING;
+    mFlags |= FIRST_FRAME;
+
+    if (mDecryptHandle != NULL) {
+        int64_t position;
+        getPosition(&position);
+        mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                Playback::START, position / 1000);
+    }
+
+    if (mAudioSource != NULL) {
+        if (mAudioPlayer == NULL) {
+            if (mAudioSink != NULL) {
+                mAudioPlayer = new AudioPlayerBase(mAudioSink, this);
+                mAudioPlayer->setSource(mAudioSource);
+
+                mTimeSource = mAudioPlayer;
+
+                // If there was a seek request before we ever started,
+                // honor the request now.
+                // Make sure to do this before starting the audio player
+                // to avoid a race condition.
+                seekAudioIfNecessary_l();
+            }
+        }
+
+        CHECK(!(mFlags & AUDIO_RUNNING));
+
+        if (mVideoSource == NULL) {
+            status_t err = startAudioPlayer_l();
+
+            if (err != OK) {
+                delete mAudioPlayer;
+                mAudioPlayer = NULL;
+
+                mFlags &= ~(PLAYING | FIRST_FRAME);
+
+                if (mDecryptHandle != NULL) {
+                    mDrmManagerClient->setPlaybackStatus(
+                            mDecryptHandle, Playback::STOP, 0);
+                }
+
+                return err;
+            }
+        }
+    }
+
+    if (mTimeSource == NULL && mAudioPlayer == NULL) {
+        mTimeSource = &mSystemTimeSource;
+    }
+
+    if (mVideoSource != NULL) {
+        // Kick off video playback
+        postVideoEvent_l();
+
+        if (mAudioSource != NULL && mVideoSource != NULL) {
+            postVideoLagEvent_l();
+        }
+    }
+
+    if (mFlags & AT_EOS) {
+        // Legacy behaviour, if a stream finishes playing and then
+        // is started again, we play from the start...
+        seekTo_l(0);
+    }
+
+    uint32_t params = IMediaPlayerService::kBatteryDataCodecStarted
+        | IMediaPlayerService::kBatteryDataTrackDecoder;
+    if ((mAudioSource != NULL) && (mAudioSource != mAudioTrack)) {
+        params |= IMediaPlayerService::kBatteryDataTrackAudio;
+    }
+    if (mVideoSource != NULL) {
+        params |= IMediaPlayerService::kBatteryDataTrackVideo;
+    }
+    addBatteryData(params);
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::startAudioPlayer_l() {
+    CHECK(!(mFlags & AUDIO_RUNNING));
+
+    if (mAudioSource == NULL || mAudioPlayer == NULL) {
+        return OK;
+    }
+
+    if (!(mFlags & AUDIOPLAYER_STARTED)) {
+        mFlags |= AUDIOPLAYER_STARTED;
+
+        // We've already started the MediaSource in order to enable
+        // the prefetcher to read its data.
+        status_t err = mAudioPlayer->start(
+                true /* sourceAlreadyStarted */);
+
+        if (err != OK) {
+            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
+            return err;
+        }
+    } else {
+        mAudioPlayer->resume();
+    }
+
+    mFlags |= AUDIO_RUNNING;
+
+    mWatchForAudioEOS = true;
+
+    return OK;
+}
+
+void PreviewPlayerBase::notifyVideoSize_l() {
+    sp<MetaData> meta = mVideoSource->getFormat();
+
+    int32_t cropLeft, cropTop, cropRight, cropBottom;
+    if (!meta->findRect(
+                kKeyCropRect, &cropLeft, &cropTop, &cropRight, &cropBottom)) {
+        int32_t width, height;
+        CHECK(meta->findInt32(kKeyWidth, &width));
+        CHECK(meta->findInt32(kKeyHeight, &height));
+
+        cropLeft = cropTop = 0;
+        cropRight = width - 1;
+        cropBottom = height - 1;
+
+        LOGV("got dimensions only %d x %d", width, height);
+    } else {
+        LOGV("got crop rect %d, %d, %d, %d",
+             cropLeft, cropTop, cropRight, cropBottom);
+    }
+
+    int32_t displayWidth;
+    if (meta->findInt32(kKeyDisplayWidth, &displayWidth)) {
+        LOGV("Display width changed (%d=>%d)", mDisplayWidth, displayWidth);
+        mDisplayWidth = displayWidth;
+    }
+    int32_t displayHeight;
+    if (meta->findInt32(kKeyDisplayHeight, &displayHeight)) {
+        LOGV("Display height changed (%d=>%d)", mDisplayHeight, displayHeight);
+        mDisplayHeight = displayHeight;
+    }
+
+    int32_t usableWidth = cropRight - cropLeft + 1;
+    int32_t usableHeight = cropBottom - cropTop + 1;
+    if (mDisplayWidth != 0) {
+        usableWidth = mDisplayWidth;
+    }
+    if (mDisplayHeight != 0) {
+        usableHeight = mDisplayHeight;
+    }
+
+    int32_t rotationDegrees;
+    if (!mVideoTrack->getFormat()->findInt32(
+                kKeyRotation, &rotationDegrees)) {
+        rotationDegrees = 0;
+    }
+
+    if (rotationDegrees == 90 || rotationDegrees == 270) {
+        notifyListener_l(
+                MEDIA_SET_VIDEO_SIZE, usableHeight, usableWidth);
+    } else {
+        notifyListener_l(
+                MEDIA_SET_VIDEO_SIZE, usableWidth, usableHeight);
+    }
+}
+
+void PreviewPlayerBase::initRenderer_l() {
+    if (mNativeWindow == NULL) {
+        return;
+    }
+
+    sp<MetaData> meta = mVideoSource->getFormat();
+
+    int32_t format;
+    const char *component;
+    int32_t decodedWidth, decodedHeight;
+    CHECK(meta->findInt32(kKeyColorFormat, &format));
+    CHECK(meta->findCString(kKeyDecoderComponent, &component));
+    CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
+    CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
+
+    int32_t rotationDegrees;
+    if (!mVideoTrack->getFormat()->findInt32(
+                kKeyRotation, &rotationDegrees)) {
+        rotationDegrees = 0;
+    }
+
+    mVideoRenderer.clear();
+
+    // Must ensure that mVideoRenderer's destructor is actually executed
+    // before creating a new one.
+    IPCThreadState::self()->flushCommands();
+
+    if (USE_SURFACE_ALLOC && strncmp(component, "OMX.", 4) == 0) {
+        // Hardware decoders avoid the CPU color conversion by decoding
+        // directly to ANativeBuffers, so we must use a renderer that
+        // just pushes those buffers to the ANativeWindow.
+        mVideoRenderer =
+            new AwesomeNativeWindowRenderer(mNativeWindow, rotationDegrees);
+    } else {
+        // Other decoders are instantiated locally and as a consequence
+        // allocate their buffers in local address space.  This renderer
+        // then performs a color conversion and copy to get the data
+        // into the ANativeBuffer.
+        mVideoRenderer = new AwesomeLocalRenderer(mNativeWindow, meta);
+    }
+}
+
+status_t PreviewPlayerBase::pause() {
+    Mutex::Autolock autoLock(mLock);
+
+    mFlags &= ~CACHE_UNDERRUN;
+
+    return pause_l();
+}
+
+status_t PreviewPlayerBase::pause_l(bool at_eos) {
+    if (!(mFlags & PLAYING)) {
+        return OK;
+    }
+
+    cancelPlayerEvents(true /* keepBufferingGoing */);
+
+    if (mAudioPlayer != NULL && (mFlags & AUDIO_RUNNING)) {
+        if (at_eos) {
+            // If we played the audio stream to completion we
+            // want to make sure that all samples remaining in the audio
+            // track's queue are played out.
+            mAudioPlayer->pause(true /* playPendingSamples */);
+        } else {
+            mAudioPlayer->pause();
+        }
+
+        mFlags &= ~AUDIO_RUNNING;
+    }
+
+    mFlags &= ~PLAYING;
+
+    if (mDecryptHandle != NULL) {
+        mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                Playback::PAUSE, 0);
+    }
+
+    uint32_t params = IMediaPlayerService::kBatteryDataTrackDecoder;
+    if ((mAudioSource != NULL) && (mAudioSource != mAudioTrack)) {
+        params |= IMediaPlayerService::kBatteryDataTrackAudio;
+    }
+    if (mVideoSource != NULL) {
+        params |= IMediaPlayerService::kBatteryDataTrackVideo;
+    }
+
+    addBatteryData(params);
+
+    return OK;
+}
+
+bool PreviewPlayerBase::isPlaying() const {
+    return (mFlags & PLAYING) || (mFlags & CACHE_UNDERRUN);
+}
+
+void PreviewPlayerBase::setSurface(const sp<Surface> &surface) {
+    Mutex::Autolock autoLock(mLock);
+
+    mSurface = surface;
+    setNativeWindow_l(surface);
+}
+
+void PreviewPlayerBase::setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {
+    Mutex::Autolock autoLock(mLock);
+
+    mSurface.clear();
+    if (surfaceTexture != NULL) {
+        setNativeWindow_l(new SurfaceTextureClient(surfaceTexture));
+    }
+}
+
+void PreviewPlayerBase::shutdownVideoDecoder_l() {
+    if (mVideoBuffer) {
+        mVideoBuffer->release();
+        mVideoBuffer = NULL;
+    }
+
+    mVideoSource->stop();
+
+    // The following hack is necessary to ensure that the OMX
+    // component is completely released by the time we may try
+    // to instantiate it again.
+    wp<MediaSource> tmp = mVideoSource;
+    mVideoSource.clear();
+    while (tmp.promote() != NULL) {
+        usleep(1000);
+    }
+    IPCThreadState::self()->flushCommands();
+}
+
+void PreviewPlayerBase::setNativeWindow_l(const sp<ANativeWindow> &native) {
+    mNativeWindow = native;
+
+    if (mVideoSource == NULL) {
+        return;
+    }
+
+    LOGI("attempting to reconfigure to use new surface");
+
+    bool wasPlaying = (mFlags & PLAYING) != 0;
+
+    pause_l();
+    mVideoRenderer.clear();
+
+    shutdownVideoDecoder_l();
+
+    CHECK_EQ(initVideoDecoder(), (status_t)OK);
+
+    if (mLastVideoTimeUs >= 0) {
+        mSeeking = SEEK;
+        mSeekNotificationSent = true;
+        mSeekTimeUs = mLastVideoTimeUs;
+        mFlags &= ~(AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS);
+    }
+
+    if (wasPlaying) {
+        play_l();
+    }
+}
+
+void PreviewPlayerBase::setAudioSink(
+        const sp<MediaPlayerBase::AudioSink> &audioSink) {
+    Mutex::Autolock autoLock(mLock);
+
+    mAudioSink = audioSink;
+}
+
+status_t PreviewPlayerBase::setLooping(bool shouldLoop) {
+    Mutex::Autolock autoLock(mLock);
+
+    mFlags = mFlags & ~LOOPING;
+
+    if (shouldLoop) {
+        mFlags |= LOOPING;
+    }
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::getDuration(int64_t *durationUs) {
+    Mutex::Autolock autoLock(mMiscStateLock);
+
+    if (mDurationUs < 0) {
+        return UNKNOWN_ERROR;
+    }
+
+    *durationUs = mDurationUs;
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::getPosition(int64_t *positionUs) {
+    if (mRTSPController != NULL) {
+        *positionUs = mRTSPController->getNormalPlayTimeUs();
+    }
+    else if (mSeeking != NO_SEEK) {
+        *positionUs = mSeekTimeUs;
+    } else if (mVideoSource != NULL
+            && (mAudioPlayer == NULL || !(mFlags & VIDEO_AT_EOS))) {
+        Mutex::Autolock autoLock(mMiscStateLock);
+        *positionUs = mVideoTimeUs;
+    } else if (mAudioPlayer != NULL) {
+        *positionUs = mAudioPlayer->getMediaTimeUs();
+    } else {
+        *positionUs = 0;
+    }
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::seekTo(int64_t timeUs) {
+    if (mExtractorFlags & MediaExtractor::CAN_SEEK) {
+        Mutex::Autolock autoLock(mLock);
+        return seekTo_l(timeUs);
+    }
+
+    return OK;
+}
+
+// static
+void PreviewPlayerBase::OnRTSPSeekDoneWrapper(void *cookie) {
+    static_cast<PreviewPlayerBase *>(cookie)->onRTSPSeekDone();
+}
+
+void PreviewPlayerBase::onRTSPSeekDone() {
+    notifyListener_l(MEDIA_SEEK_COMPLETE);
+    mSeekNotificationSent = true;
+}
+
+status_t PreviewPlayerBase::seekTo_l(int64_t timeUs) {
+    if (mRTSPController != NULL) {
+        mRTSPController->seekAsync(timeUs, OnRTSPSeekDoneWrapper, this);
+        return OK;
+    }
+
+    if (mFlags & CACHE_UNDERRUN) {
+        mFlags &= ~CACHE_UNDERRUN;
+        play_l();
+    }
+
+    if ((mFlags & PLAYING) && mVideoSource != NULL && (mFlags & VIDEO_AT_EOS)) {
+        // Video playback completed before, there's no pending
+        // video event right now. In order for this new seek
+        // to be honored, we need to post one.
+
+        postVideoEvent_l();
+    }
+
+    mSeeking = SEEK;
+    mSeekNotificationSent = false;
+    mSeekTimeUs = timeUs;
+    mFlags &= ~(AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS);
+
+    seekAudioIfNecessary_l();
+
+    if (!(mFlags & PLAYING)) {
+        LOGV("seeking while paused, sending SEEK_COMPLETE notification"
+             " immediately.");
+
+        notifyListener_l(MEDIA_SEEK_COMPLETE);
+        mSeekNotificationSent = true;
+
+        if ((mFlags & PREPARED) && mVideoSource != NULL) {
+            mFlags |= SEEK_PREVIEW;
+            postVideoEvent_l();
+        }
+    }
+
+    return OK;
+}
+
+void PreviewPlayerBase::seekAudioIfNecessary_l() {
+    if (mSeeking != NO_SEEK && mVideoSource == NULL && mAudioPlayer != NULL) {
+        mAudioPlayer->seekTo(mSeekTimeUs);
+
+        mWatchForAudioSeekComplete = true;
+        mWatchForAudioEOS = true;
+
+        if (mDecryptHandle != NULL) {
+            mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                    Playback::PAUSE, 0);
+            mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                    Playback::START, mSeekTimeUs / 1000);
+        }
+    }
+}
+
+void PreviewPlayerBase::setAudioSource(sp<MediaSource> source) {
+    CHECK(source != NULL);
+
+    mAudioTrack = source;
+}
+
+status_t PreviewPlayerBase::initAudioDecoder() {
+    sp<MetaData> meta = mAudioTrack->getFormat();
+
+    const char *mime;
+    CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+    if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) {
+        mAudioSource = mAudioTrack;
+    } else {
+        mAudioSource = OMXCodec::Create(
+                mClient.interface(), mAudioTrack->getFormat(),
+                false, // createEncoder
+                mAudioTrack);
+    }
+
+    if (mAudioSource != NULL) {
+        int64_t durationUs;
+        if (mAudioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) {
+            Mutex::Autolock autoLock(mMiscStateLock);
+            if (mDurationUs < 0 || durationUs > mDurationUs) {
+                mDurationUs = durationUs;
+            }
+        }
+
+        status_t err = mAudioSource->start();
+
+        if (err != OK) {
+            mAudioSource.clear();
+            return err;
+        }
+    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_QCELP)) {
+        // For legacy reasons we're simply going to ignore the absence
+        // of an audio decoder for QCELP instead of aborting playback
+        // altogether.
+        return OK;
+    }
+
+    return mAudioSource != NULL ? OK : UNKNOWN_ERROR;
+}
+
+void PreviewPlayerBase::setVideoSource(sp<MediaSource> source) {
+    CHECK(source != NULL);
+
+    mVideoTrack = source;
+}
+
+status_t PreviewPlayerBase::initVideoDecoder(uint32_t flags) {
+
+    // Either the application or the DRM system can independently say
+    // that there must be a hardware-protected path to an external video sink.
+    // For now we always require a hardware-protected path to external video sink
+    // if content is DRMed, but eventually this could be optional per DRM agent.
+    // When the application wants protection, then
+    //   (USE_SURFACE_ALLOC && (mSurface != 0) &&
+    //   (mSurface->getFlags() & ISurfaceComposer::eProtectedByApp))
+    // will be true, but that part is already handled by SurfaceFlinger.
+
+#ifdef DEBUG_HDCP
+    // For debugging, we allow a system property to control the protected usage.
+    // In case of uninitialized or unexpected property, we default to "DRM only".
+    bool setProtectionBit = false;
+    char value[PROPERTY_VALUE_MAX];
+    if (property_get("persist.sys.hdcp_checking", value, NULL)) {
+        if (!strcmp(value, "never")) {
+            // nop
+        } else if (!strcmp(value, "always")) {
+            setProtectionBit = true;
+        } else if (!strcmp(value, "drm-only")) {
+            if (mDecryptHandle != NULL) {
+                setProtectionBit = true;
+            }
+        // property value is empty, or unexpected value
+        } else {
+            if (mDecryptHandle != NULL) {
+                setProtectionBit = true;
+            }
+        }
+    // can' read property value
+    } else {
+        if (mDecryptHandle != NULL) {
+            setProtectionBit = true;
+        }
+    }
+    // note that usage bit is already cleared, so no need to clear it in the "else" case
+    if (setProtectionBit) {
+        flags |= OMXCodec::kEnableGrallocUsageProtected;
+    }
+#else
+    if (mDecryptHandle != NULL) {
+        flags |= OMXCodec::kEnableGrallocUsageProtected;
+    }
+#endif
+    LOGV("initVideoDecoder flags=0x%x", flags);
+    mVideoSource = OMXCodec::Create(
+            mClient.interface(), mVideoTrack->getFormat(),
+            false, // createEncoder
+            mVideoTrack,
+            NULL, flags, USE_SURFACE_ALLOC ? mNativeWindow : NULL);
+
+    if (mVideoSource != NULL) {
+        int64_t durationUs;
+        if (mVideoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) {
+            Mutex::Autolock autoLock(mMiscStateLock);
+            if (mDurationUs < 0 || durationUs > mDurationUs) {
+                mDurationUs = durationUs;
+            }
+        }
+
+        status_t err = mVideoSource->start();
+
+        if (err != OK) {
+            mVideoSource.clear();
+            return err;
+        }
+    }
+
+    return mVideoSource != NULL ? OK : UNKNOWN_ERROR;
+}
+
+void PreviewPlayerBase::finishSeekIfNecessary(int64_t videoTimeUs) {
+    if (mSeeking == SEEK_VIDEO_ONLY) {
+        mSeeking = NO_SEEK;
+        return;
+    }
+
+    if (mSeeking == NO_SEEK || (mFlags & SEEK_PREVIEW)) {
+        return;
+    }
+
+    if (mAudioPlayer != NULL) {
+        LOGV("seeking audio to %lld us (%.2f secs).", videoTimeUs, videoTimeUs / 1E6);
+
+        // If we don't have a video time, seek audio to the originally
+        // requested seek time instead.
+
+        mAudioPlayer->seekTo(videoTimeUs < 0 ? mSeekTimeUs : videoTimeUs);
+        mWatchForAudioSeekComplete = true;
+        mWatchForAudioEOS = true;
+    } else if (!mSeekNotificationSent) {
+        // If we're playing video only, report seek complete now,
+        // otherwise audio player will notify us later.
+        notifyListener_l(MEDIA_SEEK_COMPLETE);
+        mSeekNotificationSent = true;
+    }
+
+    mFlags |= FIRST_FRAME;
+    mSeeking = NO_SEEK;
+
+    if (mDecryptHandle != NULL) {
+        mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                Playback::PAUSE, 0);
+        mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
+                Playback::START, videoTimeUs / 1000);
+    }
+}
+
+void PreviewPlayerBase::onVideoEvent() {
+    Mutex::Autolock autoLock(mLock);
+    if (!mVideoEventPending) {
+        // The event has been cancelled in reset_l() but had already
+        // been scheduled for execution at that time.
+        return;
+    }
+    mVideoEventPending = false;
+
+    if (mSeeking != NO_SEEK) {
+        if (mVideoBuffer) {
+            mVideoBuffer->release();
+            mVideoBuffer = NULL;
+        }
+
+        if (mSeeking == SEEK && mCachedSource != NULL && mAudioSource != NULL
+                && !(mFlags & SEEK_PREVIEW)) {
+            // We're going to seek the video source first, followed by
+            // the audio source.
+            // In order to avoid jumps in the DataSource offset caused by
+            // the audio codec prefetching data from the old locations
+            // while the video codec is already reading data from the new
+            // locations, we'll "pause" the audio source, causing it to
+            // stop reading input data until a subsequent seek.
+
+            if (mAudioPlayer != NULL && (mFlags & AUDIO_RUNNING)) {
+                mAudioPlayer->pause();
+
+                mFlags &= ~AUDIO_RUNNING;
+            }
+            mAudioSource->pause();
+        }
+    }
+
+    if (!mVideoBuffer) {
+        MediaSource::ReadOptions options;
+        if (mSeeking != NO_SEEK) {
+            LOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);
+
+            options.setSeekTo(
+                    mSeekTimeUs,
+                    mSeeking == SEEK_VIDEO_ONLY
+                        ? MediaSource::ReadOptions::SEEK_NEXT_SYNC
+                        : MediaSource::ReadOptions::SEEK_CLOSEST_SYNC);
+        }
+        for (;;) {
+            status_t err = mVideoSource->read(&mVideoBuffer, &options);
+            options.clearSeekTo();
+
+            if (err != OK) {
+                CHECK(mVideoBuffer == NULL);
+
+                if (err == INFO_FORMAT_CHANGED) {
+                    LOGV("VideoSource signalled format change.");
+
+                    notifyVideoSize_l();
+
+                    if (mVideoRenderer != NULL) {
+                        mVideoRendererIsPreview = false;
+                        initRenderer_l();
+                    }
+                    continue;
+                }
+
+                // So video playback is complete, but we may still have
+                // a seek request pending that needs to be applied
+                // to the audio track.
+                if (mSeeking != NO_SEEK) {
+                    LOGV("video stream ended while seeking!");
+                }
+                finishSeekIfNecessary(-1);
+
+                if (mAudioPlayer != NULL
+                        && !(mFlags & (AUDIO_RUNNING | SEEK_PREVIEW))) {
+                    startAudioPlayer_l();
+                }
+
+                mFlags |= VIDEO_AT_EOS;
+                postStreamDoneEvent_l(err);
+                return;
+            }
+
+            if (mVideoBuffer->range_length() == 0) {
+                // Some decoders, notably the PV AVC software decoder
+                // return spurious empty buffers that we just want to ignore.
+
+                mVideoBuffer->release();
+                mVideoBuffer = NULL;
+                continue;
+            }
+
+            break;
+        }
+    }
+
+    int64_t timeUs;
+    CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
+
+    mLastVideoTimeUs = timeUs;
+
+    if (mSeeking == SEEK_VIDEO_ONLY) {
+        if (mSeekTimeUs > timeUs) {
+            LOGI("XXX mSeekTimeUs = %lld us, timeUs = %lld us",
+                 mSeekTimeUs, timeUs);
+        }
+    }
+
+    {
+        Mutex::Autolock autoLock(mMiscStateLock);
+        mVideoTimeUs = timeUs;
+    }
+
+    SeekType wasSeeking = mSeeking;
+    finishSeekIfNecessary(timeUs);
+
+    if (mAudioPlayer != NULL && !(mFlags & (AUDIO_RUNNING | SEEK_PREVIEW))) {
+        status_t err = startAudioPlayer_l();
+        if (err != OK) {
+            LOGE("Startung the audio player failed w/ err %d", err);
+            return;
+        }
+    }
+
+    TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource;
+
+    if (mFlags & FIRST_FRAME) {
+        mFlags &= ~FIRST_FRAME;
+        mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs;
+    }
+
+    int64_t realTimeUs, mediaTimeUs;
+    if (!(mFlags & AUDIO_AT_EOS) && mAudioPlayer != NULL
+        && mAudioPlayer->getMediaTimeMapping(&realTimeUs, &mediaTimeUs)) {
+        mTimeSourceDeltaUs = realTimeUs - mediaTimeUs;
+    }
+
+    if (wasSeeking == SEEK_VIDEO_ONLY) {
+        int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;
+
+        int64_t latenessUs = nowUs - timeUs;
+
+        if (latenessUs > 0) {
+            LOGI("after SEEK_VIDEO_ONLY we're late by %.2f secs", latenessUs / 1E6);
+        }
+    }
+
+    if (wasSeeking == NO_SEEK) {
+        // Let's display the first frame after seeking right away.
+
+        int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;
+
+        int64_t latenessUs = nowUs - timeUs;
+
+        if (latenessUs > 500000ll
+                && mRTSPController == NULL
+                && mAudioPlayer != NULL
+                && mAudioPlayer->getMediaTimeMapping(
+                    &realTimeUs, &mediaTimeUs)) {
+            LOGI("we're much too late (%.2f secs), video skipping ahead",
+                 latenessUs / 1E6);
+
+            mVideoBuffer->release();
+            mVideoBuffer = NULL;
+
+            mSeeking = SEEK_VIDEO_ONLY;
+            mSeekTimeUs = mediaTimeUs;
+
+            postVideoEvent_l();
+            return;
+        }
+
+        if (latenessUs > 40000) {
+            // We're more than 40ms late.
+            LOGV("we're late by %lld us (%.2f secs), dropping frame",
+                 latenessUs, latenessUs / 1E6);
+            mVideoBuffer->release();
+            mVideoBuffer = NULL;
+
+            postVideoEvent_l();
+            return;
+        }
+
+        if (latenessUs < -10000) {
+            // We're more than 10ms early.
+
+            postVideoEvent_l(10000);
+            return;
+        }
+    }
+
+    if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
+        mVideoRendererIsPreview = false;
+
+        initRenderer_l();
+    }
+
+    if (mVideoRenderer != NULL) {
+        mVideoRenderer->render(mVideoBuffer);
+    }
+
+    mVideoBuffer->release();
+    mVideoBuffer = NULL;
+
+    if (wasSeeking != NO_SEEK && (mFlags & SEEK_PREVIEW)) {
+        mFlags &= ~SEEK_PREVIEW;
+        return;
+    }
+
+    postVideoEvent_l();
+}
+
+void PreviewPlayerBase::postVideoEvent_l(int64_t delayUs) {
+    if (mVideoEventPending) {
+        return;
+    }
+
+    mVideoEventPending = true;
+    mQueue.postEventWithDelay(mVideoEvent, delayUs < 0 ? 10000 : delayUs);
+}
+
+void PreviewPlayerBase::postStreamDoneEvent_l(status_t status) {
+    if (mStreamDoneEventPending) {
+        return;
+    }
+    mStreamDoneEventPending = true;
+
+    mStreamDoneStatus = status;
+    mQueue.postEvent(mStreamDoneEvent);
+}
+
+void PreviewPlayerBase::postBufferingEvent_l() {
+    if (mBufferingEventPending) {
+        return;
+    }
+    mBufferingEventPending = true;
+    mQueue.postEventWithDelay(mBufferingEvent, 1000000ll);
+}
+
+void PreviewPlayerBase::postVideoLagEvent_l() {
+    if (mVideoLagEventPending) {
+        return;
+    }
+    mVideoLagEventPending = true;
+    mQueue.postEventWithDelay(mVideoLagEvent, 1000000ll);
+}
+
+void PreviewPlayerBase::postCheckAudioStatusEvent_l(int64_t delayUs) {
+    if (mAudioStatusEventPending) {
+        return;
+    }
+    mAudioStatusEventPending = true;
+    mQueue.postEventWithDelay(mCheckAudioStatusEvent, delayUs);
+}
+
+void PreviewPlayerBase::onCheckAudioStatus() {
+    Mutex::Autolock autoLock(mLock);
+    if (!mAudioStatusEventPending) {
+        // Event was dispatched and while we were blocking on the mutex,
+        // has already been cancelled.
+        return;
+    }
+
+    mAudioStatusEventPending = false;
+
+    if (mWatchForAudioSeekComplete && !mAudioPlayer->isSeeking()) {
+        mWatchForAudioSeekComplete = false;
+
+        if (!mSeekNotificationSent) {
+            notifyListener_l(MEDIA_SEEK_COMPLETE);
+            mSeekNotificationSent = true;
+        }
+
+        mSeeking = NO_SEEK;
+    }
+
+    status_t finalStatus;
+    if (mWatchForAudioEOS && mAudioPlayer->reachedEOS(&finalStatus)) {
+        mWatchForAudioEOS = false;
+        mFlags |= AUDIO_AT_EOS;
+        mFlags |= FIRST_FRAME;
+        postStreamDoneEvent_l(finalStatus);
+    }
+}
+
+status_t PreviewPlayerBase::prepare() {
+    Mutex::Autolock autoLock(mLock);
+    return prepare_l();
+}
+
+status_t PreviewPlayerBase::prepare_l() {
+    if (mFlags & PREPARED) {
+        return OK;
+    }
+
+    if (mFlags & PREPARING) {
+        return UNKNOWN_ERROR;
+    }
+
+    mIsAsyncPrepare = false;
+    status_t err = prepareAsync_l();
+
+    if (err != OK) {
+        return err;
+    }
+
+    while (mFlags & PREPARING) {
+        mPreparedCondition.wait(mLock);
+    }
+
+    return mPrepareResult;
+}
+
+status_t PreviewPlayerBase::prepareAsync() {
+    Mutex::Autolock autoLock(mLock);
+
+    if (mFlags & PREPARING) {
+        return UNKNOWN_ERROR;  // async prepare already pending
+    }
+
+    mIsAsyncPrepare = true;
+    return prepareAsync_l();
+}
+
+status_t PreviewPlayerBase::prepareAsync_l() {
+    if (mFlags & PREPARING) {
+        return UNKNOWN_ERROR;  // async prepare already pending
+    }
+
+    if (!mQueueStarted) {
+        mQueue.start();
+        mQueueStarted = true;
+    }
+
+    mFlags |= PREPARING;
+    mAsyncPrepareEvent = new AwesomeEvent(
+            this, &PreviewPlayerBase::onPrepareAsyncEvent);
+
+    mQueue.postEvent(mAsyncPrepareEvent);
+
+    return OK;
+}
+
+status_t PreviewPlayerBase::finishSetDataSource_l() {
+    sp<DataSource> dataSource;
+
+    if (!strncasecmp("http://", mUri.string(), 7)
+            || !strncasecmp("https://", mUri.string(), 8)) {
+        mConnectingDataSource = HTTPBase::Create(
+                (mFlags & INCOGNITO)
+                    ? HTTPBase::kFlagIncognito
+                    : 0);
+
+        mLock.unlock();
+        status_t err = mConnectingDataSource->connect(mUri, &mUriHeaders);
+        mLock.lock();
+
+        if (err != OK) {
+            mConnectingDataSource.clear();
+
+            LOGI("mConnectingDataSource->connect() returned %d", err);
+            return err;
+        }
+
+#if 0
+        mCachedSource = new NuCachedSource2(
+                new ThrottledSource(
+                    mConnectingDataSource, 50 * 1024 /* bytes/sec */));
+#else
+        mCachedSource = new NuCachedSource2(mConnectingDataSource);
+#endif
+        mConnectingDataSource.clear();
+
+        dataSource = mCachedSource;
+
+        String8 contentType = dataSource->getMIMEType();
+
+        if (strncasecmp(contentType.string(), "audio/", 6)) {
+            // We're not doing this for streams that appear to be audio-only
+            // streams to ensure that even low bandwidth streams start
+            // playing back fairly instantly.
+
+            // We're going to prefill the cache before trying to instantiate
+            // the extractor below, as the latter is an operation that otherwise
+            // could block on the datasource for a significant amount of time.
+            // During that time we'd be unable to abort the preparation phase
+            // without this prefill.
+
+            mLock.unlock();
+
+            for (;;) {
+                status_t finalStatus;
+                size_t cachedDataRemaining =
+                    mCachedSource->approxDataRemaining(&finalStatus);
+
+                if (finalStatus != OK || cachedDataRemaining >= kHighWaterMarkBytes
+                        || (mFlags & PREPARE_CANCELLED)) {
+                    break;
+                }
+
+                usleep(200000);
+            }
+
+            mLock.lock();
+        }
+
+        if (mFlags & PREPARE_CANCELLED) {
+            LOGI("Prepare cancelled while waiting for initial cache fill.");
+            return UNKNOWN_ERROR;
+        }
+    } else if (!strncasecmp("rtsp://", mUri.string(), 7)) {
+        if (mLooper == NULL) {
+            mLooper = new ALooper;
+            mLooper->setName("rtsp");
+            mLooper->start();
+        }
+        mRTSPController = new ARTSPController(mLooper);
+        mConnectingRTSPController = mRTSPController;
+
+        mLock.unlock();
+        status_t err = mRTSPController->connect(mUri.string());
+        mLock.lock();
+
+        mConnectingRTSPController.clear();
+
+        LOGI("ARTSPController::connect returned %d", err);
+
+        if (err != OK) {
+            mRTSPController.clear();
+            return err;
+        }
+
+        sp<MediaExtractor> extractor = mRTSPController.get();
+        return setDataSource_l(extractor);
+    } else {
+        dataSource = DataSource::CreateFromURI(mUri.string(), &mUriHeaders);
+    }
+
+    if (dataSource == NULL) {
+        return UNKNOWN_ERROR;
+    }
+
+    sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
+
+    if (extractor == NULL) {
+        return UNKNOWN_ERROR;
+    }
+
+    dataSource->getDrmInfo(mDecryptHandle, &mDrmManagerClient);
+
+    if (mDecryptHandle != NULL) {
+        CHECK(mDrmManagerClient);
+        if (RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
+            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_DRM_NO_LICENSE);
+        }
+    }
+
+    return setDataSource_l(extractor);
+}
+
+void PreviewPlayerBase::abortPrepare(status_t err) {
+    CHECK(err != OK);
+
+    if (mIsAsyncPrepare) {
+        notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
+    }
+
+    mPrepareResult = err;
+    mFlags &= ~(PREPARING|PREPARE_CANCELLED|PREPARING_CONNECTED);
+    mAsyncPrepareEvent = NULL;
+    mPreparedCondition.broadcast();
+}
+
+// static
+bool PreviewPlayerBase::ContinuePreparation(void *cookie) {
+    PreviewPlayerBase *me = static_cast<PreviewPlayerBase *>(cookie);
+
+    return (me->mFlags & PREPARE_CANCELLED) == 0;
+}
+
+void PreviewPlayerBase::onPrepareAsyncEvent() {
+    Mutex::Autolock autoLock(mLock);
+
+    if (mFlags & PREPARE_CANCELLED) {
+        LOGI("prepare was cancelled before doing anything");
+        abortPrepare(UNKNOWN_ERROR);
+        return;
+    }
+
+    if (mUri.size() > 0) {
+        status_t err = finishSetDataSource_l();
+
+        if (err != OK) {
+            abortPrepare(err);
+            return;
+        }
+    }
+
+    if (mVideoTrack != NULL && mVideoSource == NULL) {
+        status_t err = initVideoDecoder();
+
+        if (err != OK) {
+            abortPrepare(err);
+            return;
+        }
+    }
+
+    if (mAudioTrack != NULL && mAudioSource == NULL) {
+        status_t err = initAudioDecoder();
+
+        if (err != OK) {
+            abortPrepare(err);
+            return;
+        }
+    }
+
+    mFlags |= PREPARING_CONNECTED;
+
+    if (mCachedSource != NULL || mRTSPController != NULL) {
+        postBufferingEvent_l();
+    } else {
+        finishAsyncPrepare_l();
+    }
+}
+
+void PreviewPlayerBase::finishAsyncPrepare_l() {
+    if (mIsAsyncPrepare) {
+        if (mVideoSource == NULL) {
+            notifyListener_l(MEDIA_SET_VIDEO_SIZE, 0, 0);
+        } else {
+            notifyVideoSize_l();
+        }
+
+        notifyListener_l(MEDIA_PREPARED);
+    }
+
+    mPrepareResult = OK;
+    mFlags &= ~(PREPARING|PREPARE_CANCELLED|PREPARING_CONNECTED);
+    mFlags |= PREPARED;
+    mAsyncPrepareEvent = NULL;
+    mPreparedCondition.broadcast();
+}
+
+uint32_t PreviewPlayerBase::flags() const {
+    return mExtractorFlags;
+}
+
+void PreviewPlayerBase::postAudioEOS(int64_t delayUs) {
+    Mutex::Autolock autoLock(mLock);
+    postCheckAudioStatusEvent_l(delayUs);
+}
+
+void PreviewPlayerBase::postAudioSeekComplete() {
+    Mutex::Autolock autoLock(mLock);
+    postCheckAudioStatusEvent_l(0 /* delayUs */);
+}
+
+status_t PreviewPlayerBase::setParameter(int key, const Parcel &request) {
+    return OK;
+}
+
+status_t PreviewPlayerBase::getParameter(int key, Parcel *reply) {
+    return OK;
+}
+}  // namespace android
diff --git a/libvideoeditor/lvpp/PreviewPlayerBase.h b/libvideoeditor/lvpp/PreviewPlayerBase.h
new file mode 100644
index 0000000..a68d53c
--- /dev/null
+++ b/libvideoeditor/lvpp/PreviewPlayerBase.h
@@ -0,0 +1,285 @@
+/*
+ * 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 PREVIEW_PLAYER_BASE_H_
+
+#define PREVIEW_PLAYER_BASE_H_
+
+#include "HTTPBase.h"
+#include "TimedEventQueue.h"
+
+#include <media/MediaPlayerInterface.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/OMXClient.h>
+#include <media/stagefright/TimeSource.h>
+#include <utils/threads.h>
+#include <drm/DrmManagerClient.h>
+
+namespace android {
+
+struct AudioPlayerBase;
+struct DataSource;
+struct MediaBuffer;
+struct MediaExtractor;
+struct MediaSource;
+struct NuCachedSource2;
+struct ISurfaceTexture;
+
+struct ALooper;
+struct ARTSPController;
+
+class DrmManagerClinet;
+class DecryptHandle;
+
+struct AwesomeRenderer : public RefBase {
+    AwesomeRenderer() {}
+
+    virtual void render(MediaBuffer *buffer) = 0;
+
+private:
+    AwesomeRenderer(const AwesomeRenderer &);
+    AwesomeRenderer &operator=(const AwesomeRenderer &);
+};
+
+struct PreviewPlayerBase {
+    PreviewPlayerBase();
+    ~PreviewPlayerBase();
+
+    void setListener(const wp<MediaPlayerBase> &listener);
+
+    status_t setDataSource(
+            const char *uri,
+            const KeyedVector<String8, String8> *headers = NULL);
+
+    status_t setDataSource(int fd, int64_t offset, int64_t length);
+
+    status_t setDataSource(const sp<IStreamSource> &source);
+
+    void reset();
+
+    status_t prepare();
+    status_t prepare_l();
+    status_t prepareAsync();
+    status_t prepareAsync_l();
+
+    status_t play();
+    status_t pause();
+
+    bool isPlaying() const;
+
+    void setSurface(const sp<Surface> &surface);
+    void setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture);
+    void setAudioSink(const sp<MediaPlayerBase::AudioSink> &audioSink);
+    status_t setLooping(bool shouldLoop);
+
+    status_t getDuration(int64_t *durationUs);
+    status_t getPosition(int64_t *positionUs);
+
+    status_t setParameter(int key, const Parcel &request);
+    status_t getParameter(int key, Parcel *reply);
+
+    status_t seekTo(int64_t timeUs);
+
+    // This is a mask of MediaExtractor::Flags.
+    uint32_t flags() const;
+
+    void postAudioEOS(int64_t delayUs = 0ll);
+    void postAudioSeekComplete();
+
+private:
+    friend struct AwesomeEvent;
+    friend struct PreviewPlayer;
+
+    enum {
+        PLAYING             = 1,
+        LOOPING             = 2,
+        FIRST_FRAME         = 4,
+        PREPARING           = 8,
+        PREPARED            = 16,
+        AT_EOS              = 32,
+        PREPARE_CANCELLED   = 64,
+        CACHE_UNDERRUN      = 128,
+        AUDIO_AT_EOS        = 256,
+        VIDEO_AT_EOS        = 512,
+        AUTO_LOOPING        = 1024,
+
+        // We are basically done preparing but are currently buffering
+        // sufficient data to begin playback and finish the preparation phase
+        // for good.
+        PREPARING_CONNECTED = 2048,
+
+        // We're triggering a single video event to display the first frame
+        // after the seekpoint.
+        SEEK_PREVIEW        = 4096,
+
+        AUDIO_RUNNING       = 8192,
+        AUDIOPLAYER_STARTED = 16384,
+
+        INCOGNITO           = 32768,
+    };
+
+    mutable Mutex mLock;
+    Mutex mMiscStateLock;
+
+    OMXClient mClient;
+    TimedEventQueue mQueue;
+    bool mQueueStarted;
+    wp<MediaPlayerBase> mListener;
+
+    sp<Surface> mSurface;
+    sp<ANativeWindow> mNativeWindow;
+    sp<MediaPlayerBase::AudioSink> mAudioSink;
+
+    SystemTimeSource mSystemTimeSource;
+    TimeSource *mTimeSource;
+
+    String8 mUri;
+    KeyedVector<String8, String8> mUriHeaders;
+
+    sp<DataSource> mFileSource;
+
+    sp<MediaSource> mVideoTrack;
+    sp<MediaSource> mVideoSource;
+    sp<AwesomeRenderer> mVideoRenderer;
+    bool mVideoRendererIsPreview;
+
+    sp<MediaSource> mAudioTrack;
+    sp<MediaSource> mAudioSource;
+    AudioPlayerBase *mAudioPlayer;
+    int64_t mDurationUs;
+
+    int32_t mDisplayWidth;
+    int32_t mDisplayHeight;
+
+    uint32_t mFlags;
+    uint32_t mExtractorFlags;
+
+    int64_t mTimeSourceDeltaUs;
+    int64_t mVideoTimeUs;
+
+    enum SeekType {
+        NO_SEEK,
+        SEEK,
+        SEEK_VIDEO_ONLY
+    };
+    SeekType mSeeking;
+
+    bool mSeekNotificationSent;
+    int64_t mSeekTimeUs;
+
+    int64_t mBitrate;  // total bitrate of the file (in bps) or -1 if unknown.
+
+    bool mWatchForAudioSeekComplete;
+    bool mWatchForAudioEOS;
+
+    sp<TimedEventQueue::Event> mVideoEvent;
+    bool mVideoEventPending;
+    sp<TimedEventQueue::Event> mStreamDoneEvent;
+    bool mStreamDoneEventPending;
+    sp<TimedEventQueue::Event> mBufferingEvent;
+    bool mBufferingEventPending;
+    sp<TimedEventQueue::Event> mCheckAudioStatusEvent;
+    bool mAudioStatusEventPending;
+    sp<TimedEventQueue::Event> mVideoLagEvent;
+    bool mVideoLagEventPending;
+
+    sp<TimedEventQueue::Event> mAsyncPrepareEvent;
+    Condition mPreparedCondition;
+    bool mIsAsyncPrepare;
+    status_t mPrepareResult;
+    status_t mStreamDoneStatus;
+
+    void postVideoEvent_l(int64_t delayUs = -1);
+    void postBufferingEvent_l();
+    void postStreamDoneEvent_l(status_t status);
+    void postCheckAudioStatusEvent_l(int64_t delayUs);
+    void postVideoLagEvent_l();
+    status_t play_l();
+
+    MediaBuffer *mVideoBuffer;
+
+    sp<HTTPBase> mConnectingDataSource;
+    sp<NuCachedSource2> mCachedSource;
+
+    sp<ALooper> mLooper;
+    sp<ARTSPController> mRTSPController;
+    sp<ARTSPController> mConnectingRTSPController;
+
+    DrmManagerClient *mDrmManagerClient;
+    sp<DecryptHandle> mDecryptHandle;
+
+    int64_t mLastVideoTimeUs;
+
+    status_t setDataSource_l(
+            const char *uri,
+            const KeyedVector<String8, String8> *headers = NULL);
+
+    status_t setDataSource_l(const sp<DataSource> &dataSource);
+    status_t setDataSource_l(const sp<MediaExtractor> &extractor);
+    void reset_l();
+    status_t seekTo_l(int64_t timeUs);
+    status_t pause_l(bool at_eos = false);
+    void initRenderer_l();
+    void notifyVideoSize_l();
+    void seekAudioIfNecessary_l();
+
+    void cancelPlayerEvents(bool keepBufferingGoing = false);
+
+    void setAudioSource(sp<MediaSource> source);
+    status_t initAudioDecoder();
+
+    void setVideoSource(sp<MediaSource> source);
+    status_t initVideoDecoder(uint32_t flags = 0);
+
+    void onStreamDone();
+
+    void notifyListener_l(int msg, int ext1 = 0, int ext2 = 0);
+
+    void onVideoEvent();
+    void onBufferingUpdate();
+    void onCheckAudioStatus();
+    void onPrepareAsyncEvent();
+    void abortPrepare(status_t err);
+    void finishAsyncPrepare_l();
+    void onVideoLagUpdate();
+
+    bool getCachedDuration_l(int64_t *durationUs, bool *eos);
+
+    status_t finishSetDataSource_l();
+
+    static bool ContinuePreparation(void *cookie);
+
+    static void OnRTSPSeekDoneWrapper(void *cookie);
+    void onRTSPSeekDone();
+
+    bool getBitrate(int64_t *bitrate);
+
+    void finishSeekIfNecessary(int64_t videoTimeUs);
+    void ensureCacheIsFetching_l();
+
+    status_t startAudioPlayer_l();
+
+    void shutdownVideoDecoder_l();
+    void setNativeWindow_l(const sp<ANativeWindow> &native);
+
+    PreviewPlayerBase(const PreviewPlayerBase &);
+    PreviewPlayerBase &operator=(const PreviewPlayerBase &);
+};
+
+}  // namespace android
+
+#endif  // PREVIEW_PLAYER_BASE_H_
+
diff --git a/libvideoeditor/lvpp/PreviewRenderer.cpp b/libvideoeditor/lvpp/PreviewRenderer.cpp
index cfded72..8f172f3 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.cpp
+++ b/libvideoeditor/lvpp/PreviewRenderer.cpp
@@ -207,7 +207,7 @@
 //

 void PreviewRenderer::render(

         const void *data, size_t size, void *platformPrivate) {

-    android_native_buffer_t *buf;

+    ANativeWindowBuffer *buf;

     int err;

 

     if ((err = mSurface->dequeueBuffer(mSurface.get(), &buf)) != 0) {

diff --git a/libvideoeditor/lvpp/PreviewRenderer.h b/libvideoeditor/lvpp/PreviewRenderer.h
index 876ca16..ccfcf86 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.h
+++ b/libvideoeditor/lvpp/PreviewRenderer.h
@@ -72,7 +72,7 @@
     size_t mDisplayWidth, mDisplayHeight;

     size_t mDecodedWidth, mDecodedHeight;

 

-    android_native_buffer_t *mBuf;

+    ANativeWindowBuffer *mBuf;

 

     PreviewRenderer(const PreviewRenderer &);

     PreviewRenderer &operator=(const PreviewRenderer &);

diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index ed9de6e..70c38e6 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -28,16 +28,19 @@
 #include <media/stagefright/MediaSource.h>
 #include <media/stagefright/MetaData.h>
 
+#include <system/audio.h>
+
 #include "PreviewPlayer.h"
 namespace android {
 
 VideoEditorAudioPlayer::VideoEditorAudioPlayer(
         const sp<MediaPlayerBase::AudioSink> &audioSink,
-        AwesomePlayer *observer)
-    : AudioPlayer(audioSink, observer) {
+        PreviewPlayerBase *observer)
+    : AudioPlayerBase(audioSink, observer) {
 
     LOGV("VideoEditorAudioPlayer");
     mBGAudioPCMFileHandle = NULL;
+    mAudioProcess = NULL;
     mBGAudioPCMFileLength = 0;
     mBGAudioPCMFileTrimmedLength = 0;
     mBGAudioPCMFileDuration = 0;
@@ -47,6 +50,7 @@
     mBGAudioStoryBoardCurrentMediaBeginCutTS = 0;
     mBGAudioStoryBoardCurrentMediaVolumeVal = 0;
     mSeekTimeUs = 0;
+    mSource = NULL;
 }
 
 VideoEditorAudioPlayer::~VideoEditorAudioPlayer() {
@@ -55,10 +59,56 @@
     if (mStarted) {
         reset();
     }
+    if (mAudioProcess != NULL) {
+        delete mAudioProcess;
+        mAudioProcess = NULL;
+    }
+}
+void VideoEditorAudioPlayer::setSource(const sp<MediaSource> &source) {
+    Mutex::Autolock autoLock(mLock);
+
+    // Before setting source, stop any existing source.
+    // Make sure to release any buffer we hold onto so that the
+    // source is able to stop().
+
+    if (mFirstBuffer != NULL) {
+        mFirstBuffer->release();
+        mFirstBuffer = NULL;
+    }
+
+    if (mInputBuffer != NULL) {
+        LOGV("VideoEditorAudioPlayer releasing input buffer.");
+
+        mInputBuffer->release();
+        mInputBuffer = NULL;
+    }
+
+    if (mSource != NULL) {
+        mSource->stop();
+        mSource.clear();
+    }
+
+    mSource = source;
+    mReachedEOS = false;
+}
+
+sp<MediaSource> VideoEditorAudioPlayer::getSource() {
+    Mutex::Autolock autoLock(mLock);
+    return mSource;
+}
+
+void VideoEditorAudioPlayer::setObserver(PreviewPlayerBase *observer) {
+    LOGV("setObserver");
+    //CHECK(!mStarted);
+    mObserver = observer;
+}
+
+bool VideoEditorAudioPlayer::isStarted() {
+    return mStarted;
 }
 
 status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
-
+    Mutex::Autolock autoLock(mLock);
     CHECK(!mStarted);
     CHECK(mSource != NULL);
     LOGV("Start");
@@ -80,11 +130,16 @@
     veAudMixSettings audioMixSettings;
 
     // Pass on the audio ducking parameters
-    audioMixSettings.lvInDucking_threshold = mAudioMixSettings->uiInDucking_threshold;
-    audioMixSettings.lvInDucking_lowVolume = ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
-    audioMixSettings.lvInDucking_enable = mAudioMixSettings->bInDucking_enable;
-    audioMixSettings.lvPTVolLevel = ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
-    audioMixSettings.lvBTVolLevel = ((M4OSA_Float)mAudioMixSettings->uiAddVolume) /100.0;
+    audioMixSettings.lvInDucking_threshold =
+        mAudioMixSettings->uiInDucking_threshold;
+    audioMixSettings.lvInDucking_lowVolume =
+        ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
+    audioMixSettings.lvInDucking_enable =
+        mAudioMixSettings->bInDucking_enable;
+    audioMixSettings.lvPTVolLevel =
+        ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
+    audioMixSettings.lvBTVolLevel =
+        ((M4OSA_Float)mAudioMixSettings->uiAddVolume) / 100.0;
     audioMixSettings.lvBTChannelCount = mAudioMixSettings->uiBTChannelCount;
     audioMixSettings.lvPTChannelCount = mAudioMixSettings->uiNbChannels;
 
@@ -246,7 +301,7 @@
 
     if (mAudioSink.get() != NULL) {
         status_t err = mAudioSink->open(
-                mSampleRate, numChannels, AudioSystem::PCM_16_BIT,
+                mSampleRate, numChannels, AUDIO_FORMAT_PCM_16_BIT,
                 DEFAULT_AUDIOSINK_BUFFERCOUNT,
                 &VideoEditorAudioPlayer::AudioSinkCallback, this);
         if (err != OK) {
@@ -268,10 +323,10 @@
         mAudioSink->start();
     } else {
         mAudioTrack = new AudioTrack(
-                AudioSystem::MUSIC, mSampleRate, AudioSystem::PCM_16_BIT,
+                AUDIO_STREAM_MUSIC, mSampleRate, AUDIO_FORMAT_PCM_16_BIT,
                 (numChannels == 2)
-                    ? AudioSystem::CHANNEL_OUT_STEREO
-                    : AudioSystem::CHANNEL_OUT_MONO,
+                    ? AUDIO_CHANNEL_OUT_STEREO
+                    : AUDIO_CHANNEL_OUT_MONO,
                 0, 0, &AudioCallback, this, 0);
 
         if ((err = mAudioTrack->initCheck()) != OK) {
@@ -301,10 +356,37 @@
     return OK;
 }
 
+void VideoEditorAudioPlayer::resume() {
+
+    veAudMixSettings audioMixSettings;
+
+    // Single audio player is used;
+    // Pass on the audio ducking parameters
+    // which might have changed with new audio source
+    audioMixSettings.lvInDucking_threshold =
+        mAudioMixSettings->uiInDucking_threshold;
+    audioMixSettings.lvInDucking_lowVolume =
+        ((M4OSA_Float)mAudioMixSettings->uiInDucking_lowVolume) / 100.0;
+    audioMixSettings.lvInDucking_enable =
+        mAudioMixSettings->bInDucking_enable;
+    audioMixSettings.lvPTVolLevel =
+        ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal) / 100.0;
+    audioMixSettings.lvBTVolLevel =
+        ((M4OSA_Float)mAudioMixSettings->uiAddVolume) / 100.0;
+    audioMixSettings.lvBTChannelCount = mAudioMixSettings->uiBTChannelCount;
+    audioMixSettings.lvPTChannelCount = mAudioMixSettings->uiNbChannels;
+
+    // Call to Audio mix param setting
+    mAudioProcess->veSetAudioProcessingParams(audioMixSettings);
+
+    //Call the base class
+    AudioPlayerBase::resume();
+}
+
 void VideoEditorAudioPlayer::reset() {
 
     LOGV("reset");
-    AudioPlayer::reset();
+    AudioPlayerBase::reset();
 
     // Capture the current seek point
     mBGAudioPCMFileSeekPoint = 0;
@@ -331,16 +413,19 @@
     size_t size_remaining = size;
 
     M4OSA_ERR err = M4NO_ERROR;
-    M4AM_Buffer bgFrame = {NULL, 0};
-    M4AM_Buffer mixFrame = {NULL, 0};
-    M4AM_Buffer ptFrame = {NULL, 0};
+    M4AM_Buffer16 bgFrame = {NULL, 0};
+    M4AM_Buffer16 mixFrame = {NULL, 0};
+    M4AM_Buffer16 ptFrame = {NULL, 0};
     int64_t currentSteamTS = 0;
     int64_t startTimeForBT = 0;
     M4OSA_Float fPTVolLevel =
      ((M4OSA_Float)mBGAudioStoryBoardCurrentMediaVolumeVal)/100;
-    M4OSA_Int16     *pPTMdata;
+    M4OSA_Int16     *pPTMdata=NULL;
     M4OSA_UInt32     uiPCMsize = 0;
 
+    bool postSeekComplete = false;
+    bool postEOS = false;
+
     while ((size_remaining > 0)&&(err==M4NO_ERROR)) {
         MediaSource::ReadOptions options;
 
@@ -363,8 +448,9 @@
                 }
 
                 mSeeking = false;
+
                 if (mObserver) {
-                    mObserver->postAudioSeekComplete();
+                    postSeekComplete = true;
                 }
             }
         }
@@ -379,7 +465,11 @@
 
                 mIsFirstBuffer = false;
             } else {
-                status = mSource->read(&mInputBuffer, &options);
+
+                {
+                    Mutex::Autolock autoLock(mLock);
+                    status = mSource->read(&mInputBuffer, &options);
+                }
                 // Data is Primary Track, mix with background track
                 // after reading same size from Background track PCM file
                 if (status == OK)
@@ -390,9 +480,9 @@
                           (int64_t)(mAudioMixSettings->uiAddCts * 1000)) {
 
                         LOGV("VideoEditorAudioPlayer::INSIDE MIXING");
-                        LOGV("Checking %lld <= %lld - %d",
+                        LOGV("Checking %lld <= %lld",
                             mBGAudioPCMFileSeekPoint-mBGAudioPCMFileOriginalSeekPoint,
-                            mBGAudioPCMFileTrimmedLength, len);
+                            mBGAudioPCMFileTrimmedLength);
 
 
                         M4OSA_Void* ptr;
@@ -403,12 +493,12 @@
                         M4OSA_Context fp = M4OSA_NULL;
 
                         uiPCMsize = (mInputBuffer->range_length())/2;
-                        pPTMdata = (M4OSA_Int16*)(mInputBuffer->data() +
-                        mInputBuffer->range_offset());
+                        pPTMdata = (M4OSA_Int16*) ((uint8_t*) mInputBuffer->data()
+                                + mInputBuffer->range_offset());
 
                         LOGV("mix with background malloc to do len %d", len);
 
-                        bgFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_malloc( len, 1,
+                        bgFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_32bitAlignedMalloc( len, 1,
                                                        (M4OSA_Char*)"bgFrame");
                         if (NULL == bgFrame.m_dataAddress) {
                             LOGE("mBackgroundAudioSetting Malloc failed");
@@ -416,7 +506,7 @@
 
                         bgFrame.m_bufferSize = len;
 
-                        mixFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_malloc(len, 1,
+                        mixFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_32bitAlignedMalloc(len, 1,
                                                     (M4OSA_Char*)"mixFrame");
                         if (NULL == mixFrame.m_dataAddress) {
                             LOGE("mBackgroundAudioSetting Malloc failed");
@@ -450,7 +540,7 @@
                                 mBGAudioPCMFileSeekPoint = tmp32;
 
                                 if (err != M4NO_ERROR){
-                                    LOGE("M4OSA_fileReadSeek err %d", err);
+                                    LOGE("M4OSA_fileReadSeek err %d",(int)err);
                                 }
 
                                 err = M4OSA_fileReadData(mBGAudioPCMFileHandle,
@@ -497,8 +587,8 @@
                                          &ptFrame, &bgFrame, &mixFrame);
 
                                         // Overwrite the decoded buffer
-                                    M4OSA_memcpy((M4OSA_MemAddr8)ptr,
-                                         (M4OSA_MemAddr8)mixFrame.m_dataAddress, len);
+                                    memcpy((void *)ptr,
+                                         (void *)mixFrame.m_dataAddress, len);
                                 }
                             }
                         } else if (mAudioMixSettings->bLoop){
@@ -514,10 +604,10 @@
                             }
                         }
                         if (bgFrame.m_dataAddress) {
-                            M4OSA_free((M4OSA_MemAddr32)bgFrame.m_dataAddress);
+                            free(bgFrame.m_dataAddress);
                         }
                         if (mixFrame.m_dataAddress) {
-                            M4OSA_free((M4OSA_MemAddr32)mixFrame.m_dataAddress);
+                            free(mixFrame.m_dataAddress);
                         }
                     } else {
                         // No mixing;
@@ -538,7 +628,7 @@
             if (status != OK) {
                 LOGV("fillBuffer: mSource->read returned err %d", status);
                 if (mObserver && !mReachedEOS) {
-                    mObserver->postAudioEOS();
+                    postEOS = true;
                 }
 
                 mReachedEOS = true;
@@ -582,8 +672,18 @@
         size_remaining -= copy;
     }
 
-    Mutex::Autolock autoLock(mLock);
-    mNumFramesPlayed += size_done / mFrameSize;
+    {
+        Mutex::Autolock autoLock(mLock);
+        mNumFramesPlayed += size_done / mFrameSize;
+    }
+
+    if (postEOS) {
+        mObserver->postAudioEOS();
+    }
+
+    if (postSeekComplete) {
+        mObserver->postAudioSeekComplete();
+    }
 
     return size_done;
 }
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.h b/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
index 92b77b6..73aea65 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.h
@@ -27,7 +27,8 @@
 #include "VideoEditorMain.h"

 #include "M4OSA_FileReader.h"

 #include "VideoEditorBGAudioProcessing.h"

-#include <media/stagefright/AudioPlayer.h>

+#include "AudioPlayerBase.h"

+#include "PreviewPlayerBase.h"

 

 namespace android {

 

@@ -36,7 +37,7 @@
 class PreviewPlayer;

 

 

-class VideoEditorAudioPlayer : public AudioPlayer {

+class VideoEditorAudioPlayer : public AudioPlayerBase {

 public:

     enum {

         REACHED_EOS,

@@ -44,11 +45,12 @@
     };

 

     VideoEditorAudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink,

-        AwesomePlayer *audioObserver = NULL);

+        PreviewPlayerBase *audioObserver = NULL);

 

     virtual ~VideoEditorAudioPlayer();

 

     status_t start(bool sourceAlreadyStarted = false);

+    void resume();

 

     void setAudioMixSettings(M4xVSS_AudioMixingSettings* pAudioMixSettings);

     void setAudioMixPCMFileHandle(M4OSA_Context pBGAudioPCMFileHandle);

@@ -57,6 +59,11 @@
         M4OSA_UInt32 pBGAudioCurrentMediaBeginCutTS,

         M4OSA_UInt32 pBGAudioCurrentMediaVolumeVal);

 

+    void setObserver(PreviewPlayerBase *observer);

+    void setSource(const sp<MediaSource> &source);

+    sp<MediaSource> getSource();

+

+    bool isStarted();

 private:

 

     M4xVSS_AudioMixingSettings *mAudioMixSettings;

diff --git a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
index 2049f08..bcdc3de 100755
--- a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
+++ b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
@@ -22,41 +22,41 @@
 

 namespace android {

 

-VideoEditorBGAudioProcessing ::VideoEditorBGAudioProcessing() {

+VideoEditorBGAudioProcessing::VideoEditorBGAudioProcessing() {

 

     LOGV("VideoEditorBGAudioProcessing:: Construct  VideoEditorBGAudioProcessing ");

 

-    VideoEditorBGAudioProcessing::mAudVolArrIndex = 0;

-    VideoEditorBGAudioProcessing::mDoDucking = 0;

-    VideoEditorBGAudioProcessing::mDucking_enable = 0;

-    VideoEditorBGAudioProcessing::mDucking_lowVolume = 0;

-    VideoEditorBGAudioProcessing::mDucking_threshold = 0;

-    VideoEditorBGAudioProcessing::mDuckingFactor = 0;

+    mAudVolArrIndex = 0;

+    mDoDucking = 0;

+    mDucking_enable = 0;

+    mDucking_lowVolume = 0;

+    mDucking_threshold = 0;

+    mDuckingFactor = 0;

 

-    VideoEditorBGAudioProcessing::mBTVolLevel = 0;

-    VideoEditorBGAudioProcessing::mPTVolLevel = 0;

+    mBTVolLevel = 0;

+    mPTVolLevel = 0;

 

-    VideoEditorBGAudioProcessing::mIsSSRCneeded = 0;

-    VideoEditorBGAudioProcessing::mChannelConversion = 0;

+    mIsSSRCneeded = 0;

+    mChannelConversion = 0;

 

-    VideoEditorBGAudioProcessing::mBTFormat = MONO_16_BIT;

+    mBTFormat = MONO_16_BIT;

 

-    VideoEditorBGAudioProcessing::mInSampleRate = 8000;

-    VideoEditorBGAudioProcessing::mOutSampleRate = 16000;

-    VideoEditorBGAudioProcessing::mPTChannelCount = 2;

-    VideoEditorBGAudioProcessing::mBTChannelCount = 1;

+    mInSampleRate = 8000;

+    mOutSampleRate = 16000;

+    mPTChannelCount = 2;

+    mBTChannelCount = 1;

 }

 

 M4OSA_Int32 VideoEditorBGAudioProcessing::veProcessAudioMixNDuck(

         void *pPTBuffer, void *pBTBuffer, void *pOutBuffer) {

 

-    M4AM_Buffer* pPrimaryTrack   = (M4AM_Buffer*)pPTBuffer;

-    M4AM_Buffer* pBackgroundTrack = (M4AM_Buffer*)pBTBuffer;

-    M4AM_Buffer* pMixedOutBuffer  = (M4AM_Buffer*)pOutBuffer;

+    M4AM_Buffer16* pPrimaryTrack   = (M4AM_Buffer16*)pPTBuffer;

+    M4AM_Buffer16* pBackgroundTrack = (M4AM_Buffer16*)pBTBuffer;

+    M4AM_Buffer16* pMixedOutBuffer  = (M4AM_Buffer16*)pOutBuffer;

 

     LOGV("VideoEditorBGAudioProcessing::lvProcessAudioMixNDuck \

-     pPTBuffer 0x%x pBTBuffer 0x%x pOutBuffer 0x%x", pPTBuffer,

-      pBTBuffer, pOutBuffer);

+        pPTBuffer 0x%x pBTBuffer 0x%x pOutBuffer 0x%x", pPTBuffer,

+        pBTBuffer, pOutBuffer);

 

     M4OSA_ERR result = M4NO_ERROR;

     M4OSA_Int16 *pBTMdata1;

@@ -74,8 +74,8 @@
     pMixedOutBuffer->m_bufferSize = pPrimaryTrack->m_bufferSize;

 

     // Before mixing, we need to have only PT as out buffer

-    M4OSA_memcpy((M4OSA_MemAddr8)pMixedOutBuffer->m_dataAddress,

-     (M4OSA_MemAddr8)pPrimaryTrack->m_dataAddress, pMixedOutBuffer->m_bufferSize);

+    memcpy((void *)pMixedOutBuffer->m_dataAddress,

+        (void *)pPrimaryTrack->m_dataAddress, pMixedOutBuffer->m_bufferSize);

 

     // Initially contains the input primary track

     pPTMdata2 = (M4OSA_Int16*)pMixedOutBuffer->m_dataAddress;

@@ -85,7 +85,7 @@
     // Since we need to give sample count and not buffer size

     uiPCMsize = pMixedOutBuffer->m_bufferSize/2 ;

 

-    if((this->mDucking_enable) && (this->mPTVolLevel != 0.0)) {

+    if ((mDucking_enable) && (mPTVolLevel != 0.0)) {

         // LOGI("VideoEditorBGAudioProcessing:: In Ducking analysis ");

         loopIndex = 0;

         peakDbValue = 0;

@@ -93,35 +93,32 @@
 

         pPCM16Sample = (M4OSA_Int16*)pPrimaryTrack->m_dataAddress;

 

-        while( loopIndex < pPrimaryTrack->m_bufferSize/sizeof(M4OSA_Int16))

-        {

-            if (pPCM16Sample[loopIndex] >= 0){

+        while (loopIndex < pPrimaryTrack->m_bufferSize/sizeof(M4OSA_Int16)) {

+            if (pPCM16Sample[loopIndex] >= 0) {

                 peakDbValue = previousDbValue > pPCM16Sample[loopIndex] ?

-                 previousDbValue : pPCM16Sample[loopIndex];

+                        previousDbValue : pPCM16Sample[loopIndex];

                 previousDbValue = peakDbValue;

-            }else{

+            } else {

                 peakDbValue = previousDbValue > -pPCM16Sample[loopIndex] ?

-                 previousDbValue: -pPCM16Sample[loopIndex];

+                        previousDbValue: -pPCM16Sample[loopIndex];

                 previousDbValue = peakDbValue;

             }

             loopIndex++;

         }

 

-        this->mAudioVolumeArray[this->mAudVolArrIndex] =

-         getDecibelSound(peakDbValue);

+        mAudioVolumeArray[mAudVolArrIndex] = getDecibelSound(peakDbValue);

 

         LOGV("VideoEditorBGAudioProcessing:: getDecibelSound %d",

-         this->mAudioVolumeArray[this->mAudVolArrIndex]);

+            mAudioVolumeArray[mAudVolArrIndex]);

 

         // WINDOW_SIZE is 10 by default

         // Check for threshold is done after 10 cycles

-        if ( this->mAudVolArrIndex >= WINDOW_SIZE -1) {

-            this->mDoDucking = isThresholdBreached(this->mAudioVolumeArray,

-             this->mAudVolArrIndex,this->mDucking_threshold );

-

-            this->mAudVolArrIndex = 0;

+        if (mAudVolArrIndex >= WINDOW_SIZE - 1) {

+            mDoDucking = isThresholdBreached(mAudioVolumeArray,

+            mAudVolArrIndex,mDucking_threshold );

+            mAudVolArrIndex = 0;

         } else {

-            this->mAudVolArrIndex++;

+            mAudVolArrIndex++;

         }

 

         //

@@ -135,25 +132,23 @@
         // (500 ms (window under analysis) / 20 ms (sample duration))

         //

 

-        if(this->mDoDucking){

-            if ( this->mDuckingFactor > this->mDucking_lowVolume) {

+        if (mDoDucking) {

+            if (mDuckingFactor > mDucking_lowVolume) {

                 // FADE OUT BG Track

                 // Increment ducking factor in total steps in factor

                 // of low volume steps to reach low volume level

-                this->mDuckingFactor -= (this->mDucking_lowVolume);

-            }

-            else {

-                this->mDuckingFactor = this->mDucking_lowVolume;

+                mDuckingFactor -= (mDucking_lowVolume);

+            } else {

+                mDuckingFactor = mDucking_lowVolume;

             }

         } else {

-            if ( this->mDuckingFactor < 1.0 ){

+            if (mDuckingFactor < 1.0 ) {

                 // FADE IN BG Track

                 // Increment ducking factor in total steps of

                 // low volume factor to reach orig.volume level

-                this->mDuckingFactor += (this->mDucking_lowVolume);

-            }

-            else{

-                this->mDuckingFactor = 1.0;

+                mDuckingFactor += (mDucking_lowVolume);

+            } else {

+                mDuckingFactor = 1.0;

             }

         }

     } // end if - mDucking_enable

@@ -162,46 +157,42 @@
     // Mixing Logic

 

     LOGV("VideoEditorBGAudioProcessing:: Out of Ducking analysis uiPCMsize\

-     %d %f %f", this->mDoDucking, this->mDuckingFactor,this->mBTVolLevel);

+        %d %f %f", mDoDucking, mDuckingFactor,mBTVolLevel);

 

-    while(uiPCMsize-->0) {

+    while (uiPCMsize-- > 0) {

 

         M4OSA_Int32 temp;

         // Set vol factor for BT and PT

-        *pBTMdata1 = (M4OSA_Int16)(*pBTMdata1*this->mBTVolLevel);

-        *pPTMdata2 = (M4OSA_Int16)(*pPTMdata2*this->mPTVolLevel);

+        *pBTMdata1 = (M4OSA_Int16)(*pBTMdata1*mBTVolLevel);

+        *pPTMdata2 = (M4OSA_Int16)(*pPTMdata2*mPTVolLevel);

 

         // Mix the two samples

-        if ( this->mDoDucking) {

+        if (mDoDucking) {

 

             // Duck the BG track to ducking factor value before mixing

-            *pBTMdata1 = (M4OSA_Int16)((*pBTMdata1)*(this->mDuckingFactor));

+            *pBTMdata1 = (M4OSA_Int16)((*pBTMdata1)*(mDuckingFactor));

 

             // mix as normal case

             *pBTMdata1 = (M4OSA_Int16)(*pBTMdata1 /2 + *pPTMdata2 /2);

-        }

-        else {

+        } else {

 

-            *pBTMdata1 = (M4OSA_Int16)((*pBTMdata1)*(this->mDuckingFactor));

+            *pBTMdata1 = (M4OSA_Int16)((*pBTMdata1)*(mDuckingFactor));

             *pBTMdata1 = (M4OSA_Int16)(*pBTMdata1 /2 + *pPTMdata2 /2);

         }

 

-        if ( *pBTMdata1 < 0) {

+        if (*pBTMdata1 < 0) {

             temp = -(*pBTMdata1) * 2; // bring to original Amplitude level

 

-            if ( temp > 32767) {

+            if (temp > 32767) {

                 *pBTMdata1 = -32766; // less then max allowed value

-            }

-            else{

+            } else {

                 *pBTMdata1 = (M4OSA_Int16)(-temp);

             }

-        }

-        else {

+        } else {

             temp = (*pBTMdata1) * 2; // bring to original Amplitude level

             if ( temp > 32768) {

                 *pBTMdata1 = 32767; // less than max allowed value

-            }

-            else {

+            } else {

                 *pBTMdata1 = (M4OSA_Int16)temp;

             }

         }

@@ -210,141 +201,116 @@
         pPTMdata2++;

     }

     //LOGV("VideoEditorBGAudioProcessing:: Copy final out ");

-    M4OSA_memcpy((M4OSA_MemAddr8)pMixedOutBuffer->m_dataAddress,

-     (M4OSA_MemAddr8)pBackgroundTrack->m_dataAddress,

-      pBackgroundTrack->m_bufferSize);

+    memcpy((void *)pMixedOutBuffer->m_dataAddress,

+        (void *)pBackgroundTrack->m_dataAddress,

+        pBackgroundTrack->m_bufferSize);

 

     LOGV("VideoEditorBGAudioProcessing::lvProcessAudioMixNDuck EXIT");

     return result;

 }

 

-VideoEditorBGAudioProcessing:: ~VideoEditorBGAudioProcessing() {

+VideoEditorBGAudioProcessing::~VideoEditorBGAudioProcessing() {

 

- //free(VideoEditorBGAudioProcessing:: pTempBuffer);

 }

 

 M4OSA_Int32 VideoEditorBGAudioProcessing::calculateOutResampleBufSize() {

 

-    M4OSA_Int32 bufSize =0;

-

     // This already takes care of channel count in mBTBuffer.m_bufferSize

-    bufSize = (this->mOutSampleRate/this->mInSampleRate)*this->mBTBuffer.m_bufferSize;

-

-    return bufSize;

+    return (mOutSampleRate / mInSampleRate) * mBTBuffer.m_bufferSize;

 }

 

 void VideoEditorBGAudioProcessing ::veSetAudioProcessingParams(

-        veAudMixSettings gInputParams) {

+        const veAudMixSettings& gInputParams) {

 

     LOGV("VideoEditorBGAudioProcessing:: ENTER lvSetAudioProcessingParams ");

-    this->mDucking_enable       = gInputParams.lvInDucking_enable;

-    this->mDucking_lowVolume    = gInputParams.lvInDucking_lowVolume;

-    this->mDucking_threshold    = gInputParams.lvInDucking_threshold;

+    mDucking_enable       = gInputParams.lvInDucking_enable;

+    mDucking_lowVolume    = gInputParams.lvInDucking_lowVolume;

+    mDucking_threshold    = gInputParams.lvInDucking_threshold;

 

-    this->mPTVolLevel           = gInputParams.lvPTVolLevel;

-    this->mBTVolLevel           = gInputParams.lvBTVolLevel ;

+    mPTVolLevel           = gInputParams.lvPTVolLevel;

+    mBTVolLevel           = gInputParams.lvBTVolLevel ;

 

-    this->mBTChannelCount       = gInputParams.lvBTChannelCount;

-    this->mPTChannelCount       = gInputParams.lvPTChannelCount;

+    mBTChannelCount       = gInputParams.lvBTChannelCount;

+    mPTChannelCount       = gInputParams.lvPTChannelCount;

 

-    this->mBTFormat             = gInputParams.lvBTFormat;

+    mBTFormat             = gInputParams.lvBTFormat;

 

-    this->mInSampleRate         = gInputParams.lvInSampleRate;

-    this->mOutSampleRate        = gInputParams.lvOutSampleRate;

+    mInSampleRate         = gInputParams.lvInSampleRate;

+    mOutSampleRate        = gInputParams.lvOutSampleRate;

 

-    this->mAudVolArrIndex       = 0;

-    this->mDoDucking            = 0;

-    this->mDuckingFactor        = 1.0; // default

+    mAudVolArrIndex       = 0;

+    mDoDucking            = 0;

+    mDuckingFactor        = 1.0; // default

 

     LOGV("VideoEditorBGAudioProcessing::  ducking_enable 0x%x \

-     ducking_lowVolume %f  ducking_threshold %d  fPTVolLevel %f BTVolLevel %f",

-     this->mDucking_enable, this->mDucking_lowVolume, this->mDucking_threshold,

-     this->mPTVolLevel, this->mPTVolLevel);

+        ducking_lowVolume %f  ducking_threshold %d  fPTVolLevel %f BTVolLevel %f",

+        mDucking_enable, mDucking_lowVolume, mDucking_threshold,

+        mPTVolLevel, mPTVolLevel);

 

     // Following logc decides if SSRC support is needed for this mixing

-    if ( gInputParams.lvInSampleRate != gInputParams.lvOutSampleRate){

-        this->mIsSSRCneeded      = 1;

-    }else{

-        this->mIsSSRCneeded      = 0;

-    }

-    if( gInputParams.lvBTChannelCount != gInputParams.lvPTChannelCount){

+    mIsSSRCneeded = (gInputParams.lvInSampleRate != gInputParams.lvOutSampleRate);

+    if (gInputParams.lvBTChannelCount != gInputParams.lvPTChannelCount){

         if (gInputParams.lvBTChannelCount == 2){

-            this->mChannelConversion   = 1; // convert to MONO

-        }else{

-            this->mChannelConversion   = 2; // Convert to STEREO

+            mChannelConversion   = 1; // convert to MONO

+        } else {

+            mChannelConversion   = 2; // Convert to STEREO

         }

-    }else{

-        this->mChannelConversion   = 0;

+    } else {

+        mChannelConversion   = 0;

     }

     LOGV("VideoEditorBGAudioProcessing:: EXIT veSetAudioProcessingParams ");

 }

 

 

-M4OSA_Int32 VideoEditorBGAudioProcessing:: getDecibelSound(M4OSA_UInt32 value) {

-

-    int dbSound = 1;

-

-    if (value == 0) return 0;

-

-    if (value > 0x4000 && value <= 0x8000) // 32768

-        dbSound = 90;

-    else if (value > 0x2000 && value <= 0x4000) // 16384

-        dbSound = 84;

-    else if (value > 0x1000 && value <= 0x2000) // 8192

-        dbSound = 78;

-    else if (value > 0x0800 && value <= 0x1000) // 4028

-        dbSound = 72;

-    else if (value > 0x0400 && value <= 0x0800) // 2048

-        dbSound = 66;

-    else if (value > 0x0200 && value <= 0x0400) // 1024

-        dbSound = 60;

-    else if (value > 0x0100 && value <= 0x0200) // 512

-        dbSound = 54;

-    else if (value > 0x0080 && value <= 0x0100) // 256

-        dbSound = 48;

-    else if (value > 0x0040 && value <= 0x0080) // 128

-        dbSound = 42;

-    else if (value > 0x0020 && value <= 0x0040) // 64

-        dbSound = 36;

-    else if (value > 0x0010 && value <= 0x0020) // 32

-        dbSound = 30;

-    else if (value > 0x0008 && value <= 0x0010) //16

-        dbSound = 24;

-    else if (value > 0x0007 && value <= 0x0008) //8

-        dbSound = 24;

-    else if (value > 0x0003 && value <= 0x0007) // 4

-        dbSound = 18;

-    else if (value > 0x0001 && value <= 0x0003) //2

-        dbSound = 12;

-    else if (value > 0x000 && value <= 0x0001) // 1

-        dbSound = 6;

-    else

-        dbSound = 0;

-

-    return dbSound;

+// Fast way to compute 10 * log(value)

+M4OSA_Int32 VideoEditorBGAudioProcessing::getDecibelSound(M4OSA_UInt32 value) {

+    if (value <= 0 || value > 0x8000) {

+        return 0;

+    } else if (value > 0x4000) { // 32768

+        return 90;

+    } else if (value > 0x2000) { // 16384

+        return 84;

+    } else if (value > 0x1000) { // 8192

+        return 78;

+    } else if (value > 0x0800) { // 4028

+        return 72;

+    } else if (value > 0x0400) { // 2048

+        return 66;

+    } else if (value > 0x0200) { // 1024

+        return 60;

+    } else if (value > 0x0100) { // 512

+        return 54;

+    } else if (value > 0x0080) { // 256

+        return 48;

+    } else if (value > 0x0040) { // 128

+        return 42;

+    } else if (value > 0x0020) { // 64

+        return 36;

+    } else if (value > 0x0010) { // 32

+        return 30;

+    } else if (value > 0x0008) { // 16

+        return 24;

+    } else if (value > 0x0007) { // 8

+        return 24;

+    } else if (value > 0x0003) { // 4

+        return 18;

+    } else if (value > 0x0001) { // 2

+        return 12;

+    } else  { // 1

+        return 6;

+    }

 }

 

-M4OSA_Bool VideoEditorBGAudioProcessing:: isThresholdBreached(

-        M4OSA_Int32* averageValue, M4OSA_Int32 storeCount,

-         M4OSA_Int32 thresholdValue) {

+M4OSA_Bool VideoEditorBGAudioProcessing::isThresholdBreached(

+        M4OSA_Int32* averageValue,

+        M4OSA_Int32 storeCount,

+        M4OSA_Int32 thresholdValue) {

 

-    M4OSA_Bool result = 0;

-    int i;

-    int finalValue = 0;

-

-    for (i=0; i< storeCount;i++)

-        finalValue += averageValue[i];

-

-    finalValue = finalValue/storeCount;

-

-    //printf ("<%d > \t  ", finalValue);

-

-    if (finalValue > thresholdValue)

-        result = M4OSA_TRUE;

-    else

-        result = M4OSA_FALSE;

-

-    return result;

+    int totalValue = 0;

+    for (int i = 0; i < storeCount; ++i) {

+        totalValue += averageValue[i];

+    }

+    return (totalValue / storeCount > thresholdValue);

 }

 

 }//namespace android

diff --git a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
index 851a133..1015721 100755
--- a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
+++ b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.h
@@ -31,7 +31,7 @@
 typedef struct {

     M4OSA_UInt16*   m_dataAddress; // Android SRC needs a Int16 pointer

     M4OSA_UInt32    m_bufferSize;

-} M4AM_Buffer;

+} M4AM_Buffer16;    // Structure contains Int16_t pointer

 

 // Following struct will be used by app to supply the PT and BT properties

 // along with ducking values

@@ -53,10 +53,13 @@
 class VideoEditorBGAudioProcessing {

 public:

     VideoEditorBGAudioProcessing();

-    void veSetAudioProcessingParams(veAudMixSettings mixParams);

-    M4OSA_Int32 veProcessAudioMixNDuck(void* , void *, void *);

+    void veSetAudioProcessingParams(const veAudMixSettings& mixParams);

 

-protected:

+    M4OSA_Int32 veProcessAudioMixNDuck(

+                    void* primaryTrackBuffer,

+                    void* backgroundTrackBuffer,

+                    void* mixedOutputBuffer);

+

     ~VideoEditorBGAudioProcessing();

 

 private:

@@ -79,15 +82,11 @@
     M4OSA_Float mPTVolLevel;

     M4OSA_Float mBTVolLevel;

 

-    M4AM_Buffer mPTBuffer;

-    M4AM_Buffer mBTBuffer;

-    M4AM_Buffer mOutMixBuffer;

-    M4OSA_Int16 *mTempBuffer;

-    M4OSA_Int32 mTempFrameCount;

+    M4AM_Buffer16 mBTBuffer;

 

     M4OSA_Int32 getDecibelSound(M4OSA_UInt32 value);

     M4OSA_Bool  isThresholdBreached(M4OSA_Int32* averageValue,

-     M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue);

+                    M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue);

 

     // This returns the size of buffer which needs to allocated

     // before resampling is called

diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.cpp b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
index 46b18d9..912aab0 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
@@ -24,6 +24,8 @@
 

 #include <media/Metadata.h>

 #include <media/stagefright/MediaExtractor.h>

+
+#include <system/audio.h>
 

 namespace android {

 

@@ -49,13 +51,16 @@
     return OK;

 }

 

+

+status_t VideoEditorPlayer::setAudioPlayer(VideoEditorAudioPlayer *audioPlayer) {

+    return mPlayer->setAudioPlayer(audioPlayer);

+}

+

+

 status_t VideoEditorPlayer::setDataSource(

         const char *url, const KeyedVector<String8, String8> *headers) {

     LOGI("setDataSource('%s')", url);

 

-    mVeAudioSink = new VeAudioOutput();

-    mPlayer->setAudioSink(mVeAudioSink);

-

     return mPlayer->setDataSource(url, headers);

 }

 

@@ -66,13 +71,6 @@
     return (!OK);

 }

 

-status_t VideoEditorPlayer::setVideoISurface(const sp<ISurface> &surface) {

-    LOGV("setVideoISurface");

-

-    mPlayer->setISurface(surface);

-    return OK;

-}

-

 status_t VideoEditorPlayer::setVideoSurface(const sp<Surface> &surface) {

     LOGV("setVideoSurface");

 

@@ -80,6 +78,13 @@
     return OK;

 }

 

+status_t VideoEditorPlayer::setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {

+    LOGV("setVideoSurfaceTexture");

+

+    mPlayer->setSurfaceTexture(surfaceTexture);

+    return OK;

+}

+

 status_t VideoEditorPlayer::prepare() {

     LOGV("prepare");

     return mPlayer->prepare();

@@ -154,6 +159,16 @@
     return mPlayer->setLooping(loop);

 }

 

+status_t VideoEditorPlayer::setParameter(int key, const Parcel &request) {
+    LOGV("setParameter");
+    return mPlayer->setParameter(key, request);
+}
+
+status_t VideoEditorPlayer::getParameter(int key, Parcel *reply) {
+    LOGV("getParameter");
+    return mPlayer->getParameter(key, reply);
+}
+
 player_type VideoEditorPlayer::playerType() {

     LOGV("playerType");

     return STAGEFRIGHT_PLAYER;

@@ -167,6 +182,16 @@
 status_t VideoEditorPlayer::resume() {

     LOGV("resume");

     return mPlayer->resume();

+}
+
+void VideoEditorPlayer::acquireLock() {
+    LOGV("acquireLock");
+    mPlayer->acquireLock();
+}
+

+void VideoEditorPlayer::releaseLock() {

+    LOGV("releaseLock");

+    mPlayer->releaseLock();

 }

 

 status_t VideoEditorPlayer::invoke(const Parcel &request, Parcel *reply) {

@@ -277,6 +302,11 @@
     return mPlayer->readFirstVideoFrame();

 }

 

+status_t VideoEditorPlayer::getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs) {

+    mPlayer->getLastRenderedTimeMs(lastRenderedTimeMs);

+    return NO_ERROR;

+}

+

 /* Implementation of AudioSink interface */

 #undef LOG_TAG

 #define LOG_TAG "VeAudioSink"

@@ -288,7 +318,7 @@
     : mCallback(NULL),

       mCallbackCookie(NULL) {

     mTrack = 0;

-    mStreamType = AudioSystem::MUSIC;

+    mStreamType = AUDIO_STREAM_MUSIC;

     mLeftVolume = 1.0;

     mRightVolume = 1.0;

     mLatency = 0;

@@ -304,7 +334,7 @@
 void VideoEditorPlayer::VeAudioOutput::setMinBufferCount() {

 

     mIsOnEmulator = false;

-    mMinBufferCount =12;

+    mMinBufferCount = 4;

 }

 

 bool VideoEditorPlayer::VeAudioOutput::isOnEmulator() {

@@ -368,8 +398,8 @@
 

     // Check argument "bufferCount" against the mininum buffer count

     if (bufferCount < mMinBufferCount) {

-        LOGD("bufferCount (%d) is too small and increased to %d",

-         bufferCount, mMinBufferCount);

+        LOGV("bufferCount (%d) is too small and increased to %d",

+            bufferCount, mMinBufferCount);

         bufferCount = mMinBufferCount;

 

     }

@@ -397,7 +427,7 @@
                 sampleRate,

                 format,

                 (channelCount == 2) ?

-                 AudioSystem::CHANNEL_OUT_STEREO : AudioSystem::CHANNEL_OUT_MONO,

+                 AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,

                 frameCount,

                 0 /* flags */,

                 CallbackWrapper,

@@ -408,7 +438,7 @@
                 sampleRate,

                 format,

                 (channelCount == 2) ?

-                 AudioSystem::CHANNEL_OUT_STEREO : AudioSystem::CHANNEL_OUT_MONO,

+                 AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,

                 frameCount);

     }

 

diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.h b/libvideoeditor/lvpp/VideoEditorPlayer.h
index 47d174d..349f7fd 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.h
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.h
@@ -23,14 +23,14 @@
 #include "M4xVSS_API.h"

 #include "VideoEditorMain.h"

 #include "VideoEditorTools.h"

-

+#include "VideoEditorAudioPlayer.h"

 

 namespace android {

 

 struct PreviewPlayer;

 

 class VideoEditorPlayer : public MediaPlayerInterface {

-

+    public:

     class VeAudioOutput: public MediaPlayerBase::AudioSink

     {

     public:

@@ -97,8 +97,8 @@
             const char *url, const KeyedVector<String8, String8> *headers);

 

     virtual status_t setDataSource(int fd, int64_t offset, int64_t length);

-    virtual status_t setVideoISurface(const sp<ISurface> &surface);

     virtual status_t setVideoSurface(const sp<Surface> &surface);

+    virtual status_t setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture);

     virtual status_t prepare();

     virtual status_t prepareAsync();

     virtual status_t start();

@@ -114,8 +114,12 @@
     virtual status_t invoke(const Parcel &request, Parcel *reply);

     virtual void setAudioSink(const sp<AudioSink> &audioSink);

     virtual status_t suspend();

-    virtual status_t resume();

-

+    virtual status_t resume();
+    virtual void acquireLock();
+    virtual void releaseLock();

+    virtual status_t setParameter(int key, const Parcel &request);
+    virtual status_t getParameter(int key, Parcel *reply);
+
     virtual status_t getMetadata(

                         const media::Metadata::Filter& ids, Parcel *records);

 

@@ -142,8 +146,9 @@
     virtual status_t resetJniCallbackTimeStamp();

     virtual status_t setImageClipProperties(uint32_t width, uint32_t height);

     virtual status_t readFirstVideoFrame();

+    virtual status_t getLastRenderedTimeMs(uint32_t *lastRenderedTimeMs);

 

-

+    status_t setAudioPlayer(VideoEditorAudioPlayer *audioPlayer);

 private:

     PreviewPlayer       *mPlayer;

     sp<VeAudioOutput>    mVeAudioSink;

diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 78f0cda..b12d8fe 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -39,14 +39,16 @@
       mCurrentClipNumber(-1),

       mClipTotalDuration(0),

       mCurrentVideoEffect(VIDEO_EFFECT_NONE),

+      mBackgroundAudioSetting(NULL),

+      mAudioMixPCMFileHandle(NULL),

       mTarget(NULL),

       mJniCookie(NULL),

       mJniCallback(NULL),

-      mBackgroundAudioSetting(NULL),

-      mAudioMixPCMFileHandle(NULL),

-      mVideoStoryBoardTimeMsUptoFirstPreviewClip(0),

       mCurrentPlayedDuration(0),

       mCurrentClipDuration(0),

+      mVideoStoryBoardTimeMsUptoFirstPreviewClip(0),

+      mOverlayState(OVERLAY_CLEAR),

+      mActivePlayerIndex(0),

       mOutputVideoWidth(0),

       mOutputVideoHeight(0),

       bStopThreadInProgress(false),

@@ -77,7 +79,7 @@
         err = M4OSA_threadSyncClose(mThreadContext);

         if(err != M4NO_ERROR) {

             LOGE("~VideoEditorPreviewController: error 0x%x \

-            in trying to close thread", err);

+            in trying to close thread", (unsigned int) err);

             // Continue even if error

         }

 

@@ -97,29 +99,27 @@
         for(i=0;i<mNumberClipsInStoryBoard;i++)

         {

             if(mClipList[i]->pFile != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)mClipList[i]->pFile);

+                free(mClipList[i]->pFile);

                 mClipList[i]->pFile = NULL;

             }

 

-            M4OSA_free((M4OSA_MemAddr32)mClipList[i]);

+            free(mClipList[i]);

         }

-        M4OSA_free((M4OSA_MemAddr32)mClipList);

+        free(mClipList);

         mClipList = NULL;

     }

 

     if(mEffectsSettings) {

         for(i=0;i<mNumberEffects;i++) {

             if(mEffectsSettings[i].xVSS.pFramingBuffer != NULL) {

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

 

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                 mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

             }

         }

-        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+        free(mEffectsSettings);

         mEffectsSettings = NULL;

     }

 

@@ -128,11 +128,18 @@
         mAudioMixPCMFileHandle = M4OSA_NULL;

     }

 

+    if (mBackgroundAudioSetting != NULL) {

+        free(mBackgroundAudioSetting);

+        mBackgroundAudioSetting = NULL;

+    }

+

     if(mTarget != NULL) {

         delete mTarget;

         mTarget = NULL;

     }

 

+    mOverlayState = OVERLAY_CLEAR;

+

     LOGV("~VideoEditorPreviewController returns");

 }

 

@@ -161,7 +168,7 @@
     }

 

     if(mBackgroundAudioSetting != NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mBackgroundAudioSetting);

+        free(mBackgroundAudioSetting);

         mBackgroundAudioSetting = NULL;

     }

 

@@ -170,29 +177,27 @@
         for(i=0;i<mNumberClipsInStoryBoard;i++)

         {

             if(mClipList[i]->pFile != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)mClipList[i]->pFile);

+                free(mClipList[i]->pFile);

                 mClipList[i]->pFile = NULL;

             }

 

-            M4OSA_free((M4OSA_MemAddr32)mClipList[i]);

+            free(mClipList[i]);

         }

-        M4OSA_free((M4OSA_MemAddr32)mClipList);

+        free(mClipList);

         mClipList = NULL;

     }

 

     if(mEffectsSettings) {

         for(i=0;i<mNumberEffects;i++) {

             if(mEffectsSettings[i].xVSS.pFramingBuffer != NULL) {

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

 

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                 mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

             }

         }

-        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+        free(mEffectsSettings);

         mEffectsSettings = NULL;

     }

 

@@ -200,7 +205,7 @@
         mNumberClipsInStoryBoard = pSettings->uiClipNumber;

         LOGV("loadEditSettings: # of Clips = %d", mNumberClipsInStoryBoard);

 

-        mClipList = (M4VSS3GPP_ClipSettings**)M4OSA_malloc(

+        mClipList = (M4VSS3GPP_ClipSettings**)M4OSA_32bitAlignedMalloc(

          sizeof(M4VSS3GPP_ClipSettings*)*pSettings->uiClipNumber, M4VS,

          (M4OSA_Char*)"LvPP, copy of pClipList");

 

@@ -208,28 +213,28 @@
             LOGE("loadEditSettings: Malloc error");

             return M4ERR_ALLOC;

         }

-        M4OSA_memset((M4OSA_MemAddr8)mClipList,

-         sizeof(M4VSS3GPP_ClipSettings*)*pSettings->uiClipNumber, 0);

+        memset((void *)mClipList,0,

+         sizeof(M4VSS3GPP_ClipSettings*)*pSettings->uiClipNumber);

 

         for(i=0;i<pSettings->uiClipNumber;i++) {

 

             // Allocate current clip

             mClipList[i] =

-             (M4VSS3GPP_ClipSettings*)M4OSA_malloc(

+             (M4VSS3GPP_ClipSettings*)M4OSA_32bitAlignedMalloc(

               sizeof(M4VSS3GPP_ClipSettings),M4VS,(M4OSA_Char*)"clip settings");

 

             if(mClipList[i] == NULL) {

 

-                LOGE("loadEditSettings: Allocation error for mClipList[%d]", i);

+                LOGE("loadEditSettings: Allocation error for mClipList[%d]", (int)i);

                 return M4ERR_ALLOC;

             }

             // Copy plain structure

-            M4OSA_memcpy((M4OSA_MemAddr8)mClipList[i],

-             (M4OSA_MemAddr8)pSettings->pClipList[i],

+            memcpy((void *)mClipList[i],

+             (void *)pSettings->pClipList[i],

              sizeof(M4VSS3GPP_ClipSettings));

 

             if(NULL != pSettings->pClipList[i]->pFile) {

-                mClipList[i]->pFile = (M4OSA_Char*)M4OSA_malloc(

+                mClipList[i]->pFile = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(

                 pSettings->pClipList[i]->filePathSize, M4VS,

                 (M4OSA_Char*)"pClipSettingsDest->pFile");

 

@@ -239,8 +244,8 @@
                     return M4ERR_ALLOC;

                 }

 

-                M4OSA_memcpy((M4OSA_MemAddr8)mClipList[i]->pFile,

-                 (M4OSA_MemAddr8)pSettings->pClipList[i]->pFile,

+                memcpy((void *)mClipList[i]->pFile,

+                 (void *)pSettings->pClipList[i]->pFile,

                  pSettings->pClipList[i]->filePathSize);

             }

             else {

@@ -261,7 +266,7 @@
         LOGV("loadEditSettings: mNumberEffects = %d", mNumberEffects);

 

         if(mNumberEffects != 0) {

-            mEffectsSettings = (M4VSS3GPP_EffectSettings*)M4OSA_malloc(

+            mEffectsSettings = (M4VSS3GPP_EffectSettings*)M4OSA_32bitAlignedMalloc(

              mNumberEffects*sizeof(M4VSS3GPP_EffectSettings),

              M4VS, (M4OSA_Char*)"effects settings");

 

@@ -270,8 +275,8 @@
                 return M4ERR_ALLOC;

             }

 

-            M4OSA_memset((M4OSA_MemAddr8)mEffectsSettings,

-             mNumberEffects*sizeof(M4VSS3GPP_EffectSettings), 0);

+            memset((void *)mEffectsSettings,0,

+             mNumberEffects*sizeof(M4VSS3GPP_EffectSettings));

 

             for(i=0;i<mNumberEffects;i++) {

 

@@ -279,20 +284,20 @@
                 mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

                 mEffectsSettings[i].xVSS.pTextBuffer = NULL;

 

-                M4OSA_memcpy((M4OSA_MemAddr8)&(mEffectsSettings[i]),

-                 (M4OSA_MemAddr8)&(pSettings->Effects[i]),

+                memcpy((void *)&(mEffectsSettings[i]),

+                 (void *)&(pSettings->Effects[i]),

                  sizeof(M4VSS3GPP_EffectSettings));

 

                 if(pSettings->Effects[i].VideoEffectType ==

-                 M4xVSS_kVideoEffectType_Framing) {

+                 (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Framing) {

                     // Allocate the pFraming RGB buffer

                     mEffectsSettings[i].xVSS.pFramingBuffer =

-                    (M4VIFI_ImagePlane *)M4OSA_malloc(sizeof(M4VIFI_ImagePlane),

+                    (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),

                      M4VS, (M4OSA_Char*)"lvpp framing buffer");

 

                     if(mEffectsSettings[i].xVSS.pFramingBuffer == NULL) {

                         LOGE("loadEffectsSettings:Alloc error for pFramingBuf");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

                         return M4ERR_ALLOC;

                     }

@@ -311,20 +316,19 @@
                     }

                     else {

                         LOGE("loadEffectsSettings: wrong RGB type");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

                         return M4ERR_PARAMETER;

                     }

 

-                    tmp = (M4VIFI_UInt8 *)M4OSA_malloc(rgbSize, M4VS,

+                    tmp = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(rgbSize, M4VS,

                      (M4OSA_Char*)"framing buffer pac_data");

 

                     if(tmp == NULL) {

                         LOGE("loadEffectsSettings:Alloc error pFramingBuf pac");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

-                        M4OSA_free(

-                        (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                        free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                         mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

                         return M4ERR_ALLOC;

@@ -358,9 +362,9 @@
                      pSettings->Effects[i].xVSS.uialphaBlendingFadeOutTime;

 

                     // Copy the pFraming data

-                    M4OSA_memcpy((M4OSA_MemAddr8)

+                    memcpy((void *)

                     mEffectsSettings[i].xVSS.pFramingBuffer->pac_data,

-                    (M4OSA_MemAddr8)pSettings->Effects[i].xVSS.pFramingBuffer->pac_data,

+                    (void *)pSettings->Effects[i].xVSS.pFramingBuffer->pac_data,

                     rgbSize);

 

                     mEffectsSettings[i].xVSS.rgbType =

@@ -372,7 +376,7 @@
 

     if (mBackgroundAudioSetting == NULL) {

 

-        mBackgroundAudioSetting = (M4xVSS_AudioMixingSettings*)M4OSA_malloc(

+        mBackgroundAudioSetting = (M4xVSS_AudioMixingSettings*)M4OSA_32bitAlignedMalloc(

         sizeof(M4xVSS_AudioMixingSettings), M4VS,

         (M4OSA_Char*)"LvPP, copy of bgmSettings");

 

@@ -381,8 +385,8 @@
             return M4ERR_ALLOC;

         }

 

-        M4OSA_memset((M4OSA_MemAddr8)mBackgroundAudioSetting, sizeof(M4xVSS_AudioMixingSettings*), 0);

-        M4OSA_memcpy((M4OSA_MemAddr8)mBackgroundAudioSetting, (M4OSA_MemAddr8)bgmSettings, sizeof(M4xVSS_AudioMixingSettings));

+        memset((void *)mBackgroundAudioSetting, 0,sizeof(M4xVSS_AudioMixingSettings*));

+        memcpy((void *)mBackgroundAudioSetting, (void *)bgmSettings, sizeof(M4xVSS_AudioMixingSettings));

 

         if ( mBackgroundAudioSetting->pFile != M4OSA_NULL ) {

 

@@ -413,8 +417,6 @@
     Mutex::Autolock autoLock(mLock);

 

     mSurface = surface;

-    mISurface = surface->getISurface();

-    LOGV("setSurface: mISurface = %p", mISurface.get());

     return M4NO_ERROR;

 }

 

@@ -426,7 +428,7 @@
     M4OSA_UInt32 i = 0, iIncrementedDuration = 0;

     LOGV("startPreview");

 

-    if(fromMS > toMs) {

+    if(fromMS > (M4OSA_UInt32)toMs) {

         LOGE("startPreview: fromMS > toMs");

         return M4ERR_PARAMETER;

     }

@@ -452,6 +454,13 @@
         mTarget = NULL;

     }

 

+    // Create Audio player to be used for entire

+    // storyboard duration

+    mVEAudioSink = new VideoEditorPlayer::VeAudioOutput();

+    mVEAudioPlayer = new VideoEditorAudioPlayer(mVEAudioSink);

+    mVEAudioPlayer->setAudioMixSettings(mBackgroundAudioSetting);

+    mVEAudioPlayer->setAudioMixPCMFileHandle(mAudioMixPCMFileHandle);

+

     LOGV("startPreview: loop = %d", loop);

     mPreviewLooping = loop;

 

@@ -542,6 +551,7 @@
 

     // Start playing with player instance 0

     mCurrentPlayer = 0;

+    mActivePlayerIndex = 0;

 

     if(toMs == -1) {

         LOGV("startPreview: Preview till end of storyboard");

@@ -552,7 +562,7 @@
     }

     else {

         LOGV("startPreview: toMs=%d", toMs);

-        if(toMs > mClipTotalDuration) {

+        if((M4OSA_UInt32)toMs > mClipTotalDuration) {

             LOGE("startPreview: toMs > mClipTotalDuration");

             return M4ERR_PARAMETER;

         }

@@ -560,7 +570,7 @@
         iIncrementedDuration = 0;

 

         for(i=0;i<mNumberClipsInStoryBoard;i++) {

-            if(toMs <= (iIncrementedDuration +

+            if((M4OSA_UInt32)toMs <= (iIncrementedDuration +

              (mClipList[i]->uiEndCutTime - mClipList[i]->uiBeginCutTime))) {

                 // Save original value

                 mLastPreviewClipEndTime = mClipList[i]->uiEndCutTime;

@@ -585,7 +595,7 @@
     // Open the preview process thread

     err = M4OSA_threadSyncOpen(&mThreadContext, (M4OSA_ThreadDoIt)threadProc);

     if (M4NO_ERROR != err) {

-        LOGE("VideoEditorPreviewController:M4OSA_threadSyncOpen error %d", err);

+        LOGE("VideoEditorPreviewController:M4OSA_threadSyncOpen error %d", (int) err);

         return err;

     }

 

@@ -594,7 +604,7 @@
      (M4OSA_DataOption)PREVIEW_THREAD_STACK_SIZE);

 

     if (M4NO_ERROR != err) {

-        LOGE("VideoEditorPreviewController: threadSyncSetOption error %d", err);

+        LOGE("VideoEditorPreviewController: threadSyncSetOption error %d", (int) err);

         M4OSA_threadSyncClose(mThreadContext);

         mThreadContext = NULL;

         return err;

@@ -603,7 +613,7 @@
      // Start the thread

      err = M4OSA_threadSyncStart(mThreadContext, (M4OSA_Void*)this);

      if (M4NO_ERROR != err) {

-        LOGE("VideoEditorPreviewController: threadSyncStart error %d", err);

+        LOGE("VideoEditorPreviewController: threadSyncStart error %d", (int) err);

         M4OSA_threadSyncClose(mThreadContext);

         mThreadContext = NULL;

         return err;

@@ -614,14 +624,20 @@
     return M4NO_ERROR;

 }

 

-M4OSA_ERR VideoEditorPreviewController::stopPreview() {

+M4OSA_UInt32 VideoEditorPreviewController::stopPreview() {

     M4OSA_ERR err = M4NO_ERROR;

+    uint32_t lastRenderedFrameTimeMs = 0;

     LOGV("stopPreview");

 

     // Stop the thread

     if(mThreadContext != NULL) {

         bStopThreadInProgress = true;

-        err = M4OSA_semaphorePost(mSemThreadWait);

+        {

+            Mutex::Autolock autoLock(mLockSem);

+            if (mSemThreadWait != NULL) {

+                err = M4OSA_semaphorePost(mSemThreadWait);

+            }

+        }

 

         err = M4OSA_threadSyncStop(mThreadContext);

         if(err != M4NO_ERROR) {

@@ -631,7 +647,7 @@
 

         err = M4OSA_threadSyncClose(mThreadContext);

         if(err != M4NO_ERROR) {

-            LOGE("stopPreview: error 0x%x in trying to close thread", err);

+            LOGE("stopPreview: error 0x%x in trying to close thread", (unsigned int)err);

             // Continue even if error

         }

 

@@ -639,9 +655,13 @@
     }

 

     // Close the semaphore first

-    if(mSemThreadWait != NULL) {

-        err = M4OSA_semaphoreClose(mSemThreadWait);

-        LOGV("stopPreview: close semaphore returns 0x%x", err);

+    {

+        Mutex::Autolock autoLock(mLockSem);

+        if(mSemThreadWait != NULL) {

+            err = M4OSA_semaphoreClose(mSemThreadWait);

+            LOGV("stopPreview: close semaphore returns 0x%x", err);

+            mSemThreadWait = NULL;

+        }

     }

 

     for (int playerInst=0; playerInst<NBPLAYER_INSTANCES; playerInst++) {

@@ -650,16 +670,31 @@
                 LOGV("stop the player first");

                 mVePlayer[playerInst]->stop();

             }

-

-            LOGV("stopPreview: clearing mVePlayer");

-            mVePlayer[playerInst].clear();

+            if (playerInst == mActivePlayerIndex) {

+                // Return the last rendered frame time stamp

+                mVePlayer[mActivePlayerIndex]->getLastRenderedTimeMs(&lastRenderedFrameTimeMs);

+            }

+
+            //This is used to syncronize onStreamDone() in PreviewPlayer and
+            //stopPreview() in PreviewController

+            sp<VideoEditorPlayer> temp = mVePlayer[playerInst];
+            temp->acquireLock();
+            LOGV("stopPreview: clearing mVePlayer");
+            mVePlayer[playerInst].clear();
             mVePlayer[playerInst] = NULL;

+            temp->releaseLock();
         }

     }

+    LOGV("stopPreview: clear audioSink and audioPlayer");

+    mVEAudioSink.clear();

+    if (mVEAudioPlayer) {

+        delete mVEAudioPlayer;

+        mVEAudioPlayer = NULL;

+    }

 

     // If image file playing, then free the buffer pointer

     if(mFrameStr.pBuffer != M4OSA_NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mFrameStr.pBuffer);

+        free(mFrameStr.pBuffer);

         mFrameStr.pBuffer = M4OSA_NULL;

     }

 

@@ -677,7 +712,8 @@
     mOutputVideoWidth = 0;

     mOutputVideoHeight = 0;

 

-    return M4NO_ERROR;

+    LOGV("stopPreview() lastRenderedFrameTimeMs %ld", lastRenderedFrameTimeMs);

+    return lastRenderedFrameTimeMs;

 }

 

 M4OSA_ERR VideoEditorPreviewController::clearSurface(

@@ -691,9 +727,6 @@
 

     Mutex::Autolock autoLock(mLock);

 

-    // Get the Isurface to be passed to renderer

-    mISurface = surface->getISurface();

-

     // Delete previous renderer instance

     if(mTarget != NULL) {

         delete mTarget;

@@ -732,12 +765,12 @@
      (M4OSA_UInt32)outBufferStride, (M4VIFI_UInt8 *)outBuffer);

 

     /* Fill the surface with black frame */

-    M4OSA_memset((M4OSA_MemAddr8)planeOut[0].pac_data,planeOut[0].u_width *

-                            planeOut[0].u_height * 1.5,0x00);

-    M4OSA_memset((M4OSA_MemAddr8)planeOut[1].pac_data,planeOut[1].u_width *

-                            planeOut[1].u_height,128);

-    M4OSA_memset((M4OSA_MemAddr8)planeOut[2].pac_data,planeOut[2].u_width *

-                             planeOut[2].u_height,128);

+    memset((void *)planeOut[0].pac_data,0x00,planeOut[0].u_width *

+                            planeOut[0].u_height * 1.5);

+    memset((void *)planeOut[1].pac_data,128,planeOut[1].u_width *

+                            planeOut[1].u_height);

+    memset((void *)planeOut[2].pac_data,128,planeOut[2].u_width *

+                             planeOut[2].u_height);

 

     mTarget->renderYV12();

     return err;

@@ -754,8 +787,6 @@
     M4VIFI_UInt8 *pixelArray = NULL;

     Mutex::Autolock autoLock(mLock);

 

-    // Get the Isurface to be passed to renderer

-    mISurface = surface->getISurface();

     if (pCurrEditInfo != NULL) {

         pCurrEditInfo->overlaySettingsIndex = -1;

     }

@@ -813,13 +844,13 @@
 

         //Provide the overlay Update indication when there is an overlay effect

         if (mCurrentVideoEffect & VIDEO_EFFECT_FRAMING) {

-            int index;

+            M4OSA_UInt32 index;

             mCurrentVideoEffect &= ~VIDEO_EFFECT_FRAMING; //never apply framing here.

 

             // Find the effect in effectSettings array

             for (index = 0; index < mNumberEffects; index++) {

                 if(mEffectsSettings[index].VideoEffectType ==

-                    M4xVSS_kVideoEffectType_Framing) {

+                    (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Framing) {

 

                     if((mEffectsSettings[index].uiStartTime <= pFrameInfo->timeMs) &&

                         ((mEffectsSettings[index].uiStartTime+

@@ -844,10 +875,10 @@
              (M4OSA_Void *)pixelArray);

 

             if(err != M4NO_ERROR) {

-                LOGE("renderPreviewFrame: applyVideoEffect error 0x%x", err);

+                LOGE("renderPreviewFrame: applyVideoEffect error 0x%x", (unsigned int)err);

                 delete mTarget;

                 mTarget = NULL;

-                M4OSA_free((M4OSA_MemAddr32)pixelArray);

+                free(pixelArray);

                 pixelArray = NULL;

                 return err;

            }

@@ -860,10 +891,10 @@
              pFrameStr->uiFrameHeight, (M4OSA_Void *)pixelArray);

 

             if(err != M4NO_ERROR) {

-                LOGE("renderPreviewFrame:doImageRenderingMode error 0x%x", err);

+                LOGE("renderPreviewFrame:doImageRenderingMode error 0x%x", (unsigned int)err);

                 delete mTarget;

                 mTarget = NULL;

-                M4OSA_free((M4OSA_MemAddr32)pixelArray);

+                free(pixelArray);

                 pixelArray = NULL;

                 return err;

             }

@@ -876,10 +907,10 @@
          pFrameStr->uiFrameHeight, (M4OSA_Void *)pixelArray);

 

         if(err != M4NO_ERROR) {

-            LOGE("renderPreviewFrame: doImageRenderingMode error 0x%x", err);

+            LOGE("renderPreviewFrame: doImageRenderingMode error 0x%x", (unsigned int)err);

             delete mTarget;

             mTarget = NULL;

-            M4OSA_free((M4OSA_MemAddr32)pixelArray);

+            free(pixelArray);

             pixelArray = NULL;

             return err;

         }

@@ -910,10 +941,6 @@
     LOGV("preparePlayer: setDataSource instance %s",

      (const char *)pController->mClipList[index]->pFile);

 

-    pController->mVePlayer[playerInstance]->setVideoISurface(

-     pController->mISurface);

-    LOGV("preparePlayer: setVideoISurface");

-

     pController->mVePlayer[playerInstance]->setVideoSurface(

      pController->mSurface);

     LOGV("preparePlayer: setVideoSurface");

@@ -923,7 +950,7 @@
      pController->mOutputVideoSize);

     LOGV("preparePlayer: setMediaRenderingMode");

 

-    if(index == pController->mStartingClipIndex) {

+    if((M4OSA_UInt32)index == pController->mStartingClipIndex) {

         pController->mVePlayer[playerInstance]->setPlaybackBeginTime(

         pController->mFirstPreviewClipBeginTime);

     }

@@ -956,6 +983,7 @@
         LOGV("preparePlayer: seekTo(%d)",

          pController->mClipList[index]->uiBeginCutTime);

     }

+    pController->mVePlayer[pController->mCurrentPlayer]->setAudioPlayer(pController->mVEAudioPlayer);

 

     pController->mVePlayer[playerInstance]->readFirstVideoFrame();

     LOGV("preparePlayer: readFirstVideoFrame of clip");

@@ -976,7 +1004,7 @@
         LOGV("threadProc: playing file index %d total clips %d",

          pController->mCurrentClipNumber, pController->mNumberClipsToPreview);

 

-        if(pController->mCurrentClipNumber >=

+        if((M4OSA_UInt32)pController->mCurrentClipNumber >=

          pController->mNumberClipsToPreview) {

 

             LOGV("All clips previewed");

@@ -1020,7 +1048,7 @@
         }

 

         index=pController->mCurrentClipNumber;

-        if(pController->mCurrentClipNumber == pController->mStartingClipIndex) {

+        if((M4OSA_UInt32)pController->mCurrentClipNumber == pController->mStartingClipIndex) {

             pController->mCurrentPlayedDuration +=

              pController->mVideoStoryBoardTimeMsUptoFirstPreviewClip;

 

@@ -1044,7 +1072,7 @@
         LOGV("threadProc: setStoryboardStartTime");

 

         // Set the next clip duration for Audio mix here

-        if(pController->mCurrentClipNumber != pController->mStartingClipIndex) {

+        if((M4OSA_UInt32)pController->mCurrentClipNumber != pController->mStartingClipIndex) {

 

             pController->mVePlayer[pController->mCurrentPlayer]->setAudioMixStoryBoardParam(

              pController->mCurrentPlayedDuration,

@@ -1057,6 +1085,8 @@
              pController->mClipList[index]->uiBeginCutTime,

              pController->mClipList[index]->ClipProperties.uiClipAudioVolumePercentage);

         }

+        // Capture the active player being used

+        pController->mActivePlayerIndex = pController->mCurrentPlayer;

 

         pController->mVePlayer[pController->mCurrentPlayer]->start();

         LOGV("threadProc: started");

@@ -1070,16 +1100,20 @@
         pController->mPrepareReqest = M4OSA_FALSE;

         preparePlayer((void*)pController, pController->mCurrentPlayer,

             pController->mCurrentClipNumber+1);

-        err = M4OSA_semaphoreWait(pController->mSemThreadWait,

-            M4OSA_WAIT_FOREVER);

+        if (pController->mSemThreadWait != NULL) {

+            err = M4OSA_semaphoreWait(pController->mSemThreadWait,

+                M4OSA_WAIT_FOREVER);

+        }

     } else {

         if (!pController->bStopThreadInProgress) {

             LOGV("threadProc: state busy...wait for sem");

-            err = M4OSA_semaphoreWait(pController->mSemThreadWait,

-             M4OSA_WAIT_FOREVER);

+            if (pController->mSemThreadWait != NULL) {

+                err = M4OSA_semaphoreWait(pController->mSemThreadWait,

+                 M4OSA_WAIT_FOREVER);

+             }

         }

         LOGV("threadProc: sem wait returned err = 0x%x", err);

-    }

+    }
 

     //Always return M4NO_ERROR to ensure the thread keeps running

     return M4NO_ERROR;

@@ -1106,7 +1140,7 @@
             pController->mPlayerState = VePlayerIdle;

 

             //send progress callback with last frame timestamp

-            if(pController->mCurrentClipNumber ==

+            if((M4OSA_UInt32)pController->mCurrentClipNumber ==

              pController->mStartingClipIndex) {

                 clipDuration =

                  pController->mClipList[pController->mCurrentClipNumber]->uiEndCutTime

@@ -1123,7 +1157,29 @@
                  pController->mJniCookie, MSG_TYPE_PROGRESS_INDICATION,

                  &playedDuration);

 

-            M4OSA_semaphorePost(pController->mSemThreadWait);

+            if ((pController->mOverlayState == OVERLAY_UPDATE) &&

+                ((M4OSA_UInt32)pController->mCurrentClipNumber !=

+                (pController->mNumberClipsToPreview-1))) {

+                VideoEditorCurretEditInfo *pEditInfo =

+                    (VideoEditorCurretEditInfo*)M4OSA_32bitAlignedMalloc(sizeof(VideoEditorCurretEditInfo),

+                    M4VS, (M4OSA_Char*)"Current Edit info");

+                pEditInfo->overlaySettingsIndex = ext2;

+                pEditInfo->clipIndex = pController->mCurrentClipNumber;

+                pController->mOverlayState == OVERLAY_CLEAR;

+                if (pController->mJniCallback != NULL) {

+                        pController->mJniCallback(pController->mJniCookie,

+                            MSG_TYPE_OVERLAY_CLEAR, pEditInfo);

+                }

+                free(pEditInfo);

+            }

+            {

+                Mutex::Autolock autoLock(pController->mLockSem);

+                if (pController->mSemThreadWait != NULL) {

+                    M4OSA_semaphorePost(pController->mSemThreadWait);
+                    return;
+                }

+            }

+

             break;

         }

         case MEDIA_ERROR:

@@ -1164,7 +1220,7 @@
             LOGV("VIDEO PLAYBACK ALMOST over, prepare next player");

             // Select next player and prepare it

             // If there is a clip after this one

-            if ((pController->mCurrentClipNumber+1) <

+            if ((M4OSA_UInt32)(pController->mCurrentClipNumber+1) <

              pController->mNumberClipsToPreview) {

                 pController->mPrepareReqest = M4OSA_TRUE;

                 pController->mCurrentPlayer++;

@@ -1172,7 +1228,12 @@
                     pController->mCurrentPlayer = 0;

                 }

                 // Prepare the first clip to be played

-                M4OSA_semaphorePost(pController->mSemThreadWait);

+                {

+                    Mutex::Autolock autoLock(pController->mLockSem);

+                    if (pController->mSemThreadWait != NULL) {

+                        M4OSA_semaphorePost(pController->mSemThreadWait);

+                    }

+                }

             }

             break;

         case 0xBBBBBBBB:

@@ -1180,7 +1241,7 @@
             LOGV("VIDEO PLAYBACK, Update Overlay");

             int overlayIndex = ext2;

             VideoEditorCurretEditInfo *pEditInfo =

-                    (VideoEditorCurretEditInfo*)M4OSA_malloc(sizeof(VideoEditorCurretEditInfo),

+                    (VideoEditorCurretEditInfo*)M4OSA_32bitAlignedMalloc(sizeof(VideoEditorCurretEditInfo),

                     M4VS, (M4OSA_Char*)"Current Edit info");

             //ext1 = 1; start the overlay display

             //     = 2; Clear the overlay.

@@ -1189,14 +1250,16 @@
             LOGV("pController->mCurrentClipNumber = %d",pController->mCurrentClipNumber);

             if (pController->mJniCallback != NULL) {

                 if (ext1 == 1) {

+                    pController->mOverlayState = OVERLAY_UPDATE;

                     pController->mJniCallback(pController->mJniCookie,

                         MSG_TYPE_OVERLAY_UPDATE, pEditInfo);

                 } else {

+                    pController->mOverlayState = OVERLAY_CLEAR;

                     pController->mJniCallback(pController->mJniCookie,

                         MSG_TYPE_OVERLAY_CLEAR, pEditInfo);

                 }

             }

-            M4OSA_free((M4OSA_MemAddr32)pEditInfo);

+            free(pEditInfo);

             break;

         }

         default:

@@ -1439,7 +1502,7 @@
 

     err = applyRenderingMode(planeIn, planeOut, mRenderingMode);

     if(err != M4NO_ERROR) {

-        LOGE("doImageRenderingMode: applyRenderingMode returned err=0x%x", err);

+        LOGE("doImageRenderingMode: applyRenderingMode returned err=0x%x", (unsigned int)err);

     }

     return err;

 }

diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.h b/libvideoeditor/lvpp/VideoEditorPreviewController.h
index 2a2a665..4c62ac5 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.h
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.h
@@ -20,6 +20,7 @@
 

 #include <utils/Log.h>

 #include "VideoEditorPlayer.h"

+#include "VideoEditorAudioPlayer.h"

 #include "M4OSA_Semaphore.h"

 #include "M4OSA_Thread.h"

 #include "M4OSA_Clock.h"

@@ -51,6 +52,10 @@
     VePlayerAutoStop

 } VePlayerState;

 

+typedef enum {

+    OVERLAY_UPDATE = 0,

+    OVERLAY_CLEAR

+} OverlayState;

 

 // Callback mechanism from PreviewController to Jni  */

 typedef void (*jni_progress_callback_fct)(void* cookie, M4OSA_UInt32 msgType, void *argc);

@@ -70,7 +75,7 @@
     M4OSA_ERR startPreview(M4OSA_UInt32 fromMS, M4OSA_Int32 toMs,

         M4OSA_UInt16 callBackAfterFrameCount, M4OSA_Bool loop) ;

 

-    M4OSA_ERR stopPreview();

+    M4OSA_UInt32 stopPreview();

 

     M4OSA_ERR renderPreviewFrame(const sp<Surface> &surface,

         VideoEditor_renderPreviewFrameStr* pFrameInfo,

@@ -88,7 +93,6 @@
 private:

     sp<VideoEditorPlayer> mVePlayer[NBPLAYER_INSTANCES];

     int mCurrentPlayer; //Instance of the player currently being used

-    sp<ISurface> mISurface;

     sp<Surface>  mSurface;

     mutable Mutex mLock;

     M4OSA_Context mThreadContext;

@@ -117,6 +121,8 @@
     M4OSA_UInt32 mFirstPreviewClipBeginTime;

     M4OSA_UInt32 mLastPreviewClipEndTime;

     M4OSA_UInt32 mVideoStoryBoardTimeMsUptoFirstPreviewClip;

+    OverlayState mOverlayState;

+    int mActivePlayerIndex;

 

     M4xVSS_MediaRendering mRenderingMode;

     uint32_t mOutputVideoWidth;

@@ -125,8 +131,12 @@
     M4OSA_Context mSemThreadWait;

     bool mIsFiftiesEffectStarted;

 

+    sp<VideoEditorPlayer::VeAudioOutput> mVEAudioSink;

+    VideoEditorAudioPlayer *mVEAudioPlayer;

+

     M4VIFI_UInt8*  mFrameRGBBuffer;

     M4VIFI_UInt8*  mFrameYUVBuffer;

+    mutable Mutex mLockSem;

     static M4OSA_ERR preparePlayer(void* param, int playerInstance, int index);

     static M4OSA_ERR threadProc(M4OSA_Void* param);

     static void notify(void* cookie, int msg, int ext1, int ext2);

diff --git a/libvideoeditor/lvpp/VideoEditorSRC.cpp b/libvideoeditor/lvpp/VideoEditorSRC.cpp
index 091bdfb..c304ca2 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.cpp
+++ b/libvideoeditor/lvpp/VideoEditorSRC.cpp
@@ -23,6 +23,8 @@
 #include "VideoEditorSRC.h"

 #include <media/stagefright/MetaData.h>

 #include <media/stagefright/MediaDebug.h>

+#include <media/stagefright/MediaBuffer.h>

+#include <media/stagefright/MediaDefs.h>

 #include "AudioMixer.h"

 

 

@@ -46,9 +48,8 @@
     mSeekTimeUs = -1;

     mLeftover = 0;

     mLastReadSize = 0;

-#ifndef FROYO

+    mReSampledBuffer = NULL;

     mSeekMode =  ReadOptions::SEEK_PREVIOUS_SYNC;

-#endif

 

     mOutputFormat = new MetaData;

 

@@ -72,7 +73,7 @@
 

     // Allocate a  1 sec buffer (test only, to be refined)

     mInterframeBufferPosition = 0;

-    pInterframeBuffer = new uint8_t[DEFAULT_SAMPLING_FREQ * 2 * 2]; //stereo=2 * bytespersample=2

+    mInterframeBuffer = new uint8_t[DEFAULT_SAMPLING_FREQ * 2 * 2]; //stereo=2 * bytespersample=2

 

 

 }

@@ -86,9 +87,9 @@
         mOutputFormat = NULL;

     }

 

-    if (pInterframeBuffer != NULL){

-        delete pInterframeBuffer;

-        pInterframeBuffer = NULL;

+    if (mInterframeBuffer != NULL){

+        delete mInterframeBuffer;

+        mInterframeBuffer = NULL;

     }

 }

 

@@ -122,7 +123,6 @@
     success = format->findInt32(kKeyChannelCount, &mChannelCnt);

     CHECK(success);

 

-    mInputFrameSize = mChannelCnt * 2; //2 is the byte depth

     if(mSampleRate != mOutputSampleRate) {

         LOGV("Resampling required (%d != %d)", mSampleRate, mOutputSampleRate);

         mIsResamplingRequired = true;

@@ -145,9 +145,7 @@
         }

     }

     mSeekTimeUs = -1;

-#ifndef FROYO

     mSeekMode =  ReadOptions::SEEK_PREVIOUS_SYNC;

-#endif

     mStarted = true;

     mSource->start();

 

@@ -168,6 +166,10 @@
     mAccuOutBufferSize  = 0;

     mLeftover = 0;

     mLastReadSize = 0;

+    if (mReSampledBuffer != NULL) {

+        free(mReSampledBuffer);

+        mReSampledBuffer = NULL;

+    }

 

     return OK;

 }

@@ -196,20 +198,12 @@
 

         // Store the seek parameters

         int64_t seekTimeUs;

-#ifndef FROYO

         ReadOptions::SeekMode mode = ReadOptions::SEEK_PREVIOUS_SYNC;

         if (options && options->getSeekTo(&seekTimeUs, &mode)) {

-#else

-        if (options && options->getSeekTo(&seekTimeUs)) {

-#endif

             LOGV("read Seek %lld", seekTimeUs);

             mInitialTimeStampUs = -1;

             mSeekTimeUs = seekTimeUs;

-#ifndef FROYO

             mSeekMode = mode;

-#else

-            mReadOptions = *options;

-#endif

         }

 

         // We ask for 1024 frames in output

@@ -219,19 +213,25 @@
         LOGV("outBufferSize            %d", outBufferSize);

         LOGV("outFrameCnt              %d", outFrameCnt);

 

-        pTmpBuffer = (int32_t*)malloc(outFrameCnt * 2 * sizeof(int32_t)); //out is always 2 channels and resampler out is 32 bits

+        int32_t *pTmpBuffer = (int32_t*)malloc(outFrameCnt * 2 * sizeof(int32_t)); //out is always 2 channels and resampler out is 32 bits

         memset(pTmpBuffer, 0x00, outFrameCnt * 2 * sizeof(int32_t));

         // Resample to target quality

         mResampler->resample(pTmpBuffer, outFrameCnt, this);

-        int16_t *reSampledBuffer = (int16_t*)malloc(outBufferSize);

-        memset(reSampledBuffer, 0x00, outBufferSize);

+

+        // Free previous allocation

+        if (mReSampledBuffer != NULL) {

+            free(mReSampledBuffer);

+            mReSampledBuffer = NULL;

+        }

+        mReSampledBuffer = (int16_t*)malloc(outBufferSize);

+        memset(mReSampledBuffer, 0x00, outBufferSize);

 

         // Convert back to 16 bits

-        AudioMixer::ditherAndClamp((int32_t*)reSampledBuffer, pTmpBuffer, outFrameCnt);

+        AudioMixer::ditherAndClamp((int32_t*)mReSampledBuffer, pTmpBuffer, outFrameCnt);

         LOGV("Resampled buffer size %d", outFrameCnt* 2 * sizeof(int16_t));

 

         // Create new MediaBuffer

-        mCopyBuffer = new MediaBuffer((void*)reSampledBuffer, outBufferSize);

+        mCopyBuffer = new MediaBuffer((void*)mReSampledBuffer, outBufferSize);

 

         // Compute and set the new timestamp

         sp<MetaData> to = mCopyBuffer->meta_data();

@@ -278,7 +278,7 @@
     if (mLeftover > 0) {

         LOGV("Moving mLeftover =%d  from  %d", mLeftover, mLastReadSize);

         if (mLastReadSize > 0) {

-            memcpy(pInterframeBuffer, (uint8_t*) (pInterframeBuffer + mLastReadSize), mLeftover);

+            memcpy(mInterframeBuffer, (uint8_t*) (mInterframeBuffer + mLastReadSize), mLeftover);

         }

         mInterframeBufferPosition = mLeftover;

     }

@@ -290,7 +290,6 @@
 

     while ((availableFrames < pBuffer->frameCount)&&(mStarted)) {

         // if we seek, reset the initial time stamp and accumulated time

-#ifndef FROYO

         ReadOptions options;

         if (mSeekTimeUs >= 0) {

             LOGV("%p cacheMore_l Seek requested = %lld", this, mSeekTimeUs);

@@ -298,14 +297,6 @@
             options.setSeekTo(mSeekTimeUs, mode);

             mSeekTimeUs = -1;

         }

-#else

-        ReadOptions options;

-        if (mSeekTimeUs >= 0) {

-            LOGV("%p cacheMore_l Seek requested = %lld", this, mSeekTimeUs);

-            options = mReadOptions;

-            mSeekTimeUs = -1;

-        }

-#endif

         /* The first call to read() will require to buffer twice as much data */

         /* This will be needed by the resampler */

         status_t err = mSource->read(&aBuffer, &options);

@@ -317,15 +308,16 @@
             //Empty the internal buffer if there is no more data left in the source

             else {

                 lastBuffer = true;

-                mInputByteBuffer = pInterframeBuffer;

                 //clear the end of the buffer, just in case

-                memset(pInterframeBuffer+mInterframeBufferPosition, 0x00, DEFAULT_SAMPLING_FREQ * 2 * 2 - mInterframeBufferPosition);

+                memset(mInterframeBuffer+mInterframeBufferPosition, 0x00, DEFAULT_SAMPLING_FREQ * 2 * 2 - mInterframeBufferPosition);

                 mStarted = false;

             }

         }

         else {

             //copy the buffer

-            memcpy((uint8_t*) (pInterframeBuffer + mInterframeBufferPosition), (uint8_t*) (aBuffer->data() + aBuffer->range_offset()), aBuffer->range_length());

+            memcpy(((uint8_t*) mInterframeBuffer) + mInterframeBufferPosition,

+                    ((uint8_t*) aBuffer->data()) + aBuffer->range_offset(),

+                    aBuffer->range_length());

             LOGV("Read from buffer  %d", aBuffer->range_length());

 

             mInterframeBufferPosition += aBuffer->range_length();

@@ -352,7 +344,7 @@
     }

 

     //update the input buffer

-    pBuffer->raw        = (void*)(pInterframeBuffer);

+    pBuffer->raw        = (void*)(mInterframeBuffer);

 

     // Update how many bytes are left

     // (actualReadSize is updated in getNextBuffer() called from resample())

diff --git a/libvideoeditor/lvpp/VideoEditorSRC.h b/libvideoeditor/lvpp/VideoEditorSRC.h
index 3c557a4..8bfd991 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.h
+++ b/libvideoeditor/lvpp/VideoEditorSRC.h
@@ -15,20 +15,19 @@
  * limitations under the License.

  */

 

+#include <stdint.h>

+

 #include <utils/RefBase.h>

-#include <media/stagefright/MediaErrors.h>

+#include <utils/threads.h>

 

 #include <media/stagefright/MediaSource.h>

-#include <media/stagefright/MediaBuffer.h>

-#include <media/stagefright/MediaBufferGroup.h>

-#include <media/stagefright/MediaDefs.h>

 

 #include "AudioBufferProvider.h"

 #include "AudioResampler.h"

 

 namespace android {

-//struct MediaSource;

 

+struct MediaBuffer;

 

 class VideoEditorSRC : public MediaSource , public AudioBufferProvider {

 

@@ -49,14 +48,14 @@
 

     enum { //Sampling freq

         kFreq8000Hz = 8000,

-     kFreq11025Hz = 11025,

-     kFreq12000Hz = 12000,

-     kFreq16000Hz = 16000,

-     kFreq22050Hz = 22050,

-     kFreq240000Hz = 24000,

-     kFreq32000Hz = 32000,

-     kFreq44100 = 44100,

-     kFreq48000 = 48000,

+        kFreq11025Hz = 11025,

+        kFreq12000Hz = 12000,

+        kFreq16000Hz = 16000,

+        kFreq22050Hz = 22050,

+        kFreq240000Hz = 24000,

+        kFreq32000Hz = 32000,

+        kFreq44100 = 44100,

+        kFreq48000 = 48000,

     };

 

     static const uint16_t UNITY_GAIN = 0x1000;

@@ -70,13 +69,8 @@
         VideoEditorSRC &operator=(const VideoEditorSRC &);

 

         AudioResampler        *mResampler;

-        AudioBufferProvider  *mbufferProvider;

         sp<MediaSource>      mSource;

         MediaBuffer      *mCopyBuffer;

-        MediaBufferGroup *mGroup;

-        uint8_t *mInputByteBuffer;

-        int32_t mInputBufferLength;

-        int mInputFrameSize;

         int mBitDepth;

         int mChannelCnt;

         int mSampleRate;

@@ -86,9 +80,8 @@
         bool mIsChannelConvertionRequired; // for mono to stereo

         sp<MetaData> mOutputFormat;

         Mutex mLock;

-        int32_t *pTmpBuffer;

 

-        uint8_t* pInterframeBuffer;

+        uint8_t* mInterframeBuffer;

         int32_t mInterframeBufferPosition;

         int32_t mLeftover;

         int32_t mLastReadSize ;

@@ -98,6 +91,7 @@
 

         int64_t mSeekTimeUs;

         ReadOptions::SeekMode mSeekMode;

+        int16_t *mReSampledBuffer;

 

 };

 

diff --git a/libvideoeditor/lvpp/VideoEditorTools.cpp b/libvideoeditor/lvpp/VideoEditorTools.cpp
index 3c3a7b8..ad5cbc5 100755
--- a/libvideoeditor/lvpp/VideoEditorTools.cpp
+++ b/libvideoeditor/lvpp/VideoEditorTools.cpp
@@ -282,7 +282,7 @@
     /* The input Y Plane is the same as the output Y Plane */

     p_buf_src = &(PlaneIn[0].pac_data[PlaneIn[0].u_topleft]);

     p_buf_dest = &(PlaneOut[0].pac_data[PlaneOut[0].u_topleft]);

-    M4OSA_memcpy((M4OSA_Int8*)p_buf_dest,(M4OSA_Int8*)p_buf_src ,

+    memcpy((void *)p_buf_dest,(void *)p_buf_src ,

         PlaneOut[0].u_width * PlaneOut[0].u_height);

 

     /* The U and V components are planar. The need to be made interleaved */

@@ -313,7 +313,7 @@
      /* The input Y Plane is the same as the output Y Plane */

      p_buf_src = &(PlaneIn[0].pac_data[PlaneIn[0].u_topleft]);

      p_buf_dest = &(PlaneOut[0].pac_data[PlaneOut[0].u_topleft]);

-     M4OSA_memcpy((M4OSA_Int8*)p_buf_dest,(M4OSA_Int8*)p_buf_src ,

+     memcpy((void *)p_buf_dest,(void *)p_buf_src ,

          PlaneOut[0].u_width * PlaneOut[0].u_height);

 

      /* The U and V components are planar. The need to be made interleaved */

@@ -375,32 +375,32 @@
                 switch (ColorContext->colorEffectType)

                 {

                 case M4xVSS_kVideoEffectType_BlackAndWhite:

-                    M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                     PlaneIn[plane_number].u_width, 128);

+                    memset((void *)p_buf_dest,128,

+                     PlaneIn[plane_number].u_width);

                     break;

                 case M4xVSS_kVideoEffectType_Pink:

-                    M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                     PlaneIn[plane_number].u_width, 255);

+                    memset((void *)p_buf_dest,255,

+                     PlaneIn[plane_number].u_width);

                     break;

                 case M4xVSS_kVideoEffectType_Green:

-                    M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                     PlaneIn[plane_number].u_width, 0);

+                    memset((void *)p_buf_dest,0,

+                     PlaneIn[plane_number].u_width);

                     break;

                 case M4xVSS_kVideoEffectType_Sepia:

                     if(plane_number==1)

                     {

-                        M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                         PlaneIn[plane_number].u_width, 117);

+                        memset((void *)p_buf_dest,117,

+                         PlaneIn[plane_number].u_width);

                     }

                     else

                     {

-                        M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                         PlaneIn[plane_number].u_width, 139);

+                        memset((void *)p_buf_dest,139,

+                         PlaneIn[plane_number].u_width);

                     }

                     break;

                 case M4xVSS_kVideoEffectType_Negative:

-                    M4OSA_memcpy((M4OSA_MemAddr8)p_buf_dest,

-                     (M4OSA_MemAddr8)p_buf_src ,PlaneOut[plane_number].u_width);

+                    memcpy((void *)p_buf_dest,

+                     (void *)p_buf_src ,PlaneOut[plane_number].u_width);

                     break;

 

                 case M4xVSS_kVideoEffectType_ColorRGB16:

@@ -417,15 +417,15 @@
                         {

                             /*then convert to u*/

                             u = U16(r, g, b);

-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                             PlaneIn[plane_number].u_width, (M4OSA_UInt8)u);

+                            memset((void *)p_buf_dest,(M4OSA_UInt8)u,

+                             PlaneIn[plane_number].u_width);

                         }

                         if(plane_number==2)

                         {

                             /*then convert to v*/

                             v = V16(r, g, b);

-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                             PlaneIn[plane_number].u_width, (M4OSA_UInt8)v);

+                            memset((void *)p_buf_dest,(M4OSA_UInt8)v,

+                             PlaneIn[plane_number].u_width);

                         }

                     }

                     break;

@@ -448,18 +448,20 @@
                         {

                             /*then convert to u*/

                             u = U16(r, g, b);

-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                             PlaneIn[plane_number].u_width, (M4OSA_UInt8)u);

+                            memset((void *)p_buf_dest,(M4OSA_UInt8)u,

+                             PlaneIn[plane_number].u_width);

                         }

                         if(plane_number==2)

                         {

                             /*then convert to v*/

                             v = V16(r, g, b);

-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,

-                             PlaneIn[plane_number].u_width, (M4OSA_UInt8)v);

+                            memset((void *)p_buf_dest,(M4OSA_UInt8)v,

+                             PlaneIn[plane_number].u_width);

                         }

                     }

                     break;

+                default:

+                    return M4VIFI_INVALID_PARAM;

                 }

             }

             /**

@@ -476,8 +478,8 @@
                     }

                     break;

                 default:

-                    M4OSA_memcpy((M4OSA_MemAddr8)p_buf_dest,

-                     (M4OSA_MemAddr8)p_buf_src ,PlaneOut[plane_number].u_width);

+                    memcpy((void *)p_buf_dest,

+                     (void *)p_buf_src ,PlaneOut[plane_number].u_width);

                     break;

                 }

             }

@@ -646,7 +648,7 @@
 

                 if(alphaBlendingStruct != M4OSA_NULL)

                 {

-                    if(pProgress->uiProgress >= 0 && pProgress->uiProgress < (M4OSA_UInt32)(alphaBlendingStruct->m_fadeInTime*10))

+                    if(pProgress->uiProgress < (M4OSA_UInt32)(alphaBlendingStruct->m_fadeInTime*10))

                     {

                         alphaBlending = ((M4OSA_Float)(alphaBlendingStruct->m_middle - alphaBlendingStruct->m_start)*pProgress->uiProgress/(alphaBlendingStruct->m_fadeInTime*10));

                         alphaBlending += alphaBlendingStruct->m_start;

@@ -778,9 +780,9 @@
         for (x = 0; x < pPlaneOut[plane_number].u_height; x++)

         {

             if (1 == plane_number)

-                M4OSA_memset((M4OSA_MemAddr8)pOutCr, pPlaneIn[plane_number].u_width, 117); /* U value */

+                memset((void *)pOutCr, 117,pPlaneIn[plane_number].u_width); /* U value */

             else

-                M4OSA_memset((M4OSA_MemAddr8)pOutCr, pPlaneIn[plane_number].u_width, 139); /* V value */

+                memset((void *)pOutCr, 139,pPlaneIn[plane_number].u_width); /* V value */

 

             pInCr  += pPlaneIn[plane_number].u_stride;

             pOutCr += pPlaneOut[plane_number].u_stride;

@@ -858,8 +860,8 @@
         {

             for (i = u_width; i != 0; i--)

             {

-                M4OSA_memcpy((M4OSA_MemAddr8)p_cdest_line, (M4OSA_MemAddr8)p_csrc_line, u_width);

-                M4OSA_memcpy((M4OSA_MemAddr8)p_cdest, (M4OSA_MemAddr8)p_csrc, u_width);

+                memcpy((void *)p_cdest_line, (void *)p_csrc_line, u_width);

+                memcpy((void *)p_cdest, (void *)p_csrc, u_width);

             }

             p_cdest_line += u_stride_out;

             p_cdest += u_stride_out;

@@ -973,12 +975,12 @@
         /* write black lines */

         for (j = (nb_black_lines >> 1); j != 0; j--)

         {

-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);

+            memset((void *)p_dest, 0,u_width);

             p_dest += u_stride_out;

-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);

+            memset((void *)p_dest, 0,u_width);

             p_dest += u_stride_out;

-            M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);

-            M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);

+            memset((void *)p_destu, 128,u_widthuv);

+            memset((void *)p_destv, 128,u_widthuv);

             p_destu += u_stride_out_uv;

             p_destv += u_stride_out_uv;

         }

@@ -986,14 +988,14 @@
         /* copy from source image */

         for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)

         {

-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);

+            memcpy((void *)p_dest, (void *)p_src, u_width);

             p_dest += u_stride_out;

             p_src += u_stride;

-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);

+            memcpy((void *)p_dest, (void *)p_src, u_width);

             p_dest += u_stride_out;

             p_src += u_stride;

-            M4OSA_memcpy((M4OSA_MemAddr8)p_destu, (M4OSA_MemAddr8)p_srcu, u_widthuv);

-            M4OSA_memcpy((M4OSA_MemAddr8)p_destv, (M4OSA_MemAddr8)p_srcv, u_widthuv);

+            memcpy((void *)p_destu, (void *)p_srcu, u_widthuv);

+            memcpy((void *)p_destv, (void *)p_srcv, u_widthuv);

             p_destu += u_stride_out_uv;

             p_destv += u_stride_out_uv;

             p_srcu += u_stride_uv;

@@ -1010,14 +1012,14 @@
         /* copy from source image image */

         for (j = (nb_black_lines >> 1); j != 0; j--)

         {

-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);

+            memcpy((void *)p_dest, (void *)p_src, u_width);

             p_dest += u_stride_out;

             p_src += u_stride;

-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);

+            memcpy((void *)p_dest, (void *)p_src, u_width);

             p_dest += u_stride_out;

             p_src += u_stride;

-            M4OSA_memcpy((M4OSA_MemAddr8)p_destu, (M4OSA_MemAddr8)p_srcu, u_widthuv);

-            M4OSA_memcpy((M4OSA_MemAddr8)p_destv, (M4OSA_MemAddr8)p_srcv, u_widthuv);

+            memcpy((void *)p_destu, (void *)p_srcu, u_widthuv);

+            memcpy((void *)p_destv, (void *)p_srcv, u_widthuv);

             p_destu += u_stride_out_uv;

             p_destv += u_stride_out_uv;

             p_srcu += u_stride_uv;

@@ -1028,12 +1030,12 @@
         /* the pointers to p_dest, p_destu and p_destv are used through the two loops "for" */

         for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)

         {

-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);

+            memset((void *)p_dest, 0,u_width);

             p_dest += u_stride_out;

-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);

+            memset((void *)p_dest, 0,u_width);

             p_dest += u_stride_out;

-            M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);

-            M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);

+            memset((void *)p_destu, 128,u_widthuv);

+            memset((void *)p_destv, 128,u_widthuv);

             p_destu += u_stride_out_uv;

             p_destv += u_stride_out_uv;

         }

@@ -1061,7 +1063,7 @@
 

     /**

      * Allocate output YUV planes */

-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

     if(framingCtx->FramingYuv == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1071,7 +1073,7 @@
     framingCtx->FramingYuv[0].u_height = framingCtx->FramingRgb->u_height;

     framingCtx->FramingYuv[0].u_topleft = 0;

     framingCtx->FramingYuv[0].u_stride = framingCtx->FramingRgb->u_width;

-    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

+    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1126,7 +1128,7 @@
 

     /**

      * Allocate output YUV planes */

-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

     if(framingCtx->FramingYuv == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1136,7 +1138,7 @@
     framingCtx->FramingYuv[0].u_height = framingCtx->FramingRgb->u_height;

     framingCtx->FramingYuv[0].u_topleft = 0;

     framingCtx->FramingYuv[0].u_stride = framingCtx->FramingRgb->u_width;

-    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

+    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1279,16 +1281,6 @@
             u16_pix4 = *( (M4VIFI_UInt16 *) (pu8_rgbn + u32_stride_rgb + CST_RGB_16_SIZE));

 

             /* Unpack RGB565 to 8bit R, G, B */

-#if 0

-            /* (x,y) */

-            GET_RGB565(i32_r00,i32_g00,i32_b00,u16_pix1);

-            /* (x+1,y) */

-            GET_RGB565(i32_r10,i32_g10,i32_b10,u16_pix2);

-            /* (x,y+1) */

-            GET_RGB565(i32_r01,i32_g01,i32_b01,u16_pix3);

-            /* (x+1,y+1) */

-            GET_RGB565(i32_r11,i32_g11,i32_b11,u16_pix4);

-#else

             /* (x,y) */

             GET_RGB565(i32_b00,i32_g00,i32_r00,u16_pix1);

             /* (x+1,y) */

@@ -1297,8 +1289,6 @@
             GET_RGB565(i32_b01,i32_g01,i32_r01,u16_pix3);

             /* (x+1,y+1) */

             GET_RGB565(i32_b11,i32_g11,i32_r11,u16_pix4);

-#endif

-#if 1 /* Solution to avoid green effects due to transparency */

             /* If RGB is transparent color (0, 63, 0), we transform it to white (31,63,31) */

             if(i32_b00 == 0 && i32_g00 == 63 && i32_r00 == 0)

             {

@@ -1320,7 +1310,6 @@
                 i32_b11 = 31;

                 i32_r11 = 31;

             }

-#endif

             /* Convert RGB value to YUV */

             i32_u00 = U16(i32_r00, i32_g00, i32_b00);

             i32_v00 = V16(i32_r00, i32_g00, i32_b00);

@@ -1347,47 +1336,8 @@
             pu8_yn[1] = (M4VIFI_UInt8)i32_y10;

             pu8_ys[0] = (M4VIFI_UInt8)i32_y01;

             pu8_ys[1] = (M4VIFI_UInt8)i32_y11;

-#if 0 /* Temporary solution to avoid green effects due to transparency -> To be removed */

-            count_null = 4;

-            /* Store chroma data */

-            if(i32_b00 == 0 && i32_g00 == 63 && i32_r00 == 0)

-            {

-                i32_u00 = 0;

-                i32_v00 = 0;

-                count_null --;

-            }

-            if(i32_b10 == 0 && i32_g10 == 63 && i32_r10 == 0)

-            {

-                i32_u10 = 0;

-                i32_v10 = 0;

-                count_null --;

-            }

-            if(i32_b01 == 0 && i32_g01 == 63 && i32_r01 == 0)

-            {

-                i32_u01 = 0;

-                i32_v01 = 0;

-                count_null --;

-            }

-            if(i32_b11 == 0 && i32_g11 == 63 && i32_r11 == 0)

-            {

-                i32_u11 = 0;

-                i32_v11 = 0;

-                count_null --;

-            }

-

-            if(count_null == 0)

-            {

-#endif

             *pu8_u = (M4VIFI_UInt8)((i32_u00 + i32_u01 + i32_u10 + i32_u11 + 2) >> 2);

             *pu8_v = (M4VIFI_UInt8)((i32_v00 + i32_v01 + i32_v10 + i32_v11 + 2) >> 2);

-#if 0 /* Temporary solution to avoid green effects due to transparency -> To be removed */

-            }

-            else

-            {

-                *pu8_u = (M4VIFI_UInt8)((i32_u00 + i32_u01 + i32_u10 + i32_u11 + 2) / count_null);

-                *pu8_v = (M4VIFI_UInt8)((i32_v00 + i32_v01 + i32_v10 + i32_v11 + 2) / count_null);

-            }

-#endif

             /* Prepare for next column */

             pu8_rgbn += (CST_RGB_16_SIZE<<1);

             /* Update current Y plane line pointer*/

@@ -1571,7 +1521,7 @@
         p_buf_dest = &(PlaneOut[plane_number].pac_data[PlaneOut[plane_number].u_topleft]);

         for (i = 0; i < PlaneOut[plane_number].u_height; i++)

         {

-            M4OSA_memcpy((M4OSA_MemAddr8)p_buf_dest, (M4OSA_MemAddr8)p_buf_src ,PlaneOut[plane_number].u_width);

+            memcpy((void *)p_buf_dest, (void *)p_buf_src ,PlaneOut[plane_number].u_width);

             p_buf_src += PlaneIn[plane_number].u_stride;

             p_buf_dest += PlaneOut[plane_number].u_stride;

         }

@@ -1610,7 +1560,7 @@
                                                                 M4VIFI_ImagePlane *pPlaneIn,

                                                                 M4VIFI_ImagePlane *pPlaneOut)

 {

-    M4VIFI_UInt8    *pu8_data_in, *pu8_data_out;

+    M4VIFI_UInt8    *pu8_data_in, *pu8_data_out, *pu8dum;

     M4VIFI_UInt32   u32_plane;

     M4VIFI_UInt32   u32_width_in, u32_width_out, u32_height_in, u32_height_out;

     M4VIFI_UInt32   u32_stride_in, u32_stride_out;

@@ -1623,19 +1573,29 @@
     M4VIFI_UInt8    *pu8_src_top;

     M4VIFI_UInt8    *pu8_src_bottom;

 

-    if ( (pPlaneIn[0].u_height == pPlaneOut[0].u_height) && (pPlaneIn[0].u_width == pPlaneOut[0].u_width))

+    M4VIFI_UInt8    u8Wflag = 0;

+    M4VIFI_UInt8    u8Hflag = 0;

+    M4VIFI_UInt32   loop = 0;

+

+

+    /*

+     If input width is equal to output width and input height equal to

+     output height then M4VIFI_YUV420toYUV420 is called.

+    */

+    if ((pPlaneIn[0].u_height == pPlaneOut[0].u_height) &&

+              (pPlaneIn[0].u_width == pPlaneOut[0].u_width))

     {

         return M4VIFI_YUV420toYUV420(pUserData, pPlaneIn, pPlaneOut);

     }

 

     /* Check for the YUV width and height are even */

-    if( (IS_EVEN(pPlaneIn[0].u_height) == FALSE)    ||

+    if ((IS_EVEN(pPlaneIn[0].u_height) == FALSE)    ||

         (IS_EVEN(pPlaneOut[0].u_height) == FALSE))

     {

         return M4VIFI_ILLEGAL_FRAME_HEIGHT;

     }

 

-    if( (IS_EVEN(pPlaneIn[0].u_width) == FALSE) ||

+    if ((IS_EVEN(pPlaneIn[0].u_width) == FALSE) ||

         (IS_EVEN(pPlaneOut[0].u_width) == FALSE))

     {

         return M4VIFI_ILLEGAL_FRAME_WIDTH;

@@ -1659,6 +1619,16 @@
         u32_width_out   = pPlaneOut[u32_plane].u_width;

         u32_height_out  = pPlaneOut[u32_plane].u_height;

 

+        /*

+        For the case , width_out = width_in , set the flag to avoid

+        accessing one column beyond the input width.In this case the last

+        column is replicated for processing

+        */

+        if (u32_width_out == u32_width_in) {

+            u32_width_out = u32_width_out-1;

+            u8Wflag = 1;

+        }

+

         /* Compute horizontal ratio between src and destination width.*/

         if (u32_width_out >= u32_width_in)

         {

@@ -1669,6 +1639,16 @@
             u32_x_inc   = (u32_width_in * MAX_SHORT) / (u32_width_out);

         }

 

+        /*

+        For the case , height_out = height_in , set the flag to avoid

+        accessing one row beyond the input height.In this case the last

+        row is replicated for processing

+        */

+        if (u32_height_out == u32_height_in) {

+            u32_height_out = u32_height_out-1;

+            u8Hflag = 1;

+        }

+

         /* Compute vertical ratio between src and destination height.*/

         if (u32_height_out >= u32_height_in)

         {

@@ -1681,14 +1661,15 @@
 

         /*

         Calculate initial accumulator value : u32_y_accum_start.

-        u32_y_accum_start is coded on 15 bits, and represents a value between 0 and 0.5

+        u32_y_accum_start is coded on 15 bits, and represents a value

+        between 0 and 0.5

         */

         if (u32_y_inc >= MAX_SHORT)

         {

-            /*

-                Keep the fractionnal part, assimung that integer  part is coded

-                on the 16 high bits and the fractionnal on the 15 low bits

-            */

+        /*

+        Keep the fractionnal part, assimung that integer  part is coded

+        on the 16 high bits and the fractional on the 15 low bits

+        */

             u32_y_accum = u32_y_inc & 0xffff;

 

             if (!u32_y_accum)

@@ -1705,8 +1686,9 @@
 

 

         /*

-            Calculate initial accumulator value : u32_x_accum_start.

-            u32_x_accum_start is coded on 15 bits, and represents a value between 0 and 0.5

+        Calculate initial accumulator value : u32_x_accum_start.

+        u32_x_accum_start is coded on 15 bits, and represents a value

+        between 0 and 0.5

         */

         if (u32_x_inc >= MAX_SHORT)

         {

@@ -1727,12 +1709,14 @@
         u32_height = u32_height_out;

 

         /*

-        Bilinear interpolation linearly interpolates along each row, and then uses that

-        result in a linear interpolation donw each column. Each estimated pixel in the

-        output image is a weighted combination of its four neighbours according to the formula:

-        F(p',q')=f(p,q)R(-a)R(b)+f(p,q-1)R(-a)R(b-1)+f(p+1,q)R(1-a)R(b)+f(p+&,q+1)R(1-a)R(b-1)

-        with  R(x) = / x+1  -1 =< x =< 0 \ 1-x  0 =< x =< 1 and a (resp. b)weighting coefficient

-        is the distance from the nearest neighbor in the p (resp. q) direction

+        Bilinear interpolation linearly interpolates along each row, and

+        then uses that result in a linear interpolation donw each column.

+        Each estimated pixel in the output image is a weighted combination

+        of its four neighbours according to the formula:

+        F(p',q')=f(p,q)R(-a)R(b)+f(p,q-1)R(-a)R(b-1)+f(p+1,q)R(1-a)R(b)+

+        f(p+&,q+1)R(1-a)R(b-1) with  R(x) = / x+1  -1 =< x =< 0 \ 1-x

+        0 =< x =< 1 and a (resp. b)weighting coefficient is the distance

+        from the nearest neighbor in the p (resp. q) direction

         */

 

         do { /* Scan all the row */

@@ -1762,6 +1746,16 @@
                 u32_x_accum += u32_x_inc;

             } while(--u32_width);

 

+            /*

+               This u8Wflag flag gets in to effect if input and output

+               width is same, and height may be different. So previous

+               pixel is replicated here

+            */

+            if (u8Wflag) {

+                *pu8_data_out = (M4VIFI_UInt8)u32_temp_value;

+            }

+

+            pu8dum = (pu8_data_out-u32_width_out);

             pu8_data_out = pu8_data_out + u32_stride_out - u32_width_out;

 

             /* Update vertical accumulator */

@@ -1771,6 +1765,17 @@
                 u32_y_accum &= 0xffff;

             }

         } while(--u32_height);

+

+        /*

+        This u8Hflag flag gets in to effect if input and output height

+        is same, and width may be different. So previous pixel row is

+        replicated here

+        */

+        if (u8Hflag) {

+            for(loop =0; loop < (u32_width_out+u8Wflag); loop++) {

+                *pu8_data_out++ = (M4VIFI_UInt8)*pu8dum++;

+            }

+        }

     }

 

     return M4VIFI_OK;

@@ -1800,9 +1805,9 @@
         M4OSA_UInt8* pOutPlaneY = pPlaneOut[0].pac_data + pPlaneOut[0].u_topleft;

         M4OSA_UInt8* pOutPlaneU = pPlaneOut[1].pac_data + pPlaneOut[1].u_topleft;

         M4OSA_UInt8* pOutPlaneV = pPlaneOut[2].pac_data + pPlaneOut[2].u_topleft;

-        M4OSA_UInt8* pInPlaneY;

-        M4OSA_UInt8* pInPlaneU;

-        M4OSA_UInt8* pInPlaneV;

+        M4OSA_UInt8* pInPlaneY = NULL;

+        M4OSA_UInt8* pInPlaneU = NULL;

+        M4OSA_UInt8* pInPlaneV = NULL;

         M4OSA_UInt32 i;

 

         /*to keep media aspect ratio*/

@@ -1820,9 +1825,9 @@
         Media rendering: Black borders*/

         if(mediaRendering == M4xVSS_kBlackBorders)

         {

-            M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[0].pac_data,(pPlaneOut[0].u_height*pPlaneOut[0].u_stride),Y_PLANE_BORDER_VALUE);

-            M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[1].pac_data,(pPlaneOut[1].u_height*pPlaneOut[1].u_stride),U_PLANE_BORDER_VALUE);

-            M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[2].pac_data,(pPlaneOut[2].u_height*pPlaneOut[2].u_stride),V_PLANE_BORDER_VALUE);

+            memset((void *)pPlaneOut[0].pac_data,Y_PLANE_BORDER_VALUE,(pPlaneOut[0].u_height*pPlaneOut[0].u_stride));

+            memset((void *)pPlaneOut[1].pac_data,U_PLANE_BORDER_VALUE,(pPlaneOut[1].u_height*pPlaneOut[1].u_stride));

+            memset((void *)pPlaneOut[2].pac_data,V_PLANE_BORDER_VALUE,(pPlaneOut[2].u_height*pPlaneOut[2].u_stride));

 

             pImagePlanesTemp[0].u_width = pPlaneOut[0].u_width;

             pImagePlanesTemp[0].u_height = pPlaneOut[0].u_height;

@@ -1843,20 +1848,20 @@
             pImagePlanesTemp[2].pac_data = M4OSA_NULL;

 

             /* Allocates plan in local image plane structure */

-            pImagePlanesTemp[0].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[0].u_width * pImagePlanesTemp[0].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferY") ;

+            pImagePlanesTemp[0].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[0].u_width * pImagePlanesTemp[0].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferY") ;

             if(pImagePlanesTemp[0].pac_data == M4OSA_NULL)

             {

                 M4OSA_TRACE1_0("Error alloc in applyRenderingMode");

                 return M4ERR_ALLOC;

             }

-            pImagePlanesTemp[1].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[1].u_width * pImagePlanesTemp[1].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferU") ;

+            pImagePlanesTemp[1].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[1].u_width * pImagePlanesTemp[1].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferU") ;

             if(pImagePlanesTemp[1].pac_data == M4OSA_NULL)

             {

 

                 M4OSA_TRACE1_0("Error alloc in applyRenderingMode");

                 return M4ERR_ALLOC;

             }

-            pImagePlanesTemp[2].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[2].u_width * pImagePlanesTemp[2].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferV") ;

+            pImagePlanesTemp[2].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[2].u_width * pImagePlanesTemp[2].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferV") ;

             if(pImagePlanesTemp[2].pac_data == M4OSA_NULL)

             {

 

@@ -1868,9 +1873,9 @@
             pInPlaneU = pImagePlanesTemp[1].pac_data ;

             pInPlaneV = pImagePlanesTemp[2].pac_data ;

 

-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[0].pac_data,(pImagePlanesTemp[0].u_height*pImagePlanesTemp[0].u_stride),Y_PLANE_BORDER_VALUE);

-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[1].pac_data,(pImagePlanesTemp[1].u_height*pImagePlanesTemp[1].u_stride),U_PLANE_BORDER_VALUE);

-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[2].pac_data,(pImagePlanesTemp[2].u_height*pImagePlanesTemp[2].u_stride),V_PLANE_BORDER_VALUE);

+            memset((void *)pImagePlanesTemp[0].pac_data,Y_PLANE_BORDER_VALUE,(pImagePlanesTemp[0].u_height*pImagePlanesTemp[0].u_stride));

+            memset((void *)pImagePlanesTemp[1].pac_data,U_PLANE_BORDER_VALUE,(pImagePlanesTemp[1].u_height*pImagePlanesTemp[1].u_stride));

+            memset((void *)pImagePlanesTemp[2].pac_data,V_PLANE_BORDER_VALUE,(pImagePlanesTemp[2].u_height*pImagePlanesTemp[2].u_stride));

 

             if((M4OSA_UInt32)((pPlaneIn->u_height * pPlaneOut->u_width) /pPlaneIn->u_width) <= pPlaneOut->u_height)//Params.m_inputSize.m_height < Params.m_inputSize.m_width)

             {

@@ -1959,7 +1964,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -1977,7 +1982,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -1993,7 +1998,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -2004,19 +2009,19 @@
         {

             for(i=0; i<pPlaneOut[0].u_height; i++)

             {

-                M4OSA_memcpy((M4OSA_MemAddr8)pOutPlaneY, (M4OSA_MemAddr8)pInPlaneY, pPlaneOut[0].u_width);

+                memcpy((void *)pOutPlaneY, (void *)pInPlaneY, pPlaneOut[0].u_width);

                 pInPlaneY += pPlaneOut[0].u_width;

                 pOutPlaneY += pPlaneOut[0].u_stride;

             }

             for(i=0; i<pPlaneOut[1].u_height; i++)

             {

-                M4OSA_memcpy((M4OSA_MemAddr8)pOutPlaneU, (M4OSA_MemAddr8)pInPlaneU, pPlaneOut[1].u_width);

+                memcpy((void *)pOutPlaneU, (void *)pInPlaneU, pPlaneOut[1].u_width);

                 pInPlaneU += pPlaneOut[1].u_width;

                 pOutPlaneU += pPlaneOut[1].u_stride;

             }

             for(i=0; i<pPlaneOut[2].u_height; i++)

             {

-                M4OSA_memcpy((M4OSA_MemAddr8)pOutPlaneV, (M4OSA_MemAddr8)pInPlaneV, pPlaneOut[2].u_width);

+                memcpy((void *)pOutPlaneV, (void *)pInPlaneV, pPlaneOut[2].u_width);

                 pInPlaneV += pPlaneOut[2].u_width;

                 pOutPlaneV += pPlaneOut[2].u_stride;

             }

@@ -2025,11 +2030,16 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

         }

+

+        if (m_air_context != M4OSA_NULL) {

+            M4AIR_cleanUp(m_air_context);

+            m_air_context = M4OSA_NULL;

+        }

     }

 

     return err;

@@ -2124,7 +2134,7 @@
     *pContext = M4OSA_NULL ;

 

     /* Internal Context creation */

-    pC = (M4AIR_InternalContext*)M4OSA_malloc(sizeof(M4AIR_InternalContext), M4AIR, (M4OSA_Char*)"AIR internal context") ;

+    pC = (M4AIR_InternalContext*)M4OSA_32bitAlignedMalloc(sizeof(M4AIR_InternalContext), M4AIR, (M4OSA_Char*)"AIR internal context") ;

     M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, pC) ;

 

 

@@ -2157,7 +2167,7 @@
     /* Error management : we destroy the context if needed */

     if(M4OSA_NULL != pC)

     {

-        M4OSA_free((M4OSA_MemAddr32)pC) ;

+        free(pC) ;

     }

 

     *pContext = M4OSA_NULL ;

@@ -2189,7 +2199,7 @@
     {

         return M4ERR_STATE;

     }

-    M4OSA_free((M4OSA_MemAddr32)pC) ;

+    free(pC) ;

 

     return M4NO_ERROR ;

 

@@ -2518,7 +2528,7 @@
                     for (j=0; j<loc_height; j++)

                     {

                         /**< Copy one whole line */

-                        memcpy((M4OSA_MemAddr8)pu8_data_out, (M4OSA_MemAddr8)pu8_data_in, loc_width);

+                        memcpy((void *)pu8_data_out, (void *)pu8_data_in, loc_width);

 

                         /**< Update pointers */

                         pu8_data_out += pOut[i].u_stride;

@@ -2967,7 +2977,7 @@
     M4OSA_Context lImageFileFp  = M4OSA_NULL;

     M4OSA_ERR err = M4NO_ERROR;

 

-    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_malloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");

+    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_32bitAlignedMalloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");

     if(pTmpData == M4OSA_NULL) {

         LOGE("Failed to allocate memory for Image clip");

         return M4ERR_ALLOC;

@@ -2979,7 +2989,7 @@
     if((lerr != M4NO_ERROR) || (lImageFileFp == M4OSA_NULL))

     {

         LOGE("LVPreviewController: Can not open the file ");

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return M4ERR_FILE_NOT_FOUND;

     }

     lerr = M4OSA_fileReadData(lImageFileFp, (M4OSA_MemAddr8)pTmpData, &frameSize_argb);

@@ -2987,27 +2997,27 @@
     {

         LOGE("LVPreviewController: can not read the data ");

         M4OSA_fileReadClose(lImageFileFp);

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return lerr;

     }

     M4OSA_fileReadClose(lImageFileFp);

 

     M4OSA_UInt32 frameSize = (width * height * 3); //Size of YUV420 data.

-    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS, (M4OSA_Char*)"Image clip RGB888 data");

+    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS, (M4OSA_Char*)"Image clip RGB888 data");

     if(rgbPlane.pac_data == M4OSA_NULL)

     {

         LOGE("Failed to allocate memory for Image clip");

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return M4ERR_ALLOC;

     }

 

     /** Remove the alpha channel */

-    for (int i=0, j = 0; i < frameSize_argb; i++) {

+    for (M4OSA_UInt32 i=0, j = 0; i < frameSize_argb; i++) {

         if ((i % 4) == 0) continue;

         rgbPlane.pac_data[j] = pTmpData[i];

         j++;

     }

-    M4OSA_free((M4OSA_MemAddr32)pTmpData);

+    free(pTmpData);

 

 #ifdef FILE_DUMP

     FILE *fp = fopen("/sdcard/Input/test_rgb.raw", "wb");

@@ -3023,13 +3033,13 @@
         rgbPlane.u_stride = width*3;

         rgbPlane.u_topleft = 0;

 

-        yuvPlane = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane),

+        yuvPlane = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane),

                 M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

         yuvPlane[0].u_height = height;

         yuvPlane[0].u_width = width;

         yuvPlane[0].u_stride = width;

         yuvPlane[0].u_topleft = 0;

-        yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc(yuvPlane[0].u_height * yuvPlane[0].u_width * 1.5, M4VS, (M4OSA_Char*)"imageClip YUV data");

+        yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(yuvPlane[0].u_height * yuvPlane[0].u_width * 1.5, M4VS, (M4OSA_Char*)"imageClip YUV data");

 

         yuvPlane[1].u_height = yuvPlane[0].u_height >>1;

         yuvPlane[1].u_width = yuvPlane[0].u_width >> 1;

@@ -3048,9 +3058,9 @@
         //err = M4VIFI_BGR888toYUV420(M4OSA_NULL, &rgbPlane, yuvPlane);

         if(err != M4NO_ERROR)

         {

-            LOGE("error when converting from RGB to YUV: 0x%x\n", err);

+            LOGE("error when converting from RGB to YUV: 0x%x\n", (unsigned int)err);

         }

-        M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);

+        free(rgbPlane.pac_data);

 

         //LOGE("RGB to YUV done");

 #ifdef FILE_DUMP

@@ -3063,7 +3073,7 @@
         }

 #endif

         *pBuffer = yuvPlane[0].pac_data;

-        M4OSA_free((M4OSA_MemAddr32)yuvPlane);

+        free(yuvPlane);

         return M4NO_ERROR;

 

 }

@@ -3230,7 +3240,7 @@
     framingCtx->previousClipTime = -1;

 

     framingCtx->alphaBlendingStruct =

-     (M4xVSS_internalEffectsAlphaBlending*)M4OSA_malloc(

+     (M4xVSS_internalEffectsAlphaBlending*)M4OSA_32bitAlignedMalloc(

       sizeof(M4xVSS_internalEffectsAlphaBlending), M4VS,

       (M4OSA_Char*)"alpha blending struct");

 

@@ -3254,7 +3264,7 @@
 

         // If YUV buffer exists, delete it

         if(overlayYUV != NULL) {

-           M4OSA_free((M4OSA_MemAddr32)overlayYUV);

+           free(overlayYUV);

            overlayYUV = NULL;

         }

     if(effectsSettings[index].xVSS.rgbType == M4VSS3GPP_kRGB565) {

@@ -3276,7 +3286,7 @@
     }

     else {

         LOGV(" YUV buffer reuse");

-        framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(

+        framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(

             3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"YUV");

 

         if(framingCtx->FramingYuv == M4OSA_NULL) {

@@ -3330,11 +3340,11 @@
             colorEffect, err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1 = NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2 = NULL;

         }

         return err;

@@ -3357,14 +3367,14 @@
          lum_factor, NULL);

 

     if(err != M4NO_ERROR) {

-        LOGE("M4VFL_modifyLumaWithScale(%d) error %d", videoEffect, err);

+        LOGE("M4VFL_modifyLumaWithScale(%d) error %d", videoEffect, (int)err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1= NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2= NULL;

         }

         return err;

@@ -3388,14 +3398,14 @@
     err = M4VFL_applyCurtain( (M4ViComImagePlane*)planeIn,

           (M4ViComImagePlane*)planeOut, curtainParams, NULL);

     if(err != M4NO_ERROR) {

-        LOGE("M4VFL_applyCurtain(%d) error %d", videoEffect, err);

+        LOGE("M4VFL_applyCurtain(%d) error %d", videoEffect, (int)err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1= NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2 = NULL;

         }

         return err;

@@ -3423,7 +3433,7 @@
 

     frameSize = (params->videoWidth*params->videoHeight*3) >> 1;

 

-    finalOutputBuffer = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS,

+    finalOutputBuffer = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS,

      (M4OSA_Char*)("lvpp finalOutputBuffer"));

 

     if(finalOutputBuffer == NULL) {

@@ -3432,13 +3442,13 @@
     }

 

     // allocate the tempOutputBuffer

-    tempOutputBuffer = (M4VIFI_UInt8*)M4OSA_malloc(

+    tempOutputBuffer = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(

      ((params->videoHeight*params->videoWidth*3)>>1), M4VS, (M4OSA_Char*)("lvpp colorBuffer"));

 

     if(tempOutputBuffer == NULL) {

         LOGE("applyEffectsAndRenderingMode: malloc error tempOutputBuffer");

         if(NULL != finalOutputBuffer) {

-            M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+            free(finalOutputBuffer);

             finalOutputBuffer = NULL;

         }

         return M4ERR_ALLOC;

@@ -3506,7 +3516,7 @@
         // find the effect in effectSettings array

         for(i=0;i<params->numberEffects;i++) {

             if(params->effectsSettings[i].VideoEffectType ==

-             M4xVSS_kVideoEffectType_Gradient)

+             (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Gradient)

                 break;

         }

         err = applyColorEffect(M4xVSS_kVideoEffectType_Gradient,

@@ -3522,7 +3532,7 @@
         // Find the effect in effectSettings array

         for(i=0;i<params->numberEffects;i++) {

             if(params->effectsSettings[i].VideoEffectType ==

-             M4xVSS_kVideoEffectType_ColorRGB16)

+             (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_ColorRGB16)

                 break;

         }

         err = applyColorEffect(M4xVSS_kVideoEffectType_ColorRGB16,

@@ -3538,7 +3548,7 @@
         // Find the effect in effectSettings array

         for(i=0;i<params->numberEffects;i++) {

             if(params->effectsSettings[i].VideoEffectType ==

-             M4xVSS_kVideoEffectType_Fifties)

+             (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Fifties)

                 break;

         }

         if(i < params->numberEffects) {

@@ -3560,14 +3570,14 @@
              M4xVSS_kVideoEffectType_Fifties);

 

             if(err != M4NO_ERROR) {

-                LOGE("M4VSS3GPP_externalVideoEffectFifties error 0x%x", err);

+                LOGE("M4VSS3GPP_externalVideoEffectFifties error 0x%x", (unsigned int)err);

 

                 if(NULL != finalOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+                    free(finalOutputBuffer);

                     finalOutputBuffer = NULL;

                 }

                 if(NULL != tempOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+                    free(tempOutputBuffer);

                     tempOutputBuffer = NULL;

                 }

                 return err;

@@ -3585,7 +3595,7 @@
         // Find the effect in effectSettings array

         for(i=0;i<params->numberEffects;i++) {

             if(params->effectsSettings[i].VideoEffectType ==

-             M4xVSS_kVideoEffectType_Framing) {

+             (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Framing) {

                 if((params->effectsSettings[i].uiStartTime <= params->timeMs + params->timeOffset) &&

                    ((params->effectsSettings[i].uiStartTime+

                      params->effectsSettings[i].uiDuration) >= params->timeMs + params->timeOffset))

@@ -3609,10 +3619,10 @@
                       M4xVSS_kVideoEffectType_Framing);

             }

 

-            M4OSA_free((M4OSA_MemAddr32)framingCtx.alphaBlendingStruct);

+            free(framingCtx.alphaBlendingStruct);

 

             if(framingCtx.FramingYuv != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)framingCtx.FramingYuv);

+                free(framingCtx.FramingYuv);

                 framingCtx.FramingYuv = NULL;

             }

             //If prepareFramingStructure / M4VSS3GPP_externalVideoEffectFraming

@@ -3620,11 +3630,11 @@
             if(err != M4NO_ERROR) {

 

                 if(NULL != finalOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+                    free(finalOutputBuffer);

                     finalOutputBuffer = NULL;

                 }

                 if(NULL != tempOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+                    free(tempOutputBuffer);

                     tempOutputBuffer = NULL;

                 }

                 return err;

@@ -3763,11 +3773,11 @@
     err = applyRenderingMode(planeIn, planeOut, params->renderingMode);

 

     if(M4OSA_NULL != finalOutputBuffer) {

-        M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+        free(finalOutputBuffer);

         finalOutputBuffer= M4OSA_NULL;

     }

     if(M4OSA_NULL != tempOutputBuffer) {

-        M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+        free(tempOutputBuffer);

         tempOutputBuffer = M4OSA_NULL;

     }

     if(err != M4NO_ERROR) {

diff --git a/libvideoeditor/osal/inc/LV_Macros.h b/libvideoeditor/osal/inc/LV_Macros.h
index d6312cc..fa927b7 100755
--- a/libvideoeditor/osal/inc/LV_Macros.h
+++ b/libvideoeditor/osal/inc/LV_Macros.h
@@ -97,7 +97,7 @@
 { \
     if(M4OSA_NULL != (p)) \
     { \
-        M4OSA_free((M4OSA_MemAddr32)(p)) ; \
+        free((p)) ; \
         (p) = M4OSA_NULL ; \
     } \
 }
diff --git a/libvideoeditor/osal/inc/LV_Types.h b/libvideoeditor/osal/inc/LV_Types.h
deleted file mode 100755
index 534ea3a..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 M4OSA_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 M4OSA_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_CharStar.h b/libvideoeditor/osal/inc/M4OSA_CharStar.h
index b51af23..abd6c9f 100755
--- a/libvideoeditor/osal/inc/M4OSA_CharStar.h
+++ b/libvideoeditor/osal/inc/M4OSA_CharStar.h
@@ -55,46 +55,9 @@
 M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrNCopy          (M4OSA_Char   *strOut,
                                    M4OSA_Char   *strIn,
                                    M4OSA_UInt32 len2Copy);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrNCat           (M4OSA_Char   *strOut,
-                                   M4OSA_Char   *strIn,
-                                   M4OSA_UInt32 len2Append);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrCompare        (M4OSA_Char   *strIn1,
-                                   M4OSA_Char   *strIn2,
-                                   M4OSA_Int32  *cmpResult);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrNCompare       (M4OSA_Char   *strIn1,
-                                   M4OSA_Char   *strIn2,
-                                   M4OSA_UInt32 len2Comp,
-                                   M4OSA_Int32  *cmpResult);
 M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrAreIdentical   (M4OSA_Char   *strIn1,
                                    M4OSA_Char   *strIn2,
                                    M4OSA_Bool  *result);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrFindChar       (M4OSA_Char   *strIn,
-                                   M4OSA_Char   c,
-                                   M4OSA_Char   **pointerInStr);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrReverseFindChar(M4OSA_Char   *strIn,
-                                   M4OSA_Char   c,
-                                   M4OSA_Char   **pointerInStr);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrSpan           (M4OSA_Char   *strIn,
-                                   M4OSA_Char   *delimiters,
-                                   M4OSA_UInt32 *posInStr);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrSpanComplement (M4OSA_Char   *strIn,
-                                   M4OSA_Char   *delimiters,
-                                   M4OSA_UInt32 *posInStr);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrPbrk           (M4OSA_Char   *strIn,
-                                   M4OSA_Char   *delimiters,
-                                   M4OSA_Char   **pointerInStr);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrFindPattern    (M4OSA_Char   *strIn1,
-                                   M4OSA_Char   *strIn2,
-                                   M4OSA_Char   **pointerInStr1);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_UInt32 M4OSA_chrLength      (M4OSA_Char   *strIn);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_Char   M4OSA_chrToLower     (M4OSA_Char   cIn);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_Char   M4OSA_chrToUpper     (M4OSA_Char   cIn);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR    M4OSA_chrGetWord     (M4OSA_Char   *strIn,
-                                   M4OSA_Char   *beginDelimiters,
-                                   M4OSA_Char   *endDelimiters,
-                                   M4OSA_Char   *strOut,
-                                   M4OSA_UInt32 *strOutMaxLen,
-                                   M4OSA_Char   **outputPointer);
 M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetUInt32      (M4OSA_Char   *strIn,
                                    M4OSA_UInt32 *val,
                                    M4OSA_Char   **strOut,
@@ -103,37 +66,6 @@
                                    M4OSA_UInt16 *val,
                                    M4OSA_Char   **strOut,
                                    M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetUInt8       (M4OSA_Char   *strIn,
-                                   M4OSA_UInt8  *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetInt64       (M4OSA_Char   *strIn,
-                                   M4OSA_Int64  *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetInt32       (M4OSA_Char   *strIn,
-                                   M4OSA_Int32  *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetInt16       (M4OSA_Char   *strIn,
-                                   M4OSA_Int16  *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetInt8        (M4OSA_Char   *strIn,
-                                   M4OSA_Int8   *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetDouble      (M4OSA_Char   *strIn,
-                                   M4OSA_Double *val,
-                                   M4OSA_Char   **strOut);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetTime        (M4OSA_Char   *strIn,
-                                   M4OSA_Time   *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
-M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrGetFilePosition(M4OSA_Char   *strIn,
-                                   M4OSA_FilePosition *val,
-                                   M4OSA_Char   **strOut,
-                                   M4OSA_chrNumBase base);
 M4OSAL_CHARSTAR_EXPORT_TYPE M4OSA_ERR M4OSA_chrSPrintf         (M4OSA_Char  *strOut,
                                    M4OSA_UInt32 strOutMaxLen,
                                    M4OSA_Char   *format,
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_FileCommon.h b/libvideoeditor/osal/inc/M4OSA_FileCommon.h
index 663be66..eda6921 100755
--- a/libvideoeditor/osal/inc/M4OSA_FileCommon.h
+++ b/libvideoeditor/osal/inc/M4OSA_FileCommon.h
@@ -34,21 +34,7 @@
 #include "M4OSA_OptionID.h"
 
 
-
-/*#define M4OSA_FILE_POS_64_BITS_SUPPORTED*/ /*Means M4OSA_Int64 is used*/
-
-#ifndef M4OSA_FILE_POS_64_BITS_SUPPORTED
-#define M4OSA_FILE_POS_32_BITS_SUPPORTED     /*Means M4OSA_Int32 is used*/
-#endif /*M4OSA_FILE_POS_64_BITS_SUPPORTED*/
-
-
-
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
-typedef M4OSA_Int64 M4OSA_FilePosition;
-#endif
-#ifdef M4OSA_FILE_POS_32_BITS_SUPPORTED
 typedef M4OSA_Int32 M4OSA_FilePosition;
-#endif
 
 /** This enum defines the application mode access.
  *  ie, the application uses a file descriptor to read or to write  or
@@ -129,109 +115,5 @@
 #define M4ERR_FILE_INVALID_POSITION  M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000004)
 
 
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
-
-#define M4OSA_FPOS_SET(fpos_a, fpos_b)\
-        M4OSA_INT64_SET(fpos_a, fpos_b)
-
-#define M4OSA_FPOS_ADD(fpos_result, fpos_a, fpos_b)\
-        M4OSA_INT64_ADD(fpos_result, fpos_a, fpos_b)
-
-#define M4OSA_FPOS_SUB(fpos_result, fpos_a, fpos_b)\
-        M4OSA_INT64_SUB(fpos_result, fpos_a, fpos_b)
-
-#define M4OSA_FPOS_ADD_CONST_UINT32(fpos_out, fpos_in, i32_in)\
-      { M4OSA_Int64 i64_in;\
-        M4OSA_INT64_FROM_INT32(i64_in, i32_in);\
-        M4OSA_INT64_ADD(fpos_out, fpos_in, i64_in); }
-
-#define M4OSA_FPOS_SUB_CONST_UINT32(fpos_out, fpos_in, i32_in)\
-      { M4OSA_Int64 i64_in;\
-        M4OSA_INT64_FROM_INT32(i64_in, i32_in);\
-        M4OSA_INT64_SUB(fpos_out, fpos_in, i64_in); }
-
-#define M4OSA_FPOS_SCALAR_PRODUCT(fpos_result, fpos_a, i32_value)\
-        M4OSA_INT64_SCALAR_PRODUCT(fpos_result, fpos_a, i32_value)
-
-#define M4OSA_FPOS_SCALAR_DIVISION(fpos_result, fpos_a, i32_value)\
-        M4OSA_INT64_SCALAR_DIVISION(fpos_result, fpos_a, i32_value)
-
-#define M4OSA_FPOS_COMPARE(fpos_a, fpos_b)\
-        M4OSA_INT64_COMPARE(fpos_a, fpos_b)
-
-#define M4OSA_FILE_POSITION_TO_INT(fpos, ipos)\
-        M4OSA_INT64_SET(ipos, fpos)
-
-#define M4OSA_INT_TO_FILE_POSITION(ipos, fpos)\
-        M4OSA_FPOS_SET(fpos, ipos)
-
-#define M4OSA_FPOS_IS_POSITIVE(fpos_value)\
-        M4OSA_INT64_IS_POSITIVE(fpos_value)
-
-#define M4OSA_FPOS_NEG(fpos_result, fpos_value)\
-        M4OSA_INT64_NEG(fpos_result, fpos_value)
-
-#define M4OSA_FPOS_ABS(fpos_result, fpos_value)\
-        M4OSA_INT64_ABS(fpos_result, fpos_value)
-
-#define M4OSA_FPOS_LEFT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)\
-        M4OSA_INT64_LEFT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)
-
-#define M4OSA_FPOS_RIGHT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)\
-        M4OSA_INT64_RIGHT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)
-
-#endif
-
-#ifdef M4OSA_FILE_POS_32_BITS_SUPPORTED
-
-#define M4OSA_FPOS_SET(fpos_a, fpos_b)\
-        M4OSA_INT32_SET(fpos_a, fpos_b)
-
-#define M4OSA_FPOS_ADD(fpos_result, fpos_a, fpos_b)\
-        M4OSA_INT32_ADD(fpos_result, fpos_a, fpos_b)
-
-#define M4OSA_FPOS_SUB(fpos_result, fpos_a, fpos_b)\
-        M4OSA_INT32_SUB(fpos_result, fpos_a, fpos_b)
-
-#define M4OSA_FPOS_ADD_CONST_UINT32(fpos_out, fpos_in, i32_in)\
-        M4OSA_FPOS_ADD(fpos_out, fpos_in, i32_in)
-
-#define M4OSA_FPOS_SUB_CONST_UINT32(fpos_out, fpos_in, i32_in)\
-        M4OSA_FPOS_SUB(fpos_out, fpos_in, i32_in)
-
-#define M4OSA_FPOS_SCALAR_PRODUCT(fpos_result, fpos_a, i32_value)\
-        M4OSA_INT32_SCALAR_PRODUCT(fpos_result, fpos_a, i32_value)
-
-#define M4OSA_FPOS_SCALAR_DIVISION(fpos_result, fpos_a, i32_value)\
-        M4OSA_INT32_SCALAR_DIVISION(fpos_result, fpos_a, i32_value)
-
-#define M4OSA_FPOS_COMPARE(fpos_a, fpos_b)\
-        M4OSA_INT32_COMPARE(fpos_a, fpos_b)
-
-#define M4OSA_FILE_POSITION_TO_INT(fpos, ipos)\
-        M4OSA_INT32_SET(ipos, fpos)
-
-#define M4OSA_INT_TO_FILE_POSITION(ipos, fpos)\
-        M4OSA_FPOS_SET(fpos, ipos)
-
-#define M4OSA_FPOS_IS_POSITIVE(fpos_value)\
-        M4OSA_INT32_IS_POSITIVE(fpos_value)
-
-#define M4OSA_FPOS_NEG(fpos_result, fpos_value)\
-        M4OSA_INT32_NEG(fpos_result, fpos_value)
-
-#define M4OSA_FPOS_ABS(fpos_result, fpos_value)\
-        M4OSA_INT32_ABS(fpos_result, fpos_value)
-
-#define M4OSA_FPOS_LEFT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)\
-        M4OSA_INT32_LEFT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)
-
-#define M4OSA_FPOS_RIGHT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)\
-        M4OSA_INT32_RIGHT_SHIFT(fpos_result, fpos_value, ui32_nbPositions)
-
-#endif
-
-
-
 #endif /*M4OSA_FILECOMMON_H*/
 
diff --git a/libvideoeditor/osal/inc/M4OSA_FileCommon_priv.h b/libvideoeditor/osal/inc/M4OSA_FileCommon_priv.h
index f3064a7..261070f 100755
--- a/libvideoeditor/osal/inc/M4OSA_FileCommon_priv.h
+++ b/libvideoeditor/osal/inc/M4OSA_FileCommon_priv.h
@@ -46,12 +46,7 @@
 typedef struct {
    M4OSA_UInt32         coreID_read;
    M4OSA_UInt32         coreID_write;
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
-   /** The file handler */
-   M4OSA_Int32          file_desc;
-#else
    FILE*                file_desc;
-#endif /* M4OSA_FILE_POS_64_BITS_SUPPORTED */
    /** The name of the URL */
    M4OSA_Char*          url_name;
    /** The name of the file */
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_Memory.h b/libvideoeditor/osal/inc/M4OSA_Memory.h
index d0bb49c..d80fff6 100755
--- a/libvideoeditor/osal/inc/M4OSA_Memory.h
+++ b/libvideoeditor/osal/inc/M4OSA_Memory.h
@@ -39,26 +39,10 @@
 {
 #endif
 
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_MemAddr32 M4OSA_malloc (M4OSA_UInt32 size,
+M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_MemAddr32 M4OSA_32bitAlignedMalloc (M4OSA_UInt32 size,
                                                                M4OSA_CoreID coreID,
                                                                M4OSA_Char* string);
 
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_Void  M4OSA_free   (M4OSA_MemAddr32 address);
-
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_Void M4OSA_memset (M4OSA_MemAddr8 address,
-                                                          M4OSA_UInt32 size,
-                                                          M4OSA_UInt8 value);
-
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_Void M4OSA_memcpy (M4OSA_MemAddr8 outputBlock,
-                                      M4OSA_MemAddr8 inputBlock, M4OSA_UInt32 size);
-
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_MemAddr8 M4OSA_memmove(M4OSA_MemAddr8 outputBlock,
-                                              M4OSA_MemAddr8 inputBlock,
-                                              M4OSA_UInt32 size);
-
-M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_Int32 M4OSA_memcmp (M4OSA_MemAddr8 address1,
-                                      M4OSA_MemAddr8 address2, M4OSA_UInt32 size);
-
 M4OSAL_MEMORY_EXPORT_TYPE extern M4OSA_ERR M4OSA_randInit(void);
 
 
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/inc/M4OSA_Time.h b/libvideoeditor/osal/inc/M4OSA_Time.h
index 984c243..737ebad 100755
--- a/libvideoeditor/osal/inc/M4OSA_Time.h
+++ b/libvideoeditor/osal/inc/M4OSA_Time.h
@@ -33,132 +33,17 @@
 #include "M4OSA_Types.h"
 
 
-typedef M4OSA_Int64   M4OSA_Time;
+typedef signed long long  M4OSA_Time;
 
 
 /** This macro sets the unknown time value */
-#ifdef M4OSA_64BITS_SUPPORTED
-   #define M4OSA_TIME_SET_UNKNOWN(time) {time = 0x8000000000000000LL ;}
-#endif /* M4OSA_64BITS_SUPPORTED */
 
-#ifdef M4OSA_64BITS_COUPLE_INT
-   #define M4OSA_TIME_SET_UNKNOWN(time) {\
-      time.major = 0x80000000 ;\
-      time.minor = 0x00000000 ;}
-#endif /* M4OSA_64BITS_COUPLE_INT */
-
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
-   #define M4OSA_TIME_SET_UNKNOWN(time) {time = 0x80000000;}
-#endif   /* M4OSA_64BITS_NOT_SUPPORTED */
-
-
-/** This macro returns 1 if the provided time is set to unknown time,
-    and 0 else.*/
-#ifdef M4OSA_64BITS_SUPPORTED
-
-#define M4OSA_TIME_IS_UNKNOWN(time) (((M4OSA_UInt64)(time) == 0x8000000000000000LL) ? 1 : 0)
-
-#elif defined M4OSA_64BITS_COUPLE_INT
-
-#define M4OSA_TIME_IS_UNKNOWN(time)\
-   (( (M4OSA_INT64_GET_HIGH32(time) == M4OSA_unknownTimeMajor)\
-      &&(M4OSA_INT64_GET_LOW32(time) == M4OSA_unknownTimeMinor) ) ? 1:0)
-
-#else /* M4OSA_64BITS_NOT_SUPPORTED */
-
-#define M4OSA_TIME_IS_UNKNOWN(time) (((M4OSA_UInt32)(time) == 0x80000000) ? 1 : 0)
-
-#endif
-
-
-/** This macro affects time2 to time1.*/
-#define M4OSA_TIME_SET(time1, time2)\
-        M4OSA_INT64_SET(time1, time2)
-
-
-/** This macro sets time from i32.*/
-#define M4OSA_TIME_FROM_INT32(time, i32)\
-        M4OSA_INT64_FROM_INT32(time, i32)
-
-
-/** This macro sets time from i32 ui32.*/
-#define M4OSA_TIME_FROM_INT32_UINT32(time, i32, ui32)\
-        M4OSA_INT64_FROM_INT32_UINT32(time, i32, ui32)
-
-
-/** This macro tests if time is positive*/
-#define M4OSA_TIME_IS_POSITIVE(time)\
-        M4OSA_INT64_IS_POSITIVE(time)
-
-
-/** This macro sets time_out = -time_in*/
-#define M4OSA_TIME_NEG(time_out, time_in)\
-        M4OSA_INT64_NEG(time_out, time_in)
-
-
-/** This macro sets time_out = |time_in|*/
-#define M4OSA_TIME_ABS(time_out, time_in)\
-        M4OSA_INT64_ABS(time_out, time_in)
-
-
-/** This macro adds the 2 provided times (time1 and time2),
-    and writes the result in result. Both times must have the same timescale.*/
-#define M4OSA_TIME_ADD(result, time1, time2)\
-        M4OSA_INT64_ADD(result, time1, time2)
-
-
-/** This macro subs the 2 provided times (time1 and time2),
-    and writes the result in result.*/
-#define M4OSA_TIME_SUB(result, time1, time2)\
-        M4OSA_INT64_SUB(result, time1, time2)
-
-
-/** This macro does a scalar product (result = time*value),
-    and writes the result in result.*/
-#define M4OSA_TIME_SCALAR_PRODUCT(result, time, value)\
-        M4OSA_INT64_SCALAR_PRODUCT(result, time, value)
-
-
-/** This macro does a scalar division (result= time / value),
-    and writes the result in result.*/
-#define M4OSA_TIME_SCALAR_DIVISION(result, time, value)\
-        M4OSA_INT64_SCALAR_DIVISION(result, time, value)
-
-
-/** This macro updates the time to the oldTimeScale to the newTimeScale. The
-    result (the nearest rounded to the min value) is stored in result value. */
-#define M4OSA_TIME_CHANGE_TIMESCALE(result, time, oldTimeScale, newTimeScale)\
-      { M4OSA_Time t_tempTime1, t_tempTime2, t_tempTime3;\
-        M4OSA_Int32 i32_quotient = newTimeScale/oldTimeScale;\
-        M4OSA_Int32 i32_rest = newTimeScale%oldTimeScale;\
-        M4OSA_INT64_SCALAR_PRODUCT(t_tempTime1, time, i32_quotient);\
-        M4OSA_INT64_SCALAR_PRODUCT(t_tempTime2, time, i32_rest);\
-        M4OSA_INT64_SCALAR_DIVISION(t_tempTime3, t_tempTime2, oldTimeScale);\
-        M4OSA_INT64_ADD(result, t_tempTime1, t_tempTime3); }
-
-
-/** This macro tests the 2 provided times (time1 & time2).
-    The result is either:
-  * @arg  1: if time1 is bigger than time2
-  * @arg  0: if time2 is equal to time2
-  * @arg -1: if time1 is smaller than time2  */
-#define M4OSA_TIME_COMPARE(time1, time2)\
-        M4OSA_INT64_COMPARE(time1, time2)
-
+#define M4OSA_TIME_UNKNOWN 0x80000000
 
 /** This macro converts a time with a time scale to millisecond.
     The result is a M4OSA_Double*/
 #define M4OSA_TIME_TO_MS(result, time, timescale)\
-      { M4OSA_INT64_TO_DOUBLE(result, time);\
-        result = (1000*result)/((M4OSA_Double)timescale); }
-
-
-/** This macro converts a millisecond time to M4OSA_Time with the provided
-    timescale. The result (the nearest rounded to the min value) is stored
-    in time value.*/
-#define M4OSA_MS_TO_TIME(time, timescale, ms)\
-      {M4OSA_INT64_FROM_DOUBLE(time, (ms*((M4OSA_Double)(timescale))/1000.0));}
-
+      { result = (1000*(M4OSA_Double)time)/((M4OSA_Double)timescale); }
 
 #endif /*M4OSA_TIME_H*/
 
diff --git a/libvideoeditor/osal/inc/M4OSA_Types.h b/libvideoeditor/osal/inc/M4OSA_Types.h
index 250f131..2ee9568 100755
--- a/libvideoeditor/osal/inc/M4OSA_Types.h
+++ b/libvideoeditor/osal/inc/M4OSA_Types.h
@@ -29,15 +29,13 @@
 #define M4OSA_TYPES_H
 
 #include <ctype.h>
+#include <stdio.h>
+#include <string.h>
 #include "M4OSA_Export.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/*#define M4OSA_64BITS_SUPPORTED     */  /* means long long is used        */
-/*#define M4OSA_64BITS_COUPLE_INT    */    /* means couple int32 is used    */
-#define M4OSA_64BITS_NOT_SUPPORTED      /* means Int32 is used            */
-
 
 typedef signed char     M4OSA_Bool;
 typedef unsigned char   M4OSA_UInt8;
@@ -57,35 +55,6 @@
 
 typedef void            M4OSA_Void;
 
-typedef struct
-{
-   M4OSA_Int32   high;
-   M4OSA_Int32   low;
-} M4OSA_CoupleInt32;
-
-#ifdef M4OSA_64BITS_SUPPORTED
-typedef signed long long M4OSA_Int64;
-typedef unsigned long long M4OSA_UInt64;
-#endif
-
-#ifdef M4OSA_64BITS_COUPLE_INT
-typedef struct
-{
-   M4OSA_Int32 major;
-   M4OSA_UInt32 minor;
-} M4OSA_Int64;
-typedef struct
-{
-   M4OSA_UInt32 major;
-   M4OSA_UInt32 minor;
-} M4OSA_UInt64;
-#endif
-
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
-typedef M4OSA_Int32 M4OSA_Int64;
-typedef M4OSA_UInt32 M4OSA_UInt64;
-#endif
-
 /* Min & max definitions*/
 #define M4OSA_UINT8_MIN                  0
 #define M4OSA_UINT8_MAX                255
@@ -111,22 +80,6 @@
 #define M4OSA_UCHAR_MIN                  0
 #define M4OSA_UCHAR_MAX                255
 
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
-
-#define M4OSA_UINT64_MIN        M4OSA_UINT32_MIN
-#define M4OSA_UINT64_MAX        M4OSA_UINT32_MAX
-#define M4OSA_INT64_MIN          M4OSA_INT32_MIN
-#define M4OSA_INT64_MAX          M4OSA_INT32_MAX
-
-#else /* M4OSA_64BITS_NOT_SUPPORTED*/
-
-#define M4OSA_UINT64_MIN                       0
-#define M4OSA_UINT64_MAX      0xFFFFFFFFFFFFFFFFLL
-#define M4OSA_INT64_MIN       0x8000000000000000LL
-#define M4OSA_INT64_MAX       0x7FFFFFFFFFFFFFFFLL
-
-#endif /* M4OSA_64BITS_NOT_SUPPORTED*/
-
 #define M4OSA_NULL                     0x00
 #define M4OSA_TRUE                     0x01
 #define M4OSA_FALSE                    0x00
@@ -141,235 +94,9 @@
 
 typedef void*                M4OSA_Context;
 
-
 /** It is a unique ID for each core component*/
 typedef  M4OSA_UInt16 M4OSA_CoreID;
 
-
-/* Macro to support big endian and little endian platform */
-
-/* to translate a 16 bits to its Big Endian value*/
-#define M4OSA_INT16_TO_BE(ui16_host) ((((ui16_host) & (M4OSA_UInt16) 0x00ff) << 8) | \
-                                      (((ui16_host) & (M4OSA_UInt16) 0xff00) >> 8) )
-
-/* to translate a 32 bits to its Big Endian value */
-#define M4OSA_INT32_TO_BE(ui32_host) ((((ui32_host) & (M4OSA_UInt32) 0x000000ff) << 24) | \
-                                      (((ui32_host) & (M4OSA_UInt32) 0x0000ff00) <<  8) | \
-                                      (((ui32_host) & (M4OSA_UInt32) 0x00ff0000) >>  8) | \
-                                      (((ui32_host) & (M4OSA_UInt32) 0xff000000) >>  24))
-
-/* to translate a 64 bits to its Big Endian value */
-#define M4OSA_INT64_TO_BE(ui64_host) ((((ui64_host) & (M4OSA_UInt64) 0x00000000000000ff) << 56) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x000000000000ff00) << 40) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x0000000000ff0000) << 24) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x00000000ff000000) <<  8) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x000000ff00000000) >>  8) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x0000ff0000000000) >> 24) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0x00ff000000000000) >> 40) | \
-                                      (((ui64_host) & (M4OSA_UInt64) 0xff00000000000000) >> 56))
-
-/* to translate a Big Endian 16 bits to its host representation */
-#define M4OSA_BE_TO_INT16(ui16_net) ((((ui16_net) & (M4OSA_UInt16) 0x00ff) << 8) | \
-                                     (((ui16_net) & (M4OSA_UInt16) 0xff00) >> 8) )
-
-/* to translate a Big Endian 32 bits to its host representation*/
-#define M4OSA_BE_TO_INT32(ui32_net) ((((ui32_net) & (M4OSA_UInt32) 0x000000ff) << 24) | \
-                                     (((ui32_net) & (M4OSA_UInt32) 0x0000ff00) <<  8) | \
-                                     (((ui32_net) & (M4OSA_UInt32) 0x00ff0000) >>  8) | \
-                                     (((ui32_net) & (M4OSA_UInt32) 0xff000000) >>  24))
-
-/* to translate a Big Endian 64 bits to its host representation */
-#define M4OSA_BE_TO_INT64(ui64_net) ((((ui64_net) & (M4OSA_UInt64) 0x00000000000000ff) << 56) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x000000000000ff00) << 40) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x0000000000ff0000) << 24) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x00000000ff000000) <<  8) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x000000ff00000000) >>  8) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x0000ff0000000000) >> 24) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0x00ff000000000000) >> 40) | \
-                                     (((ui64_net) & (M4OSA_UInt64) 0xff00000000000000) >> 56))
-
-/* to translate a 16 bits to its Little Endian value*/
-#define M4OSA_INT16_TO_LE(ui16_host) (ui16_host)
-
-/* to translate a 32 bits to its Little Endian value */
-#define M4OSA_INT32_TO_LE(ui32_host) (ui32_host)
-
-/* to translate a 64 bits to its Little Endian value */
-#define M4OSA_INT64_TO_LE(ui64_host) (ui64_host)
-
-/* to translate a Little Endian 16 bits to its host representation */
-#define M4OSA_LE_TO_INT16(ui16_net) (ui16_net)
-
-/* to translate a Little Endian 32 bits to its host representation*/
-#define M4OSA_LE_TO_INT32(ui32_net) (ui32_net)
-
-/* to translate a Little Endian 64 bits to its host representation */
-#define M4OSA_LE_TO_INT64(ui64_net) (ui64_net)
-
-
-/* Macro to manipulate M4OSA_Int32*/
-#define M4OSA_INT32_SET(i32_out, i32_in)\
-   { i32_out = i32_in; }
-
-#define M4OSA_INT32_ADD(i32_result, i32_a, i32_b)\
-   { i32_result = (i32_a) + (i32_b); }
-
-#define M4OSA_INT32_SUB(i32_result, i32_a, i32_b)\
-   { i32_result = (i32_a) - (i32_b); }
-
-#define M4OSA_INT32_SCALAR_PRODUCT(i32_result, i32_a, i32_value)\
-   { i32_result = (i32_a) * (i32_value); }
-
-#define M4OSA_INT32_SCALAR_DIVISION(i32_result, i32_a, i32_value)\
-   { i32_result = (i32_a) / (i32_value); }
-
-#define M4OSA_INT32_COMPARE(i32_a, i32_b)\
-   ( ((i32_a) == (i32_b)) ? 0 : ( ((i32_a) > (i32_b)) ? 1 : -1) )
-
-#define M4OSA_INT32_FROM_INT32(i32_result, i32_value)\
-   { i32_result = (M4OSA_Int32)(i32_value); }
-
-#define M4OSA_INT32_FROM_INT32_UINT32(i32_result, i32_high, ui32_low)\
-   { i32_result = (M4OSA_Int32)(ui32_low); }
-
-#define M4OSA_INT32_GET_LOW32(i32_value) ((M4OSA_Int32)(i32_value))
-
-#define M4OSA_INT32_GET_HIGH32(i32_value) (0)
-
-#define M4OSA_INT32_IS_POSITIVE(i32_value) ((i32_value) >= 0)
-
-#define M4OSA_INT32_NEG(i32_result, i32_value)\
-   { i32_result = -(i32_value); }
-
-#define M4OSA_INT32_ABS(i32_result, i32_value)\
-   { if ((i32_value) > 0) { i32_result = i32_value; }\
-     else                 { i32_result = -(i32_value); } }
-
-#define M4OSA_INT32_LEFT_SHIFT(i32_result, i32_value, ui32_nbPos)\
-   { i64_result = (((ui32_nbPos)>0x1F)?0:((i64_value)<<(ui32_nbPos))); }
-
-#define M4OSA_INT32_RIGHT_SHIFT(i32_result, i32_value, ui32_nbPos)\
-   { i64_result = (((ui32_nbPos)>0x1F)?0:((i64_value)>>(ui32_nbPos))); }
-
-#define M4OSA_INT32_TO_DOUBLE(f_result, i32_value)\
-   { f_result = (M4OSA_Double)(i32_value); }
-
-#define M4OSA_INT32_FROM_DOUBLE(i32_result, f_value)\
-   { i32_result = (M4OSA_Int32)(f_value); }
-
-
-#ifdef M4OSA_64BITS_SUPPORTED
-
-/* Macro to manipulate M4OSA_Int64*/
-#define M4OSA_INT64_SET(i64_out, i64_in) { i64_out = i64_in; }
-
-#define M4OSA_INT64_ADD(i64_result, i64_a, i64_b)\
-   { i64_result = (i64_a) + (i64_b); }
-
-#define M4OSA_INT64_SUB(i64_result, i64_a, i64_b)\
-   { i64_result = (i64_a) - (i64_b); }
-
-#define M4OSA_INT64_SCALAR_PRODUCT(i64_result, i64_a, i32_value)\
-   { i64_result = (i64_a) * (i32_value); }
-
-#define M4OSA_INT64_SCALAR_DIVISION(i64_result, i64_a, i32_value)\
-   { i64_result = (i64_a) / (i32_value); }
-
-#define M4OSA_INT64_COMPARE(i64_a, i64_b)\
-   ( ((i64_a) == (i64_b)) ? 0 : ( ((i64_a) > (i64_b)) ? 1 : -1) )\
-
-#define M4OSA_INT64_FROM_INT32(i64_result, i32_value)\
-   { i64_result = (M4OSA_Int64)(i32_value); }
-
-#define M4OSA_INT64_FROM_INT32_UINT32(i64_result, i32_high, ui32_low)\
-   { i64_result = (i32_high); i64_result = (i64_result<<32)+(ui32_low); }
-
-#define M4OSA_INT64_GET_LOW32(i64_value)\
-   ((M4OSA_Int32)((i64_value) & 0xFFFFFFFF))
-
-#define M4OSA_INT64_GET_HIGH32(i64_value)\
-   ((M4OSA_Int32)(((i64_value) >> 32) & 0xFFFFFFFF))
-
-#define M4OSA_INT64_IS_POSITIVE(i64_value) (((i64_value)>=0)?1:0)
-
-#define M4OSA_INT64_NEG(i64_result, i64_value)\
-   { i64_result = -(i64_value); }
-
-#define M4OSA_INT64_ABS(i64_result, i64_value)\
-   { if (M4OSA_INT64_IS_POSITIVE(i64_value)) { i64_result = i64_value; }\
-     else { M4OSA_INT64_NEG(i64_result, i64_value); } }
-
-#define M4OSA_INT64_LEFT_SHIFT(i64_result, i64_value, ui32_nbPos)\
-   { i64_result = (((ui32_nbPos)>0x3F)?0:((i64_value)<<(ui32_nbPos))); }
-
-#define M4OSA_INT64_RIGHT_SHIFT(i64_result, i64_value, ui32_nbPos)\
-   { i64_result = (((ui32_nbPos)>0x3F)?0:((i64_value)>>(ui32_nbPos))); }
-
-#define M4OSA_INT64_TO_DOUBLE(f_result, i64_value)\
-   { f_result = (M4OSA_Double)(i64_value); }
-
-#define M4OSA_INT64_FROM_DOUBLE(i64_result, f_value)\
-   { i64_result = (M4OSA_Int64)(f_value); }
-
-#endif   /*M4OSA_64BITS_SUPPORTED*/
-
-
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
-
-#define M4OSA_INT64_SET(i64_out, i64_in)\
-        M4OSA_INT32_SET(i64_out, i64_in)
-
-#define M4OSA_INT64_ADD(i64_result, i64_a, i64_b)\
-        M4OSA_INT32_ADD(i64_result, i64_a, i64_b)
-
-#define M4OSA_INT64_SUB(i64_result, i64_a, i64_b)\
-        M4OSA_INT32_SUB(i64_result, i64_a, i64_b)
-
-#define M4OSA_INT64_SCALAR_PRODUCT(i64_result, i64_a, i32_value)\
-        M4OSA_INT32_SCALAR_PRODUCT(i64_result, i64_a, i32_value)
-
-#define M4OSA_INT64_SCALAR_DIVISION(i64_result, i64_a, i32_value)\
-        M4OSA_INT32_SCALAR_DIVISION(i64_result, i64_a, i32_value)
-
-#define M4OSA_INT64_COMPARE(i64_a, i64_b)\
-        M4OSA_INT32_COMPARE(i64_a, i64_b)
-
-#define M4OSA_INT64_FROM_INT32(i64_result, i32_value)\
-        M4OSA_INT32_FROM_INT32(i64_result, i32_value)
-
-#define M4OSA_INT64_FROM_INT32_UINT32(i64_result, i32_high, ui32_low)\
-        M4OSA_INT32_FROM_INT32_UINT32(i64_result, i32_high, ui32_low)
-
-#define M4OSA_INT64_GET_LOW32(i64_value)\
-        M4OSA_INT32_GET_LOW32(i64_value)
-
-#define M4OSA_INT64_GET_HIGH32(i64_value)\
-        M4OSA_INT32_GET_HIGH32(i64_value)
-
-#define M4OSA_INT64_IS_POSITIVE(i64_value)\
-        M4OSA_INT32_IS_POSITIVE(i64_value)
-
-#define M4OSA_INT64_NEG(i64_result, i64_value)\
-        M4OSA_INT32_NEG(i64_result, i64_value)
-
-#define M4OSA_INT64_ABS(i64_result, i64_value)\
-        M4OSA_INT32_ABS(i64_result, i64_value)
-
-#define M4OSA_INT64_LEFT_SHIFT(i64_result, i64_value, ui32_nbPositions)\
-        M4OSA_INT32_LEFT_SHIFT(i64_result, i64_value, ui32_nbPositions)
-
-#define M4OSA_INT64_RIGHT_SHIFT(i64_result, i64_value, ui32_nbPositions)\
-        M4OSA_INT32_RIGHT_SHIFT(i64_result, i64_value, ui32_nbPositions)
-
-#define M4OSA_INT64_TO_DOUBLE(f_result, i64_value)\
-        M4OSA_INT32_TO_DOUBLE(f_result, i64_value)
-
-#define M4OSA_INT64_FROM_DOUBLE(i64_result, f_value)\
-        M4OSA_INT32_FROM_DOUBLE(i64_result, f_value)
-
-#endif /*M4OSA_64BITS_NOT_SUPPORTED*/
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/libvideoeditor/osal/src/Android.mk b/libvideoeditor/osal/src/Android.mk
index b9351c2..1b21079 100755
--- a/libvideoeditor/osal/src/Android.mk
+++ b/libvideoeditor/osal/src/Android.mk
@@ -28,18 +28,12 @@
 LOCAL_SRC_FILES:=          \

     M4OSA_CharStar.c \

     M4OSA_Clock.c \

-    M4OSA_FileCache.c \

     M4OSA_FileCommon.c \

-    M4OSA_FileExtra.c \

     M4OSA_FileReader.c \

-    M4OSA_FileReader_RAM.c \

     M4OSA_FileWriter.c \

-    M4OSA_FileWriter_RAM.c \

     M4OSA_Mutex.c \

     M4OSA_Random.c \

     M4OSA_Semaphore.c \

-    M4OSA_String.c \

-    M4OSA_String_priv.c \

     M4OSA_Thread.c \

     M4PSW_DebugTrace.c \

     M4PSW_MemoryInterface.c \

@@ -73,9 +67,5 @@
     -DUSE_STAGEFRIGHT_READERS \

     -DUSE_STAGEFRIGHT_3GPP_READER

 

-# Don't prelink this library.  For more efficient code, you may want

-# to add this library to the prelink map and set this to true.

-LOCAL_PRELINK_MODULE := false

-

 include $(BUILD_STATIC_LIBRARY)

 

diff --git a/libvideoeditor/osal/src/LVOSA_FileReader_optim.c b/libvideoeditor/osal/src/LVOSA_FileReader_optim.c
index 36541f0..dc84eab 100755
--- a/libvideoeditor/osal/src/LVOSA_FileReader_optim.c
+++ b/libvideoeditor/osal/src/LVOSA_FileReader_optim.c
@@ -167,7 +167,8 @@
 
     for(i=0; i<M4OSA_READBUFFER_NB; i++)
     {
-        apContext->buffer[i].data = (M4OSA_MemAddr8) M4OSA_malloc(M4OSA_READBUFFER_SIZE, M4OSA_FILE_READER, "M4OSA_FileReader_BufferInit");
+        apContext->buffer[i].data = (M4OSA_MemAddr8) M4OSA_32bitAlignedMalloc(M4OSA_READBUFFER_SIZE, 
+            M4OSA_FILE_READER, (M4OSA_Char *)"M4OSA_FileReader_BufferInit");
         M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, apContext->buffer[i].data);
     }
 
@@ -182,7 +183,7 @@
 
     for(i=0; i<M4OSA_READBUFFER_NB; i++)
         if(apContext->buffer[i].data != M4OSA_NULL)
-            M4OSA_free((M4OSA_MemAddr32)apContext->buffer[i].data);
+            free(apContext->buffer[i].data);
 }
 
 /**************************************************************/
@@ -207,7 +208,7 @@
     copysize = apContext->buffer[i].size - offset;
     copysize = (size < copysize) ? size : copysize;
 
-    M4OSA_memcpy(pData, apContext->buffer[i].data + offset, copysize);
+    memcpy((void *)pData, (void *)(apContext->buffer[i].data + offset), copysize);
 
     apContext->buffer[i].remain -= copysize;
     apContext->buffer[i].nbFillSinceLastAcess = 0;
@@ -449,30 +450,6 @@
         err = errno;
         M4OSA_TRACE1_1("M4OSA_FileReader_CalculateSize ERR = 0x%x", err);
     }
-#if 0
-    fileSeekPosition = 0;
-    errno = apContext->FS->seek(apContext->aFileDesc, M4OSA_kFileSeekEnd, &fileSeekPosition);
-
-    if (M4NO_ERROR != errno)
-    {
-        apContext->readFilePos = M4OSA_EOF;
-        err = errno;
-        M4OSA_TRACE1_1("M4OSA_FileReader_CalculateSize ERR1 = 0x%x", err);
-    }
-    else
-    {
-        /* Retrieve size of the file */
-        errno = apContext->FS->getOption(apContext->aFileDesc,
-                                         M4OSA_kFileReadGetFilePosition,
-                                         (M4OSA_DataOption*) &apContext->fileSize);
-        if (M4NO_ERROR != errno)
-        {
-            err = errno;
-            M4OSA_TRACE1_1("M4OSA_FileReader_CalculateSize ERR2 = 0x%x", err);
-        }
-        apContext->readFilePos = apContext->fileSize;
-    }
-#endif
 #else
     ret_val = apContext->FS->pFctPtr_Seek(apContext->aFileDesc, 0, M4OSA_kFileSeekEnd, &errno);
 
@@ -544,8 +521,8 @@
     *pContext = M4OSA_NULL;
 
     /*      Allocate memory for the File reader context. */
-    apContext = (M4OSA_FileReader_Context_optim *)M4OSA_malloc(sizeof(M4OSA_FileReader_Context_optim),
-                                      M4OSA_FILE_READER, "M4OSA_FileReader_Context_optim");
+    apContext = (M4OSA_FileReader_Context_optim *)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileReader_Context_optim),
+                                      M4OSA_FILE_READER, (M4OSA_Char *)"M4OSA_FileReader_Context_optim");
 
     M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, apContext);
 
@@ -554,11 +531,11 @@
 
     /*Set the optimized functions, to be called by the user*/
 
-    apContext->FS = (M4OSA_FileReadPointer*) M4OSA_malloc(sizeof(M4OSA_FileReadPointer),
-                                       M4OSA_FILE_READER, "NXPSW_FileReaderOptim_init");
+    apContext->FS = (M4OSA_FileReadPointer*) M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileReadPointer),
+                                       M4OSA_FILE_READER, (M4OSA_Char *)"M4OSA_FileReaderOptim_init");
     if (M4OSA_NULL==apContext->FS)
     {
-        M4OSA_TRACE1_0("NXPSW_FileReaderOptim_init - ERROR : allocation failed");
+        M4OSA_TRACE1_0("M4OSA_FileReaderOptim_init - ERROR : allocation failed");
         return M4ERR_ALLOC;
     }
     apContext->FS->openRead  = M4OSA_fileReadOpen;
@@ -567,7 +544,7 @@
     apContext->FS->closeRead = M4OSA_fileReadClose;
     apContext->FS->setOption = M4OSA_fileReadSetOption;
     apContext->FS->getOption = M4OSA_fileReadGetOption;
-   #else
+#else
     apContext->FS = FS;
 #endif
 
@@ -661,7 +638,7 @@
             M4OSA_FileReader_BufferFree(apContext);
         }
 
-        M4OSA_free((M4OSA_MemAddr32) apContext);
+        free( apContext);
         *pContext = M4OSA_NULL;
     }
 
@@ -976,12 +953,12 @@
     //>>>> GLM20090212 : set the low level function statically
     if (apContext->FS != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32) apContext->FS);
+        free( apContext->FS);
     }
     //<<<< GLM20090212 : set the low level function statically
 
     /* Free the context */
-    M4OSA_free((M4OSA_MemAddr32)apContext);
+    free(apContext);
 
     /* Return without error */
     return err;
diff --git a/libvideoeditor/osal/src/M4OSA_CharStar.c b/libvideoeditor/osal/src/M4OSA_CharStar.c
index 4a865c1..eb7e525 100755
--- a/libvideoeditor/osal/src/M4OSA_CharStar.c
+++ b/libvideoeditor/osal/src/M4OSA_CharStar.c
@@ -76,114 +76,6 @@
 
 /**
  ************************************************************************
- * @brief      This function mimics the functionality of the libc's strncat().
- * @note       It appends at most len2Append characters from pStrIn to the end
- *             of pStrOut. The initial character of pStrIn overrides the null
- *             character at the end of pStrOut. THIS LAST NULL CHARACTER IN
- *             pStrOut MUST BE PRESENT.
- *             - If a null character appears in pStrIn before len2Append
- *               characters are appended, the function appends all characters
- *               from pStrIn, up to this M4OSA_NULL character.
- *             - If len2Append is greater than the length of pStrIn, the length
- *               of pStrIn is used in place of len2Append. The resulting string
- *               is terminated with a null character.
- *             - pStrOut and pStrIn MUST NOT OVERLAP (this is NOT CHECKED).
- * @param      pStrOut: (OUT) Destination character string.
- * @param      pStrIn: (IN) character string to append.
- * @param      len2Append: (IN) Max number of characters from pStrIn to append.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pStrOut is M4OSA_NULL.
-  ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrNCat(M4OSA_Char* pStrOut, M4OSA_Char* pStrIn,
-                                                        M4OSA_UInt32 len2Append)
-{
-    M4OSA_TRACE1_3("M4OSA_chrNCat\t(M4OSA_Char* %x,M4OSA_Char* %x,M4OSA_UInt32 %ld)",
-                            pStrOut,pStrIn,len2Append);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrOut, M4ERR_PARAMETER,
-                                       "M4OSA_chrNCat:\tpStrOut is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn,M4ERR_PARAMETER,
-                                        "M4OSA_chrNCat:\tpStrIn is M4OSA_NULL");
-
-    strncat((char *)pStrOut, (const char*)pStrIn, (size_t)len2Append);
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strcmp().
- * @note       It compares pStrIn1 and pStrIn2 lexicographically.
- *             The value returned in cmpResult is greater than, equal to, or
- *             less than 0, if the string pointed to by pStrIn1 is greater than,
- *             equal to, or less than the string pointed to by pStrIn2
- *             respectively. The sign of a non-zero return value is determined
- *             by the sign of the difference between the values of the first
- *             pair of bytes that differ in the strings being compared.
- * @param      pStrIn1: (IN) First character string.
- * @param      pStrIn2: (IN) Second character string.
- * @param      cmpResult: (OUT) Comparison result.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn1 pStrIn2 or cmpResult is M4OSA_NULL.
-  ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrCompare(M4OSA_Char* pStrIn1, M4OSA_Char* pStrIn2,
-                                                        M4OSA_Int32* pCmpResult)
-{
-    M4OSA_TRACE1_3("M4OSA_chrCompare\t(M4OSA_Char* %x,M4OSA_Char* %x,M4OSA_Int32* %x)",
-                    pStrIn1,pStrIn2,pCmpResult);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn1, M4ERR_PARAMETER,
-                                     "M4OSA_chrCompare:\tstrIn1 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn2, M4ERR_PARAMETER,
-                                     "M4OSA_chrCompare:\tstrIn2 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pCmpResult, M4ERR_PARAMETER,
-                                  "M4OSA_chrCompare:\tcmpResult is M4OSA_NULL");
-
-    *pCmpResult = (M4OSA_Int32)strcmp((const char *)pStrIn1, (const char *)pStrIn2);
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
-  * @brief      This function mimics the functionality of the libc's strncmp().
- * @note       It lexicographically compares at most the first len2Comp
- *             characters in pStrIn1 and pStrIn2.
- *             The value returned in cmpResult is greater than, equal to, or
- *             less than 0, if the first len2Comp characters of the string
- *             pointed to by pStrIn1 is greater than, equal to, or less than the
- *             first len2Comp characters of the string pointed to by pStrIn2
- *             respectively. The sign of a non-zero return value is determined
- *             by the sign of the difference between the values of the first
- *             pair of bytes that differ in the strings being compared.
- * @param      pStrIn1: (IN) First character string.
- * @param      pStrIn2: (IN) Second character string.
- * @param      len2Comp: (IN) Length used for the comparison.
- * @param      cmpResult: (OUT) Comparison result.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn1 pStrIn2 or cmpResult is M4OSA_NULL.
-  ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrNCompare(M4OSA_Char* pStrIn1,M4OSA_Char* pStrIn2,
-                            M4OSA_UInt32 len2Comp, M4OSA_Int32* pCmpResult)
-{
-    M4OSA_TRACE1_4("M4OSA_chrNCompare\t(M4OSA_Char* %x,M4OSA_Char* %x,"
-        "M4OSA_Int32 %ld, M4OSA_Int32* %x)",pStrIn1,pStrIn2,len2Comp,pCmpResult);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn1,M4ERR_PARAMETER,
-                                   "M4OSA_chrNCompare:\tpStrIn1 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn2,M4ERR_PARAMETER,
-                                   "M4OSA_chrNCompare:\tpStrIn2 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pCmpResult,M4ERR_PARAMETER,
-                                "M4OSA_chrNCompare:\tpCmpResult is M4OSA_NULL");
-
-    *pCmpResult = (M4OSA_Int32)strncmp((const char*)pStrIn1, (const char*)pStrIn2,
-                                                              (size_t)len2Comp);
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
   * @brief      This function returns the boolean comparison of pStrIn1 and pStrIn2.
  * @note       The value returned in result is M4OSA_TRUE if the string
  *             pointed to by pStrIn1 is strictly identical to the string pointed
@@ -229,331 +121,6 @@
     return M4NO_ERROR;
 }
 
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strchr().
- * @note       It finds the first occurrence (i.e. starting from the beginning
- *             of the string) of c in pStrIn and set *pPointerInStr to this
- *             position.
- *             If no occurrence is found, *pPointerInStr is set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string where to search.
- * @param      c: (IN) Character to search.
- * @param      pPointerInStr: (OUT) pointer on the first occurrence of c.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pPointerInStr is M4OSA_NULL.
- * @return     M4WAR_CHR_NOT_FOUND: no occurrence of c found.
-  ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrFindChar (M4OSA_Char* pStrIn, M4OSA_Char c,
-                                                            M4OSA_Char** pInStr)
-{
-    M4OSA_TRACE1_3("M4OSA_chrFindChar\t(M4OSA_Char* %x, M4OSA_Char %c"
-        "M4OSA_Char** %x)",pStrIn,c,pInStr);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn,M4ERR_PARAMETER,
-                                    "M4OSA_chrFindChar:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pInStr,M4ERR_PARAMETER,
-                                    "M4OSA_chrFindChar:\tpInStr is M4OSA_NULL");
-
-    *pInStr = (M4OSA_Char*)strchr((const char *)pStrIn,(int)c);
-    if(M4OSA_NULL == *pInStr)
-    {
-        return M4WAR_CHR_NOT_FOUND;
-    }
-    else
-    {
-        return M4NO_ERROR;
-    }
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strrchr().
- * @note       It finds the last occurrence (i.e. starting from the end of the
- *             string, backward) of c in pStrIn and set *pPointerInStr to this
- *             position.
- *             If no occurrence is found, *pPointerInStr is set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string where to search.
- * @param      c: (IN) Character to search.
- * @param      pPointerInStr: (OUT) pointer on the first occurrence of c.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pPointerInStr is M4OSA_NULL.
- * @return     M4WAR_CHR_NOT_FOUND: no occurrence of c found.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrReverseFindChar(M4OSA_Char* pStrIn, M4OSA_Char c,M4OSA_Char** pInStr)
-{
-    M4OSA_TRACE1_3("M4OSA_chrReverseFindChar\t(M4OSA_Char* %x, M4OSA_Char %c"
-                        "M4OSA_Char** %x)",pStrIn,c,pInStr);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                             "M4OSA_chrReverseFindChar:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pInStr, M4ERR_PARAMETER,
-                             "M4OSA_chrReverseFindChar:\tpInStr is M4OSA_NULL");
-
-    *pInStr = (M4OSA_Char*)strrchr((const char *)pStrIn,(int)c);
-    if(M4OSA_NULL == *pInStr)
-    {
-        return M4WAR_CHR_NOT_FOUND;
-    }
-    else
-    {
-        return M4NO_ERROR;
-    }
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strspn().
- * @note       It returns the length of the initial segment of string pStrIn
- *             that consists entirely of characters from string pDelimiters
- *             (it "spans" this set of characters).
- *             If no occurrence of any character present in pDelimiters is found
- *             at the beginning of pStrIn, *pPosInStr is M4OSA_NULL.
- * @param      pStrIn: (IN) Character string where to search.
- * @param      pDelimiters: (IN) Character string containing the set of
- *             characters to search.
- * @param      pPosInStr: (OUT) Length of the initial segment.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn, pDelimiters or pPosInStr is M4OSA_NULL.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrSpan(M4OSA_Char* pStrIn,M4OSA_Char* pDelimiters,
-                                                        M4OSA_UInt32* pPosInStr)
-{
-    M4OSA_TRACE1_3("M4OSA_chrSpan\t(M4OSA_Char* %x,M4OSA_Char* %x"
-        "M4OSA_UInt32* %x)",pStrIn,pDelimiters,pPosInStr);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                        "M4OSA_chrSpan:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pDelimiters, M4ERR_PARAMETER,
-                                   "M4OSA_chrSpan:\tpDelimiters is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pPosInStr, M4ERR_PARAMETER,
-                                     "M4OSA_chrSpan:\tpPosInStr is M4OSA_NULL");
-
-    *pPosInStr = (M4OSA_UInt32)strspn((const char *)pStrIn,
-                                                     (const char *)pDelimiters);
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strcspn().
- * @note       It returns the length of the initial segment of string pStrIn
- *             that consists entirely of characters NOT from string delimiters
- *             (it spans the complement of this set of characters).
- *             If no occurrence of any character present in delimiters is found
- *             in pStrIn, *pPosInStr is set to the length of pStrIn.
- * @param      pStrIn: (IN) Character string where to search.
- * @param      delimiters: (IN) Character string containing the set of
- *             characters to search.
- * @param      pPosInStr: (OUT) Length of the initial segment.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn, delimiters or pPosInStr is M4OSA_NULL.
- * @return     M4WAR_CHR_NOT_FOUND: no occurrence of any character present in
- *             delimiters has been found in pStrIn.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrSpanComplement (M4OSA_Char* pStrIn, M4OSA_Char* pDelimiters,
-                                                        M4OSA_UInt32* pPosInStr)
-{
-    M4OSA_TRACE1_3("M4OSA_chrSpanComplement\t(M4OSA_Char* %x,M4OSA_Char* %x"
-        "M4OSA_UInt32* %x)",pStrIn,pDelimiters,pPosInStr);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn,M4ERR_PARAMETER,
-                              "M4OSA_chrSpanComplement:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pDelimiters,M4ERR_PARAMETER,
-                         "M4OSA_chrSpanComplement:\tpDelimiters is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pPosInStr,M4ERR_PARAMETER,
-                           "M4OSA_chrSpanComplement:\tpPosInStr is M4OSA_NULL");
-
-    *pPosInStr = (M4OSA_UInt32)strcspn((const char *)pStrIn,
-                                                     (const char *)pDelimiters);
-    if(*pPosInStr < (M4OSA_UInt32)strlen((const char *)pStrIn))
-    {
-        return M4NO_ERROR;
-    }
-    else
-    {
-        return M4WAR_CHR_NOT_FOUND;
-    }
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strpbrk().
- * @note       It returns a pointer to the first occurrence in string pStrIn
- *             of any character from string pDelimiters, or a null pointer if
- *             no character from pDelimiters exists in pStrIn. In the latter
- *             case, WAR_NO_FOUND is returned.
- * @param      pStrIn: (IN) Character string where to search.
- * @param      pDelimiters: (IN) Character string containing the set of
- *             characters to search.
- * @param      pPointerInStr: (OUT) Pointer on the first character belonging to
- *             pDelimiters.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn, pDelimiters or pPosInStr is M4OSA_NULL.
- * @return     M4WAR_CHR_NOT_FOUND: no occurrence of any character present in
- *             pDelimiters has been found in pStrIn.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrPbrk(M4OSA_Char* pStrIn, M4OSA_Char* pDelimiters,
-                                                     M4OSA_Char **pPointerInStr)
-{
-    M4OSA_TRACE1_3("M4OSA_chrPbrk\t(M4OSA_Char* %x,M4OSA_Char* %x"
-        "M4OSA_Char** %x)",pStrIn,pDelimiters,pPointerInStr);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn,M4ERR_PARAMETER,
-                              "M4OSA_chrSpanComplement:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pDelimiters,M4ERR_PARAMETER,
-                         "M4OSA_chrSpanComplement:\tpDelimiters is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pPointerInStr,M4ERR_PARAMETER,
-                       "M4OSA_chrSpanComplement:\tpPointerInStr is M4OSA_NULL");
-
-    *pPointerInStr = (M4OSA_Char*)strpbrk((const char *)pStrIn,
-                                                     (const char *)pDelimiters);
-    if(M4OSA_NULL == *pPointerInStr)
-    {
-        return M4WAR_CHR_NOT_FOUND;
-    }
-    else
-    {
-        return M4NO_ERROR;
-    }
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strstr().
- * @note       It locates the first occurrence of the string pStrIn2 (excluding
- *             the terminating null character) in string pStrIn1 and set
- *             pPointerInStr1 to the located string, or to a null pointer if the
- *             string is not found, in which case M4WAR_CHR_NOT_FOUND is
- *             returned. If pStrIn2 points to a string with zero length (that
- *             is, the string ""), the function returns pStrIn1.
- * @param      pStrIn1: (IN) Character string where to search.
- * @param      pStrIn2: (IN) Character string to search.
- * @param      pPointerInStr1: (OUT) Pointer on the first character of pStrIn2
- *             in pStrIn1.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn1, pStrIn2 or pPointerInStr1 is M4OSA_NULL.
- * @return     M4WAR_CHR_NOT_FOUND: no occurrence of pStrIn2 has been found in
- *             pStrIn1.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrFindPattern(M4OSA_Char* pStrIn1, M4OSA_Char* pStrIn2,
-                                                    M4OSA_Char** pPointerInStr1)
-{
-    M4OSA_TRACE1_3("M4OSA_chrFindPattern\t(M4OSA_Char* %x,M4OSA_Char* %x"
-        "M4OSA_Char** %x)",pStrIn1,pStrIn2,pPointerInStr1);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn1,M4ERR_PARAMETER,
-                                "M4OSA_chrFindPattern:\tpStrIn1 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn2,M4ERR_PARAMETER,
-                                "M4OSA_chrFindPattern:\tpStrIn2 is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pPointerInStr1,M4ERR_PARAMETER,
-                         "M4OSA_chrFindPattern:\tpPointerInStr1 is M4OSA_NULL");
-
-    *pPointerInStr1 = (M4OSA_Char*)strstr((const char *)pStrIn1,
-                                                         (const char *)pStrIn2);
-    if(M4OSA_NULL == *pPointerInStr1)
-    {
-        return M4WAR_CHR_NOT_FOUND;
-    }
-    else
-    {
-        return M4NO_ERROR;
-    }
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's strlen().
- * @note       It returns the number of characters in pStrIn, not including
- *             the terminating null character.
- *             This function have no return code. It does not check that pStrIn
- *             does not point to null, nor is a valid character string (i.e.
- *             null-terminated).
- * @param      pStrIn: (IN) Character string.
- * @return     number of characters in pStrIn.
- ************************************************************************
-*/
-M4OSA_UInt32 M4OSA_chrLength(M4OSA_Char* pStrIn)
-{
-    M4OSA_TRACE1_1("M4OSA_chrLength\t(M4OSA_Char* %x)",pStrIn);
-    return (M4OSA_UInt32)strlen((const char *)pStrIn);
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's tolower().
- * @note       It converts the character to lower case, if possible and
- *             appropriate, and returns it.
- * @param      cIn: (IN) Input character to convert.
- * @return     converted character.
- ************************************************************************
-*/
-M4OSA_Char M4OSA_chrToLower (M4OSA_Char cIn)
-{
-    M4OSA_TRACE1_1("M4OSA_chrToLower\t(M4OSA_Char %c)",cIn);
-    return (M4OSA_Char)tolower((int)cIn);
-}
-
-/**
- ************************************************************************
- * @brief      This function mimics the functionality of the libc's toupper().
- * @note       It converts the character to upper case, if possible and
- *             appropriate, and returns it.
- * @param      cIn: (IN) Input character to convert.
- * @return     converted character.
- ************************************************************************
-*/
-M4OSA_Char M4OSA_chrToUpper(M4OSA_Char cIn)
-{
-    M4OSA_TRACE1_1("M4OSA_chrToUpper\t(M4OSA_Char %c)",cIn);
-    return (M4OSA_Char)toupper((int)cIn);
-}
-
-
-M4OSA_ERR M4OSA_chrGetWord(M4OSA_Char*    pStrIn,
-                           M4OSA_Char*    pBeginDelimiters,
-                           M4OSA_Char*    pEndDelimiters,
-                           M4OSA_Char*    pStrOut,
-                           M4OSA_UInt32*pStrOutMaxLen,
-                           M4OSA_Char** pOutputPointer)
-{
-    M4OSA_Char   *pTemp;
-    M4OSA_UInt32  pos;
-    M4OSA_ERR     errorCode;
-
-    M4OSA_TRACE1_4("M4OSA_chrGetWord\t(M4OSA_Char* %x,...,...,M4OSA_Char* %x,"
-        "M4OSA_UInt32* %x,M4OSA_Char** %x)",
-                                   pStrIn,pStrOut,pStrOutMaxLen,pOutputPointer);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                     "M4OSA_chrGetWord:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pBeginDelimiters, M4ERR_PARAMETER,
-                            "M4OSA_chrGetWord:\tbeginDelimiters is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pEndDelimiters, M4ERR_PARAMETER,
-                              "M4OSA_chrGetWord:\tendDelimiters is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrOut, M4ERR_PARAMETER,
-                                    "M4OSA_chrGetWord:\tpStrOut is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrOutMaxLen, M4ERR_PARAMETER,
-                               "M4OSA_chrGetWord:\tstrOutMaxLen is M4OSA_NULL");
-
-    errorCode = M4OSA_chrSpan(pStrIn, pBeginDelimiters, &pos);
-    pTemp     = pStrIn + pos;
-    errorCode = M4OSA_chrSpanComplement(pTemp, pEndDelimiters, &pos);
-    if(pos > *pStrOutMaxLen)
-    {
-        *pStrOutMaxLen = pos;
-        return M4ERR_CHR_STR_OVERFLOW;
-    }
-    if(pos)
-    {
-        M4OSA_memcpy((M4OSA_MemAddr8)pStrOut,(M4OSA_MemAddr8)pTemp, pos);
-    }
-    pStrOut[pos]   = '\0';
-    if(M4OSA_NULL != pOutputPointer)
-    {
-        *pOutputPointer = pTemp + pos;
-    }
-    return M4NO_ERROR;
-}
 
 /**
  ************************************************************************
@@ -737,639 +304,6 @@
     return M4NO_ERROR;
 }
 
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_UInt8 from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_UInt8 value pVal, assuming a
- *             representation in base provided by the parameter base. pStrOut is
- *             set to the first character of the string following the last
- *             character of the number that has been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of negative number, pStrOut is not updated, and pVal is
- *               set to null.
- *             - in case of numerical overflow, pVal is set to M4OSA_UINT8_MAX.
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             greater than M4OSA_UINT8_MAX.
- * @return     M4WAR_CHR_NEGATIVE: the character string represents a negative
- *             number.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetUInt8(M4OSA_Char*        pStrIn,
-                            M4OSA_UInt8*    pVal,
-                            M4OSA_Char**    pStrOut,
-                            M4OSA_chrNumBase base)
-{
-    M4OSA_UInt32 ul;
-    char*        pTemp;
-
-    M4OSA_TRACE1_4("M4OSA_chrGetUInt8\t(M4OSA_Char* %x, M4OSA_UInt8* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                    "M4OSA_chrGetUInt8:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                      "M4OSA_chrGetUInt8:\tpVal is M4OSA_NULL");
-
-    switch(base)
-    {
-    case M4OSA_kchrDec:
-        ul = strtoul((const char *)pStrIn, &pTemp, 10);
-        break;
-    case M4OSA_kchrHexa:
-        ul = strtoul((const char *)pStrIn, &pTemp, 16);
-        break;
-    case M4OSA_kchrOct:
-        ul = strtoul((const char *)pStrIn, &pTemp, 8);
-        break;
-    default:
-        return M4ERR_PARAMETER;
-    }
-
-    /* has conversion failed ? */
-    if((M4OSA_Char*)pTemp == pStrIn)
-    {
-        *pVal = 0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* was the number negative ? */
-    if(*(pStrIn+strspn((const char *)pStrIn," \t")) == '-')
-    {
-        *pVal = 0;
-        return M4WAR_CHR_NEGATIVE;
-    }
-
-    /* has an overflow occured ? */
-    if(ul>M4OSA_UINT8_MAX)
-    {
-        *pVal = M4OSA_UINT8_MAX;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    *pVal = (M4OSA_UInt8)ul;
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = (M4OSA_Char*)pTemp;
-    }
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Int64 from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_Int64 value pVal, assuming a
- *             decimal representation. pStrOut is set to the first character of
- *             the string following the last character of the number that has
- *             been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of numerical overflow or underflow, pVal is set to
- *               M4OSA_INT64_MAX or M4OSA_INT64_MIN respectively.
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- *             FOR THE MOMENT, ONLY DECIMAL REPRESENTATION IS HANDLED.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             greater than M4OSA_INT64_MAX or less than M4OSA_INT64_MIN
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetInt64(M4OSA_Char* pStrIn, M4OSA_Int64* pVal,
-                            M4OSA_Char** pStrOut, M4OSA_chrNumBase base)
-{
-#ifdef M4OSA_64BITS_SUPPORTED
-    M4OSA_Int64     maxVal   =  M4OSA_INT64_MAX; /* this is 2^63-1 */
-    M4OSA_Int64     minVal   =  M4OSA_INT64_MIN; /* this is -2^63+1 */
-    M4OSA_Char   maxStr[] =  "9223372036854775807";
-    M4OSA_Char*  beginNum;
-    M4OSA_UInt32 maxLen   = strlen((const char *)maxStr);
-    M4OSA_UInt32 chrCount = 0;
-    M4OSA_UInt8  negative = 0;
-
-    M4OSA_TRACE1_4((M4OSA_Char *)"M4OSA_chrGetInt64\t(M4OSA_Char* %x, M4OSA_UInt64* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                    "M4OSA_chrGetInt64:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                      "M4OSA_chrGetInt64:\tpVal is M4OSA_NULL");
-
-    switch(base)
-    {
-    case M4OSA_kchrDec:
-        break;
-    case M4OSA_kchrOct:
-        return M4ERR_NOT_IMPLEMENTED;
-    case M4OSA_kchrHexa:
-        return M4ERR_NOT_IMPLEMENTED;
-    default:
-        return M4ERR_PARAMETER;
-    }
-
-    /* trim blank characters */
-    while (*pStrIn == ' ' || *pStrIn == '\t') pStrIn++;
-
-    /* get the sign */
-    if (*pStrIn == '+') pStrIn++;
-    else if (*pStrIn == '-')
-    {
-        negative = 1;
-        pStrIn++;
-    }
-    beginNum = pStrIn;
-
-    /* get the length of the numerical part */
-    while((*pStrIn >= '0') && (*pStrIn <= '9'))
-    {
-        pStrIn++;
-        chrCount++;
-    }
-
-    /* has conversion failed ? */
-    if(!chrCount)
-    {
-        *pVal = 0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* has overflow (or underflow) occured ? */
-    if((chrCount > maxLen) /* obvious overflow (or underflow) */
-        ||
-        ((chrCount == maxLen) && (strncmp((const char *)beginNum,
-                                           (const char *)maxStr, maxLen) > 0)))
-        /* less obvious overflow (or underflow) */
-    {
-        if(negative)
-        {
-            *pVal = minVal;
-        }
-        else
-        {
-            *pVal = maxVal;
-        }
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = beginNum+chrCount;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    pStrIn = beginNum;
-    *pVal  = 0;
-    while((*pStrIn >= '0') && (*pStrIn <= '9'))
-    {
-        *pVal = (*pVal)*10 + (*pStrIn++ - '0');
-    }
-    if(negative)
-    {
-        *pVal = -*pVal;
-    }
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = pStrIn;
-    }
-    return M4NO_ERROR;
-#elif defined M4OSA_64BITS_NOT_SUPPORTED
-    return(M4OSA_chrGetInt32(pStrIn, (M4OSA_Int32*) pVal, pStrOut, M4OSA_kchrDec));
-#else
-    return(M4ERR_NOT_IMPLEMENTED);
-#endif
-
-                                   }
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Int32 from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_Int32 value pVal, assuming a
- *             representation in base provided by the parameter base. pStrOut is
- *             set to the first character of the string following the last
- *             character of the number that has been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of numerical overflow or underflow, pVal is set to
- *               M4OSA_INT32_MAX or M4OSA_INT32_MIN respectively.
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             greater than M4OSA_INT32_MAX or less than M4OSA_INT32_MIN
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetInt32(M4OSA_Char*        pStrIn,
-                            M4OSA_Int32*    pVal,
-                            M4OSA_Char**    pStrOut,
-                            M4OSA_chrNumBase base)
-{
-    M4OSA_Int32 l;
-    char*       pTemp;
-
-    M4OSA_TRACE1_4("M4OSA_chrGetInt32\t(M4OSA_Char* %x, M4OSA_Int32* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn,M4ERR_PARAMETER,
-                                    "M4OSA_chrGetInt32:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal,M4ERR_PARAMETER,
-                                      "M4OSA_chrGetInt32:\tpVal is M4OSA_NULL");
-
-    errno = 0;
-    switch(base)
-    {
-    case M4OSA_kchrDec:
-        l = strtol((const char *)pStrIn, &pTemp, 10);
-        break;
-    case M4OSA_kchrHexa:
-        l = strtol((const char *)pStrIn, &pTemp, 16);
-        break;
-    case M4OSA_kchrOct:
-        l = strtol((const char *)pStrIn, &pTemp, 8);
-        break;
-    default:
-        return M4ERR_PARAMETER;
-    }
-
-    /* has conversion failed ? */
-    if((M4OSA_Char*)pTemp == pStrIn)
-    {
-        *pVal = 0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* has an overflow occured ? */
-    if((errno == ERANGE) && (l == M4OSA_INT32_MAX))
-    {
-        *pVal = M4OSA_INT32_MAX;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* has an underflow occured ? */
-    if((errno == ERANGE) && (l ==  M4OSA_INT32_MIN))
-    {
-        *pVal = M4OSA_INT32_MIN;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    *pVal = (M4OSA_Int32)l;
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = (M4OSA_Char*)pTemp;
-    }
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Int16 from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_Int16 value pVal, assuming a
- *             representation in base provided by the parameter base. pStrOut is
- *             set to the first character of the string following the last
- *             character of the number that has been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of numerical overflow or underflow, pVal is set to
- *               M4OSA_INT16_MAX or M4OSA_INT16_MIN respectively.
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             greater than M4OSA_INT16_MAX or less than M4OSA_INT16_MIN
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetInt16(M4OSA_Char*        pStrIn,
-                            M4OSA_Int16*    pVal,
-                            M4OSA_Char**    pStrOut,
-                            M4OSA_chrNumBase base)
-{
-    M4OSA_Int32 l;
-    char*       pTemp;
-
-    M4OSA_TRACE1_4("M4OSA_chrGetInt16\t(M4OSA_Char* %x, M4OSA_Int16* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                    "M4OSA_chrGetInt16:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                      "M4OSA_chrGetInt16:\tpVal is M4OSA_NULL");
-
-    switch(base)
-    {
-    case M4OSA_kchrDec:
-        l = strtol((const char *)pStrIn, &pTemp, 10);
-        break;
-    case M4OSA_kchrHexa:
-        l = strtol((const char *)pStrIn, &pTemp, 16);
-        break;
-    case M4OSA_kchrOct:
-        l = strtol((const char *)pStrIn, &pTemp, 8);
-        break;
-    default:
-        return M4ERR_PARAMETER;
-    }
-
-    /* has conversion failed ? */
-    if((M4OSA_Char*)pTemp == pStrIn)
-    {
-        *pVal = 0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* has an overflow occured ? */
-    if(l>M4OSA_INT16_MAX)
-    {
-        *pVal = M4OSA_INT16_MAX;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* has an underflow occured ? */
-    if(l<M4OSA_INT16_MIN)
-    {
-        *pVal = M4OSA_INT16_MIN;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    *pVal = (M4OSA_UInt16)l;
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = (M4OSA_Char*)pTemp;
-    }
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Int8 from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_Int8 value pVal, assuming a
- *             representation in base provided by the parameter base. pStrOut is
- *             set to the first character of the string following the last
- *             character of the number that has been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of numerical overflow or underflow, pVal is set to
- *               M4OSA_INT8_MAX or M4OSA_INT8_MIN respectively.
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             greater than M4OSA_INT8_MAX or less than M4OSA_INT8_MIN
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetInt8(M4OSA_Char*    pStrIn,
-                           M4OSA_Int8*    pVal,
-                           M4OSA_Char**    pStrOut,
-                           M4OSA_chrNumBase base)
-{
-    M4OSA_Int32 l;
-    char*       pTemp;
-
-    M4OSA_TRACE1_4("M4OSA_chrGetInt8\t(M4OSA_Char* %x, M4OSA_Int8* %x"
-                   "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,
-                                                                          base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                     "M4OSA_chrGetInt8:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                       "M4OSA_chrGetInt8:\tpVal is M4OSA_NULL");
-
-    switch(base)
-    {
-    case M4OSA_kchrDec:
-        l = strtol((const char *)pStrIn, &pTemp, 10);
-        break;
-    case M4OSA_kchrHexa:
-        l = strtol((const char *)pStrIn, &pTemp, 16);
-        break;
-    case M4OSA_kchrOct:
-        l = strtol((const char *)pStrIn, &pTemp, 8);
-        break;
-    default:
-        return M4ERR_PARAMETER;
-    }
-
-    /* has conversion failed ? */
-    if((M4OSA_Char*)pTemp == pStrIn)
-    {
-        *pVal = 0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* has an overflow occured ? */
-    if(l>M4OSA_INT8_MAX)
-    {
-        *pVal = M4OSA_INT8_MAX;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* has an underflow occured ? */
-    if(l<M4OSA_INT8_MIN)
-    {
-        *pVal = M4OSA_INT8_MIN;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    *pVal = (M4OSA_UInt8)l;
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = (M4OSA_Char*)pTemp;
-    }
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Double from string.
- * @note       This function converts the first set of non-whitespace
- *             characters of pStrIn to a M4OSA_Double value pVal. pStrOut is set
- *             to the first character of the string following the last
- *             character of the number that has been converted.
- *             - in case of a failure during the conversion, pStrOut is not
- *               updated, and pVal is set to null.
- *             - in case of numerical overflow or underflow, pVal is set to null
- *             - if pStrOut is not to be used, it can be set to M4OSA_NULL.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: an underflow or overflow occurs during the
- *             conversion.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetDouble(M4OSA_Char*    pStrIn,
-                             M4OSA_Double*    pVal,
-                             M4OSA_Char**    pStrOut)
-{
-    M4OSA_Double d;
-    char*        pTemp;
-
-    M4OSA_TRACE1_3("M4OSA_chrGetDouble\t(M4OSA_Char* %x, M4OSA_Double* %x"
-        "M4OSA_Char** %x)",pStrIn,pVal,pStrOut);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                   "M4OSA_chrGetDouble:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                     "M4OSA_chrGetDouble:\tpVal is M4OSA_NULL");
-
-    errno = 0;
-    d = strtod((const char *)pStrIn, &pTemp);
-
-    /* has conversion failed ? */
-    if((M4OSA_Char*)pTemp == pStrIn)
-    {
-        *pVal = 0.0;
-        return M4ERR_CHR_CONV_FAILED;
-    }
-
-    /* has an overflow or underflow occured ? */
-    if(errno == ERANGE)
-    {
-        *pVal = 0.0;
-        if(M4OSA_NULL != pStrOut)
-        {
-            *pStrOut = (M4OSA_Char*)pTemp;
-        }
-        return M4WAR_CHR_NUM_RANGE;
-    }
-
-    /* nominal case */
-    *pVal = (M4OSA_Double)d;
-    if(M4OSA_NULL != pStrOut)
-    {
-        *pStrOut = (M4OSA_Char*)pTemp;
-    }
-
-    return M4NO_ERROR;
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_Time from string.
- * @note       Since, M4OSA_Time is defined as M4OSA_Int64, it calls
- *             M4OSA_chrGetInt64().
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             out of range.
- ************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetTime(M4OSA_Char*    pStrIn,
-                           M4OSA_Time*    pVal,
-                           M4OSA_Char**    pStrOut,
-                           M4OSA_chrNumBase base)
-{
-    M4OSA_TRACE1_4("M4OSA_chrGetTime\t(M4OSA_Char* %x, M4OSA_Time* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                                     "M4OSA_chrGetTime:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                                       "M4OSA_chrGetTime:\tpVal is M4OSA_NULL");
-
-    return M4OSA_chrGetInt64(pStrIn,(M4OSA_Int64*)pVal,pStrOut,base);
-}
-
-/**
- ************************************************************************
- * @brief      This function gets a M4OSA_FilePosition from string.
- * @note       Depending on the M4OSA_FilePosition definition, this function
- *             calls the correspoding underlying type.
- * @param      pStrIn: (IN) Character string.
- * @param      pVal: (OUT) read value.
- * @param      pStrOut: (OUT) Output character string.
- * @param      base: (IN) Base of the character string representation.
- * @return     M4NO_ERROR: there is no error.
- * @return     M4ERR_PARAMETER: pStrIn or pVal is M4OSA_NULL.
- * @return     M4ERR_CHR_CONV_FAILED: conversion failure.
- * @return     M4WAR_CHR_NUM_RANGE: the character string represents a number
- *             out of range.
- ******************************************************************************
-*/
-M4OSA_ERR M4OSA_chrGetFilePosition(M4OSA_Char*            pStrIn,
-                                   M4OSA_FilePosition*    pVal,
-                                   M4OSA_Char**            pStrOut,
-                                   M4OSA_chrNumBase        base)
-{
-    M4OSA_TRACE1_4("M4OSA_chrGetFilePosition\t(M4OSA_Char* %x, M4OSA_FilePosition* %x"
-        "M4OSA_Char** %x,M4OSA_chrNumBase %d)",pStrIn,pVal,pStrOut,base);
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pStrIn, M4ERR_PARAMETER,
-                             "M4OSA_chrGetFilePosition:\tpStrIn is M4OSA_NULL");
-    M4OSA_DEBUG_IF2(M4OSA_NULL == pVal, M4ERR_PARAMETER,
-                               "M4OSA_chrGetFilePosition:\tpVal is M4OSA_NULL");
-
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
-    return M4OSA_chrGetInt64(pStrIn,(M4OSA_Int64*)pVal,pStrOut,base);
-#else
-    return M4OSA_chrGetInt32(pStrIn,(M4OSA_Int32*)pVal,pStrOut,base);
-#endif
-
-}
-
 M4OSA_ERR M4OSA_chrSPrintf(M4OSA_Char  *pStrOut, M4OSA_UInt32 strOutMaxLen,
                            M4OSA_Char   *format, ...)
 {
@@ -1467,19 +401,9 @@
 
     newFormatLength = strlen((const char *)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_malloc(newFormatLength,
+    newFormat =(M4OSA_Char*)M4OSA_32bitAlignedMalloc(newFormatLength,
         M4OSA_CHARSTAR,(M4OSA_Char*)"M4OSA_chrPrintf: newFormat");
     if(M4OSA_NULL == newFormat)
         return M4ERR_ALLOC;
@@ -1532,36 +456,17 @@
         {
             if(!strncmp((const char *)format, "ll", 2))
             {
-#ifdef M4OSA_64BITS_SUPPORTED
-                *pTemp++ = 'l'; /* %ll */
-                *pTemp++ = 'l';
-#else
                 *pTemp++ = 'l'; /* %l */
-#endif
                 format +=2;                         /* span the "ll" prefix */
             }
             else if(!strncmp((const char *)format, "tm", 2))
             {
-#ifdef M4OSA_64BITS_SUPPORTED
-                *pTemp++ = 'l'; /* %ll */
-                *pTemp++ = 'l';
-#else
                 *pTemp++ = 'l'; /* %l */
-#endif
                 format +=2;                         /* span the "tm" prefix */
             }
             else if(!strncmp((const char *)format, "aa", 2))
             {
-#ifdef M4OSA_64BITS_SUPPORTED
-#ifdef M4OSA_FILE_POS_64_BITS_SUPPORTED
-                *pTemp++ = 'l'; /* %ll */
                 *pTemp++ = 'l';
-#else
-                *pTemp++ = 'l';
-#endif
-#else
-                *pTemp++ = 'l';
-#endif
                 format +=2;                         /* span the "aa" prefix */
             }
         }
@@ -1588,7 +493,7 @@
 
     err = vsnprintf((char *)pStrOut, (size_t)strOutMaxLen + 1, (const char *)newFormat, marker);
     va_end(marker);
-    M4OSA_free((M4OSA_MemAddr32)newFormat);
+    free(newFormat);
     if ((err<0) || ((M4OSA_UInt32)err>strOutMaxLen))
     {
         pStrOut[strOutMaxLen] = '\0';
diff --git a/libvideoeditor/osal/src/M4OSA_Clock.c b/libvideoeditor/osal/src/M4OSA_Clock.c
index 9148fe6..85fe303 100755
--- a/libvideoeditor/osal/src/M4OSA_Clock.c
+++ b/libvideoeditor/osal/src/M4OSA_Clock.c
@@ -58,17 +58,10 @@
 {
     struct timeval tv;
     struct timezone tz;
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
     M4OSA_UInt32 u32_time = 0;
     M4OSA_UInt32 u32_time_hi;
     M4OSA_UInt32 u32_time_lo;
     M4OSA_UInt32 u32_time_lh;
-#else /* M4OSA_64BITS_SUPPORTED */
-    M4OSA_Int64 i64_time = 0;
-    M4OSA_Int64 i64_time_hi;
-    M4OSA_Int64 i64_time_lo;
-    M4OSA_Int64 i64_temp;
-#endif /* M4OSA_64BITS_SUPPORTED */
     M4OSA_UInt32 factor;
 
     M4OSA_TRACE1_2("M4OSA_clockGetTime\t\tM4OSA_Time* 0x%x\tM4OSA_UInt32 %d",
@@ -83,7 +76,6 @@
 
     if(gettimeofday(&tv, &tz) == 0)
     {
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
         u32_time_lo = (tv.tv_sec & 0xFFFF) * timescale;
         u32_time_hi = (((tv.tv_sec >> 16) & 0xFFFF) * timescale) + ((u32_time_lo >> 16) & 0xFFFF);
         u32_time_lo &= 0xFFFF;
@@ -91,16 +83,8 @@
         u32_time_hi += ((u32_time_lo >> 16) & 0xFFFF);
         u32_time_lo &= 0xFFFF;
         u32_time = ((u32_time_hi & 0x7FFF) << 16) | u32_time_lo;
-#else /* M4OSA_64BITS_SUPPORTED */
-        tv.tv_usec /= factor;
-        M4OSA_INT64_FROM_INT32_UINT32(i64_time_hi, 0, tv.tv_sec);
-        M4OSA_INT64_FROM_INT32_UINT32(i64_time_lo, 0, tv.tv_usec);
-        M4OSA_INT64_SCALAR_PRODUCT(i64_temp, i64_time_hi, timescale);
-        M4OSA_INT64_ADD(i64_time, i64_temp, i64_time_lo);
-#endif /* M4OSA_64BITS_SUPPORTED */
     }
 
-#ifdef M4OSA_64BITS_NOT_SUPPORTED
     /* M4OSA_Time is signed, so we need to check the max value*/
     if (u32_time > M4OSA_INT32_MAX)
     {
@@ -113,14 +97,6 @@
     {
         return M4WAR_TIMESCALE_TOO_BIG;
     }
-#else /* M4OSA_64BITS_SUPPORTED */
-    *pTime = (M4OSA_Time)i64_time;
-
-    if( timescale > 1000000 )
-    {
-        return M4WAR_TIMESCALE_TOO_BIG;
-    }
-#endif /* M4OSA_64BITS_SUPPORTED */
 
     return M4NO_ERROR;
 }
diff --git a/libvideoeditor/osal/src/M4OSA_FileCache.c b/libvideoeditor/osal/src/M4OSA_FileCache.c
deleted file mode 100755
index a804123..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_malloc(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;
-    M4OSA_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_malloc(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;
-    M4OSA_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(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_malloc(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)
-        {
-            M4OSA_free((M4OSA_MemAddr32)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_malloc(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_malloc(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_malloc(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*/
-            {
-                M4OSA_free((M4OSA_MemAddr32)apContext->FS);
-            }
-
-            M4OSA_free((M4OSA_MemAddr32)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)
-        {
-            M4OSA_free((M4OSA_MemAddr32)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 */
-    M4OSA_free((M4OSA_MemAddr32)apContext->FS);
-    M4OSA_free((M4OSA_MemAddr32)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);
-
-    M4OSA_free((M4OSA_MemAddr32)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_FileCommon.c b/libvideoeditor/osal/src/M4OSA_FileCommon.c
index 52fe781..5927661 100755
--- a/libvideoeditor/osal/src/M4OSA_FileCommon.c
+++ b/libvideoeditor/osal/src/M4OSA_FileCommon.c
@@ -25,7 +25,7 @@
 
 #ifndef USE_STAGEFRIGHT_CODECS
 #error "USE_STAGEFRIGHT_CODECS is not defined"
-#endif USE_STAGEFRIGHT_CODECS
+#endif /*USE_STAGEFRIGHT_CODECS*/
 
 #ifdef UTF_CONVERSION
 #include <string.h>
@@ -45,7 +45,6 @@
 #include "M4OSA_Memory.h"
 #include "M4OSA_CharStar.h"
 
-//#define FILE_LOWER_CASE //defined to support limitaion of lower case file system in sdcard.
 /**
  ************************************************************************
  * @brief      This function opens the provided URL and returns its context.
@@ -86,9 +85,6 @@
     FILE* pFileHandler = M4OSA_NULL;
     M4OSA_FileContext *pFileContext    = M4OSA_NULL;
 
-#ifdef FILE_LOWER_CASE
-    M4OSA_Char *tmpLowerCaseUrl = M4OSA_NULL;
-#endif
 
 #ifdef UTF_CONVERSION
     /*FB: to test the UTF16->UTF8 conversion into Video Artist*/
@@ -96,7 +92,7 @@
     M4OSA_Void* tempConversionBuf;
     M4OSA_UInt32 tempConversionSize = 1000;
 
-    tempConversionBuf = (M4OSA_Char*)M4OSA_malloc(tempConversionSize +1, 0, "conversion buf");
+    tempConversionBuf = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(tempConversionSize +1, 0, "conversion buf");
     if(tempConversionBuf == M4OSA_NULL)
     {
         M4OSA_TRACE1_0("Error when allocating conversion buffer\n");
@@ -108,7 +104,6 @@
     printf("file open %s\n", tempConversionBuf);
 #endif /*UTF CONVERSION*/
 
-///*tmpLSA*/M4OSA_TRACE1_2("### M4OSA_fileCommonOpen %s 0x%X", pUrl, fileModeAccess);
     M4OSA_TRACE3_4("M4OSA_fileCommonOpen\t\tM4OSA_UInt16 %d\tM4OSA_Context* 0x%x\t"
         "M4OSA_Char* %s\tfileModeAccess %d", core_id, pContext, pUrl, fileModeAccess);
 
@@ -139,46 +134,37 @@
     M4OSA_DEBUG_IF1((M4OSA_FILE_WRITER == core_id) && !(fileModeAccess & M4OSA_kFileWrite),
         M4ERR_FILE_BAD_MODE_ACCESS, "M4OSA_fileCommonOpen: M4OSA_kFileWrite");
 
-#ifdef FILE_LOWER_CASE
-    tmpLowerCaseUrl = (M4OSA_Char*)M4OSA_malloc(strlen(pUrl) +1, 0, "conversion buf");
-    for(i=0; i<strlen(pUrl); i++)
-    {
-        tmpLowerCaseUrl[i] = M4OSA_chrToLower(pUrl[i]);
-    }
-    tmpLowerCaseUrl[i] = '\0'; //null terminate
-#endif
-
     /* Create flag necessary for opening file */
     if ((fileModeAccess & M4OSA_kFileRead) &&
         (fileModeAccess & M4OSA_kFileWrite)&&(fileModeAccess & M4OSA_kFileCreate))
     {
-        M4OSA_chrNCat(mode, pWriteString, 1);
-        M4OSA_chrNCat(mode, pPlusString, 1);
+        strncat((char *)mode, (const char *)pWriteString, (size_t)1);
+        strncat((char *)mode, (const char *)pPlusString, (size_t)1);
     }
     else
     {
         if(fileModeAccess & M4OSA_kFileAppend)
         {
-            M4OSA_chrNCat(mode, pAppendString, 1);
+            strncat((char *)mode, (const char *)pAppendString, (size_t)1);
         }
         else if(fileModeAccess & M4OSA_kFileRead)
         {
-            M4OSA_chrNCat(mode, pReadString, 1);
+            strncat((char *)mode, (const char *)pReadString, (size_t)1);
         }
         else if(fileModeAccess & M4OSA_kFileWrite)
         {
-            M4OSA_chrNCat(mode, pWriteString, 1);
+            strncat((char *)mode, (const char *)pWriteString, (size_t)1);
         }
 
         if((fileModeAccess & M4OSA_kFileRead)&&(fileModeAccess & M4OSA_kFileWrite))
         {
-            M4OSA_chrNCat(mode,pPlusString, 1);
+            strncat((char *)mode,(const char *)pPlusString, (size_t)1);
         }
     }
 
     if(!(fileModeAccess & M4OSA_kFileIsTextMode))
     {
-        M4OSA_chrNCat(mode, pBinaryString, 1);
+        strncat((char *)mode, (const char *)pBinaryString,(size_t)1);
     }
 
     /*Open the file*/
@@ -187,14 +173,9 @@
     /*Open the converted path*/
     pFileHandler = fopen((const char *)tempConversionBuf, (const char *)mode);
     /*Free the temporary decoded buffer*/
-    M4OSA_free((M4OSA_MemAddr32)tempConversionBuf);
+    free(tempConversionBuf);
 #else /* UTF_CONVERSION */
-#ifdef FILE_LOWER_CASE
-    pFileHandler = fopen((const char *)tmpLowerCaseUrl, (const char *)mode);
-    M4OSA_free((M4OSA_MemAddr32)tmpLowerCaseUrl);
-#else
     pFileHandler = fopen((const char *)pUrl, (const char *)mode);
-#endif
 #endif /* UTF_CONVERSION */
 
     if (M4OSA_NULL == pFileHandler)
@@ -233,7 +214,7 @@
     }
 
     /* Allocate the file context */
-    pFileContext = (M4OSA_FileContext*) M4OSA_malloc(sizeof(M4OSA_FileContext),
+    pFileContext = (M4OSA_FileContext*) M4OSA_32bitAlignedMalloc(sizeof(M4OSA_FileContext),
                     core_id, (M4OSA_Char*)"M4OSA_fileCommonOpen: file context");
     if (M4OSA_NULL == pFileContext)
     {
@@ -268,28 +249,28 @@
         pFileContext->m_DescrModeAccess = M4OSA_kDescWriteAccess;
     }
 
-    M4OSA_INT_TO_FILE_POSITION(0, pFileContext->read_position);
-    M4OSA_INT_TO_FILE_POSITION(0, pFileContext->write_position);
+    pFileContext->read_position = 0;
+    pFileContext->write_position = 0;
 
     /* Allocate the memory to store the URL string */
-    pFileContext->url_name = (M4OSA_Char*) M4OSA_malloc(M4OSA_chrLength(pUrl)+1,
+    pFileContext->url_name = (M4OSA_Char*) M4OSA_32bitAlignedMalloc(strlen((const char *)pUrl)+1,
                         core_id, (M4OSA_Char*)"M4OSA_fileCommonOpen: URL name");
     if (M4OSA_NULL == pFileContext->url_name)
     {
         fclose(pFileHandler);
-        M4OSA_free((M4OSA_MemAddr32)pFileContext);
+        free(pFileContext);
         M4OSA_DEBUG(M4ERR_ALLOC, "M4OSA_fileCommonOpen");
         return M4ERR_ALLOC;
     }
-    M4OSA_chrNCopy(pFileContext->url_name, pUrl, M4OSA_chrLength(pUrl)+1);
+    M4OSA_chrNCopy(pFileContext->url_name, pUrl, strlen((const char *)pUrl)+1);
 
     /* Get the file name */
     err = M4OSA_fileCommonGetFilename(pUrl, &pFileContext->file_name);
     if(M4NO_ERROR != err)
     {
         fclose(pFileHandler);
-        M4OSA_free((M4OSA_MemAddr32)pFileContext->url_name);
-        M4OSA_free((M4OSA_MemAddr32)pFileContext);
+        free(pFileContext->url_name);
+        free(pFileContext);
         M4OSA_DEBUG(err, "M4OSA_fileCommonOpen");
         return err;
     }
@@ -326,7 +307,6 @@
     pFileContext->file_size = iSize;
 
     *pContext = pFileContext;
-//    /*tmpLSA*/M4OSA_TRACE1_1("### M4OSA_fileCommonOpen pFileContext 0x%X", pFileContext);
 
     return M4NO_ERROR;
 }
@@ -399,8 +379,8 @@
     M4OSA_FileContext* pFileContext = pContext;
     M4OSA_FilePosition fpos_current;
     M4OSA_FilePosition fpos_seek;
-    M4OSA_FilePosition fpos_null;
-    M4OSA_FilePosition fpos_neg_un;
+    M4OSA_FilePosition fpos_null = 0;
+    M4OSA_FilePosition fpos_neg_un = -1;
     M4OSA_FilePosition fpos_file_size;
     M4OSA_FilePosition fpos_seek_from_beginning;
 
@@ -411,39 +391,36 @@
     M4OSA_DEBUG_IF2(0 == seekMode, M4ERR_PARAMETER, "M4OSA_fileCommonSeek");
     M4OSA_DEBUG_IF2(M4OSA_NULL == pFilePos, M4ERR_PARAMETER, "M4OSA_fileCommonSeek");
 
-    M4OSA_INT_TO_FILE_POSITION(0, fpos_null);
-    M4OSA_INT_TO_FILE_POSITION(-1, fpos_neg_un);
-    M4OSA_FPOS_SET(fpos_file_size, pFileContext->file_size);
+    fpos_file_size = pFileContext->file_size;
 
     if(SeekRead == pFileContext->current_seek)
     {
-        M4OSA_FPOS_SET(fpos_current, pFileContext->read_position);
+        fpos_current = pFileContext->read_position;
     }
     else if(SeekWrite == pFileContext->current_seek)
     {
-        M4OSA_FPOS_SET(fpos_current, pFileContext->write_position);
+        fpos_current = pFileContext->write_position;
     }
     else
     {
-        M4OSA_INT_TO_FILE_POSITION(0, fpos_current);
+        fpos_current = 0;
     }
 
     switch(seekMode)
     {
     case M4OSA_kFileSeekCurrent:
         {
-            M4OSA_FPOS_SET(fpos_seek, *pFilePos);
+            fpos_seek = *pFilePos;
             break;
         }
     case M4OSA_kFileSeekBeginning:
         {
-            M4OSA_FPOS_SUB(fpos_seek, *pFilePos, fpos_current)
-                break;
+            fpos_seek = *pFilePos - fpos_current;
+            break;
         }
     case M4OSA_kFileSeekEnd:
         {
-            M4OSA_FPOS_ADD(fpos_seek, fpos_file_size, *pFilePos);
-            M4OSA_FPOS_SUB(fpos_seek, fpos_seek, fpos_current);
+            fpos_seek = *pFilePos + fpos_file_size - fpos_current;
             break;
         }
     default:
@@ -452,7 +429,7 @@
         }
     }
 
-    M4OSA_FPOS_ADD(fpos_seek_from_beginning, fpos_current, fpos_seek);
+    fpos_seek_from_beginning = fpos_current + fpos_seek;
 
     if(fseek(pFileContext->file_desc, fpos_seek, SEEK_CUR) != 0)
     {
@@ -474,7 +451,7 @@
     }
 
     /* Set the returned position from the beginning of the file */
-    M4OSA_FPOS_SET(*pFilePos, fpos_seek_from_beginning);
+    *pFilePos = fpos_seek_from_beginning;
 
     /* SEEK done, reset end of file value */
     pFileContext->b_is_end_of_file = M4OSA_FALSE;
@@ -509,10 +486,10 @@
                      "M4OSA_fileCommonClose: semaphore_context is M4OSA_NULL");
 #endif /* M4OSA_FILE_BLOCK_WITH_SEMAPHORE */
 
-    M4OSA_free((M4OSA_MemAddr32)pFileContext->url_name);
+    free(pFileContext->url_name);
     pFileContext->url_name = M4OSA_NULL;
 
-    M4OSA_free((M4OSA_MemAddr32)pFileContext->file_name);
+    free(pFileContext->file_name);
     pFileContext->file_name = M4OSA_NULL;
 
     i32_err_code = fclose(pFileContext->file_desc);
@@ -523,7 +500,7 @@
     M4OSA_semaphoreClose(pFileContext->semaphore_context);/* free the semaphore */
 #endif /* M4OSA_FILE_BLOCK_WITH_SEMAPHORE */
 
-    M4OSA_free((M4OSA_MemAddr32)pFileContext);
+    free(pFileContext);
 
     if (i32_err_code != 0)
     {
@@ -565,17 +542,17 @@
         return M4ERR_BAD_CONTEXT;
     }
 
-    M4OSA_INT64_FROM_INT32(pAttribute->creationDate.time, TheStat.st_ctime);
-    M4OSA_INT64_FROM_INT32(pAttribute->lastAccessDate.time, TheStat.st_atime);
-    M4OSA_INT64_FROM_INT32(pAttribute->modifiedDate.time, TheStat.st_mtime);
+    pAttribute->creationDate.time = (M4OSA_Time)TheStat.st_ctime;
+    pAttribute->lastAccessDate.time = (M4OSA_Time)TheStat.st_atime;
+    pAttribute->modifiedDate.time = (M4OSA_Time)TheStat.st_mtime;
 
-    pAttribute->creationDate.timeScale    = 1;
-    pAttribute->lastAccessDate.timeScale= 1;
-    pAttribute->modifiedDate.timeScale    = 1;
+    pAttribute->creationDate.timeScale = 1;
+    pAttribute->lastAccessDate.timeScale = 1;
+    pAttribute->modifiedDate.timeScale = 1;
 
-    pAttribute->creationDate.referenceYear    = 1970;
-    pAttribute->lastAccessDate.referenceYear= 1970;
-    pAttribute->modifiedDate.referenceYear    = 1970;
+    pAttribute->creationDate.referenceYear = 1970;
+    pAttribute->lastAccessDate.referenceYear = 1970;
+    pAttribute->modifiedDate.referenceYear = 1970;
 
     pAttribute->modeAccess = fileContext->access_mode;
 
@@ -608,10 +585,10 @@
     M4OSA_DEBUG_IF2(M4OSA_NULL == pUrl,    M4ERR_PARAMETER,
                                   "M4OSA_fileCommonGetURL: pUrl is M4OSA_NULL");
 
-    uiLength = M4OSA_chrLength(pFileContext->url_name)+1;
+    uiLength = strlen((const char *)pFileContext->url_name)+1;
 
     /* Allocate the memory to store the url_name */
-    *pUrl = (M4OSA_Char*)M4OSA_malloc(uiLength, M4OSA_FILE_COMMON,
+    *pUrl = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(uiLength, M4OSA_FILE_COMMON,
                                     (M4OSA_Char*)"M4OSA_fileCommonGetURL: url");
     if(M4OSA_NULL == *pUrl)
     {
@@ -660,7 +637,7 @@
     *pFileName = M4OSA_NULL;
 
     /*Parse URL*/
-    iUrlLen = M4OSA_chrLength(pUrl);
+    iUrlLen = strlen((const char *)pUrl);
     for(i=iUrlLen-1; i>=0; i--)
     {
         if (pUrl[i] != '\\' && pUrl[i] != '/')
@@ -673,7 +650,7 @@
         }
     }
 
-    ptrFilename = (M4OSA_Char*) M4OSA_malloc(FileNameLen+1, M4OSA_FILE_COMMON,
+    ptrFilename = (M4OSA_Char*) M4OSA_32bitAlignedMalloc(FileNameLen+1, M4OSA_FILE_COMMON,
                     (M4OSA_Char*)"M4OSA_fileCommonGetFilename: Filename string");
     if (ptrFilename == M4OSA_NULL)
     {
diff --git a/libvideoeditor/osal/src/M4OSA_FileExtra.c b/libvideoeditor/osal/src/M4OSA_FileExtra.c
deleted file mode 100755
index 4a7b532..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_malloc(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*/
-    M4OSA_free((M4OSA_MemAddr32)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_malloc(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 */
-    M4OSA_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)
-    {
-        M4OSA_free((M4OSA_MemAddr32)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;
-    }
-
-    M4OSA_free((M4OSA_MemAddr32)pDstFilename);
-    M4OSA_free((M4OSA_MemAddr32)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);
-    }
-
-    M4OSA_free((M4OSA_MemAddr32)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.c b/libvideoeditor/osal/src/M4OSA_FileReader.c
index be3bb37..5e9f757 100755
--- a/libvideoeditor/osal/src/M4OSA_FileReader.c
+++ b/libvideoeditor/osal/src/M4OSA_FileReader.c
@@ -117,8 +117,7 @@
         }
         else
         {
-            M4OSA_FPOS_ADD_CONST_UINT32(pFileContext->read_position,
-                                       pFileContext->read_position, uiSizeRead);
+            pFileContext->read_position = pFileContext->read_position + uiSizeRead;
             if ((M4OSA_UInt32)uiSizeRead < *pSize)
             {
                 *pSize = uiSizeRead;
@@ -170,8 +169,7 @@
     }
     else
     {
-        M4OSA_FPOS_ADD_CONST_UINT32(pFileContext->read_position,
-                    pFileContext->read_position, uiSizeRead);
+        pFileContext->read_position = pFileContext->read_position + uiSizeRead;
         if ((M4OSA_UInt32)uiSizeRead < *pSize)
         {
             *pSize = uiSizeRead;
@@ -310,7 +308,7 @@
     }
     else
     {
-        M4OSA_FPOS_SET(pFileContext->read_position, *pPosition);
+        pFileContext->read_position = *pPosition;
     }
 
 #ifdef M4OSA_FILE_BLOCK_WITH_SEMAPHORE
diff --git a/libvideoeditor/osal/src/M4OSA_FileReader_RAM.c b/libvideoeditor/osal/src/M4OSA_FileReader_RAM.c
deleted file mode 100755
index 24acfaa..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_malloc(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)
-        {
-            M4OSA_free((M4OSA_MemAddr32)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;
-
-    M4OSA_free((M4OSA_MemAddr32)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.c b/libvideoeditor/osal/src/M4OSA_FileWriter.c
index 1fc73dc..92b462f 100755
--- a/libvideoeditor/osal/src/M4OSA_FileWriter.c
+++ b/libvideoeditor/osal/src/M4OSA_FileWriter.c
@@ -113,12 +113,12 @@
         }
         fflush(pFileContext->file_desc);
 
-        M4OSA_FPOS_ADD_CONST_UINT32(pFileContext->write_position, pFileContext->write_position, WriteSize);
+        pFileContext->write_position = pFileContext->write_position + WriteSize;
 
         /* Update the file size */
-        if(M4OSA_FPOS_COMPARE(pFileContext->write_position, pFileContext->file_size) > 0)
+        if(pFileContext->write_position > pFileContext->file_size)
         {
-            M4OSA_FPOS_SET(pFileContext->file_size, pFileContext->write_position);
+            pFileContext->file_size = pFileContext->write_position;
         }
         return err;
     }
@@ -160,14 +160,12 @@
         return M4ERR_BAD_CONTEXT;
     }
 
-    M4OSA_FPOS_ADD_CONST_UINT32(pFileContext->write_position,
-                                pFileContext->write_position,
-                                uiSizeWrite);
+    pFileContext->write_position = pFileContext->write_position + uiSizeWrite;
 
     /* Update the file size */
-    if(M4OSA_FPOS_COMPARE(pFileContext->write_position, pFileContext->file_size) > 0)
+    if(pFileContext->write_position > pFileContext->file_size)
     {
-        M4OSA_FPOS_SET(pFileContext->file_size, pFileContext->write_position);
+        pFileContext->file_size = pFileContext->write_position;
     }
 
     if((M4OSA_UInt32)uiSizeWrite < uiSize)
@@ -285,7 +283,7 @@
         return err;
     }
 
-    M4OSA_FPOS_SET(pFileContext->write_position, *pPosition);
+    pFileContext->write_position = *pPosition;
 
     pFileContext->current_seek = SeekWrite;
 
diff --git a/libvideoeditor/osal/src/M4OSA_FileWriter_RAM.c b/libvideoeditor/osal/src/M4OSA_FileWriter_RAM.c
deleted file mode 100755
index 9341ca9..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_malloc(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)
-        {
-            M4OSA_free((M4OSA_MemAddr32)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 */
-    M4OSA_free((M4OSA_MemAddr32)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_Mutex.c b/libvideoeditor/osal/src/M4OSA_Mutex.c
index 0d857f6..8db3e2a 100755
--- a/libvideoeditor/osal/src/M4OSA_Mutex.c
+++ b/libvideoeditor/osal/src/M4OSA_Mutex.c
@@ -67,7 +67,7 @@
 
     *pContext = M4OSA_NULL;
 
-    pMutexContext = (M4OSA_MutexContext*)M4OSA_malloc(sizeof(M4OSA_MutexContext),
+    pMutexContext = (M4OSA_MutexContext*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_MutexContext),
                     M4OSA_MUTEX, (M4OSA_Char*)"M4OSA_mutexOpen: mutex context");
 
     if(M4OSA_NULL == pMutexContext)
@@ -96,7 +96,7 @@
     if(!opened)
     {
         M4OSA_DEBUG(M4ERR_CONTEXT_FAILED, "M4OSA_mutexOpen: OS mutex creation failed");
-        M4OSA_free((M4OSA_MemAddr32)pMutexContext);
+        free(pMutexContext);
         return M4ERR_CONTEXT_FAILED ;
     }
 
@@ -269,7 +269,7 @@
 
     pthread_mutex_destroy(&pMutexContext->mutex);
 
-    M4OSA_free((M4OSA_MemAddr32) pMutexContext);
+    free( pMutexContext);
 
     return M4NO_ERROR;
 }
diff --git a/libvideoeditor/osal/src/M4OSA_Semaphore.c b/libvideoeditor/osal/src/M4OSA_Semaphore.c
index a99b136..aeac0a9 100755
--- a/libvideoeditor/osal/src/M4OSA_Semaphore.c
+++ b/libvideoeditor/osal/src/M4OSA_Semaphore.c
@@ -77,7 +77,7 @@
 
    *context = M4OSA_NULL;
 
-   semaphoreContext = (M4OSA_SemaphoreContext*) M4OSA_malloc(
+   semaphoreContext = (M4OSA_SemaphoreContext*) M4OSA_32bitAlignedMalloc(
                       sizeof(M4OSA_SemaphoreContext), M4OSA_SEMAPHORE,
                       (M4OSA_Char*)"M4OSA_semaphoreOpen: semaphore context");
 
@@ -90,7 +90,7 @@
 
    if (0 != sem_init(&semaphoreContext->semaphore, 0, initial_count))
    {
-      M4OSA_free((M4OSA_MemAddr32)semaphoreContext);
+      free(semaphoreContext);
 
       M4OSA_DEBUG(M4ERR_CONTEXT_FAILED,
          "M4OSA_semaphoreOpen: OS semaphore creation failed");
@@ -257,7 +257,7 @@
 
    sem_destroy(&semaphoreContext->semaphore);
 
-   M4OSA_free((M4OSA_MemAddr32)semaphoreContext);
+   free(semaphoreContext);
 
    return M4NO_ERROR;
 }
diff --git a/libvideoeditor/osal/src/M4OSA_String.c b/libvideoeditor/osal/src/M4OSA_String.c
deleted file mode 100755
index af98b4b..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_malloc(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)
-    {
-        M4OSA_free((M4OSA_MemAddr32)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 */
-    M4OSA_free((M4OSA_MemAddr32)(pStr->pui8_buffer));
-
-    /* Free M4OSA_String structure memory */
-    M4OSA_free((M4OSA_MemAddr32)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_malloc(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);
-
-    M4OSA_free((M4OSA_MemAddr32)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_malloc(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");
-
-    M4OSA_free((M4OSA_MemAddr32)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)
-    {
-        M4OSA_free((M4OSA_MemAddr32)pOstr->pui8_buffer);
-        M4OSA_free((M4OSA_MemAddr32)pOstr);
-    }
-
-    if(nstr2free == M4OSA_TRUE)
-    {
-        M4OSA_free((M4OSA_MemAddr32)pNstr->pui8_buffer);
-        M4OSA_free((M4OSA_MemAddr32)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_malloc(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);
-
-        M4OSA_free((M4OSA_MemAddr32)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 07cef33..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)
-      {
-         M4OSA_free((M4OSA_MemAddr32)buffer);
-      }
-
-      /* Allocate the actual M4OSA_String content */
-      buffer = (M4OSA_Char*)M4OSA_malloc(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_malloc(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);
-
-         M4OSA_free((M4OSA_MemAddr32)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_malloc(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_malloc(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);
-            M4OSA_free((M4OSA_MemAddr32)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_malloc(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);
-
-            M4OSA_free((M4OSA_MemAddr32)ibuffer);
-
-            istr->pui8_buffer = buffer;
-
-            istr->ui32_size = ui32_size;
-         }
-         else
-         {
-            buffer = (M4OSA_Char*)M4OSA_malloc(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);
-
-            M4OSA_free((M4OSA_MemAddr32)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_malloc(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);
-
-      M4OSA_free((M4OSA_MemAddr32)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_malloc(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_malloc(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);
-
-      M4OSA_free((M4OSA_MemAddr32)patterns);
-
-      M4OSA_free((M4OSA_MemAddr32)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_malloc(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);
-
-   M4OSA_free((M4OSA_MemAddr32)newFormat);
-
-   if (M4ERR_CHR_STR_OVERFLOW == err)
-   {
-       return M4ERR_STR_OVERFLOW;
-   }
-   else
-   {
-       return M4NO_ERROR;
-   }
-}
-
diff --git a/libvideoeditor/osal/src/M4OSA_Thread.c b/libvideoeditor/osal/src/M4OSA_Thread.c
index c09b82c..793c0e4 100755
--- a/libvideoeditor/osal/src/M4OSA_Thread.c
+++ b/libvideoeditor/osal/src/M4OSA_Thread.c
@@ -56,10 +56,6 @@
 
    M4OSA_mutexLock(threadContext->stateMutex, M4OSA_WAIT_FOREVER);
 
-   /*if(threadContext->startCallBack != M4OSA_NULL)
-   {
-      threadContext->startCallBack(threadContext, userData);
-   }*/
 
    threadContext->state = M4OSA_kThreadRunning;
 
@@ -141,7 +137,7 @@
    *context = M4OSA_NULL;
 
    threadContext =
-      (M4OSA_ThreadContext*)M4OSA_malloc(sizeof(M4OSA_ThreadContext),
+      (M4OSA_ThreadContext*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_ThreadContext),
       M4OSA_THREAD, (M4OSA_Char*)"M4OSA_threadSyncOpen: thread context");
 
    if(threadContext == M4OSA_NULL)
@@ -156,11 +152,6 @@
    threadContext->name = M4OSA_NULL;
    threadContext->threadID = 0;
    threadContext->coreID = M4OSA_THREAD;
-/*
-   threadContext->userData = M4OSA_NULL;
-   threadContext->stopCallBack = M4OSA_NULL;
-   threadContext->startCallBack = M4OSA_NULL;
-*/
    threadContext->state = M4OSA_kThreadOpened;
    threadContext->priority = M4OSA_kThreadNormalPriority ;
 
@@ -256,29 +247,6 @@
          {
             if ( 0 == pthread_attr_setschedpolicy( &attribute, SCHED_OTHER ) )
             {
-#if 0
-                min = sched_get_priority_min( SCHED_OTHER );
-                max = sched_get_priority_max( SCHED_OTHER );
-
-                switch(threadContext->priority)
-                {
-                case M4OSA_kThreadLowestPriority:
-                    priority = min;
-                    break;
-                case M4OSA_kThreadLowPriority:
-                    priority = min + ( max - min ) / 4;
-                    break;
-                case M4OSA_kThreadNormalPriority:
-                    priority = min + ( max - min ) / 2;
-                    break;
-                case M4OSA_kThreadHighPriority:
-                    priority = max - ( max - min ) / 4;
-                    break;
-                case M4OSA_kThreadHighestPriority:
-                    priority = max;
-                    break;
-                }
-#else
                 /* Tentative patches to handle priorities in a better way : */
                 /* Use Android's predefined priorities (range +19..-20)
                  *rather than Linux ones (0..99)*/
@@ -313,7 +281,6 @@
                     priority = ANDROID_PRIORITY_URGENT_AUDIO;
                     break;
                 }
-#endif
                 sched.sched_priority = priority;
 
                 if ( 0 == pthread_attr_setschedparam( &attribute, &sched ) )
@@ -475,10 +442,10 @@
 
    if(threadContext->name != M4OSA_NULL)
    {
-      M4OSA_free((M4OSA_MemAddr32)threadContext->name);
+      free(threadContext->name);
    }
 
-   M4OSA_free((M4OSA_MemAddr32)threadContext);
+   free(threadContext);
 
    return M4NO_ERROR;
 }
@@ -546,48 +513,6 @@
    return M4NO_ERROR;
 }
 
-
-
-
-#if(M4OSA_OPTIONID_THREAD_STARTED == M4OSA_TRUE)
-
-/*M4OSA_ERR M4OSA_SetThreadSyncStarted(M4OSA_Context context,
-                                 M4OSA_DataOption optionValue)
-{
-   M4OSA_ThreadContext* threadContext = (M4OSA_ThreadContext*)context ;
-
-   M4OSA_TRACE2_2("M4OSA_SetThreadSyncStarted\t\tM4OSA_Context 0x%x\t"
-                  "M4OSA_DataOption 0x%x", context, optionValue);
-
-   threadContext->startCallBack = (M4OSA_ThreadCallBack)optionValue;
-
-   return M4NO_ERROR;
-}*/
-
-#endif /*M4OSA_OPTIONID_THREAD_STARTED*/
-
-
-
-
-#if(M4OSA_OPTIONID_THREAD_STOPPED == M4OSA_TRUE)
-
-/*M4OSA_ERR M4OSA_SetThreadSyncStopped(M4OSA_Context context,
-                                 M4OSA_DataOption optionValue)
-{
-   M4OSA_ThreadContext* threadContext = (M4OSA_ThreadContext*)context;
-
-   M4OSA_TRACE2_2("M4OSA_SetThreadSyncStopped\t\tM4OSA_Context 0x%x\t"
-                  "M4OSA_DataOption 0x%x", context, optionValue);
-
-   threadContext->stopCallBack = (M4OSA_ThreadCallBack)optionValue;
-
-   return M4NO_ERROR;
-}*/
-
-#endif /*M4OSA_OPTIONID_THREAD_STOPPED*/
-
-
-
 #if(M4OSA_OPTIONID_THREAD_PRIORITY == M4OSA_TRUE)
 
 M4OSA_ERR M4OSA_SetThreadSyncPriority(M4OSA_Context context,
@@ -629,16 +554,16 @@
 
    if(threadContext->name != NULL)
    {
-      M4OSA_free((M4OSA_MemAddr32)threadContext->name);
+      free(threadContext->name);
       threadContext->name = M4OSA_NULL;
    }
 
    if(optionValue != M4OSA_NULL)
    {
-      nameSize = M4OSA_chrLength(name)+1;
+      nameSize = strlen((const char *)name)+1;
 
       threadContext->name =
-         (M4OSA_Char*)M4OSA_malloc(nameSize, M4OSA_THREAD,
+         (M4OSA_Char*)M4OSA_32bitAlignedMalloc(nameSize, M4OSA_THREAD,
          (M4OSA_Char*)"M4OSA_SetThreadSyncName: thread name");
 
       if(threadContext == M4OSA_NULL)
@@ -646,7 +571,7 @@
          return M4ERR_ALLOC;
       }
 
-      M4OSA_memcpy((M4OSA_MemAddr8)threadContext->name, (M4OSA_MemAddr8)name,
+      memcpy((void *)threadContext->name, (void *)name,
                    nameSize);
    }
 
@@ -673,29 +598,6 @@
 
 #endif /*M4OSA_OPTIONID_THREAD_STACK_SIZE*/
 
-
-
-#if(M4OSA_OPTIONID_THREAD_USER_DATA == M4OSA_TRUE)
-
-/*M4OSA_ERR M4OSA_SetThreadSyncUserData(M4OSA_Context context,
-                                  M4OSA_DataOption optionValue)
-{
-   M4OSA_ThreadContext* threadContext = (M4OSA_ThreadContext*)context;
-
-   M4OSA_TRACE2_2("M4OSA_SetThreadSyncUserData\t\tM4OSA_Context 0x%x\t"
-                  "M4OSA_DataOption 0x%x", context, optionValue);
-
-   threadContext->userData = (M4OSA_Void*)optionValue;
-
-   return M4NO_ERROR;
-}*/
-
-#endif /*M4OSA_OPTIONID_THREAD_USER_DATA*/
-
-
-
-
-
 /**
  ************************************************************************
  * @brief      This method asks the core OSAL-Thread component to set the value
@@ -756,32 +658,6 @@
 
    switch(optionID)
    {
-#if(M4OSA_OPTIONID_THREAD_STARTED == M4OSA_TRUE)
-      /*case M4OSA_ThreadStarted:
-      {
-         err_code = M4OSA_SetThreadSyncStarted(context, optionValue);
-
-         break;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_STARTED*/
-
-#if(M4OSA_OPTIONID_THREAD_STOPPED == M4OSA_TRUE)
-      /*case M4OSA_ThreadStopped:
-      {
-         err_code = M4OSA_SetThreadSyncStopped(context, optionValue);
-
-         break;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_STOPPED*/
-
-#if(M4OSA_OPTIONID_THREAD_USER_DATA == M4OSA_TRUE)
-      /*case M4OSA_ThreadUserData:
-      {
-         err_code = M4OSA_SetThreadSyncUserData(context, optionValue);
-
-         break;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_USER_DATA*/
 
 #if(M4OSA_OPTIONID_THREAD_PRIORITY == M4OSA_TRUE)
       case M4OSA_ThreadPriority:
@@ -876,38 +752,6 @@
 
    switch(optionID)
    {
-#if(M4OSA_OPTIONID_THREAD_STARTED == M4OSA_TRUE)
-      /*case M4OSA_ThreadStarted:
-      {
-         M4OSA_ThreadCallBack* startCallBack = (M4OSA_ThreadCallBack*)optionValue;
-
-         *startCallBack = threadContext->startCallBack;
-
-         return M4NO_ERROR;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_STARTED*/
-
-#if(M4OSA_OPTIONID_THREAD_STOPPED == M4OSA_TRUE)
-      /*case M4OSA_ThreadStopped:
-      {
-         M4OSA_ThreadCallBack* stopCallBack = (M4OSA_ThreadCallBack*)optionValue;
-
-         *stopCallBack = threadContext->stopCallBack;
-
-         return M4NO_ERROR;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_STOPPED*/
-
-#if(M4OSA_OPTIONID_THREAD_USER_DATA == M4OSA_TRUE)
-      /*case M4OSA_ThreadUserData:
-      {
-         M4OSA_Void** userData = (M4OSA_Void**)optionValue;
-
-         *userData = threadContext->userData;
-
-         return M4NO_ERROR;
-      }*/
-#endif /*M4OSA_OPTIONID_THREAD_USER_DATA*/
 
 #if(M4OSA_OPTIONID_THREAD_PRIORITY == M4OSA_TRUE)
       case M4OSA_ThreadPriority:
diff --git a/libvideoeditor/osal/src/M4PSW_MemoryInterface.c b/libvideoeditor/osal/src/M4PSW_MemoryInterface.c
index 1dd4d3a..6c33fc1 100755
--- a/libvideoeditor/osal/src/M4PSW_MemoryInterface.c
+++ b/libvideoeditor/osal/src/M4PSW_MemoryInterface.c
@@ -30,7 +30,7 @@
 #ifndef M4VPS_ADVANCED_MEMORY_MANAGER
 /**
  ************************************************************************
- * @fn         M4OSA_MemAddr32 M4OSA_malloc(M4OSA_UInt32 size,
+ * @fn         M4OSA_MemAddr32 M4OSA_32bitAlignedMalloc(M4OSA_UInt32 size,
  *                                          M4OSA_CoreID coreID,
  *                                          M4OSA_Char* string)
  * @brief      this function allocates a memory block (at least 32 bits aligned)
@@ -42,7 +42,7 @@
  ************************************************************************
 */
 
-M4OSA_MemAddr32 M4OSA_malloc(M4OSA_UInt32 size,
+M4OSA_MemAddr32 M4OSA_32bitAlignedMalloc(M4OSA_UInt32 size,
                              M4OSA_CoreID coreID,
                              M4OSA_Char* string)
 {
@@ -68,116 +68,5 @@
     return Address;
 }
 
-
-/**
- ************************************************************************
- * @fn         M4OSA_Void M4OSA_free(M4OSA_MemAddr32 address)
- * @brief      this function free the provided memory block
- * @note       As in stlib.h, this function does nothing if address is NULL.
- * @param      address (IN): address of the block to free
- * @return     none
- ************************************************************************
-*/
-
-M4OSA_Void M4OSA_free (M4OSA_MemAddr32 address)
-{
-    free(address);
-}
-
-
-/**
- ************************************************************************
- * @fn         M4OSA_Void M4OSA_memset(M4OSA_MemAddr8 block,
- *                                     M4OSA_UInt32 size,
- *                                     M4OSA_UInt8 value)
- * @brief      this function initializes the provided memory block with value
- * @note
- * @param      block (IN): address of block to fill
- * @param      size  (IN): size of the provided block
- * @param      value (IN): value used for initialization
- * @return     none
- ************************************************************************
-*/
-
-M4OSA_Void M4OSA_memset(M4OSA_MemAddr8 block,
-                        M4OSA_UInt32 size,
-                        M4OSA_UInt8 value)
-{
-    memset((void*)block, value, size);
-}
-
-
-/**
- ************************************************************************
- * @fn         M4OSA_Void M4OSA_memcpy(M4OSA_MemAddr8 outputBlock,
- *                                     M4OSA_MemAddr8 inputBlock,
- *                                     M4OSA_UInt32 size)
- * @brief      this function copies 'size' bytes from inputBlock to outputBlock
- * @note
- * @param      outputBlock (IN): address of block to fill
- * @param      inputBlock  (IN): address of the input block
- * @param      size (IN): size of the block to copy (in bytes)
- * @return     none
- ************************************************************************
-*/
-
-M4OSA_Void M4OSA_memcpy(M4OSA_MemAddr8 outputBlock,
-                        M4OSA_MemAddr8 inputBlock,
-                        M4OSA_UInt32 size)
-{
-    memcpy((void*)outputBlock, (void*)inputBlock,  size);
-}
-
-/**
- ************************************************************************
- * @fn         M4OSA_MemAddr8 M4OSA_memmove(M4OSA_MemAddr8 outputBlock, M4OSA_MemAddr8 inputBlock, M4OSA_UInt32 size)
- * @brief      this function moves 'size' bytes from inputBlock to outputBlock
- *               unlike M4OSA_memcpy, the two buffers can have an overlap.
- * @note       increment memcpy byte number (François VALETTE)
- * @param      outputBlock (IN): address of block to fill
- * @param      inputBlock  (IN): address of the input block
- * @param      size (IN): size of the block to copy (in bytes)
- * @return     address of the output block, i.e. the first parameter
- ************************************************************************
-*/
-M4OSA_MemAddr8 M4OSA_memmove(M4OSA_MemAddr8 outputBlock,
-                         M4OSA_MemAddr8 inputBlock,
-                         M4OSA_UInt32 size)
-{
-   return memmove((void*)outputBlock, (void*)inputBlock,  size);
-}
-
-/**
- ************************************************************************
- * @fn         M4OSA_Int32 M4OSA_memcmp(M4OSA_MemAddr8 address1, M4OSA_MemAddr8 address2, M4OSA_UInt32 size)
- * @brief      this function compares the first 'size' bytes of address1 and
-               'address2' and return a value indicating their relationship.
- * @note
- * @param      address1 (IN): memory address 1
- * @param      address2 (IN): memory address 2
- * @param      size (IN): size of the block to compare (in bytes)
- * @return     +1, if first bytes of adress1 are smaller than those of address2
- * @return      0, if both blocks are identical
- * @return    -1, if first bytes of address1 are bigger than those of address2
- ************************************************************************
-*/
-
-M4OSA_Int32 M4OSA_memcmp(M4OSA_MemAddr8 address1,
-                         M4OSA_MemAddr8 address2,
-                         M4OSA_UInt32 size)
-{
-    M4OSA_Int32 i32_result = memcmp(address1, address2, size);
-    if (i32_result > 0) {
-        return 1;
-    }
-    else if (i32_result < 0) {
-        return((M4OSA_Int32)-1);
-    }
-    return 0;
-}
-
-
-
-
 #endif
 
diff --git a/libvideoeditor/osal/src/M4PSW_Trace.c b/libvideoeditor/osal/src/M4PSW_Trace.c
index ef39d82..17b0af6 100755
--- a/libvideoeditor/osal/src/M4PSW_Trace.c
+++ b/libvideoeditor/osal/src/M4PSW_Trace.c
@@ -64,9 +64,9 @@
 
     /* do the actual print */
 #ifdef NO_FILE
-    __android_log_print(ANDROID_LOG_INFO, "LifeVibesTrace", "%s", (char*)message);
+    __android_log_print(ANDROID_LOG_INFO, "M4OSA_Trace", "%s", (char*)message);
 #else /* NO_FILE     */
-    __android_log_print(ANDROID_LOG_INFO, "LifeVibesTrace", "%s", "%s at %lu in %s",
+    __android_log_print(ANDROID_LOG_INFO, "M4OSA_Trace", "%s", "%s at %lu in %s",
                                                    (char *)message, line, file);
 #endif /* NO_FILE     */
 
@@ -89,9 +89,9 @@
 
     /* do the actual print */
 #ifdef NO_FILE
-    __android_log_print(ANDROID_LOG_INFO, "LifeVibesTrace", "%s", (char*)message);
+    __android_log_print(ANDROID_LOG_INFO, "M4OSA_TRACE_traceFunction", "%s", (char*)message);
 #else /* NO_FILE     */
-    __android_log_print(ANDROID_LOG_INFO, "LifeVibesTrace", "%s", "%s at %lu in %s",
+    __android_log_print(ANDROID_LOG_INFO, "M4OSA_TRACE_traceFunction", "%s", "%s at %lu in %s",
                                             (char *)message, line, (char*)file);
 #endif /* NO_FILE     */
 
diff --git a/libvideoeditor/vss/3gpwriter/src/Android.mk b/libvideoeditor/vss/3gpwriter/src/Android.mk
index ab97e8c..75971b3 100755
--- a/libvideoeditor/vss/3gpwriter/src/Android.mk
+++ b/libvideoeditor/vss/3gpwriter/src/Android.mk
@@ -54,9 +54,5 @@
 LOCAL_CFLAGS += -Wno-multichar \
     -DDUPLICATE_STTS_IN_LAST_AU
 
-# Don't prelink this library.  For more efficient code, you may want
-# to add this library to the prelink map and set this to true.
-LOCAL_PRELINK_MODULE := false
-
 include $(BUILD_STATIC_LIBRARY)
 
diff --git a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Interface.c b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Interface.c
index c719fe6..7fde1f1 100755
--- a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Interface.c
+++ b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Interface.c
@@ -32,7 +32,6 @@
 #include "M4OSA_FileWriter.h"        /**< Include for OSAL file accesses implementation */
 #include "M4OSA_Memory.h"            /**< Include for OSAL memory accesses implementation */
 #include "M4OSA_Debug.h"            /**< OSAL debug tools */
-#include "M4OSA_CharStar.h"            /**< For M4OSA_chrLength() */
 
 /**
  * Writer includes */
@@ -107,7 +106,7 @@
     /**
      *    Allocate memory for the context */
     *pContext=M4OSA_NULL;
-    apContext = (M4WRITER_3GP_InternalContext*)M4OSA_malloc(
+    apContext = (M4WRITER_3GP_InternalContext*)M4OSA_32bitAlignedMalloc(
                     sizeof(M4WRITER_3GP_InternalContext),
                     M4WRITER_3GP,
                     (M4OSA_Char *)"M4WRITER_3GP_InternalContext");
@@ -366,7 +365,7 @@
 
     /**
      *    Deallocate our own context */
-    M4OSA_free((M4OSA_MemAddr32)apContext);
+    free(apContext);
 
     M4OSA_TRACE2_1("M4WRITER_3GP_closeWrite: returning 0x%x", err);
     return err;
@@ -462,7 +461,7 @@
                be a text string */
             memval.addr = (M4OSA_MemAddr32)optionValue;
             /**< this is max string size copied by the core */
-            memval.size = M4OSA_chrLength(optionValue);
+            memval.size = strlen((const char *)optionValue);
             err = M4MP4W_setOption(
                 apContext->pMP4Context,M4MP4W_integrationTag, &memval);
             if (M4OSA_ERR_IS_ERROR(err))
@@ -864,7 +863,7 @@
 
     /**
      *    Allocate the global interface structure */
-    pGlobal = (M4WRITER_GlobalInterface*)M4OSA_malloc(
+    pGlobal = (M4WRITER_GlobalInterface*)M4OSA_32bitAlignedMalloc(
                 sizeof(M4WRITER_GlobalInterface),
                 M4WRITER_3GP, (M4OSA_Char *)"M4WRITER_GlobalInterface");
     if (M4OSA_NULL == pGlobal)
@@ -879,13 +878,13 @@
     /**
      *    Allocate the data interface structure */
     pData =
-        (M4WRITER_DataInterface *)M4OSA_malloc(sizeof(M4WRITER_DataInterface),
+        (M4WRITER_DataInterface *)M4OSA_32bitAlignedMalloc(sizeof(M4WRITER_DataInterface),
         M4WRITER_3GP, (M4OSA_Char *)"M4WRITER_DataInterface");
     if (M4OSA_NULL == pData)
     {
         M4OSA_TRACE1_0("unable to allocate M4WRITER_DataInterface,\
              returning M4ERR_ALLOC");
-        M4OSA_free((M4OSA_MemAddr32)pGlobal);
+        free(pGlobal);
         *SrcGlobalInterface = M4OSA_NULL;
         *SrcDataInterface = M4OSA_NULL;
         return (M4OSA_ERR)M4ERR_ALLOC;
diff --git a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Utils.c b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Utils.c
index 5da85eb..4ec4f64 100755
--- a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Utils.c
+++ b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Utils.c
@@ -119,13 +119,13 @@
 void* M4MP4W_realloc(M4OSA_MemAddr32 ptr, M4OSA_UInt32 oldSize, M4OSA_UInt32 newSize)
 /*******************************************************************************/
 {
-    M4OSA_MemAddr32 ptr2 = (M4OSA_MemAddr32)M4OSA_malloc(newSize, M4MP4_WRITER,
+    M4OSA_MemAddr32 ptr2 = (M4OSA_MemAddr32)M4OSA_32bitAlignedMalloc(newSize, M4MP4_WRITER,
                                                           (M4OSA_Char *)"realloc");
     if (M4OSA_NULL != ptr2)
     {
-        M4OSA_memcpy((M4OSA_MemAddr8)ptr2, (M4OSA_MemAddr8)ptr, oldSize);
+        memcpy((void *)ptr2, (void *)ptr, oldSize);
     }
-    M4OSA_free(ptr);
+    free(ptr);
     return ptr2;
 }
 
@@ -151,55 +151,55 @@
 #ifdef _M4MP4W_MOOV_FIRST
         for (i=0; i<=mMp4FileDataPtr->audioTrackPtr->LastAllocatedChunk; i++)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->Chunk[i]);
+            free(mMp4FileDataPtr->audioTrackPtr->Chunk[i]);
         }
 #else
         if ((M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk) &&
              (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk[0]))
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->Chunk[0]);
+            free(mMp4FileDataPtr->audioTrackPtr->Chunk[0]);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable);
+            free(mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable);
         }
 #endif /*_M4MP4W_MOOV_FIRST*/
 
         /*now dynamic*/
         if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->Chunk);
+            free(mMp4FileDataPtr->audioTrackPtr->Chunk);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkSizeTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->chunkSizeTable);
+            free(mMp4FileDataPtr->audioTrackPtr->chunkSizeTable);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable);
+            free(mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable);
+            free(mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable);
         }
 
         if (mMp4FileDataPtr->audioTrackPtr->TABLE_STTS != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->TABLE_STTS);
+            free(mMp4FileDataPtr->audioTrackPtr->TABLE_STTS);
         }
 
         if (mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ);
+            free(mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ);
         }
 
         if (mMp4FileDataPtr->audioTrackPtr->DSI != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr->DSI);
+            free(mMp4FileDataPtr->audioTrackPtr->DSI);
             mMp4FileDataPtr->audioTrackPtr->DSI = M4OSA_NULL;
         }
 
-        M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->audioTrackPtr);
+        free(mMp4FileDataPtr->audioTrackPtr);
         mMp4FileDataPtr->audioTrackPtr = M4OSA_NULL;
     }
     if (mMp4FileDataPtr->videoTrackPtr != M4OSA_NULL)
@@ -210,69 +210,69 @@
 #ifdef _M4MP4W_MOOV_FIRST
         for (i=0; i<=mMp4FileDataPtr->videoTrackPtr->LastAllocatedChunk; i++)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->Chunk[i]);
+            free(mMp4FileDataPtr->videoTrackPtr->Chunk[i]);
         }
 #else
         if ((M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk) &&
              (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk[0]))
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->Chunk[0]);
+            free(mMp4FileDataPtr->videoTrackPtr->Chunk[0]);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable);
+            free(mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable);
         }
 #endif /*_M4MP4W_MOOV_FIRST*/
 
         /*now dynamic*/
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->Chunk);
+            free(mMp4FileDataPtr->videoTrackPtr->Chunk);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkSizeTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->chunkSizeTable);
+            free(mMp4FileDataPtr->videoTrackPtr->chunkSizeTable);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable);
+            free(mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable);
+            free(mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable);
         }
 
         if (mMp4FileDataPtr->videoTrackPtr->DSI != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->DSI);
+            free(mMp4FileDataPtr->videoTrackPtr->DSI);
             mMp4FileDataPtr->videoTrackPtr->DSI = M4OSA_NULL;
         }
 
         /*now dynamic*/
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STTS)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->TABLE_STTS);
+            free(mMp4FileDataPtr->videoTrackPtr->TABLE_STTS);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ);
+            free(mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ);
         }
         if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STSS)
         {
-            M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->TABLE_STSS);
+            free(mMp4FileDataPtr->videoTrackPtr->TABLE_STSS);
         }
 
-        M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr);
+        free(mMp4FileDataPtr->videoTrackPtr);
         mMp4FileDataPtr->videoTrackPtr = M4OSA_NULL;
     }
 
     if (mMp4FileDataPtr->embeddedString != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->embeddedString);
+        free(mMp4FileDataPtr->embeddedString);
         mMp4FileDataPtr->embeddedString = M4OSA_NULL;
     }
 
-    M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr);
+    free(mMp4FileDataPtr);
 
     return M4NO_ERROR;
 }
diff --git a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
index b37dded..cb0c84f 100755
--- a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
+++ b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
@@ -560,7 +560,7 @@
     /* The context reuse mode was suppressed*/
 
     mMp4FileDataPtr =
-        (M4MP4W_Mp4FileData *)M4OSA_malloc(sizeof(M4MP4W_Mp4FileData),
+        (M4MP4W_Mp4FileData *)M4OSA_32bitAlignedMalloc(sizeof(M4MP4W_Mp4FileData),
         M4MP4_WRITER, (M4OSA_Char *)"MP4 writer context");
     ERR_CHECK(mMp4FileDataPtr != M4OSA_NULL, M4ERR_ALLOC);
     mMp4FileDataPtr->url = outputFileDescriptor;
@@ -614,8 +614,8 @@
 
     /* ftyp atom */
 
-    M4OSA_memset((M4OSA_MemAddr8) &mMp4FileDataPtr->ftyp,
-        sizeof(mMp4FileDataPtr->ftyp), 0);
+    memset((void *) &mMp4FileDataPtr->ftyp,0,
+        sizeof(mMp4FileDataPtr->ftyp));
 
     *contextPtr = mMp4FileDataPtr;
 
@@ -656,7 +656,7 @@
             if (mMp4FileDataPtr->audioTrackPtr == M4OSA_NULL)
             {
                 mMp4FileDataPtr->audioTrackPtr = (M4MP4W_AudioTrackData
-                    *)M4OSA_malloc(sizeof(M4MP4W_AudioTrackData),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4MP4W_AudioTrackData),
                     M4MP4_WRITER, (M4OSA_Char *)"M4MP4W_AudioTrackData");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr != M4OSA_NULL,
                     M4ERR_ALLOC);
@@ -677,7 +677,7 @@
 #ifdef _M4MP4W_MOOV_FIRST
 
                 mMp4FileDataPtr->audioTrackPtr->Chunk =
-                    (M4OSA_UChar ** )M4OSA_malloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
+                    (M4OSA_UChar ** )M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
                     * sizeof(M4OSA_UChar *),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->Chunk");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->Chunk != M4OSA_NULL,
@@ -686,14 +686,14 @@
 #else
 
                 mMp4FileDataPtr->audioTrackPtr->Chunk =
-                    (M4OSA_UChar ** )M4OSA_malloc(sizeof(M4OSA_UChar *),
+                    (M4OSA_UChar ** )M4OSA_32bitAlignedMalloc(sizeof(M4OSA_UChar *),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->Chunk");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->Chunk != M4OSA_NULL,
                     M4ERR_ALLOC);
                 mMp4FileDataPtr->audioTrackPtr->Chunk[0] = M4OSA_NULL;
 
                 mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->chunkOffsetTable");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable
@@ -702,26 +702,26 @@
 #endif /*_M4MP4W_MOOV_FIRST*/
 
                 mMp4FileDataPtr->audioTrackPtr->TABLE_STTS =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_STTS_AUDIO_ALLOC_SIZE,
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_STTS_AUDIO_ALLOC_SIZE,
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->TABLE_STTS");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->TABLE_STTS
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->audioTrackPtr->nbOfAllocatedSttsBlocks = 1;
 
                 mMp4FileDataPtr->audioTrackPtr->chunkSizeTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->chunkSizeTable");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->chunkSizeTable
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->chunkSampleNbTable");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_AUDIO_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->chunkTimeMsTable");
                 ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable
@@ -780,13 +780,13 @@
                     ERR_CHECK(streamDescPtr->decoderSpecificInfoSize == 9,
                         M4ERR_PARAMETER);
                     mMp4FileDataPtr->audioTrackPtr->DSI =
-                        (M4OSA_UChar *)M4OSA_malloc(9, M4MP4_WRITER,
+                        (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(9, M4MP4_WRITER,
                         (M4OSA_Char *)"audioTrackPtr->DSI");
                     ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->DSI != M4OSA_NULL,
                         M4ERR_ALLOC);
-                    M4OSA_memcpy(
-                        (M4OSA_MemAddr8)mMp4FileDataPtr->audioTrackPtr->DSI,
-                        (M4OSA_MemAddr8)streamDescPtr->decoderSpecificInfo,
+                    memcpy(
+                        (void *)mMp4FileDataPtr->audioTrackPtr->DSI,
+                        (void *)streamDescPtr->decoderSpecificInfo,
                         9);
                 }
                 else
@@ -815,13 +815,13 @@
                     ERR_CHECK(streamDescPtr->decoderSpecificInfoSize == 6,
                         M4ERR_PARAMETER);
                     mMp4FileDataPtr->audioTrackPtr->DSI =
-                        (M4OSA_UChar *)M4OSA_malloc(6, M4MP4_WRITER,
+                        (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(6, M4MP4_WRITER,
                         (M4OSA_Char *)"audioTrackPtr->DSI");
                     ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->DSI != M4OSA_NULL,
                         M4ERR_ALLOC);
-                    M4OSA_memcpy(
-                        (M4OSA_MemAddr8)mMp4FileDataPtr->audioTrackPtr->DSI,
-                        (M4OSA_MemAddr8)streamDescPtr->decoderSpecificInfo,
+                    memcpy(
+                        (void *)mMp4FileDataPtr->audioTrackPtr->DSI,
+                        (void *)streamDescPtr->decoderSpecificInfo,
                         6);
                 }
                 else
@@ -849,14 +849,14 @@
                 if (mMp4FileDataPtr->audioTrackPtr->dsiSize != 0)
                 {
                     mMp4FileDataPtr->audioTrackPtr->DSI =
-                        (M4OSA_UChar *)M4OSA_malloc(
+                        (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(
                         streamDescPtr->decoderSpecificInfoSize,
                         M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->DSI");
                     ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->DSI != M4OSA_NULL,
                         M4ERR_ALLOC);
-                    M4OSA_memcpy(
-                        (M4OSA_MemAddr8)mMp4FileDataPtr->audioTrackPtr->DSI,
-                        (M4OSA_MemAddr8)streamDescPtr->decoderSpecificInfo,
+                    memcpy(
+                        (void *)mMp4FileDataPtr->audioTrackPtr->DSI,
+                        (void *)streamDescPtr->decoderSpecificInfo,
                         streamDescPtr->decoderSpecificInfoSize);
                 }
                 else
@@ -883,7 +883,7 @@
             if (mMp4FileDataPtr->videoTrackPtr == M4OSA_NULL)
             {
                 mMp4FileDataPtr->videoTrackPtr = (M4MP4W_VideoTrackData
-                    *)M4OSA_malloc(sizeof(M4MP4W_VideoTrackData),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4MP4W_VideoTrackData),
                     M4MP4_WRITER, (M4OSA_Char *)"M4MP4W_VideoTrackData");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr != M4OSA_NULL,
                     M4ERR_ALLOC);
@@ -905,7 +905,7 @@
 #ifdef _M4MP4W_MOOV_FIRST
 
                 mMp4FileDataPtr->videoTrackPtr->Chunk =
-                    (M4OSA_UChar ** )M4OSA_malloc(M4MP4W_CHUNK_ALLOC_NB
+                    (M4OSA_UChar ** )M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_ALLOC_NB
                     * sizeof(M4OSA_UChar *),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->Chunk");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->Chunk != M4OSA_NULL,
@@ -915,14 +915,14 @@
                 /*re-use the same chunk and flush it when full*/
 
                 mMp4FileDataPtr->videoTrackPtr->Chunk =
-                    (M4OSA_UChar ** )M4OSA_malloc(sizeof(M4OSA_UChar *),
+                    (M4OSA_UChar ** )M4OSA_32bitAlignedMalloc(sizeof(M4OSA_UChar *),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->Chunk");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->Chunk != M4OSA_NULL,
                     M4ERR_ALLOC);
                 mMp4FileDataPtr->videoTrackPtr->Chunk[0] = M4OSA_NULL;
 
                 mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->chunkOffsetTable");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable
@@ -933,19 +933,19 @@
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->Chunk != M4OSA_NULL,
                     M4ERR_ALLOC);
                 mMp4FileDataPtr->videoTrackPtr->chunkSizeTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->chunkSizeTable");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->chunkSizeTable
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_CHUNK_ALLOC_NB
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_ALLOC_NB
                     * sizeof(M4OSA_UInt32),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->chunkSampleNbTable");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable =
-                    (M4MP4W_Time32 *)M4OSA_malloc(M4MP4W_CHUNK_ALLOC_NB
+                    (M4MP4W_Time32 *)M4OSA_32bitAlignedMalloc(M4MP4W_CHUNK_ALLOC_NB
                     * sizeof(M4MP4W_Time32),
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->chunkTimeMsTable");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable
@@ -954,7 +954,7 @@
                 mMp4FileDataPtr->videoTrackPtr->LastAllocatedChunk = 0;
                 /*tables are now dynamic*/
                 mMp4FileDataPtr->videoTrackPtr->TABLE_STTS =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_STTS_ALLOC_SIZE,
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_STTS_ALLOC_SIZE,
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->TABLE_STTS");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->TABLE_STTS
                     != M4OSA_NULL, M4ERR_ALLOC);
@@ -962,13 +962,13 @@
 #ifdef _M4MP4W_OPTIMIZE_FOR_PHONE
 
                 mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ =
-                    (M4OSA_UInt16 *)M4OSA_malloc(M4MP4W_STSZ_ALLOC_SIZE,
+                    (M4OSA_UInt16 *)M4OSA_32bitAlignedMalloc(M4MP4W_STSZ_ALLOC_SIZE,
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->TABLE_STSZ");
 
 #else
 
                 mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_STSZ_ALLOC_SIZE,
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_STSZ_ALLOC_SIZE,
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->TABLE_STSZ");
 
 #endif
@@ -977,7 +977,7 @@
                     != M4OSA_NULL, M4ERR_ALLOC);
                 mMp4FileDataPtr->videoTrackPtr->nbOfAllocatedStszBlocks = 1;
                 mMp4FileDataPtr->videoTrackPtr->TABLE_STSS =
-                    (M4OSA_UInt32 *)M4OSA_malloc(M4MP4W_STSS_ALLOC_SIZE,
+                    (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(M4MP4W_STSS_ALLOC_SIZE,
                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->TABLE_STSS");
                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->TABLE_STSS
                     != M4OSA_NULL, M4ERR_ALLOC);
@@ -1050,14 +1050,14 @@
                     mMp4FileDataPtr->videoTrackPtr->dsiSize =
                         (M4OSA_UInt8)streamDescPtr->decoderSpecificInfoSize;
                     mMp4FileDataPtr->videoTrackPtr->DSI =
-                        (M4OSA_UChar *)M4OSA_malloc(
+                        (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(
                         streamDescPtr->decoderSpecificInfoSize,
                         M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                     ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI != M4OSA_NULL,
                         M4ERR_ALLOC);
-                    M4OSA_memcpy(
-                        (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->DSI,
-                        (M4OSA_MemAddr8)streamDescPtr->decoderSpecificInfo,
+                    memcpy(
+                        (void *)mMp4FileDataPtr->videoTrackPtr->DSI,
+                        (void *)streamDescPtr->decoderSpecificInfo,
                         streamDescPtr->decoderSpecificInfoSize);
                 }
                 else
@@ -1090,14 +1090,14 @@
                     mMp4FileDataPtr->videoTrackPtr->dsiSize =
                         (M4OSA_UInt8)streamDescPtr->decoderSpecificInfoSize;
                     mMp4FileDataPtr->videoTrackPtr->DSI =
-                        (M4OSA_UChar *)M4OSA_malloc(
+                        (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(
                         streamDescPtr->decoderSpecificInfoSize,
                         M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                     ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI != M4OSA_NULL,
                         M4ERR_ALLOC);
-                    M4OSA_memcpy(
-                        (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->DSI,
-                        (M4OSA_MemAddr8)streamDescPtr->decoderSpecificInfo,
+                    memcpy(
+                        (void *)mMp4FileDataPtr->videoTrackPtr->DSI,
+                        (void *)streamDescPtr->decoderSpecificInfo,
                         streamDescPtr->decoderSpecificInfoSize);
                     mMp4FileDataPtr->filesize +=
                         streamDescPtr->decoderSpecificInfoSize;
@@ -1133,7 +1133,7 @@
 
                         /* Copy the DSI (SPS + PPS) */
                         mMp4FileDataPtr->videoTrackPtr->DSI =
-                            (M4OSA_UChar *)M4OSA_malloc(
+                            (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(
                             streamDescPtr->decoderSpecificInfoSize,
                             M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                         ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI
@@ -1143,25 +1143,25 @@
                             (M4OSA_UInt16 *)streamDescPtr->decoderSpecificInfo;
                         SPSLength = DSI[6];
                         PPSLength = DSI[10];
-                        M4OSA_memcpy(
-                            (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->DSI,
-                            (M4OSA_MemAddr8)(streamDescPtr->
-                            decoderSpecificInfo)+12, 2);
-                        M4OSA_memcpy(
-                            (M4OSA_MemAddr8)(mMp4FileDataPtr->videoTrackPtr->
-                            DSI)+2, (M4OSA_MemAddr8)(streamDescPtr->
-                            decoderSpecificInfo)+28, SPSLength);
+                        memcpy(
+                            (void *)mMp4FileDataPtr->videoTrackPtr->DSI,
+                            (void *)((streamDescPtr->
+                            decoderSpecificInfo)+12), 2);
+                        memcpy(
+                            (void *)((mMp4FileDataPtr->videoTrackPtr->
+                            DSI)+2), (void *)((streamDescPtr->
+                            decoderSpecificInfo)+28), SPSLength);
 
-                        M4OSA_memcpy(
-                            (M4OSA_MemAddr8)(mMp4FileDataPtr->videoTrackPtr->
-                            DSI)+2 + SPSLength,
-                            (M4OSA_MemAddr8)(streamDescPtr->
-                            decoderSpecificInfo)+20, 2);
-                        M4OSA_memcpy(
-                            (M4OSA_MemAddr8)(mMp4FileDataPtr->videoTrackPtr->
-                            DSI)+4 + SPSLength,
-                            (M4OSA_MemAddr8)(streamDescPtr->
-                            decoderSpecificInfo)+28 + SPSLength,
+                        memcpy(
+                            (void *)((mMp4FileDataPtr->videoTrackPtr->
+                            DSI)+2 + SPSLength),
+                            (void *)((streamDescPtr->
+                            decoderSpecificInfo)+20), 2);
+                        memcpy(
+                            (void *)((mMp4FileDataPtr->videoTrackPtr->
+                            DSI)+4 + SPSLength),
+                            (void *)((streamDescPtr->
+                            decoderSpecificInfo)+28 + SPSLength),
                             PPSLength);
                         /* - H.264 trimming */
                     }
@@ -1173,14 +1173,14 @@
 
                         /* Copy the DSI (SPS + PPS) */
                         mMp4FileDataPtr->videoTrackPtr->DSI =
-                            (M4OSA_UChar *)M4OSA_malloc(
+                            (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(
                             streamDescPtr->decoderSpecificInfoSize,
                             M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                         ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI
                             != M4OSA_NULL, M4ERR_ALLOC);
-                        M4OSA_memcpy(
-                            (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->DSI,
-                            (M4OSA_MemAddr8)streamDescPtr->
+                        memcpy(
+                            (void *)mMp4FileDataPtr->videoTrackPtr->DSI,
+                            (void *)streamDescPtr->
                             decoderSpecificInfo,
                             streamDescPtr->decoderSpecificInfoSize);
                     }
@@ -1224,7 +1224,7 @@
 
         /* First audio chunk allocation */
         mMp4FileDataPtr->audioTrackPtr->Chunk[0] = (M4OSA_UChar
-            *)M4OSA_malloc(mMp4FileDataPtr->audioTrackPtr->MaxChunkSize,
+            *)M4OSA_32bitAlignedMalloc(mMp4FileDataPtr->audioTrackPtr->MaxChunkSize,
             M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->Chunk[0]");
         ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->Chunk[0] != M4OSA_NULL,
             M4ERR_ALLOC);
@@ -1240,7 +1240,7 @@
 
         /* First video chunk allocation */
         mMp4FileDataPtr->videoTrackPtr->Chunk[0] = (M4OSA_UChar
-            *)M4OSA_malloc(mMp4FileDataPtr->videoTrackPtr->MaxChunkSize,
+            *)M4OSA_32bitAlignedMalloc(mMp4FileDataPtr->videoTrackPtr->MaxChunkSize,
             M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->Chunk[0]");
         ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->Chunk[0] != M4OSA_NULL,
             M4ERR_ALLOC);
@@ -1363,8 +1363,7 @@
             safetyFileSize += mMp4FileDataPtr->audioTrackPtr->MaxChunkSize;
         }
 
-        M4OSA_memset(dummyData, sizeof(dummyData),
-            0xCA); /* For extra safety. */
+        memset((void *)dummyData, 0xCA,sizeof(dummyData)); /* For extra safety. */
 
         for ( i = 0;
             i < (safetyFileSize + sizeof(dummyData) - 1) / sizeof(dummyData);
@@ -1574,7 +1573,7 @@
 
         mMp4FileDataPtr->audioTrackPtr->
             Chunk[mMp4FileDataPtr->audioTrackPtr->currentChunk] = (M4OSA_UChar
-            *)M4OSA_malloc(mMp4FileDataPtr->audioTrackPtr->MaxChunkSize,
+            *)M4OSA_32bitAlignedMalloc(mMp4FileDataPtr->audioTrackPtr->MaxChunkSize,
             M4MP4_WRITER, (M4OSA_Char *)"audioTrackPtr->currentChunk");
         ERR_CHECK(mMp4FileDataPtr->audioTrackPtr->
             Chunk[mMp4FileDataPtr->audioTrackPtr->currentChunk]
@@ -1815,7 +1814,7 @@
 
         mMp4FileDataPtr->videoTrackPtr->
             Chunk[mMp4FileDataPtr->videoTrackPtr->currentChunk] = (M4OSA_UChar
-            *)M4OSA_malloc(mMp4FileDataPtr->videoTrackPtr->MaxChunkSize,
+            *)M4OSA_32bitAlignedMalloc(mMp4FileDataPtr->videoTrackPtr->MaxChunkSize,
             M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->MaxChunkSize");
         ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->
             Chunk[mMp4FileDataPtr->videoTrackPtr->currentChunk]
@@ -2237,7 +2236,7 @@
                         CommonData.sampleNb
                         * 4 / M4MP4W_STSZ_AUDIO_ALLOC_SIZE;
                     mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ =
-                        (M4OSA_UInt32 *)M4OSA_malloc(
+                        (M4OSA_UInt32 *)M4OSA_32bitAlignedMalloc(
                         mMp4FileDataPtr->audioTrackPtr->
                         nbOfAllocatedStszBlocks
                         * M4MP4W_STSZ_AUDIO_ALLOC_SIZE,
@@ -2880,7 +2879,6 @@
 
 #ifndef _M4MP4W_MOOV_FIRST
 
-    M4OSA_UInt32 filePos;
     M4OSA_FilePosition moovPos, mdatPos;
 
 #endif /*_M4MP4W_MOOV_FIRST*/
@@ -3617,12 +3615,8 @@
 
 #endif /*_M4MP4W_MOOV_FIRST*/
 
-    /* Pierre Lebeaupin 19/12/2007: changing the way the mdat size is computed. */
 #ifndef _M4MP4W_MOOV_FIRST
     /* seek is used to get the current position relative to the start of the file. */
-    /* M4OSA_INT_TO_FILE_POSITION(0, moovPos);
-    /CLEANUPonERR( mMp4FileDataPtr->fileWriterFunctions->seek(mMp4FileDataPtr->fileWriterContext,
-     M4OSA_kFileSeekCurrent, &moovPos) ); */
     /* ... or rather, seek used to be used for that, but it has been found this functionality
     is not reliably, or sometimes not at all, implemented in the various OSALs, so we now avoid
     using it. */
@@ -3635,9 +3629,6 @@
     /* moovPos will be used after writing the moov. */
 
 #endif /*_M4MP4W_MOOV_FIRST*/
-    /* End of Pierre Lebeaupin 19/12/2007: changing the way the mdat size is computed. */
-
-    /*moov*/
 
     CLEANUPonERR(M4MP4W_putBE32(moovSize, mMp4FileDataPtr->fileWriterFunctions,
         fileWriterContext));
@@ -4512,13 +4503,12 @@
     /*overwrite mdat size*/
 
     if (mMp4FileDataPtr->ftyp.major_brand != 0)
-        filePos = 16 + mMp4FileDataPtr->ftyp.nbCompatibleBrands * 4;
+        mdatPos= 16 + mMp4FileDataPtr->ftyp.nbCompatibleBrands * 4;
     else
-        filePos = 24;
+        mdatPos = 24;
 
-    M4OSA_INT_TO_FILE_POSITION(filePos, mdatPos);
-    M4OSA_FPOS_SUB(moovPos, moovPos, mdatPos);
-    M4OSA_FILE_POSITION_TO_INT(moovPos, mdatSize);
+    moovPos = moovPos - mdatPos;
+    mdatSize = moovPos;
 
     CLEANUPonERR(mMp4FileDataPtr->fileWriterFunctions->seek(fileWriterContext,
         M4OSA_kFileSeekBeginning, &mdatPos)); /*seek after ftyp...*/
@@ -4579,14 +4569,14 @@
 
     if (M4OSA_NULL != mMp4FileDataPtr->embeddedString)
     {
-        M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->embeddedString);
+        free(mMp4FileDataPtr->embeddedString);
         mMp4FileDataPtr->embeddedString = M4OSA_NULL;
     }
 
     /* Delete integration tag */
     if (M4OSA_NULL != mMp4FileDataPtr->integrationTag)
     {
-        M4OSA_free((M4OSA_MemAddr32)mMp4FileDataPtr->integrationTag);
+        free(mMp4FileDataPtr->integrationTag);
         mMp4FileDataPtr->integrationTag = M4OSA_NULL;
     }
 
@@ -4707,11 +4697,11 @@
         memAddrPtr->size = 16;
         /*if no value was set, return the default string */
         if (mMp4FileDataPtr->embeddedString != M4OSA_NULL)
-            M4OSA_memcpy((M4OSA_MemAddr8)memAddrPtr->addr,
-            (M4OSA_MemAddr8)mMp4FileDataPtr->embeddedString, 16);
+            memcpy((void *)memAddrPtr->addr,
+            (void *)mMp4FileDataPtr->embeddedString, 16);
         else
-            M4OSA_memcpy((M4OSA_MemAddr8)memAddrPtr->addr,
-            (M4OSA_MemAddr8)BlockSignatureSkipDefaultEmbeddedString,
+            memcpy((void *)memAddrPtr->addr,
+            (void *)BlockSignatureSkipDefaultEmbeddedString,
             16);
         break;
 
@@ -4725,11 +4715,11 @@
         memAddrPtr->size = 60;
         /*if no value was set, return the default string 0 */
         if (mMp4FileDataPtr->integrationTag != M4OSA_NULL)
-            M4OSA_memcpy((M4OSA_MemAddr8)memAddrPtr->addr,
-            (M4OSA_MemAddr8)mMp4FileDataPtr->integrationTag, 60);
+            memcpy((void *)memAddrPtr->addr,
+            (void *)mMp4FileDataPtr->integrationTag, 60);
         else
-            M4OSA_memcpy((M4OSA_MemAddr8)memAddrPtr->addr,
-            (M4OSA_MemAddr8)BlockSignatureSkipDefaultIntegrationTag,
+            memcpy((void *)memAddrPtr->addr,
+            (void *)BlockSignatureSkipDefaultIntegrationTag,
             60);
         break;
 
@@ -4956,14 +4946,14 @@
             if (mMp4FileDataPtr->embeddedString == M4OSA_NULL)
             {
                 mMp4FileDataPtr->embeddedString =
-                    (M4OSA_UChar *)M4OSA_malloc(16, M4MP4_WRITER,
+                    (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(16, M4MP4_WRITER,
                     (M4OSA_Char *)"embeddedString");
                 ERR_CHECK(mMp4FileDataPtr->embeddedString != M4OSA_NULL,
                     M4ERR_ALLOC);
             }
             /*else, just overwrite the previously set string*/
-            M4OSA_memcpy((M4OSA_MemAddr8)mMp4FileDataPtr->embeddedString,
-                (M4OSA_MemAddr8)memAddrPtr->addr, 16);
+            memcpy((void *)mMp4FileDataPtr->embeddedString,
+                (void *)memAddrPtr->addr, 16);
             break;
 
         case (M4MP4W_integrationTag):
@@ -4975,7 +4965,7 @@
             if (mMp4FileDataPtr->integrationTag == M4OSA_NULL)
             {
                 mMp4FileDataPtr->integrationTag =
-                    (M4OSA_UChar *)M4OSA_malloc(60, M4MP4_WRITER,
+                    (M4OSA_UChar *)M4OSA_32bitAlignedMalloc(60, M4MP4_WRITER,
                     (M4OSA_Char *)"integrationTag");
                 ERR_CHECK(mMp4FileDataPtr->integrationTag != M4OSA_NULL,
                     M4ERR_ALLOC);
@@ -4983,16 +4973,16 @@
             /*else, just overwrite the previously set string*/
             if (memAddrPtr->size < 60)
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)mMp4FileDataPtr->integrationTag,
-                    (M4OSA_MemAddr8)BlockSignatureSkipDefaultIntegrationTag,
+                memcpy((void *)mMp4FileDataPtr->integrationTag,
+                    (void *)BlockSignatureSkipDefaultIntegrationTag,
                     60);
-                M4OSA_memcpy((M4OSA_MemAddr8)mMp4FileDataPtr->integrationTag,
-                    (M4OSA_MemAddr8)memAddrPtr->addr, memAddrPtr->size);
+                memcpy((void *)mMp4FileDataPtr->integrationTag,
+                    (void *)memAddrPtr->addr, memAddrPtr->size);
             }
             else
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)mMp4FileDataPtr->integrationTag,
-                    (M4OSA_MemAddr8)memAddrPtr->addr, 60);
+                memcpy((void *)mMp4FileDataPtr->integrationTag,
+                    (void *)memAddrPtr->addr, 60);
             }
             break;
 
@@ -5180,14 +5170,14 @@
                                 mMp4FileDataPtr->videoTrackPtr->dsiSize =
                                     (M4OSA_UInt8)streamIDmemAddrPtr->size;
                                 mMp4FileDataPtr->videoTrackPtr->DSI = (M4OSA_UChar
-                                    *)M4OSA_malloc(streamIDmemAddrPtr->size,
+                                    *)M4OSA_32bitAlignedMalloc(streamIDmemAddrPtr->size,
                                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI
                                     != M4OSA_NULL, M4ERR_ALLOC);
-                                M4OSA_memcpy(
-                                    (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->
+                                memcpy(
+                                    (void *)mMp4FileDataPtr->videoTrackPtr->
                                     DSI,
-                                    (M4OSA_MemAddr8)streamIDmemAddrPtr->addr,
+                                    (void *)streamIDmemAddrPtr->addr,
                                     streamIDmemAddrPtr->size);
 
                                 break;
@@ -5216,14 +5206,14 @@
                                 mMp4FileDataPtr->videoTrackPtr->dsiSize =
                                     (M4OSA_UInt8)streamIDmemAddrPtr->size;
                                 mMp4FileDataPtr->videoTrackPtr->DSI = (M4OSA_UChar
-                                    *)M4OSA_malloc(streamIDmemAddrPtr->size,
+                                    *)M4OSA_32bitAlignedMalloc(streamIDmemAddrPtr->size,
                                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI
                                     != M4OSA_NULL, M4ERR_ALLOC);
-                                M4OSA_memcpy(
-                                    (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->
+                                memcpy(
+                                    (void *)mMp4FileDataPtr->videoTrackPtr->
                                     DSI,
-                                    (M4OSA_MemAddr8)streamIDmemAddrPtr->addr,
+                                    (void *)streamIDmemAddrPtr->addr,
                                     streamIDmemAddrPtr->size);
                                 mMp4FileDataPtr->filesize +=
                                     streamIDmemAddrPtr->size;
@@ -5238,8 +5228,7 @@
                                     /* + H.264 trimming */
                                     if (M4OSA_TRUE == mMp4FileDataPtr->bMULPPSSPS)
                                     {
-                                        M4OSA_free(
-                                            (M4OSA_MemAddr32)mMp4FileDataPtr->videoTrackPtr->DSI);
+                                        free(mMp4FileDataPtr->videoTrackPtr->DSI);
 
                                         // Do not strip the DSI
                                         /* Store the DSI size */
@@ -5249,14 +5238,14 @@
                                             ,mMp4FileDataPtr->videoTrackPtr->dsiSize);
                                         /* Copy the DSI (SPS + PPS) */
                                         mMp4FileDataPtr->videoTrackPtr->DSI =
-                                            (M4OSA_UChar*)M4OSA_malloc(
+                                            (M4OSA_UChar*)M4OSA_32bitAlignedMalloc(
                                             streamIDmemAddrPtr->size, M4MP4_WRITER,
                                             (M4OSA_Char *)"videoTrackPtr->DSI");
                                         ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI !=
                                              M4OSA_NULL, M4ERR_ALLOC);
-                                        M4OSA_memcpy(
-                                            (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->DSI,
-                                            (M4OSA_MemAddr8)streamIDmemAddrPtr->addr,
+                                        memcpy(
+                                            (void *)mMp4FileDataPtr->videoTrackPtr->DSI,
+                                            (void *)streamIDmemAddrPtr->addr,
                                             streamIDmemAddrPtr->size);
 
                                         break;
@@ -5284,14 +5273,14 @@
 
                                 /* Copy the DSI (SPS + PPS) */
                                 mMp4FileDataPtr->videoTrackPtr->DSI = (M4OSA_UChar
-                                    *)M4OSA_malloc(streamIDmemAddrPtr->size,
+                                    *)M4OSA_32bitAlignedMalloc(streamIDmemAddrPtr->size,
                                     M4MP4_WRITER, (M4OSA_Char *)"videoTrackPtr->DSI");
                                 ERR_CHECK(mMp4FileDataPtr->videoTrackPtr->DSI
                                     != M4OSA_NULL, M4ERR_ALLOC);
-                                M4OSA_memcpy(
-                                    (M4OSA_MemAddr8)mMp4FileDataPtr->videoTrackPtr->
+                                memcpy(
+                                    (void *)mMp4FileDataPtr->videoTrackPtr->
                                     DSI,
-                                    (M4OSA_MemAddr8)streamIDmemAddrPtr->addr,
+                                    (void *)streamIDmemAddrPtr->addr,
                                     streamIDmemAddrPtr->size);
                                 break;
 
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/M4DA_Types.h b/libvideoeditor/vss/common/inc/M4DA_Types.h
index d41f934..0779bf9 100755
--- a/libvideoeditor/vss/common/inc/M4DA_Types.h
+++ b/libvideoeditor/vss/common/inc/M4DA_Types.h
@@ -83,7 +83,7 @@
     M4_StreamType    m_streamType;                /**< Stream type */
     M4OSA_UInt32    m_streamId;                    /**< Stream Id (unique number definning
                                                         the stream) */
-    M4OSA_Int64        m_duration;                    /**< Duration of the stream in milli
+    M4OSA_Int32        m_duration;                    /**< Duration of the stream in milli
                                                             seconds */
     M4OSA_UInt32    m_averageBitRate;            /**< Average bitrate in kb/s */
     M4OSA_UInt32    m_maxAUSize;                /**< Maximum size of an Access Unit */
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 @@
 #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 @@
 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/M4VD_Tools.h b/libvideoeditor/vss/common/inc/M4VD_Tools.h
old mode 100644
new mode 100755
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/common/inc/M4_VideoEditingCommon.h b/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
index d68c881..79831bb 100755
--- a/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
+++ b/libvideoeditor/vss/common/inc/M4_VideoEditingCommon.h
@@ -112,34 +112,38 @@
 */
 typedef enum
 {
-    M4VIDEOEDITING_kMPEG4_SP_Level_0               = 0,
-    M4VIDEOEDITING_kMPEG4_SP_Level_0b              = 1,
-    M4VIDEOEDITING_kMPEG4_SP_Level_1               = 2,
-    M4VIDEOEDITING_kMPEG4_SP_Level_2               = 3,
-    M4VIDEOEDITING_kMPEG4_SP_Level_3               = 4,
-    M4VIDEOEDITING_kH263_Profile_0_Level_10        = 5,
-    M4VIDEOEDITING_kH263_Profile_0_Level_20        = 6,
-    M4VIDEOEDITING_kH263_Profile_0_Level_30        = 7,
-    M4VIDEOEDITING_kH263_Profile_0_Level_40        = 8,
-    M4VIDEOEDITING_kH263_Profile_0_Level_45        = 9,
-    M4VIDEOEDITING_kMPEG4_SP_Level_4a              = 10,
-    M4VIDEOEDITING_kMPEG4_SP_Level_5               = 11,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1         = 12,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1b        = 13,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_1       = 14,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_2       = 15,
-    M4VIDEOEDITING_kH264_Profile_0_Level_1_3       = 16,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2         = 17,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2_1       = 18,
-    M4VIDEOEDITING_kH264_Profile_0_Level_2_2       = 19,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3         = 20,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3_1       = 21,
-    M4VIDEOEDITING_kH264_Profile_0_Level_3_2       = 22,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4         = 23,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4_1       = 24,
-    M4VIDEOEDITING_kH264_Profile_0_Level_4_2       = 25,
-    M4VIDEOEDITING_kH264_Profile_0_Level_5         = 26,
-    M4VIDEOEDITING_kH264_Profile_0_Level_5_1       = 27,
+    /* H.263 Profiles and levels */
+    M4VIDEOEDITING_kH263_Profile_0_Level_10        = 0,
+    M4VIDEOEDITING_kH263_Profile_0_Level_20        = 1,
+    M4VIDEOEDITING_kH263_Profile_0_Level_30        = 2,
+    M4VIDEOEDITING_kH263_Profile_0_Level_40        = 3,
+    M4VIDEOEDITING_kH263_Profile_0_Level_45        = 4,
+    /* MPEG-4 Profiles and levels */
+    M4VIDEOEDITING_kMPEG4_SP_Level_0               = 50,
+    M4VIDEOEDITING_kMPEG4_SP_Level_0b              = 51,
+    M4VIDEOEDITING_kMPEG4_SP_Level_1               = 52,
+    M4VIDEOEDITING_kMPEG4_SP_Level_2               = 53,
+    M4VIDEOEDITING_kMPEG4_SP_Level_3               = 54,
+    M4VIDEOEDITING_kMPEG4_SP_Level_4a              = 55,
+    M4VIDEOEDITING_kMPEG4_SP_Level_5               = 56,
+    /* AVC Profiles and levels */
+    M4VIDEOEDITING_kH264_Profile_0_Level_1         = 150,
+    M4VIDEOEDITING_kH264_Profile_0_Level_1b        = 151,
+    M4VIDEOEDITING_kH264_Profile_0_Level_1_1       = 152,
+    M4VIDEOEDITING_kH264_Profile_0_Level_1_2       = 153,
+    M4VIDEOEDITING_kH264_Profile_0_Level_1_3       = 154,
+    M4VIDEOEDITING_kH264_Profile_0_Level_2         = 155,
+    M4VIDEOEDITING_kH264_Profile_0_Level_2_1       = 156,
+    M4VIDEOEDITING_kH264_Profile_0_Level_2_2       = 157,
+    M4VIDEOEDITING_kH264_Profile_0_Level_3         = 158,
+    M4VIDEOEDITING_kH264_Profile_0_Level_3_1       = 159,
+    M4VIDEOEDITING_kH264_Profile_0_Level_3_2       = 160,
+    M4VIDEOEDITING_kH264_Profile_0_Level_4         = 161,
+    M4VIDEOEDITING_kH264_Profile_0_Level_4_1       = 162,
+    M4VIDEOEDITING_kH264_Profile_0_Level_4_2       = 163,
+    M4VIDEOEDITING_kH264_Profile_0_Level_5         = 164,
+    M4VIDEOEDITING_kH264_Profile_0_Level_5_1       = 165,
+    /* Unsupported profile and level */
     M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range = 255
 } M4VIDEOEDITING_VideoProfileAndLevel;
 
diff --git a/libvideoeditor/vss/common/inc/VideoEditorResampler.h b/libvideoeditor/vss/common/inc/VideoEditorResampler.h
index fe9876c..c4e3a89 100755
--- a/libvideoeditor/vss/common/inc/VideoEditorResampler.h
+++ b/libvideoeditor/vss/common/inc/VideoEditorResampler.h
@@ -23,13 +23,13 @@
 
 #include "M4OSA_Types.h"
 
-M4OSA_Int32 LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
+M4OSA_Context LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
                                      M4OSA_Int32 sampleRate, M4OSA_Int32 quality);
-void LVAudiosetSampleRate(M4OSA_Int32 resamplerContext,M4OSA_Int32 inSampleRate);
-void LVAudiosetVolume(M4OSA_Int32 resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) ;
+void LVAudiosetSampleRate(M4OSA_Context resamplerContext,M4OSA_Int32 inSampleRate);
+void LVAudiosetVolume(M4OSA_Context resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) ;
 void LVAudioresample_LowQuality(M4OSA_Int16* out, M4OSA_Int16* input,
-                                     M4OSA_Int32 outFrameCount, M4OSA_Int32 resamplerContext);
-void LVDestroy(M4OSA_Int32 resamplerContext);
+                                     M4OSA_Int32 outFrameCount, M4OSA_Context resamplerContext);
+void LVDestroy(M4OSA_Context resamplerContext);
 
 void MonoTo2I_16( const M4OSA_Int16 *src,
                         M4OSA_Int16 *dst,
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_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 @@
      *    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_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_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 @@
 #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_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 069b84d..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
@@ -84,14 +80,21 @@
 
 typedef enum
 {
-    M4VSS3GPP_kEditVideoState_READ_WRITE    = 10,    /**< Doing Read/Write operation
-                                                        (no decoding/encoding) */
-    M4VSS3GPP_kEditVideoState_BEGIN_CUT     = 11,    /**< Decode encode to create an I frame */
-    M4VSS3GPP_kEditVideoState_DECODE_ENCODE = 12,    /**< Doing Read-Decode/Filter/
-                                                        Encode-Write operation */
-    M4VSS3GPP_kEditVideoState_TRANSITION    = 13,    /**< Transition; blending of two videos */
-    M4VSS3GPP_kEditVideoState_AFTER_CUT     = 14    /**< Special Read/Write mode after a
-                                                            begin cut (time frozen) */
+    /**< Doing Read/Write operation. This operation will have no processing
+     * on input frames. Only time stamp manipulations in output file. */
+    M4VSS3GPP_kEditVideoState_READ_WRITE    = 10,
+    /**< Decode encode to create an I frame. This is done for a single frame
+     * to create a new reference frame. */
+    M4VSS3GPP_kEditVideoState_BEGIN_CUT     = 11,
+    /**< Doing Read->Decode->Filter->Encode->Write operation on the input file
+     * to create the output file. */
+    M4VSS3GPP_kEditVideoState_DECODE_ENCODE = 12,
+    /**< Applied when Transition is active and blending of two videos is
+     * required. */
+    M4VSS3GPP_kEditVideoState_TRANSITION    = 13,
+    /**< Special Read/Write mode used after BEGIN_CUT state. The frame
+     * is already coded as I frame in BEGIN_CUT state; so skip it. */
+    M4VSS3GPP_kEditVideoState_AFTER_CUT     = 14
 }
 M4VSS3GPP_EditVideoState;
 
@@ -592,24 +595,13 @@
      * 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 */
     M4OSA_Bool               m_bClipExternalHasStarted;  /**< Flag to indicate that an
                                                               external effect is active */
+    M4OSA_Int32              iInOutTimeOffset;
+    M4OSA_Bool               bEncodeTillEoF;
 } M4VSS3GPP_InternalEditContext;
 
 
@@ -716,7 +708,7 @@
     M4OSA_Bool                  bDoDucking;
     M4OSA_Bool                  bLoop;
     M4OSA_Bool                  bNoLooping;
-    M4OSA_Int32                 pLVAudioResampler;
+    M4OSA_Context              pLVAudioResampler;
     M4OSA_Bool                  bjumpflag;
 
 } M4VSS3GPP_InternalAudioMixingContext;
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_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 9bed7b7..e999867 100755
--- a/libvideoeditor/vss/inc/M4xVSS_Internal.h
+++ b/libvideoeditor/vss/inc/M4xVSS_Internal.h
@@ -335,9 +335,6 @@
     M4OSA_Bool                                bAudioMono;
     M4VIDEOEDITING_Bitrate                    OutputVideoBitrate;
     M4VIDEOEDITING_Bitrate                    OutputAudioBitrate;
-#ifdef TIMESCALE_BUG
-    M4OSA_UInt32                            OutputVideoTimescale;
-#endif
     M4OSA_Bool                                isBGM;
     /**< This boolean is used to know if the output file is already created or not */
     M4OSA_Bool                                isCreated;
@@ -389,17 +386,6 @@
  *            a JPEG by chunk mode.
  ******************************************************************************
 */
-#if 0
-typedef struct {
-    M4OSA_FileReadPointer*    m_pFileReadPtr;
-    M4OSA_Context            m_pJPEGFileIn;
-    M4OSA_Void*                m_pFileIn;
-    M4SPS_Stream            m_inputStream;
-    M4OSA_UInt32            m_total_read;
-    M4OSA_UInt32            m_fileSize;
-
-} M4xVSS_internalJpegChunkMode;
-#endif
 
 /**
  ******************************************************************************
@@ -493,20 +479,6 @@
     /*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 16c4fd9..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 @@
     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,181 +566,6 @@
  */
 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);
-
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_getExifInfo(M4MCS_Context pContext);
- * @brief    Retrieve the EXIF tags informations from a Still picture
- * @note    This function will allocate and fill a Exif tag struct
- *            exifTags structure must be allocated/deallocated by the user
- *            exifTags members will point to internal SPE information, user should not try
- *          to modify or deallocate them
- * @param    pContext            (IN) MCS context
- * @return    M4NO_ERROR:            No error
- * @return    M4ERR_PARAMETER:    pContext is M4OSA_NULL
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_getExifInfo(M4MCS_Context pContext, M4MCS_ExifInfos* exifTags);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerAudioEncoderExtended(M4MCS_Context pContext,
- *                                     M4ENCODER_AudioFormat encoderType,
- *                                     M4ENCODER_AudioGlobalInterface    *pEncoderInterface,
- *                                     M4OSA_Void* pUserData);
- * @brief    Registers an external Audio Encoder
- * @note This is much different from the external audio encoder to cope up with specific
- *       requirement of OMX codec implementation.
- * @param  pContext           (IN) MCS context
- * @param  encoderType        (IN) Type of encoder
- * @param  pEncoderInterface  (IN) Encoder interface to OMX shell function
- * @param  pUserData          (IN) Pointer on a user data to give to external encoder
- *                                 (OMX Core Context)
- * @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_registerAudioEncoderExtended(M4MCS_Context pContext,
-                                     M4ENCODER_AudioFormat encoderType,
-                                     M4ENCODER_AudioGlobalInterface    *pEncoderInterface,
-                                     M4OSA_Void* pUserData);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerVideoDecoderExtended(M4MCS_Context    context,
-                                     M4VD_VideoType        decoderType,
-                                     M4DECODER_VideoInterface    *pDecoderInterface,
-                                     M4OSA_Void* pUserData)
- * @brief    Registers an external Video decoder
- * @note This is much different from the external video decoder to cope up with specific
- *       requirement of OMX codec implementation.
- * @param  pContext           (IN) MCS context
- * @param  decoderType        (IN) Type of decoder (MPEG4 ...)
- * @param  pVidDecoderInterface  (IN) Decoder interface of type 'M4DECODER_VideoInterface'
- * @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_registerVideoDecoderExtended(M4MCS_Context    context,
-                                     M4VD_VideoType        decoderType,
-                                     M4OSA_Context    pVidDecoderInterface,
-                                     M4OSA_Void* pUserData);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerVideoEncoderExtended()
- * @brief    Registers an external Video encoder
- * @note This is much different from the external video encoder to cope up with specific
- *       requirement of OMX codec implementation.
-             So we use M4ENCODER_GlobalInterface instead of M4VE_Interface.
- * @param  pContext           (IN) MCS context
- * @param  encoderType        (IN) Type of encoder (MPEG4 ...)
- * @param  pEncoderInterface  (IN) Encoder interface of type 'M4ENCODER_VideoInterface'
- * @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:        MCS is not in an appropriate state for this function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_registerVideoEncoderExtended(M4MCS_Context pContext,
-                                     M4VE_EncoderType encoderType,
-                                     M4OSA_Context    pEncoderInterface,
-                                     M4OSA_Void* pUserData);
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerAudioDecoderExtended(M4MCS_Context pContext,
-                                     M4AD_Type decoderType,
-                                     M4AD_Interface    *pDecoderInterface,
-                                     M4OSA_Void* pUserData);
- * @brief    Registers an external Audio Decoder
- * @note This is much different from the external audio decoder to cope up with specific
- *       requirement of OMX codec implementation.
- * @param  pContext           (IN) MCS context
- * @param  decoderType        (IN) Type of decoder
- * @param  pDecoderInterface  (IN) Decoder interface to OMX shell function
- * @param  pUserData          (IN) Pointer on a user data to give to external decoder
- *                                 (OMX Core Context)
- * @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_registerAudioDecoderExtended(M4MCS_Context pContext,
-                                     M4AD_Type decoderType,
-                                     M4AD_Interface    *pDecoderInterface,
-                                     M4OSA_Void* pUserData);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h b/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
index b9d60d2..cd3a7f3 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
@@ -119,6 +119,6 @@
 /* ----- OTHERS ERRORS ----- */
 #define M4MCS_ERR_OUTPUT_FILE_SIZE_TOO_SMALL                M4OSA_ERR_CREATE( M4_ERR, M4MCS, 0x50)
 #define M4MCS_ERR_NOMORE_SPACE                              M4OSA_ERR_CREATE(M4_ERR, M4MCS, 0x51)
-
+#define M4MCS_ERR_FILE_DRM_PROTECTED                        M4OSA_ERR_CREATE(M4_ERR, M4MCS, 0x52)
 #endif /* __M4MCS_ErrorCodes_H__ */
 
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_InternalFunctions.h b/libvideoeditor/vss/mcs/inc/M4MCS_InternalFunctions.h
index 422e40d..597a591 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_InternalFunctions.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_InternalFunctions.h
@@ -337,31 +337,6 @@
                                             M4OSA_UInt32 uiPCMsize,
                                             M4MCS_ExternalProgress *pProgress);
 
-#ifdef TIMESCALE_BUG
-/**
- ************************************************************************
- * 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
- * @param
- * @return
- ************************************************************************
- */
-M4OSA_ERR M4MCS_intParseVideoDSI(M4MCS_InternalContext* pC);
-
-/**
- ************************************************************************
- * M4OSA_ERR M4MCS_intChangeAUVideoTimescale( )
- * @brief
- * @note
- * @param    pC           (IN/OUT) Internal edit context
- * @return
- ************************************************************************
- */
-M4OSA_ERR M4MCS_intChangeAUVideoTimescale(M4MCS_InternalContext* pC);
-#endif /* TIMESCALE_BUG */
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h b/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
index 9611fcf..ca63cc0 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_InternalTypes.h
@@ -127,28 +127,6 @@
     M4MCS_kStreamState_FINISHED  = 2    /**< The stream has finished encoding    */
 } M4MCS_StreamState;
 
-#ifdef TIMESCALE_BUG
-/**
- ******************************************************************************
- * enum            M4MCS_VolParse
- * @brief        VOL parsing results needed for VOP parsing
- ******************************************************************************
- */
-typedef struct
-{
-    M4OSA_UInt8 video_object_layer_shape;
-    M4OSA_UInt8 sprite_enable;
-    M4OSA_UInt8 reduced_resolution_vop_enable;
-    M4OSA_UInt8 scalability;
-    M4OSA_UInt8 enhancement_type;
-    M4OSA_UInt8 complexity_estimation_disable;
-    M4OSA_UInt8 interlaced;
-    M4OSA_UInt8 sprite_warping_points;
-    M4OSA_UInt8 sprite_brightness_change;
-    M4OSA_UInt8 quant_precision;
-
-} M4MCS_VolParse;
-#endif
 
 /**
  ******************************************************************************
@@ -437,13 +415,6 @@
     M4OSA_UInt32            uiAudioBitrate;     /**< Targeted audio bitrate in bps */
     M4OSA_UInt32            uiVideoBitrate;     /**< Targeted video bitrate in bps */
 
-#ifdef TIMESCALE_BUG
-    M4OSA_UInt32    uiVideoTimescale;     /**< Targeted timescale without decode/encode process */
-    M4OSA_UInt32    uiTimescaleLength;    /**< Length of the VOP time increment in bits */
-    M4OSA_UInt32    uiOrigVideoTimescale; /**< Original timescale */
-    M4OSA_UInt32    uiOrigTimescaleLength;/**< Original length of the VOP time increment in bits*/
-    M4MCS_VolParse  volParsing;           /**< VOL parsing results needed for VOP parsing */
-#endif
     M4OSA_UInt8     uiProgress;  /**< Progress information saved at each step to be able to
                                       return it in case of pause */
 
@@ -511,7 +482,7 @@
     M4OSA_MemAddr8         pPosInSsrcBufferIn; /**< Position into the SSRC in buffer */
     M4OSA_MemAddr8         pPosInSsrcBufferOut;/**< Position into the SSRC out buffer */
 
-    M4OSA_Int32            *pLVAudioResampler;
+    M4OSA_Context          pLVAudioResampler;
 
 
     /**
diff --git a/libvideoeditor/vss/mcs/src/Android.mk b/libvideoeditor/vss/mcs/src/Android.mk
index 707a583..d1d48bb 100755
--- a/libvideoeditor/vss/mcs/src/Android.mk
+++ b/libvideoeditor/vss/mcs/src/Android.mk
@@ -28,7 +28,6 @@
 LOCAL_SRC_FILES:=          \
       M4MCS_API.c \
       M4MCS_AudioEffects.c \
-      M4MCS_BitstreamParser.c \
       M4MCS_Codecs.c \
       M4MCS_MediaAndCodecSubscription.c \
       M4MCS_VideoPreProcessing.c
@@ -58,10 +57,5 @@
 LOCAL_CFLAGS += -Wno-multichar \
     -DM4MCS_WITH_FAST_OPEN
 
-
-# Don't prelink this library.  For more efficient code, you may want
-# to add this library to the prelink map and set this to true.
-LOCAL_PRELINK_MODULE := false
-
 include $(BUILD_STATIC_LIBRARY)
 
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index d04befa..8bed904 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -151,7 +151,7 @@
 {
     NSWAVC_MCS_t *p_bs = M4OSA_NULL;
     M4OSA_ERR err = M4NO_ERROR;
-    p_bs = (NSWAVC_MCS_t *)M4OSA_malloc(sizeof(NSWAVC_MCS_t), M4MCS,
+    p_bs = (NSWAVC_MCS_t *)M4OSA_32bitAlignedMalloc(sizeof(NSWAVC_MCS_t), M4MCS,
         (M4OSA_Char *)"NSWAVC_MCS_t");
 
     if( M4OSA_NULL == p_bs )
@@ -756,8 +756,8 @@
 
     // StageFright codecs may add a start code, make sure it is not present
 
-    if( !M4OSA_memcmp((M4OSA_MemAddr8)inbuff,
-        (M4OSA_MemAddr8)"\x00\x00\x00\x01", 4) )
+    if( !memcmp((void *)inbuff,
+        "\x00\x00\x00\x01", 4) )
     {
         M4OSA_TRACE1_3(
             "H264MCS_ProcessNALU ERROR : NALU start code has not been removed %d "
@@ -768,9 +768,9 @@
     }
 
     // StageFright encoder does not provide the size in the first 4 bytes of the AU, add it
-    pTmpBuff1 = (M4OSA_Int8 *)M4OSA_malloc(inbuf_size + 4, M4MCS,
+    pTmpBuff1 = (M4OSA_Int8 *)M4OSA_32bitAlignedMalloc(inbuf_size + 4, M4MCS,
         (M4OSA_Char *)"tmpNALU");
-    M4OSA_memcpy((M4OSA_MemAddr8)(pTmpBuff1 + 4), (M4OSA_MemAddr8)inbuff,
+    memcpy((void *)(pTmpBuff1 + 4), (void *)inbuff,
         inbuf_size);
     pTmpBuff1[3] = ( (M4OSA_UInt32)inbuf_size) & 0x000000FF;
     pTmpBuff1[2] = ( (M4OSA_UInt32)inbuf_size >> 8) & 0x000000FF;
@@ -1006,7 +1006,7 @@
 
     // StageFright encoder does not provide the size in the first 4 bytes of the AU, add it
 
-    M4OSA_free((M4OSA_MemAddr32)pTmpBuff1);
+    free(pTmpBuff1);
     pTmpBuff1 = M4OSA_NULL;
     inbuff = (M4OSA_UInt8 *)pTmpBuff2;
 
@@ -1566,7 +1566,7 @@
         instance->final_PPS_ID = Clip_PPSID[cnt];
 
         instance->m_pFinalDSI =
-            (M4OSA_UInt8 *)M4OSA_malloc(instance->m_decoderSpecificInfoSize,
+            (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(instance->m_decoderSpecificInfoSize,
             M4MCS, (M4OSA_Char *)"instance->m_pFinalDSI");
 
         if( instance->m_pFinalDSI == M4OSA_NULL )
@@ -1576,8 +1576,8 @@
         }
 
         instance->m_pFinalDSISize = instance->m_decoderSpecificInfoSize;
-        M4OSA_memcpy((M4OSA_MemAddr8)instance->m_pFinalDSI,
-            (M4OSA_MemAddr8)instance->m_pDecoderSpecificInfo,
+        memcpy((void *)instance->m_pFinalDSI,
+            (void *)instance->m_pDecoderSpecificInfo,
             instance->m_decoderSpecificInfoSize);
     }
     else
@@ -1596,7 +1596,7 @@
         size = instance->m_decoderSpecificInfoSize + instance->m_encoderPPSSize
             + 10;
 
-        instance->m_pFinalDSI = (M4OSA_UInt8 *)M4OSA_malloc(size, M4MCS,
+        instance->m_pFinalDSI = (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(size, M4MCS,
             (M4OSA_Char *)"instance->m_pFinalDSI");
 
         if( instance->m_pFinalDSI == M4OSA_NULL )
@@ -1605,8 +1605,8 @@
             return M4ERR_ALLOC;
         }
 
-        M4OSA_memcpy((M4OSA_MemAddr8)instance->m_pFinalDSI,
-            (M4OSA_MemAddr8)instance->m_pDecoderSpecificInfo,
+        memcpy((void *)instance->m_pFinalDSI,
+            (void *)instance->m_pDecoderSpecificInfo,
             instance->m_decoderSpecificInfoSize);
 
         temp = instance->m_pFinalDSI[lClipDSI_PPS_offset];
@@ -1955,8 +1955,8 @@
         else
         {
             p_bs->Buffer = p_bs->Buffer - 5;
-            M4OSA_memcpy((M4OSA_MemAddr8) &outbuff[outbuffpos],
-                (M4OSA_MemAddr8)p_bs->Buffer, nal_size + 4);
+            memcpy((void *) &outbuff[outbuffpos],
+                (void *)p_bs->Buffer, nal_size + 4);
 
             outbuff[outbuffpos] = (M4OSA_UInt8)((nal_size >> 24)& 0xFF);
         outbuff[outbuffpos + 1] = (M4OSA_UInt8)((nal_size >> 16)& 0xFF);;
@@ -2036,30 +2036,30 @@
 
     if( M4OSA_NULL != instance->encoder_pps.slice_group_id )
     {
-        M4OSA_free((M4OSA_MemAddr32)instance->encoder_pps.slice_group_id);
+        free(instance->encoder_pps.slice_group_id);
     }
 
     if( M4OSA_NULL != instance->p_encoder_sps )
     {
-        M4OSA_free((M4OSA_MemAddr32)instance->p_encoder_sps);
+        free(instance->p_encoder_sps);
         instance->p_encoder_sps = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != instance->p_encoder_pps )
     {
-        M4OSA_free((M4OSA_MemAddr32)instance->p_encoder_pps);
+        free(instance->p_encoder_pps);
         instance->p_encoder_pps = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != instance->m_pFinalDSI )
     {
-        M4OSA_free((M4OSA_MemAddr32)instance->m_pFinalDSI);
+        free(instance->m_pFinalDSI);
         instance->m_pFinalDSI = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != instance )
     {
-        M4OSA_free((M4OSA_MemAddr32)instance);
+        free(instance);
         instance = M4OSA_NULL;
     }
 
@@ -2130,7 +2130,7 @@
 
     /**
     * Allocate the MCS context and return it to the user */
-    pC = (M4MCS_InternalContext *)M4OSA_malloc(sizeof(M4MCS_InternalContext),
+    pC = (M4MCS_InternalContext *)M4OSA_32bitAlignedMalloc(sizeof(M4MCS_InternalContext),
         M4MCS, (M4OSA_Char *)"M4MCS_InternalContext");
     *pContext = pC;
 
@@ -2251,18 +2251,6 @@
     pC->uiVideoBitrate =
         M4VIDEOEDITING_kUndefinedBitrate; /**< No bitrate set yet */
 
-#ifdef TIMESCALE_BUG
-
-    /* By default, timescale is not modified; if this value is not 0, timescale is
-     * modified without decode/encode process
-     */
-    pC->uiVideoTimescale = 0;
-    pC->uiTimescaleLength = 0;
-    pC->uiOrigVideoTimescale = 0;
-    pC->uiOrigTimescaleLength = 0;
-
-#endif
-
     pC->WriterVideoStream.streamType = M4SYS_kVideoUnknown;
     pC->WriterVideoStreamInfo.Header.pBuf = M4OSA_NULL;
     pC->WriterAudioStream.streamType = M4SYS_kAudioUnknown;
@@ -3164,7 +3152,7 @@
                         (M4OSA_MemAddr8)pC->m_pInstance->m_pDecoderSpecificInfo);
 
                     pC->m_pInstance->m_pFinalDSI =
-                        (M4OSA_UInt8 *)M4OSA_malloc(pC->m_pInstance-> \
+                        (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(pC->m_pInstance-> \
                         m_decoderSpecificInfoSize, M4MCS,
                         (M4OSA_Char *)"instance->m_pFinalDSI");
 
@@ -3173,8 +3161,8 @@
                         M4OSA_TRACE1_0("instance->m_pFinalDSI: allocation error");
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pInstance->m_pFinalDSI,
-                        (M4OSA_MemAddr8)pC-> \
+                    memcpy((void *)pC->m_pInstance->m_pFinalDSI,
+                        (void *)pC-> \
                         m_pInstance->m_pDecoderSpecificInfo,
                         pC->m_pInstance->m_decoderSpecificInfoSize);
                 }
@@ -3222,7 +3210,7 @@
     free effects list*/
     if( M4OSA_NULL != pC->pEffects )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pEffects);
+        free(pC->pEffects);
         pC->pEffects = M4OSA_NULL;
     }
     pC->nbEffects = 0;
@@ -3234,13 +3222,7 @@
 
     if( M4OSA_NULL != pC->H264MCSTempBuffer )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->H264MCSTempBuffer);
-    }
-
-    if( M4OSA_NULL != pC->m_pInstance )
-    {
-        err = H264MCS_Freeinstance(pC->m_pInstance);
-        pC->m_pInstance = M4OSA_NULL;
+        free(pC->H264MCSTempBuffer);
     }
 
     M4OSA_TRACE3_0("M4MCS_close(): returning M4NO_ERROR");
@@ -3307,6 +3289,12 @@
         return M4ERR_STATE;
     }
 
+    if( M4OSA_NULL != pC->m_pInstance )
+    {
+        err = H264MCS_Freeinstance(pC->m_pInstance);
+        pC->m_pInstance = M4OSA_NULL;
+    }
+
     /* ----- Free video encoder stuff, if needed ----- */
 
     if( ( M4OSA_NULL != pC->pViEncCtxt)
@@ -3331,7 +3319,7 @@
     if( ( M4ENCODER_kH263 == pC->EncodingVideoFormat)
         && (M4OSA_NULL != pC->WriterVideoStreamInfo.Header.pBuf) )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->WriterVideoStreamInfo.Header.pBuf);
+        free(pC->WriterVideoStreamInfo.Header.pBuf);
         pC->WriterVideoStreamInfo.Header.pBuf = M4OSA_NULL;
     }
 
@@ -3339,22 +3327,22 @@
     {
         if( M4OSA_NULL != pC->pPreResizeFrame[0].pac_data )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->pPreResizeFrame[0].pac_data);
+            free(pC->pPreResizeFrame[0].pac_data);
             pC->pPreResizeFrame[0].pac_data = M4OSA_NULL;
         }
 
         if( M4OSA_NULL != pC->pPreResizeFrame[1].pac_data )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->pPreResizeFrame[1].pac_data);
+            free(pC->pPreResizeFrame[1].pac_data);
             pC->pPreResizeFrame[1].pac_data = M4OSA_NULL;
         }
 
         if( M4OSA_NULL != pC->pPreResizeFrame[2].pac_data )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->pPreResizeFrame[2].pac_data);
+            free(pC->pPreResizeFrame[2].pac_data);
             pC->pPreResizeFrame[2].pac_data = M4OSA_NULL;
         }
-        M4OSA_free((M4OSA_MemAddr32)pC->pPreResizeFrame);
+        free(pC->pPreResizeFrame);
         pC->pPreResizeFrame = M4OSA_NULL;
     }
 
@@ -3362,25 +3350,25 @@
 
     if( M4OSA_NULL != pC->SsrcScratch )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->SsrcScratch);
+        free(pC->SsrcScratch);
         pC->SsrcScratch = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->pSsrcBufferIn )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pSsrcBufferIn);
+        free(pC->pSsrcBufferIn);
         pC->pSsrcBufferIn = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->pSsrcBufferOut )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pSsrcBufferOut);
+        free(pC->pSsrcBufferOut);
         pC->pSsrcBufferOut = M4OSA_NULL;
     }
 
     if (pC->pLVAudioResampler != M4OSA_NULL)
     {
-        LVDestroy((M4OSA_Int32)pC->pLVAudioResampler);
+        LVDestroy(pC->pLVAudioResampler);
         pC->pLVAudioResampler = M4OSA_NULL;
     }
 
@@ -3413,7 +3401,7 @@
 
     if( M4OSA_NULL != pC->pAudioEncoderBuffer )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pAudioEncoderBuffer);
+        free(pC->pAudioEncoderBuffer);
         pC->pAudioEncoderBuffer = M4OSA_NULL;
     }
 
@@ -3441,7 +3429,7 @@
 
     /**
     * Free the context itself */
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
     pC = M4OSA_NULL;
 
     M4OSA_TRACE3_0("M4MCS_cleanUp(): returning M4NO_ERROR");
@@ -3577,8 +3565,8 @@
 
     /**
     * Copy previously computed properties into given structure */
-    M4OSA_memcpy((M4OSA_MemAddr8)pFileProperties,
-        (M4OSA_MemAddr8) &pC->InputFileProperties,
+    memcpy((void *)pFileProperties,
+        (void *) &pC->InputFileProperties,
         sizeof(M4VIDEOEDITING_ClipProperties));
 
     return M4NO_ERROR;
@@ -3678,19 +3666,6 @@
     /* Set video parameters */
     if( pC->novideo == M4OSA_FALSE )
     {
-#ifdef TIMESCALE_BUG
-        /* Check if we are in timescale modification */
-
-        if( pParams->OutputVideoTimescale != 0 )
-        {
-            pC->uiVideoTimescale = pParams->OutputVideoTimescale;
-
-            /* If timescale modification mode is on, we force NULL video encoding ... */
-            pParams->OutputVideoFormat = M4VIDEOEDITING_kNullVideo;
-        }
-
-#endif
-
         /**
         * Check Video Format correctness */
 
@@ -4306,7 +4281,7 @@
     {
         M4OSA_UInt32 j = 0;
         pC->nbEffects = pParams->nbEffects;
-        pC->pEffects = (M4MCS_EffectSettings *)M4OSA_malloc(pC->nbEffects \
+        pC->pEffects = (M4MCS_EffectSettings *)M4OSA_32bitAlignedMalloc(pC->nbEffects \
             *sizeof(M4MCS_EffectSettings), M4MCS,
             (M4OSA_Char *)"Allocation of effects list");
 
@@ -4319,8 +4294,8 @@
         for ( j = 0; j < pC->nbEffects; j++ )
         {
             /* Copy effect to "local" structure */
-            M4OSA_memcpy((M4OSA_MemAddr8) &(pC->pEffects[j]),
-                (M4OSA_MemAddr8) &(pParams->pEffects[j]),
+            memcpy((void *) &(pC->pEffects[j]),
+                (void *) &(pParams->pEffects[j]),
                 sizeof(M4MCS_EffectSettings));
 
             switch( pC->pEffects[j].AudioEffectType )
@@ -5907,7 +5882,7 @@
         * Allocate the intermediate video plane that will receive the decoded image before
          resizing */
         pC->pPreResizeFrame =
-            (M4VIFI_ImagePlane *)M4OSA_malloc(3 * sizeof(M4VIFI_ImagePlane),
+            (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(3 * sizeof(M4VIFI_ImagePlane),
             M4MCS, (M4OSA_Char *)"m_pPreResizeFrame");
 
         if( M4OSA_NULL == pC->pPreResizeFrame )
@@ -5932,7 +5907,7 @@
             pPreResizeFrame[0].u_width; /**< simple case: stride equals width */
 
         pC->pPreResizeFrame[0].pac_data =
-            (M4VIFI_UInt8 *)M4OSA_malloc(pC->pPreResizeFrame[0].u_stride \
+            (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pC->pPreResizeFrame[0].u_stride \
             *pC->pPreResizeFrame[0].u_height, M4MCS,
             (M4OSA_Char *)"m_pPreResizeFrame[0].pac_data");
 
@@ -5955,7 +5930,7 @@
             pPreResizeFrame[1].u_width; /**< simple case: stride equals width */
 
         pC->pPreResizeFrame[1].pac_data =
-            (M4VIFI_UInt8 *)M4OSA_malloc(pC->pPreResizeFrame[1].u_stride \
+            (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pC->pPreResizeFrame[1].u_stride \
             *pC->pPreResizeFrame[1].u_height, M4MCS,
             (M4OSA_Char *)"m_pPreResizeFrame[1].pac_data");
 
@@ -5978,7 +5953,7 @@
             pPreResizeFrame[2].u_width; /**< simple case: stride equals width */
 
         pC->pPreResizeFrame[2].pac_data =
-            (M4VIFI_UInt8 *)M4OSA_malloc(pC->pPreResizeFrame[2].u_stride \
+            (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pC->pPreResizeFrame[2].u_stride \
             *pC->pPreResizeFrame[2].u_height, M4MCS,
             (M4OSA_Char *)"m_pPreResizeFrame[1].pac_data");
 
@@ -6135,7 +6110,7 @@
         pC->AudioDecBufferOut.m_bufferSize =
             pC->InputFileProperties.uiDecodedPcmSize;
         pC->AudioDecBufferOut.m_dataAddress =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->AudioDecBufferOut.m_bufferSize \
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->AudioDecBufferOut.m_bufferSize \
             *sizeof(short), M4MCS, (M4OSA_Char *)"AudioDecBufferOut.m_bufferSize");
     }
 
@@ -6384,7 +6359,7 @@
     /**
     * Allocate buffer for the input of the SSRC */
     pC->pSsrcBufferIn =
-        (M4OSA_MemAddr8)M4OSA_malloc(pC->iSsrcNbSamplIn * sizeof(short) \
+        (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->iSsrcNbSamplIn * sizeof(short) \
         *pC->pReaderAudioStream->m_nbChannels, M4MCS,
         (M4OSA_Char *)"pSsrcBufferIn");
 
@@ -6400,7 +6375,7 @@
     /**
     * Allocate buffer for the output of the SSRC */
     pC->pSsrcBufferOut =
-        (M4OSA_MemAddr8)M4OSA_malloc(pC->iSsrcNbSamplOut * sizeof(short) \
+        (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->iSsrcNbSamplOut * sizeof(short) \
         *pC->pReaderAudioStream->m_nbChannels, M4MCS,
         (M4OSA_Char *)"pSsrcBufferOut");
 
@@ -6413,18 +6388,22 @@
     }
 
 
-    pC->pLVAudioResampler = (M4OSA_Int32)LVAudioResamplerCreate(
+    pC->pLVAudioResampler = LVAudioResamplerCreate(
         16, /*gInputParams.lvBTChannelCount*/
-        /*pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels*/
         (M4OSA_Int16)pC->InputFileProperties.uiNbChannels/*ssrcParams.SSRC_NrOfChannels*/,
-        /* gInputParams.lvOutSampleRate*//*pSettings->outputASF*/
-        pC->AudioEncParams.Frequency/*ssrcParams.SSRC_Fs_Out*/, 1);
-    LVAudiosetSampleRate((M4OSA_Int32)pC->pLVAudioResampler,
+        (M4OSA_Int32)(pC->AudioEncParams.Frequency)/*ssrcParams.SSRC_Fs_Out*/, 1);
+
+     if( M4OSA_NULL == pC->pLVAudioResampler)
+     {
+         return M4ERR_ALLOC;
+     }
+
+    LVAudiosetSampleRate(pC->pLVAudioResampler,
         /*gInputParams.lvInSampleRate*/
         /*pC->pAddedClipCtxt->pSettings->ClipProperties.uiSamplingFrequency*/
         pC->InputFileProperties.uiSamplingFrequency/*ssrcParams.SSRC_Fs_In*/);
 
-    LVAudiosetVolume((M4OSA_Int32)pC->pLVAudioResampler, (M4OSA_Int16)(0x1000 /* 0x7fff */),
+    LVAudiosetVolume(pC->pLVAudioResampler, (M4OSA_Int16)(0x1000 /* 0x7fff */),
         (M4OSA_Int16)(0x1000/*0x7fff*/));
 
 
@@ -6486,7 +6465,7 @@
 
     pC->pPosInAudioEncoderBuffer = M4OSA_NULL;
     pC->pAudioEncoderBuffer =
-        (M4OSA_MemAddr8)M4OSA_malloc(pC->audioEncoderGranularity, M4MCS,
+        (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->audioEncoderGranularity, M4MCS,
         (M4OSA_Char *)"pC->pAudioEncoderBuffer");
 
     /**
@@ -6680,7 +6659,7 @@
             * Creates the H263 DSI */
             pC->WriterVideoStreamInfo.Header.Size =
                 7; /**< H263 output DSI is always 7 bytes */
-            pDSI = (M4OSA_MemAddr8)M4OSA_malloc(7, M4MCS, (M4OSA_Char
+            pDSI = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(7, M4MCS, (M4OSA_Char
                 *)"pC->WriterVideoStreamInfo.Header.pBuf (DSI H263)");
 
             if( M4OSA_NULL == pDSI )
@@ -6766,51 +6745,6 @@
         }
         else if( M4ENCODER_kNULL == pC->EncodingVideoFormat )
         {
-#ifdef TIMESCALE_BUG
-            /* if we are in "timescale mode", we need to know on how many bits the v
-            op_time_increment is coded and to change the DSI */
-
-            if( pC->uiVideoTimescale == 0 )
-            {
-                /* If we copy the stream from the input, we copy its DSI */
-                pC->WriterVideoStreamInfo.Header.Size = pC->pReaderVideoStream->
-                    m_basicProperties.m_decoderSpecificInfoSize;
-                pC->WriterVideoStreamInfo.Header.pBuf =
-                    (M4OSA_MemAddr8)pC->pReaderVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo;
-            }
-            else
-            {
-                /* Allocate a new DSI */
-                pC->WriterVideoStreamInfo.Header.Size = pC->pReaderVideoStream->
-                    m_basicProperties.m_decoderSpecificInfoSize;
-                pC->WriterVideoStreamInfo.Header.pBuf =
-                    (M4OSA_Void
-                    *)M4OSA_malloc(pC->WriterVideoStreamInfo.Header.Size,
-                    M4MCS,
-                    (M4OSA_Char
-                    *)
-                    "New decoder specific info for timescale modification");
-
-                if( pC->WriterVideoStreamInfo.Header.pBuf == M4OSA_NULL )
-                {
-                    M4OSA_TRACE1_0("M4MCS_intPrepareWriter: Allocation error\
-                                   pC->WriterVideoStreamInfo.Header.pBuf");
-                    return M4ERR_ALLOC;
-                }
-
-                /* Copy Reading DSI to new DSI */
-                M4OSA_memcpy(pC->WriterVideoStreamInfo.Header.pBuf,
-                    pC->pReaderVideoStream->
-                    m_basicProperties.m_pDecoderSpecificInfo,
-                    pC->WriterVideoStreamInfo.Header.Size);
-
-                /* Call a function to change DSI and to get the nb of bits on which the
-                vop_time_increment is coded */
-                err = M4MCS_intParseVideoDSI(pC);
-            }
-
-#else
             /* If we copy the stream from the input, we copy its DSI */
 
             pC->WriterVideoStreamInfo.Header.Size = pC->pReaderVideoStream->
@@ -6819,8 +6753,6 @@
                 (M4OSA_MemAddr8)pC->pReaderVideoStream->
                 m_basicProperties.m_pDecoderSpecificInfo;
 
-#endif
-
         }
         /* otherwise (MPEG4), the DSI will be recovered from the encoder later on. */
 
@@ -7928,7 +7860,7 @@
             }
 
             pC->m_pDataAddress1 =
-                (M4OSA_MemAddr8)M4OSA_malloc(pC->ReaderAudioAU1.m_maxsize,
+                (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->ReaderAudioAU1.m_maxsize,
                 M4MCS, (M4OSA_Char *)"Temporary AU1 buffer");
 
             if( pC->m_pDataAddress1 == M4OSA_NULL )
@@ -7982,8 +7914,8 @@
                     pC->ReaderAudioAU1.m_maxsize;
             }
             /**/
-            M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataAddress1,
-                (M4OSA_MemAddr8)pC->ReaderAudioAU1.m_dataAddress,
+            memcpy((void *)pC->m_pDataAddress1,
+                (void *)pC->ReaderAudioAU1.m_dataAddress,
                 pC->ReaderAudioAU1.m_size);
         }
 
@@ -8003,7 +7935,7 @@
                 return err;
             }
             pC->m_pDataAddress2 =
-                (M4OSA_MemAddr8)M4OSA_malloc(pC->ReaderAudioAU2.m_maxsize,
+                (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->ReaderAudioAU2.m_maxsize,
                 M4MCS, (M4OSA_Char *)"Temporary AU buffer");
 
             if( pC->m_pDataAddress2 == M4OSA_NULL )
@@ -8017,8 +7949,8 @@
         * Read the next audio AU in the input file */
         if( pC->ReaderAudioAU2.m_CTS > pC->ReaderAudioAU1.m_CTS )
         {
-            M4OSA_memcpy((M4OSA_MemAddr8) &pC->ReaderAudioAU,
-                (M4OSA_MemAddr8) &pC->ReaderAudioAU2, sizeof(M4_AccessUnit));
+            memcpy((void *) &pC->ReaderAudioAU,
+                (void *) &pC->ReaderAudioAU2, sizeof(M4_AccessUnit));
             err = pC->m_pReaderDataIt->m_pFctGetNextAu(pC->pReaderContext,
                 (M4_StreamHandler *)pC->pReaderAudioStream,
                 &pC->ReaderAudioAU1);
@@ -8046,8 +7978,8 @@
                     pC->ReaderAudioAU1.m_maxsize;
             }
             /**/
-            M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataAddress1,
-                (M4OSA_MemAddr8)pC->ReaderAudioAU1.m_dataAddress,
+            memcpy((void *)pC->m_pDataAddress1,
+                (void *)pC->ReaderAudioAU1.m_dataAddress,
                 pC->ReaderAudioAU1.m_size);
             pC->m_audioAUDuration =
                 pC->ReaderAudioAU1.m_CTS - pC->ReaderAudioAU2.m_CTS;
@@ -8055,8 +7987,8 @@
         }
         else
         {
-            M4OSA_memcpy((M4OSA_MemAddr8) &pC->ReaderAudioAU,
-                (M4OSA_MemAddr8) &pC->ReaderAudioAU1, sizeof(M4_AccessUnit));
+            memcpy((void *) &pC->ReaderAudioAU,
+                (void *) &pC->ReaderAudioAU1, sizeof(M4_AccessUnit));
             err = pC->m_pReaderDataIt->m_pFctGetNextAu(pC->pReaderContext,
                 (M4_StreamHandler *)pC->pReaderAudioStream,
                 &pC->ReaderAudioAU2);
@@ -8085,8 +8017,8 @@
                     pC->ReaderAudioAU2.m_maxsize;
             }
             /**/
-            M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataAddress2,
-                (M4OSA_MemAddr8)pC->ReaderAudioAU2.m_dataAddress,
+            memcpy((void *)pC->m_pDataAddress2,
+                (void *)pC->ReaderAudioAU2.m_dataAddress,
                 pC->ReaderAudioAU2.m_size);
             pC->m_audioAUDuration =
                 pC->ReaderAudioAU2.m_CTS - pC->ReaderAudioAU1.m_CTS;
@@ -8138,15 +8070,15 @@
             if( pC->InputFileProperties.uiNbChannels == 1 )
             {
                 pC->WriterAudioAU.size = M4VSS3GPP_AAC_AU_SILENCE_MONO_SIZE;
-                M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress,
-                    (M4OSA_MemAddr8)M4VSS3GPP_AAC_AU_SILENCE_MONO,
+                memcpy((void *)pC->WriterAudioAU.dataAddress,
+                    (void *)M4VSS3GPP_AAC_AU_SILENCE_MONO,
                     pC->WriterAudioAU.size);
             }
             else if( pC->InputFileProperties.uiNbChannels == 2 )
             {
                 pC->WriterAudioAU.size = M4VSS3GPP_AAC_AU_SILENCE_STEREO_SIZE;
-                M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress,
-                    (M4OSA_MemAddr8)M4VSS3GPP_AAC_AU_SILENCE_STEREO,
+                memcpy((void *)pC->WriterAudioAU.dataAddress,
+                    (void *)M4VSS3GPP_AAC_AU_SILENCE_STEREO,
                     pC->WriterAudioAU.size);
             }
             else
@@ -8161,17 +8093,17 @@
             == M4VIDEOEDITING_kAMR_NB )
         {
             pC->WriterAudioAU.size = M4VSS3GPP_AMR_AU_SILENCE_FRAME_048_SIZE;
-            M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress,
-                (M4OSA_MemAddr8)M4VSS3GPP_AMR_AU_SILENCE_FRAME_048,
+            memcpy((void *)pC->WriterAudioAU.dataAddress,
+                (void *)M4VSS3GPP_AMR_AU_SILENCE_FRAME_048,
                 pC->WriterAudioAU.size);
             /* Some remaining AMR AU needs to be copied */
             if( pC->ReaderAudioAU.m_size != 0 )
             {
                 /* Update Writer AU */
                 pC->WriterAudioAU.size += pC->ReaderAudioAU.m_size;
-                M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress
-                    + M4VSS3GPP_AMR_AU_SILENCE_FRAME_048_SIZE,
-                    (M4OSA_MemAddr8)pC->ReaderAudioAU.m_dataAddress,
+                memcpy((void *)(pC->WriterAudioAU.dataAddress
+                    + M4VSS3GPP_AMR_AU_SILENCE_FRAME_048_SIZE),
+                    (void *)pC->ReaderAudioAU.m_dataAddress,
                     pC->ReaderAudioAU.m_size);
             }
         }
@@ -8181,8 +8113,8 @@
             M4OSA_TRACE3_1(
                 "M4MCS_intAudioNullEncoding(): Copying audio AU: size=%d",
                 pC->ReaderAudioAU.m_size);
-            M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress,
-                (M4OSA_MemAddr8)pC->ReaderAudioAU.m_dataAddress,
+            memcpy((void *)pC->WriterAudioAU.dataAddress,
+                (void *)pC->ReaderAudioAU.m_dataAddress,
                 pC->ReaderAudioAU.m_size);
             pC->WriterAudioAU.size = pC->ReaderAudioAU.m_size;
         }
@@ -8194,8 +8126,8 @@
         M4OSA_TRACE3_1(
             "M4MCS_intAudioNullEncoding(): Copying audio AU: size=%d",
             pC->ReaderAudioAU.m_size);
-        M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterAudioAU.dataAddress,
-            (M4OSA_MemAddr8)pC->ReaderAudioAU.m_dataAddress,
+        memcpy((void *)pC->WriterAudioAU.dataAddress,
+            (void *)pC->ReaderAudioAU.m_dataAddress,
             pC->ReaderAudioAU.m_size);
         pC->WriterAudioAU.size = pC->ReaderAudioAU.m_size;
     }
@@ -8417,7 +8349,7 @@
 
     /**
     * Copy from the decoder out buffer into the Ssrc in buffer */
-    M4OSA_memcpy(pC->pPosInSsrcBufferIn, pC->pPosInDecBufferOut,
+    memcpy((void *)pC->pPosInSsrcBufferIn, (void *)pC->pPosInDecBufferOut,
         uiDecoder2Ssrc_NbBytes);
 
     /**
@@ -8464,29 +8396,29 @@
     if( pC->pReaderAudioStream->m_nbChannels == 1 )
     {
         tempBuffOut =
-            (short *)M4OSA_malloc((pC->iSsrcNbSamplOut * sizeof(short) * 2
+            (short *)M4OSA_32bitAlignedMalloc((pC->iSsrcNbSamplOut * sizeof(short) * 2
             * ((*pC).InputFileProperties).uiNbChannels),
             M4VSS3GPP,(M4OSA_Char *) "tempBuffOut");
-        M4OSA_memset((M4OSA_MemAddr8)tempBuffOut, (pC->iSsrcNbSamplOut * sizeof(short) * 2
-            * ((*pC).InputFileProperties).uiNbChannels), 0);
+        memset((void *)tempBuffOut, 0,(pC->iSsrcNbSamplOut * sizeof(short) * 2
+            * ((*pC).InputFileProperties).uiNbChannels));
 
         LVAudioresample_LowQuality((short *)tempBuffOut, (short *)pSsrcInput,
-            pC->iSsrcNbSamplOut, (M4OSA_Int32)pC->pLVAudioResampler);
+            pC->iSsrcNbSamplOut, pC->pLVAudioResampler);
     }
     else
     {
-        M4OSA_memset(pC->pSsrcBufferOut, (pC->iSsrcNbSamplOut * sizeof(short)
-            * ((*pC).InputFileProperties).uiNbChannels), 0);
+        memset((void *)pC->pSsrcBufferOut, 0, (pC->iSsrcNbSamplOut * sizeof(short)
+            * ((*pC).InputFileProperties).uiNbChannels));
 
         LVAudioresample_LowQuality((short *)pC->pSsrcBufferOut,
-            (short *)pSsrcInput, pC->iSsrcNbSamplOut, (M4OSA_Int32)pC->pLVAudioResampler);
+            (short *)pSsrcInput, pC->iSsrcNbSamplOut, pC->pLVAudioResampler);
     }
 
     if( pC->pReaderAudioStream->m_nbChannels == 1 )
     {
         From2iToMono_16((short *)tempBuffOut, (short *)pC->pSsrcBufferOut,
             (short)pC->iSsrcNbSamplOut);
-        M4OSA_free((M4OSA_MemAddr32)tempBuffOut);
+        free(tempBuffOut);
     }
 
 
@@ -8603,7 +8535,7 @@
     else
     {
         /* copy from the ssrc out buffer into the encoder in buffer */
-        M4OSA_memcpy(pC->pPosInAudioEncoderBuffer, pC->pPosInSsrcBufferOut,
+        memcpy((void *)pC->pPosInAudioEncoderBuffer, (void *)pC->pPosInSsrcBufferOut,
             uiSsrc2Encoder_NbBytes);
     }
 
@@ -8694,16 +8626,16 @@
         if( pC->pEffects[*pActiveEffectNumber].ExtAudioEffectFct != M4OSA_NULL )
         {
             M4MCS_ExternalProgress pProgress;
-            M4OSA_UInt64 tempProgress = 0;
+            M4OSA_UInt32 tempProgress = 0;
             pProgress.uiClipTime = (M4OSA_UInt32)pC->ReaderAudioAU.m_CTS;
 
             pProgress.uiOutputTime = ( pC->WriterAudioAU.CTS * 1000)
                 / pC->WriterAudioStream.timeScale;
-            tempProgress = ( (M4OSA_UInt64)pC->ReaderAudioAU.m_CTS
+            tempProgress = ( (M4OSA_UInt32)pC->ReaderAudioAU.m_CTS
                 - pC->pEffects[*pActiveEffectNumber].uiStartTime
                 - pC->uiBeginCutTime) * 1000;
             pProgress.uiProgress =
-                (M4OSA_UInt32)(tempProgress / (M4OSA_UInt64)pC->pEffects[
+                (M4OSA_UInt32)(tempProgress / (M4OSA_UInt32)pC->pEffects[
                     *pActiveEffectNumber].uiDuration);
 
                     err = pC->pEffects[*pActiveEffectNumber].ExtAudioEffectFct(
@@ -8835,8 +8767,8 @@
 {
     if( *addr != M4OSA_NULL )
     {
-        M4OSA_free(( M4OSA_MemAddr32) * addr);
-        *addr = (M4OSA_MemAddr8)M4OSA_malloc(newSize, M4MCS,
+        free(*addr);
+        *addr = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(newSize, M4MCS,
             (M4OSA_Char *)"Reallocation of temporary AU buffer");
 
         if( *addr == M4OSA_NULL )
@@ -8995,16 +8927,6 @@
 
     pC->bLastDecodedFrameCTS = M4OSA_TRUE;
 
-    /* - CRLV6775 -H.264 Trimming */
-
-    /* commented,this part is done further on one of the temporary video AU (video AU1 or video AU2)*/
-#if 0
-    /**
-    * Read the next video AU in the input file */
-
-    err = pC->m_pReaderDataIt->m_pFctGetNextAu(pC->pReaderContext,
-        (M4_StreamHandler *)pC->pReaderVideoStream, &pC->ReaderVideoAU);
-#endif
 
     /* Find the next AU duration to obtain a more precise video end cut*/
     /**
@@ -9027,7 +8949,7 @@
         }
 
         pC->m_pDataVideoAddress1 =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->ReaderVideoAU1.m_maxsize, M4MCS,
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->ReaderVideoAU1.m_maxsize, M4MCS,
             (M4OSA_Char *)"Temporary video AU1 buffer");
 
         if( pC->m_pDataVideoAddress1 == M4OSA_NULL )
@@ -9077,8 +8999,8 @@
             pC->pReaderVideoStream->m_basicProperties.m_maxAUSize =
                 pC->ReaderVideoAU1.m_maxsize;
         }
-        M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataVideoAddress1,
-            (M4OSA_MemAddr8)pC->ReaderVideoAU1.m_dataAddress,
+        memcpy((void *)pC->m_pDataVideoAddress1,
+            (void *)pC->ReaderVideoAU1.m_dataAddress,
             pC->ReaderVideoAU1.m_size);
     }
 
@@ -9098,7 +9020,7 @@
             return err;
         }
         pC->m_pDataVideoAddress2 =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->ReaderVideoAU2.m_maxsize, M4MCS,
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->ReaderVideoAU2.m_maxsize, M4MCS,
             (M4OSA_Char *)"Temporary video AU buffer");
 
         if( pC->m_pDataVideoAddress2 == M4OSA_NULL )
@@ -9111,8 +9033,8 @@
     * Read the next video AU in the input file */
     if( pC->ReaderVideoAU2.m_CTS > pC->ReaderVideoAU1.m_CTS )
     {
-        M4OSA_memcpy((M4OSA_MemAddr8) &pC->ReaderVideoAU,
-            (M4OSA_MemAddr8) &pC->ReaderVideoAU2, sizeof(M4_AccessUnit));
+        memcpy((void *) &pC->ReaderVideoAU,
+            (void *) &pC->ReaderVideoAU2, sizeof(M4_AccessUnit));
         err = pC->m_pReaderDataIt->m_pFctGetNextAu(pC->pReaderContext,
             (M4_StreamHandler *)pC->pReaderVideoStream,
             &pC->ReaderVideoAU1);
@@ -9137,16 +9059,16 @@
             pC->pReaderVideoStream->m_basicProperties.m_maxAUSize =
                 pC->ReaderVideoAU1.m_maxsize;
         }
-        M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataVideoAddress1,
-            (M4OSA_MemAddr8)pC->ReaderVideoAU1.m_dataAddress,
+        memcpy((void *)pC->m_pDataVideoAddress1,
+            (void *)pC->ReaderVideoAU1.m_dataAddress,
             pC->ReaderVideoAU1.m_size);
         videoAUDuration = pC->ReaderVideoAU1.m_CTS - pC->ReaderVideoAU2.m_CTS;
         pC->ReaderVideoAU.m_dataAddress = pC->m_pDataVideoAddress2;
     }
     else
     {
-        M4OSA_memcpy((M4OSA_MemAddr8) &pC->ReaderVideoAU,
-            (M4OSA_MemAddr8) &pC->ReaderVideoAU1, sizeof(M4_AccessUnit));
+        memcpy((void *) &pC->ReaderVideoAU,
+            (void *) &pC->ReaderVideoAU1, sizeof(M4_AccessUnit));
         err = pC->m_pReaderDataIt->m_pFctGetNextAu(pC->pReaderContext,
             (M4_StreamHandler *)pC->pReaderVideoStream,
             &pC->ReaderVideoAU2);
@@ -9171,8 +9093,8 @@
             pC->pReaderVideoStream->m_basicProperties.m_maxAUSize =
                 pC->ReaderVideoAU2.m_maxsize;
         }
-        M4OSA_memcpy((M4OSA_MemAddr8)pC->m_pDataVideoAddress2,
-            (M4OSA_MemAddr8)pC->ReaderVideoAU2.m_dataAddress,
+        memcpy((void *)pC->m_pDataVideoAddress2,
+            (void *)pC->ReaderVideoAU2.m_dataAddress,
             pC->ReaderVideoAU2.m_size);
         videoAUDuration = pC->ReaderVideoAU2.m_CTS - pC->ReaderVideoAU1.m_CTS;
         pC->ReaderVideoAU.m_dataAddress = pC->m_pDataVideoAddress1;
@@ -9208,33 +9130,6 @@
                 err);
             return err;
         }
-#ifdef TIMESCALE_BUG
-        /* If we are in timescale modification mode or classic copy mode */
-
-        if( pC->uiVideoTimescale != 0 )
-        {
-            /**
-            * Copy video data from reader AU to writer AU */
-            //M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterVideoAU.dataAddress,
-            //(M4OSA_MemAddr8)pC->ReaderVideoAU.m_dataAddress, pC->ReaderVideoAU.m_size);
-            pC->WriterVideoAU.size = pC->ReaderVideoAU.m_size;
-
-            /* Call internal function to change AU timescale */
-            err = M4MCS_intChangeAUVideoTimescale(pC);
-
-            /**
-            * Convert CTS unit from milliseconds to timescale */
-            pC->WriterVideoAU.CTS =
-                (M4OSA_Time)((( pC->ReaderVideoAU.m_CTS - pC->dViDecStartingCts)
-                * (pC->WriterVideoStream.timeScale / 1000.0)));
-            pC->WriterVideoAU.nbFrag = 0;
-            pC->WriterVideoAU.attribute = pC->ReaderVideoAU.m_attribute;
-        }
-        else
-
-#endif
-
-        {
             /**
             * Copy video data from reader AU to writer AU */
             M4OSA_TRACE3_1(
@@ -9251,10 +9146,10 @@
 
                     if( pC->H264MCSTempBuffer != M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pC->H264MCSTempBuffer);
+                        free(pC->H264MCSTempBuffer);
                     }
                     pC->H264MCSTempBuffer =
-                        (M4OSA_UInt8 *)M4OSA_malloc(pC->H264MCSTempBufferSize,
+                        (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(pC->H264MCSTempBufferSize,
                         M4MCS, (M4OSA_Char *)"pC->H264MCSTempBuffer");
 
                     if( pC->H264MCSTempBuffer == M4OSA_NULL )
@@ -9278,8 +9173,8 @@
                         (M4OSA_UInt8 *)pC->ReaderVideoAU.m_dataAddress ,
                         pC->ReaderVideoAU.m_size);
 
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterVideoAU.dataAddress,
-                        (M4OSA_MemAddr8)(pC->ReaderVideoAU.m_dataAddress + 4),
+                    memcpy((void *)pC->WriterVideoAU.dataAddress,
+                        (void *)(pC->ReaderVideoAU.m_dataAddress + 4),
                         pC->ReaderVideoAU.m_size - 4);
                     pC->WriterVideoAU.size = pC->ReaderVideoAU.m_size - 4;
                     WritebufferAdd =
@@ -9287,8 +9182,8 @@
                 }
                 else
                 {
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterVideoAU.dataAddress,
-                        (M4OSA_MemAddr8)(pC->H264MCSTempBuffer + 4),
+                    memcpy((void *)pC->WriterVideoAU.dataAddress,
+                        (void *)(pC->H264MCSTempBuffer + 4),
                         pC->H264MCSTempBufferDataSize - 4);
                     pC->WriterVideoAU.size = pC->H264MCSTempBufferDataSize - 4;
                     WritebufferAdd =
@@ -9298,8 +9193,8 @@
             /* H.264 Trimming */
             else
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)pC->WriterVideoAU.dataAddress,
-                    (M4OSA_MemAddr8)pC->ReaderVideoAU.m_dataAddress,
+                memcpy((void *)pC->WriterVideoAU.dataAddress,
+                    (void *)pC->ReaderVideoAU.m_dataAddress,
                     pC->ReaderVideoAU.m_size);
                 pC->WriterVideoAU.size = pC->ReaderVideoAU.m_size;
             }
@@ -9313,7 +9208,6 @@
 
             M4OSA_TRACE3_1("M4MCS_intVideoNullEncoding(): video AU: CTS=%d ms",
                 pC->WriterVideoAU.CTS);
-        }
 
         /**
         * Write it to the output file */
@@ -9333,13 +9227,13 @@
         {
             if( pC->m_pInstance->is_done == 1 )
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)(WritebufferAdd - 4),
-                    (M4OSA_MemAddr8)(pC->ReaderVideoAU.m_dataAddress), 4);
+                memcpy((void *)(WritebufferAdd - 4),
+                    (void *)(pC->ReaderVideoAU.m_dataAddress), 4);
             }
             else
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)(WritebufferAdd - 4),
-                    (M4OSA_MemAddr8)(pC->H264MCSTempBuffer), 4);
+                memcpy((void *)(WritebufferAdd - 4),
+                    (void *)(pC->H264MCSTempBuffer), 4);
             }
         } /* H.264 Trimming */
     }
@@ -9410,7 +9304,7 @@
     * Check for end cut.
     * We must check here if the end cut is reached, because in that case we must
     * call the last encode step (-> bLastFrame set to true) */
-    if( ( pC->dViDecCurrentCts + pC->dCtsIncrement + 0.5) >= (pC->uiEndCutTime
+    if( ( pC->dViDecCurrentCts + pC->dCtsIncrement ) >= (pC->uiEndCutTime
         + M4MCS_ABS(pC->dViDecStartingCts - pC->uiBeginCutTime)) )
     {
         FrameMode =
@@ -9483,8 +9377,8 @@
     pC->InputFileProperties.Version[2] = M4VIDEOEDITING_VERSION_REVISION;
     pC->InputFileProperties.uiClipDuration = 0;
 
-    M4OSA_memset((M4OSA_MemAddr8) &pC->InputFileProperties.ftyp,
-        sizeof(M4VIDEOEDITING_FtypBox), 0);
+    memset((void *) &pC->InputFileProperties.ftyp,
+        0, sizeof(M4VIDEOEDITING_FtypBox));
 
     /**
     * Reset video characteristics */
@@ -10503,25 +10397,25 @@
 
     if( pC->m_pDataAddress1 != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pDataAddress1);
+        free(pC->m_pDataAddress1);
         pC->m_pDataAddress1 = M4OSA_NULL;
     }
 
     if( pC->m_pDataAddress2 != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pDataAddress2);
+        free(pC->m_pDataAddress2);
         pC->m_pDataAddress2 = M4OSA_NULL;
     }
     /*Bug fix 11/12/2008 (to obtain more precise video end cut)*/
     if( pC->m_pDataVideoAddress1 != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pDataVideoAddress1);
+        free(pC->m_pDataVideoAddress1);
         pC->m_pDataVideoAddress1 = M4OSA_NULL;
     }
 
     if( pC->m_pDataVideoAddress2 != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pDataVideoAddress2);
+        free(pC->m_pDataVideoAddress2);
         pC->m_pDataVideoAddress2 = M4OSA_NULL;
     }
     /**/
@@ -10559,7 +10453,7 @@
 
     if( M4OSA_NULL != pC->AudioDecBufferOut.m_dataAddress )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->AudioDecBufferOut.m_dataAddress);
+        free(pC->AudioDecBufferOut.m_dataAddress);
         pC->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
     }
 
@@ -10686,13 +10580,18 @@
         M4OSA_UInt32 uiDummy, uiCoreId;
         M4OSA_TRACE1_1("M4MCS_open_normalMode(): m_pReader->m_pFctOpen returns 0x%x", err);
 
-        /**
-        * If the error is from the core reader, we change it to a public VXS error */
-        M4OSA_ERR_SPLIT(err, uiDummy, uiCoreId, uiDummy);
-        if (M4MP4_READER == uiCoreId)
-        {
-            M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_INVALID_INPUT_FILE");
-            return M4MCS_ERR_INVALID_INPUT_FILE;
+        if (err == ((M4OSA_UInt32)M4ERR_UNSUPPORTED_MEDIA_TYPE)) {
+            M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_FILE_DRM_PROTECTED");
+            return M4MCS_ERR_FILE_DRM_PROTECTED;
+        } else {
+            /**
+            * If the error is from the core reader, we change it to a public VXS error */
+            M4OSA_ERR_SPLIT(err, uiDummy, uiCoreId, uiDummy);
+            if (M4MP4_READER == uiCoreId)
+            {
+                M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_INVALID_INPUT_FILE");
+                return M4MCS_ERR_INVALID_INPUT_FILE;
+            }
         }
         return err;
     }
@@ -10900,711 +10799,3 @@
     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_malloc(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);
-        M4OSA_free((M4OSA_MemAddr32)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);
-        M4OSA_free((M4OSA_MemAddr32)shellInterface);
-        M4OSA_free((M4OSA_MemAddr32)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);
-        M4OSA_free((M4OSA_MemAddr32)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 )
-    {
-        M4OSA_free((M4OSA_MemAddr32)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 )
-    {
-        M4OSA_free((M4OSA_MemAddr32)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;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_getExifInfo(M4MCS_Context pContext);
- * @brief    Retrieve the EXIF tags informations from a Still picture
- * @note    This function will allocate and fill a Exif tag struct
- *            exifTags structure must be allocated/deallocated by the user
- *            exifTags members will point to internal SPE information, user should not try
- *             to modify or deallocate them
- * @param    pContext            (IN) MCS context
- * @return    M4NO_ERROR:            No error
- * @return    M4ERR_PARAMETER:    pContext is M4OSA_NULL
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_getExifInfo( M4MCS_Context pContext, M4MCS_ExifInfos *exifTags )
-{
-    M4MCS_InternalContext *pC = (M4MCS_InternalContext *)(pContext);
-    M4OSA_ERR err;
-
-    M4OSA_TRACE2_1("M4MCS_getExifInfo called with pContext=0x%x", pContext);
-
-    /**
-    * Check input parameters */
-    M4OSA_DEBUG_IF2((M4OSA_NULL == pContext), M4ERR_PARAMETER,
-        "M4MCS_getExifInfo: pContext is M4OSA_NULL");
-
-#ifdef M4MCS_SUPPORT_STILL_PICTURE
-
-    if( pC->m_bIsStillPicture )
-    {
-        /**
-        * Call the corresponding still picture MCS function*/
-        return M4MCS_stillPicGetExifInfo(pC, exifTags);
-    }
-
-#endif /*M4MCS_SUPPORT_STILL_PICTURE*/
-
-    return M4ERR_NOT_IMPLEMENTED;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerVideoDecoderExtended(M4MCS_Context    context,
-M4DECODER_VideoType        decoderType,
-M4DECODER_VideoInterface    *pDecoderInterface,
-M4OSA_Void* pUserData)
- * @brief    Registers an external Video decoder
- * @note This is much different from the external video decoder to cope up with specific
- *        requirement of OMX codec implementation.
-So we use M4DECODER_VideoInterface instead of M4VD_Interface.
- * @param  pContext           (IN) MCS context
- * @param  decoderType        (IN) Type of decoder (MPEG4 ...)
- * @param  pVidDecoderInterface  (IN) Decoder interface of type 'M4DECODER_VideoInterface'
- * @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_registerVideoDecoderExtended( M4MCS_Context context,
-                                             M4VD_VideoType decoderType,
-                                             M4OSA_Context pVidDecoderInterface,
-                                             M4OSA_Void *pUserData )
-{
-    M4OSA_ERR err = M4NO_ERROR;
-    M4DECODER_VideoType nativeType;
-    M4DECODER_EXTERNAL_UserDataType shellUserData;
-    M4DECODER_VideoInterface *pDecoderInterface =
-        (M4DECODER_VideoInterface *)pVidDecoderInterface;
-    M4MCS_InternalContext *pC = (M4MCS_InternalContext *)context;
-    M4OSA_Bool bResetCurrentVideoDecoder = M4OSA_FALSE;
-    M4_StreamType mediaType = M4DA_StreamTypeUnknown;
-
-    M4OSA_TRACE3_1(
-        "M4MCS_registerVideoDecoderExtended invoked with context = 0x%x",
-        context);
-
-    switch( decoderType )
-    {
-        case M4VD_kMpeg4VideoDec:
-        case M4VD_kH263VideoDec:
-            nativeType = M4DECODER_kVideoTypeMPEG4;
-            mediaType = M4DA_StreamTypeVideoMpeg4;
-            break;
-
-        case M4VD_kH264VideoDec:
-            nativeType = M4DECODER_kVideoTypeAVC;
-            mediaType = M4DA_StreamTypeVideoMpeg4Avc;
-            break;
-
-        default:
-            M4OSA_TRACE1_1(
-                "M4MCS_registerVideoDecoderExtended: unknown decoderType %d",
-                decoderType);
-            return M4ERR_PARAMETER;
-    }
-
-    if( M4OSA_NULL != pC->m_pVideoDecoder )
-    {
-        M4OSA_TRACE3_0(
-            "M4MCS_registerVideoDecoderExtended: pC->m_pVideoDecoder already set to \
-            previous registered dec shell");
-
-        if( ( ( ( pC->pReaderVideoStream->m_basicProperties.m_streamType
-            == M4DA_StreamTypeVideoH263)
-            || (pC->pReaderVideoStream->m_basicProperties.m_streamType
-            == M4DA_StreamTypeVideoMpeg4))
-            && (mediaType == M4DA_StreamTypeVideoMpeg4))
-            || (( pC->pReaderVideoStream->m_basicProperties.m_streamType
-            == M4DA_StreamTypeVideoMpeg4Avc)
-            && (mediaType == M4DA_StreamTypeVideoMpeg4Avc)) )
-            bResetCurrentVideoDecoder = M4OSA_TRUE;
-    }
-
-    err = M4MCS_registerVideoDecoder(context, nativeType, pDecoderInterface);
-
-    /** Provide the application user data back to the interface functions. **
-    * For now we donot provide 'M4DECODER_EXTERNAL_UserDataType' **/
-    ( (M4MCS_InternalContext
-        *)context)->m_pVideoDecoderUserDataTable[nativeType] = pUserData;
-
-    if( ( M4NO_ERROR == err) && (M4OSA_TRUE == bResetCurrentVideoDecoder) )
-    {
-        err = M4MCS_setCurrentVideoDecoder(context, mediaType);
-        M4OSA_TRACE3_1(
-            "M4MCS_registerVideoDecoderExtended: M4MCS_setCurrentVideoDecoder returned 0x%x",
-            err);
-    }
-    M4OSA_TRACE1_1(
-        "M4MCS_registerVideoDecoderExtended returning with error  = 0x%x", err);
-    return err;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerVideoEncoderExtended()
- * @brief    Registers an external Video encoder
- * @note This is much different from the external video encoder to cope up with specific
- *            requirement of OMX codec implementation.
-So we use M4ENCODER_GlobalInterface instead of M4VE_Interface.
- * @param  pContext           (IN) MCS context
- * @param  encoderType        (IN) Type of encoder (MPEG4 ...)
- * @param  pEncoderInterface  (IN) Encoder interface of type 'M4ENCODER_VideoInterface'
- * @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:        MCS is not in an appropriate state for this function to be called
- ******************************************************************************
- */
-M4OSA_ERR M4MCS_registerVideoEncoderExtended( M4MCS_Context pContext,
-                                             M4VE_EncoderType encoderType,
-                                             M4OSA_Context pEncoderInterface,
-                                             M4OSA_Void *pUserData )
-{
-    M4OSA_ERR err = M4NO_ERROR;
-    M4ENCODER_Format nativeType;
-    M4ENCODER_GlobalInterface *pEncShellInterface =
-        (M4ENCODER_GlobalInterface *)pEncoderInterface;
-    M4MCS_InternalContext *pC = (M4MCS_InternalContext *)pContext;
-    M4OSA_Bool bResetCurrentVideoEncoder = M4OSA_FALSE;
-    M4VIDEOEDITING_VideoFormat mediaType = M4VIDEOEDITING_kNoneVideo;
-
-    M4OSA_TRACE3_1(
-        "M4MCS_registerVideoEncoderExtended invoked with context = 0x%x",
-        pContext);
-
-    switch( encoderType )
-    {
-        case M4VE_kMpeg4VideoEnc:
-            nativeType = M4ENCODER_kMPEG4;
-            mediaType = M4VIDEOEDITING_kMPEG4;
-            break;
-
-        case M4VE_kH263VideoEnc:
-            nativeType = M4ENCODER_kH263;
-            mediaType = M4VIDEOEDITING_kH263;
-            break;
-
-        case M4VE_kH264VideoEnc:
-            nativeType = M4ENCODER_kH264;
-            mediaType = M4VIDEOEDITING_kH264;
-            break;
-
-        default:
-            M4OSA_TRACE1_1(
-                "M4MCS_registerVideoEncoderExtended: unknown encoderType %d",
-                encoderType);
-            return M4ERR_PARAMETER;
-    }
-
-    if( M4OSA_NULL != pC->pVideoEncoderGlobalFcts )
-    {
-        M4OSA_TRACE3_0(
-            "M4MCS_registerVideoEncoderExtended:\
-                 pC->pVideoEncoderGlobalFcts already set to previous registered Enc shell");
-
-        if( pC->EncodingVideoFormat == nativeType )
-            bResetCurrentVideoEncoder = M4OSA_TRUE;
-    }
-
-    err = M4MCS_registerVideoEncoder(pContext, nativeType, pEncShellInterface);
-
-    ( (M4MCS_InternalContext
-        *)pContext)->pVideoEncoderExternalAPITable[nativeType]
-    = pEncoderInterface;
-    ( (M4MCS_InternalContext
-        *)pContext)->pVideoEncoderUserDataTable[nativeType] = pUserData;
-
-    if( ( M4NO_ERROR == err) && (M4OSA_TRUE == bResetCurrentVideoEncoder) )
-    {
-        err = M4MCS_setCurrentVideoEncoder(pContext, mediaType);
-        M4OSA_TRACE3_1(
-            "M4MCS_registerVideoEncoderExtended: M4MCS_setCurrentVideoEncoder returned 0x%x",
-            err);
-    }
-    M4OSA_TRACE1_1(
-        "M4MCS_registerVideoEncoderExtended returning with error  = 0x%x", err);
-    return err;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerAudioEncoderExtended(M4MCS_Context pContext,
-M4ENCODER_AudioFormat encoderType,
-M4ENCODER_AudioGlobalInterface    *pEncoderInterface,
-M4OSA_Void* pUserData);
- * @brief    Registers an external Audio Encoder
- * @note This is much different from the external audio encoder to cope up with specific
- *        requirement of OMX codec implementation.
- * @param  pContext           (IN) MCS context
- * @param  encoderType        (IN) Type of encoder
- * @param  pEncoderInterface  (IN) Encoder interface to OMX shell function
- * @param  pUserData          (IN) Pointer on a user data to give to external encoder
- *                              (OMX Core Context)
- * @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_registerAudioEncoderExtended( M4MCS_Context pContext,
-                                             M4ENCODER_AudioFormat encoderType,
-                                             M4ENCODER_AudioGlobalInterface *pEncoderInterface,
-                                             M4OSA_Void *pUserData )
-{
-    M4OSA_ERR err = M4NO_ERROR;
-    M4MCS_InternalContext *pC = (M4MCS_InternalContext *)pContext;
-    M4OSA_Bool bResetCurrentAudioEncoder = M4OSA_FALSE;
-    M4VIDEOEDITING_AudioFormat mediaType = M4VIDEOEDITING_kNoneAudio;
-
-    switch( encoderType )
-    {
-        case M4ENCODER_kAMRNB:
-            mediaType = M4VIDEOEDITING_kAMR_NB;
-            break;
-
-        case M4ENCODER_kAAC:
-            mediaType = M4VIDEOEDITING_kAAC;
-            break;
-
-        case M4ENCODER_MP3:
-            mediaType = M4VIDEOEDITING_kMP3;
-            break;
-
-        default:
-            M4OSA_TRACE1_1(
-                "M4MCS_registerAudioEncoderExtended: unknown encoderType %d",
-                encoderType);
-            return M4ERR_PARAMETER;
-    }
-
-    if( M4OSA_NULL != pC->pAudioEncoderGlobalFcts )
-    {
-        M4OSA_TRACE3_0(
-            "M4MCS_registerAudioEncoderExtended: pC->pAudioEncoderGlobalFcts already set to \
-                previous registered Enc shell");
-
-        if( pC->AudioEncParams.Format == encoderType )
-            bResetCurrentAudioEncoder = M4OSA_TRUE;
-    }
-
-    err = M4MCS_registerAudioEncoder(pContext, encoderType, pEncoderInterface);
-
-    if( M4NO_ERROR != err )
-    {
-        M4OSA_TRACE1_1(
-            "M4MCS_registerAudioEncoderExtended: \
-                M4MCS_registerAudioEncoder failed with error 0x%08X",
-            err);
-        M4OSA_free((M4OSA_MemAddr32)pEncoderInterface);
-        return err;
-    }
-
-    ( (M4MCS_InternalContext
-        *)pContext)->pAudioEncoderInterface[encoderType] = pEncoderInterface;
-    ( (M4MCS_InternalContext
-        *)pContext)->pAudioEncoderUserDataTable[encoderType] = pUserData;
-
-    if( ( M4NO_ERROR == err) && (M4OSA_TRUE == bResetCurrentAudioEncoder) )
-    {
-        err = M4MCS_setCurrentAudioEncoder(pContext, mediaType);
-        M4OSA_TRACE3_1(
-            "M4MCS_registerAudioEncoderExtended: M4MCS_setCurrentAudioEncoder returned 0x%x",
-            err);
-    }
-    return err;
-}
-
-/**
- ******************************************************************************
- * M4OSA_ERR M4MCS_registerAudioDecoderExtended(M4MCS_Context pContext,
-M4AD_Type decoderType,
-M4AD_Interface    *pDecoderInterface,
-M4OSA_Void* pUserData);
- * @brief    Registers an external Audio Decoder
- * @note This is much different from the external audio decoder to cope up with specific
- *             requirement of OMX codec implementation.
- * @param  pContext           (IN) MCS context
- * @param  decoderType        (IN) Type of decoder
- * @param  pDecoderInterface  (IN) Decoder interface to OMX shell function
- * @param  pUserData          (IN) Pointer on a user data to give to external decoder
- *                                (OMX Core Context)
- * @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_registerAudioDecoderExtended( M4MCS_Context pContext,
-                                             M4AD_Type decoderType,
-                                             M4AD_Interface *pDecoderInterface,
-                                             M4OSA_Void *pUserData )
-{
-    M4OSA_ERR err = M4NO_ERROR;
-    M4MCS_InternalContext *pC = (M4MCS_InternalContext *)pContext;
-    M4OSA_Bool bResetCurrentAudioDecoder = M4OSA_FALSE;
-    M4_StreamType mediaType = M4DA_StreamTypeUnknown;
-
-    switch( decoderType )
-    {
-        case M4AD_kTypeAMRNB:
-            mediaType = M4DA_StreamTypeAudioAmrNarrowBand;
-            break;
-
-        case M4AD_kTypeAAC:
-            mediaType = M4DA_StreamTypeAudioAac;
-            break;
-
-        case M4AD_kTypeMP3:
-            mediaType = M4DA_StreamTypeAudioMp3;
-            break;
-
-        default:
-            M4OSA_TRACE1_1(
-                "M4MCS_registerAudioDecoderExtended: unknown decoder type %d",
-                decoderType);
-            return M4ERR_PARAMETER;
-    }
-
-    if( M4OSA_NULL != pC->m_pAudioDecoder )
-    {
-        M4OSA_TRACE3_0(
-            "M4MCS_registerAudioDecoderExtended:\
-                 pC->m_pAudioDecoder already set to previous registered Dec shell");
-
-        if( pC->pReaderAudioStream->m_basicProperties.m_streamType
-            == mediaType )
-            bResetCurrentAudioDecoder = M4OSA_TRUE;
-
-        /* Audio decoder may be created for getting input Clip properties.
-         In that case, previous audio dec context needs to be destroyed*
-        * before registering new decoder shell */
-        if( M4OSA_NULL != pC->pAudioDecCtxt )
-        {
-            err = pC->m_pAudioDecoder->m_pFctDestroyAudioDec(pC->pAudioDecCtxt);
-            pC->pAudioDecCtxt = M4OSA_NULL;
-
-            if( M4NO_ERROR != err )
-            {
-                M4OSA_TRACE1_1(
-                    "M4MCS_registerAudioDecoderExtended:\
-                         m_pAudioDecoder->m_pFctDestroyAudioDec returns 0x%x",
-                    err);
-            }
-        }
-    }
-
-    err = M4MCS_registerAudioDecoder(pContext, decoderType, pDecoderInterface);
-
-    if( M4NO_ERROR != err )
-    {
-        M4OSA_TRACE1_1(
-            "M4MCS_registerAudioDecoderExtended:\
-                 M4MCS_registerAudioDecoder failed with error 0x%08X",
-            err);
-        M4OSA_free((M4OSA_MemAddr32)pDecoderInterface);
-        return err;
-    }
-
-    ( (M4MCS_InternalContext
-        *)pContext)->m_pAudioDecoderItTable[decoderType] = pDecoderInterface;
-    ( (M4MCS_InternalContext
-        *)pContext)->m_pAudioDecoderUserDataTable[decoderType] = pUserData;
-
-    ( (M4MCS_InternalContext *)pContext)->bExtOMXAudDecoder = M4OSA_TRUE;
-
-    if( ( M4NO_ERROR == err) && (M4OSA_TRUE == bResetCurrentAudioDecoder) )
-    {
-        err = M4MCS_setCurrentAudioDecoder(pContext, mediaType);
-        M4OSA_TRACE3_1(
-            "M4MCS_registerAudioDecoderExtended: M4MCS_setCurrentAudioDecoder returned 0x%x",
-            err);
-    }
-    return err;
-}
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c b/libvideoeditor/vss/mcs/src/M4MCS_BitstreamParser.c
deleted file mode 100755
index 182e476..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;
-
-    M4OSA_memset(in, pC->ReaderVideoAU.m_size , 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 == 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/mcs/src/M4MCS_Codecs.c b/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
index 9dffaad..cbff66c 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_Codecs.c
@@ -211,7 +211,7 @@
         /* can be legitimate, in cases where we have one version that can use external encoders
         but which still has the built-in one to be able to work without an external encoder; in
         this case the new encoder simply replaces the old one (i.e. we unregister it first). */
-        M4OSA_free((M4OSA_MemAddr32)pC->pVideoEncoderInterface[MediaType]);
+        free(pC->pVideoEncoderInterface[MediaType]);
         pC->pVideoEncoderInterface[MediaType] = M4OSA_NULL;
     }
 
@@ -265,12 +265,12 @@
 
     if(M4OSA_NULL != pC->pAudioEncoderInterface[MediaType])
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pAudioEncoderInterface[MediaType]);
+        free(pC->pAudioEncoderInterface[MediaType]);
         pC->pAudioEncoderInterface[MediaType] = M4OSA_NULL;
 
         if(M4OSA_NULL != pC->pAudioEncoderUserDataTable[MediaType])
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->pAudioEncoderUserDataTable[MediaType]);
+            free(pC->pAudioEncoderUserDataTable[MediaType]);
             pC->pAudioEncoderUserDataTable[MediaType] = M4OSA_NULL;
         }
     }
@@ -366,12 +366,12 @@
         /* can be legitimate, in cases where we have one version that can use external decoders
         but which still has the built-in one to be able to work without an external decoder; in
         this case the new decoder simply replaces the old one (i.e. we unregister it first). */
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pVideoDecoderItTable[decoderType]);
+        free(pC->m_pVideoDecoderItTable[decoderType]);
         pC->m_pVideoDecoderItTable[decoderType] = M4OSA_NULL;
         /* oh, and don't forget the user data, too. */
         if (pC->m_pVideoDecoderUserDataTable[decoderType] != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pVideoDecoderUserDataTable[decoderType]);
+            free(pC->m_pVideoDecoderUserDataTable[decoderType]);
             pC->m_pVideoDecoderUserDataTable[decoderType] = M4OSA_NULL;
         }
 #endif /* are external decoders possible? */
@@ -420,12 +420,12 @@
 
     if(M4OSA_NULL != pC->m_pAudioDecoderItTable[decoderType])
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioDecoderItTable[decoderType]);
+        free(pC->m_pAudioDecoderItTable[decoderType]);
         pC->m_pAudioDecoderItTable[decoderType] = M4OSA_NULL;
 
         if(M4OSA_NULL != pC->m_pAudioDecoderUserDataTable[decoderType])
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioDecoderUserDataTable[decoderType]);
+            free(pC->m_pAudioDecoderUserDataTable[decoderType]);
             pC->m_pAudioDecoderUserDataTable[decoderType] = M4OSA_NULL;
         }
     }
@@ -455,12 +455,12 @@
     {
         if (pC->WriterInterface[i].pGlobalFcts != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->WriterInterface[i].pGlobalFcts );
+            free(pC->WriterInterface[i].pGlobalFcts );
             pC->WriterInterface[i].pGlobalFcts = M4OSA_NULL;
         }
         if (pC->WriterInterface[i].pDataFcts != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->WriterInterface[i].pDataFcts );
+            free(pC->WriterInterface[i].pDataFcts );
             pC->WriterInterface[i].pDataFcts = M4OSA_NULL;
         }
     }
@@ -491,7 +491,7 @@
     {
         if (pC->pVideoEncoderInterface[i] != M4OSA_NULL)
         {
-            M4OSA_free( (M4OSA_MemAddr32)pC->pVideoEncoderInterface[i] );
+            free(pC->pVideoEncoderInterface[i] );
             pC->pVideoEncoderInterface[i] = M4OSA_NULL;
         }
     }
@@ -503,7 +503,7 @@
             /*Don't free external audio encoders interfaces*/
             if (M4OSA_FALSE == pC->pAudioEncoderFlag[i])
             {
-                M4OSA_free( (M4OSA_MemAddr32)pC->pAudioEncoderInterface[i] );
+                free(pC->pAudioEncoderInterface[i] );
             }
             pC->pAudioEncoderInterface[i] = M4OSA_NULL;
         }
@@ -535,12 +535,12 @@
     {
         if (pC->m_pReaderGlobalItTable[i] != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderGlobalItTable[i] );
+            free(pC->m_pReaderGlobalItTable[i] );
             pC->m_pReaderGlobalItTable[i] = M4OSA_NULL;
         }
         if (pC->m_pReaderDataItTable[i] != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderDataItTable[i] );
+            free(pC->m_pReaderDataItTable[i] );
             pC->m_pReaderDataItTable[i] = M4OSA_NULL;
         }
     }
@@ -572,7 +572,7 @@
     {
         if (pC->m_pVideoDecoderItTable[i] != M4OSA_NULL)
         {
-            M4OSA_free( (M4OSA_MemAddr32)pC->m_pVideoDecoderItTable[i] );
+            free(pC->m_pVideoDecoderItTable[i] );
             pC->m_pVideoDecoderItTable[i] = M4OSA_NULL;
         }
     }
@@ -584,7 +584,7 @@
             /*Don't free external audio decoders interfaces*/
             if (M4OSA_FALSE == pC->m_pAudioDecoderFlagTable[i])
             {
-                M4OSA_free( (M4OSA_MemAddr32)pC->m_pAudioDecoderItTable[i] );
+                free(pC->m_pAudioDecoderItTable[i] );
             }
             pC->m_pAudioDecoderItTable[i] = M4OSA_NULL;
         }
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_VideoPreProcessing.c b/libvideoeditor/vss/mcs/src/M4MCS_VideoPreProcessing.c
index f9dffdb..36ad9d9 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_VideoPreProcessing.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_VideoPreProcessing.c
@@ -91,15 +91,12 @@
      is black borders */
     if(pC->MediaRendering == M4MCS_kBlackBorders)
     {
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[0].pac_data,
-            (pPlaneOut[0].u_height*pPlaneOut[0].u_stride),
-            Y_PLANE_BORDER_VALUE);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[1].pac_data,
-            (pPlaneOut[1].u_height*pPlaneOut[1].u_stride),
-            U_PLANE_BORDER_VALUE);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[2].pac_data,
-            (pPlaneOut[2].u_height*pPlaneOut[2].u_stride),
-            V_PLANE_BORDER_VALUE);
+        memset((void *)pPlaneOut[0].pac_data,Y_PLANE_BORDER_VALUE,
+            (pPlaneOut[0].u_height*pPlaneOut[0].u_stride));
+        memset((void *)pPlaneOut[1].pac_data,U_PLANE_BORDER_VALUE,
+            (pPlaneOut[1].u_height*pPlaneOut[1].u_stride));
+        memset((void *)pPlaneOut[2].pac_data,V_PLANE_BORDER_VALUE,
+            (pPlaneOut[2].u_height*pPlaneOut[2].u_stride));
     }
     else if ((M4OSA_NULL == pC->ReaderVideoAU.m_dataAddress) ||
              (M4OSA_NULL == pC->pViDecCtxt))
@@ -107,12 +104,12 @@
         /**
          * We must fill the input of the encoder with a dummy image, because
          * encoding noise leads to a huge video AU, and thus a writer buffer overflow. */
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[0].pac_data,
-             pPlaneOut[0].u_stride * pPlaneOut[0].u_height, 0);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[1].pac_data,
-             pPlaneOut[1].u_stride * pPlaneOut[1].u_height, 0);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[2].pac_data,
-             pPlaneOut[2].u_stride * pPlaneOut[2].u_height, 0);
+        memset((void *)pPlaneOut[0].pac_data,0,
+             pPlaneOut[0].u_stride * pPlaneOut[0].u_height);
+        memset((void *)pPlaneOut[1].pac_data,0,
+             pPlaneOut[1].u_stride * pPlaneOut[1].u_height);
+        memset((void *)pPlaneOut[2].pac_data,0,
+             pPlaneOut[2].u_stride * pPlaneOut[2].u_height);
 
         M4OSA_TRACE1_0("M4MCS_intApplyVPP: pReaderVideoAU->m_dataAddress is M4OSA_NULL,\
                        returning M4NO_ERROR");
@@ -200,7 +197,7 @@
 
                     /* Allocates plan in local image plane structure */
                     pImagePlanesTemp[0].pac_data =
-                        (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[0]\
+                        (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[0]\
                         .u_width * pImagePlanesTemp[0].u_height, M4VS,
                         (M4OSA_Char *)"M4xVSS_PictureCallbackFct: temporary plane bufferY") ;
                     if(pImagePlanesTemp[0].pac_data == M4OSA_NULL)
@@ -209,7 +206,7 @@
                         return M4ERR_ALLOC;
                     }
                     pImagePlanesTemp[1].pac_data =
-                        (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[1]\
+                        (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[1]\
                         .u_width * pImagePlanesTemp[1].u_height, M4VS,
                         (M4OSA_Char *)"M4xVSS_PictureCallbackFct: temporary plane bufferU") ;
                     if(pImagePlanesTemp[1].pac_data == M4OSA_NULL)
@@ -218,7 +215,7 @@
                         return M4ERR_ALLOC;
                     }
                     pImagePlanesTemp[2].pac_data =
-                        (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[2]\
+                        (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[2]\
                         .u_width * pImagePlanesTemp[2].u_height,
                         M4VS,(M4OSA_Char *)"M4xVSS_PictureCallbackFct: temporary plane bufferV") ;
                     if(pImagePlanesTemp[2].pac_data == M4OSA_NULL)
@@ -231,15 +228,12 @@
                     pInPlaneU = pImagePlanesTemp[1].pac_data ;
                     pInPlaneV = pImagePlanesTemp[2].pac_data ;
 
-                    M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[0].pac_data,
-                        (pImagePlanesTemp[0].u_height*pImagePlanesTemp[0].u_stride),
-                        Y_PLANE_BORDER_VALUE);
-                    M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[1].pac_data,
-                        (pImagePlanesTemp[1].u_height*pImagePlanesTemp[1].u_stride),
-                        U_PLANE_BORDER_VALUE);
-                    M4OSA_memset((M4OSA_MemAddr8)pImagePlanesTemp[2].pac_data,
-                        (pImagePlanesTemp[2].u_height*pImagePlanesTemp[2].u_stride),
-                        V_PLANE_BORDER_VALUE);
+                    memset((void *)pImagePlanesTemp[0].pac_data,Y_PLANE_BORDER_VALUE,
+                        (pImagePlanesTemp[0].u_height*pImagePlanesTemp[0].u_stride));
+                    memset((void *)pImagePlanesTemp[1].pac_data,U_PLANE_BORDER_VALUE,
+                        (pImagePlanesTemp[1].u_height*pImagePlanesTemp[1].u_stride));
+                    memset((void *)pImagePlanesTemp[2].pac_data,V_PLANE_BORDER_VALUE,
+                        (pImagePlanesTemp[2].u_height*pImagePlanesTemp[2].u_stride));
 
                     if((M4OSA_UInt32)((pC->pPreResizeFrame->u_height * pPlaneOut->u_width)\
                          /pC->pPreResizeFrame->u_width) <= pPlaneOut->u_height)
@@ -389,24 +383,24 @@
                 {
                     for(i=0; i<pPlaneOut[0].u_height; i++)
                     {
-                        M4OSA_memcpy(   (M4OSA_MemAddr8)pOutPlaneY,
-                                        (M4OSA_MemAddr8)pInPlaneY,
+                        memcpy(   (void *)pOutPlaneY,
+                                        (void *)pInPlaneY,
                                         pPlaneOut[0].u_width);
                         pInPlaneY += pPlaneOut[0].u_width;
                         pOutPlaneY += pPlaneOut[0].u_stride;
                     }
                     for(i=0; i<pPlaneOut[1].u_height; i++)
                     {
-                        M4OSA_memcpy(   (M4OSA_MemAddr8)pOutPlaneU,
-                                        (M4OSA_MemAddr8)pInPlaneU,
+                        memcpy(   (void *)pOutPlaneU,
+                                        (void *)pInPlaneU,
                                         pPlaneOut[1].u_width);
                         pInPlaneU += pPlaneOut[1].u_width;
                         pOutPlaneU += pPlaneOut[1].u_stride;
                     }
                     for(i=0; i<pPlaneOut[2].u_height; i++)
                     {
-                        M4OSA_memcpy(   (M4OSA_MemAddr8)pOutPlaneV,
-                                        (M4OSA_MemAddr8)pInPlaneV,
+                        memcpy(   (void *)pOutPlaneV,
+                                        (void *)pInPlaneV,
                                         pPlaneOut[2].u_width);
                         pInPlaneV += pPlaneOut[2].u_width;
                         pOutPlaneV += pPlaneOut[2].u_stride;
@@ -416,7 +410,7 @@
                     {
                         if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)
+                            free(
                                         pImagePlanesTemp[i].pac_data);
                             pImagePlanesTemp[i].pac_data = M4OSA_NULL;
                         }
@@ -441,14 +435,14 @@
     else
     {
         /* Copy last decoded plane to output plane */
-        M4OSA_memcpy((M4OSA_MemAddr8)pPlaneOut[0].pac_data,
-                        (M4OSA_MemAddr8)pC->lastDecodedPlane[0].pac_data,
+        memcpy((void *)pPlaneOut[0].pac_data,
+                        (void *)pC->lastDecodedPlane[0].pac_data,
                          (pPlaneOut[0].u_height * pPlaneOut[0].u_width));
-        M4OSA_memcpy((M4OSA_MemAddr8)pPlaneOut[1].pac_data,
-                        (M4OSA_MemAddr8)pC->lastDecodedPlane[1].pac_data,
+        memcpy((void *)pPlaneOut[1].pac_data,
+                        (void *)pC->lastDecodedPlane[1].pac_data,
                           (pPlaneOut[1].u_height * pPlaneOut[1].u_width));
-        M4OSA_memcpy((M4OSA_MemAddr8)pPlaneOut[2].pac_data,
-                        (M4OSA_MemAddr8)pC->lastDecodedPlane[2].pac_data,
+        memcpy((void *)pPlaneOut[2].pac_data,
+                        (void *)pC->lastDecodedPlane[2].pac_data,
                           (pPlaneOut[2].u_height * pPlaneOut[2].u_width));
         pC->lastDecodedPlane = pPlaneOut;
     }
diff --git a/libvideoeditor/vss/src/Android.mk b/libvideoeditor/vss/src/Android.mk
index 57c970f..41cd15d 100755
--- a/libvideoeditor/vss/src/Android.mk
+++ b/libvideoeditor/vss/src/Android.mk
@@ -38,9 +38,8 @@
       M4VSS3GPP_EditAudio.c \
       M4VSS3GPP_EditVideo.c \
       M4VSS3GPP_MediaAndCodecSubscription.c \
-      M4ChannelCoverter.c \
+      M4ChannelConverter.c \
       M4VD_EXTERNAL_BitstreamParser.c \
-      M4VD_EXTERNAL_Interface.c \
       M4AIR_API.c \
       M4READER_Pcm.c \
       M4PCMR_CoreReader.c \
@@ -85,11 +84,5 @@
     -DM4xVSS_RESERVED_MOOV_DISK_SPACEno \
     -DDECODE_GIF_ON_SAVING
 
-# Don't prelink this library.  For more efficient code, you may want
-# to add this library to the prelink map and set this to true.
-LOCAL_PRELINK_MODULE := false
-
-
-
 include $(BUILD_STATIC_LIBRARY)
 
diff --git a/libvideoeditor/vss/src/M4AD_Null.c b/libvideoeditor/vss/src/M4AD_Null.c
index faac43b..5620358 100755
--- a/libvideoeditor/vss/src/M4AD_Null.c
+++ b/libvideoeditor/vss/src/M4AD_Null.c
@@ -86,7 +86,7 @@
     M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
                 "M4AD_NULL_create: invalid pointer pStreamHandler");
 
-    pC = (M4AD_NullContext*)M4OSA_malloc(sizeof(M4AD_NullContext),
+    pC = (M4AD_NullContext*)M4OSA_32bitAlignedMalloc(sizeof(M4AD_NullContext),
                  M4DECODER_AUDIO, (M4OSA_Char *)"M4AD_NullContext");
     if (pC == (M4AD_NullContext*)0)
     {
@@ -118,7 +118,7 @@
 
     M4OSA_DEBUG_IF1((context == M4OSA_NULL), M4ERR_PARAMETER, "M4AD_NULL_destroy: invalid context");
 
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
 
     return M4NO_ERROR;
 }
@@ -171,11 +171,11 @@
     }
     else
     {
-        M4OSA_memcpy(pDecodedPCMBuffer->m_dataAddress, pInputBuffer->m_dataAddress,
+        memcpy((void *)pDecodedPCMBuffer->m_dataAddress, (void *)pInputBuffer->m_dataAddress,
                     pInputBuffer->m_bufferSize );
     }
 #else /*M4AD_FORCE_16BITS*/
-    M4OSA_memcpy(pDecodedPCMBuffer->m_dataAddress, pInputBuffer->m_dataAddress,
+    memcpy((void *)pDecodedPCMBuffer->m_dataAddress, (void *)pInputBuffer->m_dataAddress,
                     pInputBuffer->m_bufferSize );
 #endif /*M4AD_FORCE_16BITS*/
 
@@ -234,7 +234,7 @@
 */
 M4OSA_ERR M4AD_NULL_getInterface( M4AD_Type *pDecoderType, M4AD_Interface **pDecoderInterface)
 {
-    *pDecoderInterface = (  M4AD_Interface*)M4OSA_malloc( sizeof(M4AD_Interface),
+    *pDecoderInterface = (  M4AD_Interface*)M4OSA_32bitAlignedMalloc( sizeof(M4AD_Interface),
                             M4DECODER_AUDIO, (M4OSA_Char *)"M4AD_Interface" );
     if (M4OSA_NULL == *pDecoderInterface)
     {
diff --git a/libvideoeditor/vss/src/M4AIR_API.c b/libvideoeditor/vss/src/M4AIR_API.c
index 6a3546d..cb423e0 100755
--- a/libvideoeditor/vss/src/M4AIR_API.c
+++ b/libvideoeditor/vss/src/M4AIR_API.c
@@ -128,7 +128,7 @@
     *pContext = M4OSA_NULL ;
 
     /* Internal Context creation */
-    pC = (M4AIR_InternalContext*)M4OSA_malloc(sizeof(M4AIR_InternalContext),
+    pC = (M4AIR_InternalContext*)M4OSA_32bitAlignedMalloc(sizeof(M4AIR_InternalContext),
          M4AIR,(M4OSA_Char *)"AIR internal context") ;
     M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, pC) ;
 
@@ -162,7 +162,7 @@
     /* Error management : we destroy the context if needed */
     if(M4OSA_NULL != pC)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC) ;
+        free(pC) ;
     }
 
     *pContext = M4OSA_NULL ;
@@ -193,7 +193,7 @@
     {
         return M4ERR_STATE;
     }
-    M4OSA_free((M4OSA_MemAddr32)pC) ;
+    free(pC) ;
 
     return M4NO_ERROR ;
 
@@ -531,7 +531,7 @@
                     for(j=0;j<pOut[i].u_height;j++)
                     {
                         /**< Copy one whole line */
-                        M4OSA_memcpy((M4OSA_MemAddr8)pu8_data_out, (M4OSA_MemAddr8)pu8_data_in,
+                        memcpy((void *)pu8_data_out, (void *)pu8_data_in,
                              pOut[i].u_width);
 
                         /**< Update pointers */
diff --git a/libvideoeditor/vss/src/M4AMRR_CoreReader.c b/libvideoeditor/vss/src/M4AMRR_CoreReader.c
index 14f5271..db2100f 100755
--- a/libvideoeditor/vss/src/M4AMRR_CoreReader.c
+++ b/libvideoeditor/vss/src/M4AMRR_CoreReader.c
@@ -178,7 +178,7 @@
     M4OSA_DEBUG_IF2((M4OSA_NULL == pContext),M4ERR_PARAMETER,"Context M4OSA_NULL");
     M4OSA_DEBUG_IF2((M4OSA_NULL == pFileDescriptor),M4ERR_PARAMETER,"File Desc. M4OSA_NULL");
 
-    M4_Token = (M4OSA_Char*)M4OSA_malloc(sizeof(M4OSA_MemAddr32)*3, M4AMR_READER,
+    M4_Token = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_MemAddr32)*3, M4AMR_READER,
                  (M4OSA_Char *)("M4_Token"));
     if(M4OSA_NULL == M4_Token)
     {
@@ -186,11 +186,11 @@
         return M4ERR_ALLOC ;
     }
 
-    pStreamContext= (M4_AMRR_Context*)M4OSA_malloc(sizeof(M4_AMRR_Context), M4AMR_READER,
+    pStreamContext= (M4_AMRR_Context*)M4OSA_32bitAlignedMalloc(sizeof(M4_AMRR_Context), M4AMR_READER,
                      (M4OSA_Char *)("pStreamContext"));
     if(M4OSA_NULL == pStreamContext)
     {
-        M4OSA_free((M4OSA_MemAddr32)M4_Token);
+        free(M4_Token);
         *pContext = M4OSA_NULL ;
         return M4ERR_ALLOC ;
     }
@@ -211,8 +211,8 @@
     if ( err != M4NO_ERROR )
     {
         /* M4OSA_DEBUG_IF3((err != M4NO_ERROR),err,"File open failed"); */
-        M4OSA_free((M4OSA_MemAddr32)pStreamContext);
-        M4OSA_free((M4OSA_MemAddr32)M4_Token);

+        free(pStreamContext);
+        free(M4_Token);
         *pContext = M4OSA_NULL ;
         return err ;
     }
@@ -266,7 +266,7 @@
     /*  No Profile level defined */
     pStreamContext->m_status = M4AMRR_kOpened;
 
-    M4OSA_free((M4OSA_MemAddr32)M4_Token);
+    free(M4_Token);
     *pContext = pStreamContext ;
     return M4NO_ERROR;
 
@@ -277,8 +277,8 @@
         pStreamContext->m_pOsaFilePtrFct->closeRead(pStreamContext->m_pAMRFile);
     }
 
-    M4OSA_free((M4OSA_MemAddr32)M4_Token);
-    M4OSA_free((M4OSA_MemAddr32)pStreamContext);
+    free(M4_Token);
+    free(pStreamContext);
 
     *pContext = M4OSA_NULL ;
 
@@ -347,10 +347,10 @@
 
     /* Timescale equals Sampling Frequency: NB-8000 Hz, WB-16000 Hz */
     pStreamDesc->timeScale = (pStreamContext->m_streamType == M4SYS_kAMR )?8000:16000;
-    M4OSA_TIME_SET_UNKNOWN(pStreamDesc->duration);
+    pStreamDesc->duration = M4OSA_TIME_UNKNOWN;
 
     pStreamContext->m_pStreamHandler =
-         (M4SYS_StreamDescription*)M4OSA_malloc(sizeof(M4SYS_StreamDescription),
+         (M4SYS_StreamDescription*)M4OSA_32bitAlignedMalloc(sizeof(M4SYS_StreamDescription),
              M4AMR_READER, (M4OSA_Char *)("pStreamContext->m_pStreamHandler"));
     if(M4OSA_NULL == pStreamContext->m_pStreamHandler)
     {
@@ -361,7 +361,7 @@
     pStreamContext->m_pStreamHandler->averageBitrate = pStreamDesc->averageBitrate;
     pStreamContext->m_pStreamHandler->decoderSpecificInfo = M4OSA_NULL ;
     pStreamContext->m_pStreamHandler->decoderSpecificInfoSize = 0 ;
-    M4OSA_TIME_SET_UNKNOWN(pStreamContext->m_pStreamHandler->duration);
+    pStreamContext->m_pStreamHandler->duration = M4OSA_TIME_UNKNOWN;
     pStreamContext->m_pStreamHandler->profileLevel = 0xFF ;
     pStreamContext->m_pStreamHandler->streamID = 1;
     pStreamContext->m_pStreamHandler->streamType = pStreamDesc->streamType ;
@@ -441,7 +441,7 @@
     {
         size = pStreamContext->m_maxAuSize ;
         /* dataAddress is owned by Parser, application should not delete or free it */
-        pStreamContext->m_pdataAddress =(M4OSA_MemAddr32)M4OSA_malloc(size + (4 - size % 4),
+        pStreamContext->m_pdataAddress =(M4OSA_MemAddr32)M4OSA_32bitAlignedMalloc(size + (4 - size % 4),
             M4AMR_READER, (M4OSA_Char *)("pStreamContext->m_pdataAddress"));
         if(M4OSA_NULL == pStreamContext->m_pdataAddress)
         {
@@ -595,7 +595,7 @@
     /*Make explicit time cast, but take care that timescale is not used !!!*/
     M4OSA_TIME_TO_MS(time_double, time, 1000);
 
-    M4OSA_INT64_FROM_INT32(*pObtainCTS, 0);
+    *pObtainCTS = 0;
 
     M4OSA_DEBUG_IF2((M4OSA_NULL == Context),M4ERR_PARAMETER,"Context M4OSA_NULL");
     M4OSA_DEBUG_IF2((pStreamContext->m_contextId != M4AMRR_CONTEXTID),M4ERR_BAD_CONTEXT,
@@ -611,7 +611,7 @@
 
         count = 0 ;
         pStreamContext->m_pSeekIndex =
-             (M4OSA_UInt32*)M4OSA_malloc(M4AMRR_NUM_SEEK_ENTRIES * sizeof(M4OSA_UInt32),
+             (M4OSA_UInt32*)M4OSA_32bitAlignedMalloc(M4AMRR_NUM_SEEK_ENTRIES * sizeof(M4OSA_UInt32),
                  M4AMR_READER, (M4OSA_Char *)("pStreamContext->m_pSeekIndex"));
 
         if(M4OSA_NULL == pStreamContext->m_pSeekIndex)
@@ -740,11 +740,11 @@
 
     if ( partSeekTime == 0)
     {
-        M4OSA_TIME_SET(*pObtainCTS, time);
+        *pObtainCTS = time;
         return M4NO_ERROR;
     }
 
-    M4OSA_INT64_FROM_DOUBLE(*pObtainCTS, (time_double - (M4OSA_Double)partSeekTime)) ;
+    *pObtainCTS = (M4OSA_Time)(time_double - (M4OSA_Double)partSeekTime);
 
     switch(seekMode)
     {
@@ -793,7 +793,7 @@
         if ( size == 0)
         {
             /* If the target time is invalid, point to begining and return */
-            M4OSA_INT64_FROM_INT32(*pObtainCTS, 0);
+            *pObtainCTS = 0;
             filePos = pStreamContext->m_pSeekIndex[0];
             pStreamContext->m_pOsaFilePtrFct->seek(pStreamContext->m_pAMRFile,
                  M4OSA_kFileSeekBeginning, &filePos);
@@ -834,23 +834,23 @@
     /* Check if AU data Address is allocated memory and free it */
     if(M4OSA_NULL != pStreamContext->m_pdataAddress)
     {
-        M4OSA_free((M4OSA_MemAddr32)pStreamContext->m_pdataAddress);
+        free(pStreamContext->m_pdataAddress);
     }
 
     /* Check if the stream handler is allocated memory */
     if(M4OSA_NULL != pStreamContext->m_pStreamHandler)
     {
-        M4OSA_free((M4OSA_MemAddr32)pStreamContext->m_pStreamHandler);
+        free(pStreamContext->m_pStreamHandler);
     }
 
     /* Seek table is created only when seek is used, so check if memory is allocated */
     if(M4OSA_NULL != pStreamContext->m_pSeekIndex)
     {
-        M4OSA_free((M4OSA_MemAddr32)pStreamContext->m_pSeekIndex);
+        free(pStreamContext->m_pSeekIndex);
     }
 
     /* Free the context */
-    M4OSA_free((M4OSA_MemAddr32)pStreamContext);
+    free(pStreamContext);
 
     return M4NO_ERROR ;
 }
diff --git a/libvideoeditor/vss/src/M4ChannelCoverter.c b/libvideoeditor/vss/src/M4ChannelConverter.c
similarity index 100%
rename from libvideoeditor/vss/src/M4ChannelCoverter.c
rename to libvideoeditor/vss/src/M4ChannelConverter.c
diff --git a/libvideoeditor/vss/src/M4PCMR_CoreReader.c b/libvideoeditor/vss/src/M4PCMR_CoreReader.c
index 15fd9c8..efde770 100755
--- a/libvideoeditor/vss/src/M4PCMR_CoreReader.c
+++ b/libvideoeditor/vss/src/M4PCMR_CoreReader.c
@@ -76,7 +76,7 @@
 
     /* Allocates the context */
     context = M4OSA_NULL;
-    context = (M4PCMR_Context *)M4OSA_malloc(sizeof(M4PCMR_Context), M4WAV_READER,
+    context = (M4PCMR_Context *)M4OSA_32bitAlignedMalloc(sizeof(M4PCMR_Context), M4WAV_READER,
          (M4OSA_Char *)"M4PCMR_openRead");
     if (M4OSA_NULL == context)
     {
@@ -95,7 +95,7 @@
     context->m_pDecoderSpecInfo = M4OSA_NULL;
 
     /* Set sample frequency */
-    pTempURL = (M4OSA_Char*)pUrl + (M4OSA_chrLength((M4OSA_Char*)pUrl)-11);
+    pTempURL = (M4OSA_Char*)pUrl + (strlen((const char *)pUrl)-11);
     M4OSA_chrNCopy(value, pTempURL, 5);
     M4OSA_chrGetUInt32(pTempURL, &(context->m_decoderConfig.SampleFrequency),
          M4OSA_NULL, M4OSA_kchrDec);
@@ -106,7 +106,7 @@
     M4OSA_chrGetUInt16(pTempURL, &(context->m_decoderConfig.nbChannels),
          M4OSA_NULL, M4OSA_kchrDec);
 
-    M4OSA_chrNCopy(pUrl,pUrl, (M4OSA_chrLength((M4OSA_Char*)pUrl)-12));
+    M4OSA_chrNCopy(pUrl,pUrl, (strlen((const char *)pUrl)-12));
     /* Open the file */
     context->m_fileContext = M4OSA_NULL;
     err = pFileFunction->openRead(&(context->m_fileContext), pUrl, M4OSA_kFileRead);
@@ -141,7 +141,7 @@
     context->m_dataStartOffset = 0;
     context->m_pFileReadFunc = pFileFunction;
 
-    context->m_pAuBuffer = (M4OSA_MemAddr32)M4OSA_malloc(context->m_blockSize, M4WAV_READER,
+    context->m_pAuBuffer = (M4OSA_MemAddr32)M4OSA_32bitAlignedMalloc(context->m_blockSize, M4WAV_READER,
          (M4OSA_Char *)"Core PCM reader Access Unit");
     if (M4OSA_NULL == context->m_pAuBuffer)
     {
@@ -161,7 +161,7 @@
         context->m_pFileReadFunc->closeRead(context->m_fileContext);
 
     /* Free internal context */
-    M4OSA_free((M4OSA_MemAddr32)context);
+    free(context);
     *pContext = M4OSA_NULL;
 
     return err;
@@ -213,7 +213,7 @@
     /* Allocates decoder specific info structure */
     pStreamDesc->decoderSpecificInfo = M4OSA_NULL;
     pStreamDesc->decoderSpecificInfo =
-        (M4OSA_MemAddr32)M4OSA_malloc( sizeof(M4PCMC_DecoderSpecificInfo), M4WAV_READER,
+        (M4OSA_MemAddr32)M4OSA_32bitAlignedMalloc( sizeof(M4PCMC_DecoderSpecificInfo), M4WAV_READER,
              (M4OSA_Char *)"M4PCMR_getNextStream");
     if(pStreamDesc->decoderSpecificInfo == M4OSA_NULL)
     {
@@ -221,8 +221,8 @@
     }
     /* Fill decoderSpecificInfo structure, with decoder config structure filled in 'openread'
          function */
-    M4OSA_memcpy((M4OSA_MemAddr8)pStreamDesc->decoderSpecificInfo,
-         (M4OSA_MemAddr8)&c->m_decoderConfig, sizeof(M4PCMC_DecoderSpecificInfo));
+    memcpy((void *)pStreamDesc->decoderSpecificInfo,
+         (void *)&c->m_decoderConfig, sizeof(M4PCMC_DecoderSpecificInfo));
 
     /* Fill other fields of pStreamDesc structure */
     pStreamDesc->timeScale = 1000;
@@ -569,7 +569,7 @@
 
     if(c->m_pDecoderSpecInfo != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)c->m_pDecoderSpecInfo);
+        free(c->m_pDecoderSpecInfo);
     }
 
     /* Check Reader's state */
@@ -584,7 +584,7 @@
 
     if (M4OSA_NULL != c->m_pAuBuffer)
     {
-        M4OSA_free((M4OSA_MemAddr32)c->m_pAuBuffer);
+        free(c->m_pAuBuffer);
     }
 
     /* Close the file */
@@ -596,7 +596,7 @@
     /* Free internal context */
     if (M4OSA_NULL != c)
     {
-        M4OSA_free((M4OSA_MemAddr32)c);
+        free(c);
     }
 
     return err;
diff --git a/libvideoeditor/vss/src/M4PTO3GPP_API.c b/libvideoeditor/vss/src/M4PTO3GPP_API.c
index 5581cbd..2ce22f6 100755
--- a/libvideoeditor/vss/src/M4PTO3GPP_API.c
+++ b/libvideoeditor/vss/src/M4PTO3GPP_API.c
@@ -169,7 +169,7 @@
 
     /**
      *  Allocate the M4PTO3GPP context and return it to the user */
-    pC = (M4PTO3GPP_InternalContext*)M4OSA_malloc(sizeof(M4PTO3GPP_InternalContext), M4PTO3GPP,
+    pC = (M4PTO3GPP_InternalContext*)M4OSA_32bitAlignedMalloc(sizeof(M4PTO3GPP_InternalContext), M4PTO3GPP,
         (M4OSA_Char *)"M4PTO3GPP_InternalContext");
     *pContext = pC;
     if (M4OSA_NULL == pC)
@@ -242,13 +242,6 @@
     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;
 }
@@ -424,8 +417,8 @@
 
     /**
      * Copy the M4PTO3GPP_Params structure */
-    M4OSA_memcpy((M4OSA_MemAddr8)(&pC->m_Params),
-                (M4OSA_MemAddr8)pParams, sizeof(M4PTO3GPP_Params));
+    memcpy((void *)(&pC->m_Params),
+                (void *)pParams, sizeof(M4PTO3GPP_Params));
     M4OSA_TRACE1_1("M4PTO3GPP_Open: outputVideoBitrate = %d", pC->m_Params.OutputVideoBitrate);
 
     /***********************************/
@@ -527,7 +520,7 @@
 
                     /**
                      *  Allocate audio AU used for read operations */
-                    pC->m_pReaderAudioAU = (M4_AccessUnit*)M4OSA_malloc(sizeof(M4_AccessUnit),
+                    pC->m_pReaderAudioAU = (M4_AccessUnit*)M4OSA_32bitAlignedMalloc(sizeof(M4_AccessUnit),
                         M4PTO3GPP,(M4OSA_Char *)"pReaderAudioAU");
                     if (M4OSA_NULL == pC->m_pReaderAudioAU)
                     {
@@ -857,8 +850,8 @@
                      *  Copy audio data from reader AU to writer AU */
                     M4OSA_TRACE2_1("M4PTO3GPP_Step(): Copying audio AU: size=%d",
                         pC->m_pReaderAudioAU->m_size);
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->m_WriterAudioAU.dataAddress,
-                        (M4OSA_MemAddr8)pC->m_pReaderAudioAU->m_dataAddress,
+                    memcpy((void *)pC->m_WriterAudioAU.dataAddress,
+                        (void *)pC->m_pReaderAudioAU->m_dataAddress,
                         pC->m_pReaderAudioAU->m_size);
                     pC->m_WriterAudioAU.size = pC->m_pReaderAudioAU->m_size;
 
@@ -1143,7 +1136,7 @@
 
     if (M4OSA_NULL != pC->m_pReaderAudioAU)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderAudioAU);
+        free(pC->m_pReaderAudioAU);
         pC->m_pReaderAudioAU = M4OSA_NULL;
     }
 
@@ -1162,22 +1155,22 @@
 
     if (M4OSA_NULL != pC->m_pWriterVideoStream)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterVideoStream);
+        free(pC->m_pWriterVideoStream);
         pC->m_pWriterVideoStream = M4OSA_NULL;
     }
     if (M4OSA_NULL != pC->m_pWriterAudioStream)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterAudioStream);
+        free(pC->m_pWriterAudioStream);
         pC->m_pWriterAudioStream = M4OSA_NULL;
     }
     if (M4OSA_NULL != pC->m_pWriterVideoStreamInfo)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterVideoStreamInfo);
+        free(pC->m_pWriterVideoStreamInfo);
         pC->m_pWriterVideoStreamInfo = M4OSA_NULL;
     }
     if (M4OSA_NULL != pC->m_pWriterAudioStreamInfo)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterAudioStreamInfo);
+        free(pC->m_pWriterAudioStreamInfo);
         pC->m_pWriterAudioStreamInfo = M4OSA_NULL;
     }
 
@@ -1186,28 +1179,28 @@
      *  Free the shells interfaces */
     if (M4OSA_NULL != pC->m_pReaderGlobInt)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderGlobInt);
+        free(pC->m_pReaderGlobInt);
         pC->m_pReaderGlobInt = M4OSA_NULL;
     }
     if (M4OSA_NULL != pC->m_pReaderDataInt)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderDataInt);
+        free(pC->m_pReaderDataInt);
         pC->m_pReaderDataInt = M4OSA_NULL;
     }
 
     if(M4OSA_NULL != pC->m_pEncoderInt)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pEncoderInt);
+        free(pC->m_pEncoderInt);
         pC->m_pEncoderInt = M4OSA_NULL;
     }
     if(M4OSA_NULL != pC->m_pWriterGlobInt)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterGlobInt);
+        free(pC->m_pWriterGlobInt);
         pC->m_pWriterGlobInt = M4OSA_NULL;
     }
     if(M4OSA_NULL != pC->m_pWriterDataInt)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pWriterDataInt);
+        free(pC->m_pWriterDataInt);
         pC->m_pWriterDataInt = M4OSA_NULL;
     }
     /**< Do not free pC->pOsaMemoryPtrFct and pC->pOsaMemoryPtrFct, because it's owned by the \
@@ -1215,7 +1208,7 @@
 
     /**
      *  Free the context itself */
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
     pC = M4OSA_NULL;
 
     M4OSA_TRACE3_0("M4PTO3GPP_CleanUp(): returning M4NO_ERROR");
@@ -1263,23 +1256,6 @@
     {
         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_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_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 @@
                                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 \
@@ -1564,7 +1512,7 @@
     /**
      *  Allocate and fill the video stream structures for the writer */
     pC->m_pWriterVideoStream =
-        (M4SYS_StreamDescription*)M4OSA_malloc(sizeof(M4SYS_StreamDescription), M4PTO3GPP,
+        (M4SYS_StreamDescription*)M4OSA_32bitAlignedMalloc(sizeof(M4SYS_StreamDescription), M4PTO3GPP,
         (M4OSA_Char *)"pWriterVideoStream");
     if (M4OSA_NULL == pC->m_pWriterVideoStream)
     {
@@ -1573,7 +1521,7 @@
         return M4ERR_ALLOC;
     }
     pC->m_pWriterVideoStreamInfo =
-        (M4WRITER_StreamVideoInfos*)M4OSA_malloc(sizeof(M4WRITER_StreamVideoInfos), M4PTO3GPP,
+        (M4WRITER_StreamVideoInfos*)M4OSA_32bitAlignedMalloc(sizeof(M4WRITER_StreamVideoInfos), M4PTO3GPP,
         (M4OSA_Char *)"pWriterVideoStreamInfo");
     if (M4OSA_NULL == pC->m_pWriterVideoStreamInfo)
     {
@@ -1672,7 +1620,7 @@
     if(M4OSA_NULL != pC->m_pReaderAudioStream)
     {
         pC->m_pWriterAudioStream =
-            (M4SYS_StreamDescription*)M4OSA_malloc(sizeof(M4SYS_StreamDescription), M4PTO3GPP,
+            (M4SYS_StreamDescription*)M4OSA_32bitAlignedMalloc(sizeof(M4SYS_StreamDescription), M4PTO3GPP,
             (M4OSA_Char *)"pWriterAudioStream");
         if (M4OSA_NULL == pC->m_pWriterAudioStream)
         {
@@ -1681,7 +1629,7 @@
             return M4ERR_ALLOC;
         }
         pC->m_pWriterAudioStreamInfo =
-            (M4WRITER_StreamAudioInfos*)M4OSA_malloc(sizeof(M4WRITER_StreamAudioInfos), M4PTO3GPP,
+            (M4WRITER_StreamAudioInfos*)M4OSA_32bitAlignedMalloc(sizeof(M4WRITER_StreamAudioInfos), M4PTO3GPP,
             (M4OSA_Char *)"pWriterAudioStreamInfo");
         if (M4OSA_NULL == pC->m_pWriterAudioStreamInfo)
         {
@@ -1952,8 +1900,8 @@
         return err;
     }
 
-    M4OSA_memcpy((M4OSA_MemAddr8)pWriterAudioAU->dataAddress,
-     (M4OSA_MemAddr8)M4PTO3GPP_AMR_AU_SILENCE_122_FRAME, M4PTO3GPP_AMR_AU_SILENCE_FRAME_122_SIZE);
+    memcpy((void *)pWriterAudioAU->dataAddress,
+     (void *)M4PTO3GPP_AMR_AU_SILENCE_122_FRAME, M4PTO3GPP_AMR_AU_SILENCE_FRAME_122_SIZE);
     pWriterAudioAU->size    = M4PTO3GPP_AMR_AU_SILENCE_FRAME_122_SIZE;
     pWriterAudioAU->CTS     = mtIncCts;
     pWriterAudioAU->nbFrag  = 0;
@@ -2000,8 +1948,8 @@
         return err;
     }
 
-    M4OSA_memcpy((M4OSA_MemAddr8)pWriterAudioAU->dataAddress,
-                (M4OSA_MemAddr8)M4PTO3GPP_AMR_AU_SILENCE_048_FRAME,
+    memcpy((void *)pWriterAudioAU->dataAddress,
+                (void *)M4PTO3GPP_AMR_AU_SILENCE_048_FRAME,
                 M4PTO3GPP_AMR_AU_SILENCE_FRAME_048_SIZE);
     pWriterAudioAU->size    = M4PTO3GPP_AMR_AU_SILENCE_FRAME_048_SIZE;
     pWriterAudioAU->CTS     = mtIncCts;
@@ -2020,41 +1968,3 @@
 }
 
 
-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/M4PTO3GPP_VideoPreProcessing.c b/libvideoeditor/vss/src/M4PTO3GPP_VideoPreProcessing.c
index bcbfaf0..53fb5c9 100755
--- a/libvideoeditor/vss/src/M4PTO3GPP_VideoPreProcessing.c
+++ b/libvideoeditor/vss/src/M4PTO3GPP_VideoPreProcessing.c
@@ -120,8 +120,8 @@
          * (the last pic is splited due to the callback extra-call... */
         for (i=0; i<3; i++)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)pPlaneOut[i].pac_data,
-                 (M4OSA_MemAddr8)pC->pSavedPlane[i].pac_data,
+            memcpy((void *)pPlaneOut[i].pac_data,
+                 (void *)pC->pSavedPlane[i].pac_data,
                      pPlaneOut[i].u_stride * pPlaneOut[i].u_height);
         }
     }
diff --git a/libvideoeditor/vss/src/M4READER_Amr.c b/libvideoeditor/vss/src/M4READER_Amr.c
index 32bf9cf..a7cd653 100755
--- a/libvideoeditor/vss/src/M4READER_Amr.c
+++ b/libvideoeditor/vss/src/M4READER_Amr.c
@@ -71,7 +71,7 @@
     M4OSA_DEBUG_IF1((pContext == 0), M4ERR_PARAMETER,
          "M4READER_AMR_create: invalid context pointer");
 
-    pReaderContext = (M4READER_AMR_Context*)M4OSA_malloc(sizeof(M4READER_AMR_Context),
+    pReaderContext = (M4READER_AMR_Context*)M4OSA_32bitAlignedMalloc(sizeof(M4READER_AMR_Context),
          M4READER_AMR, (M4OSA_Char *)"M4READER_AMR_Context");
     if (pReaderContext == M4OSA_NULL)
     {
@@ -80,7 +80,7 @@
 
     pReaderContext->m_pAudioStream  = M4OSA_NULL;
     pReaderContext->m_audioAu.dataAddress = M4OSA_NULL;
-    M4OSA_INT64_FROM_INT32(pReaderContext->m_maxDuration, 0);
+    pReaderContext->m_maxDuration = 0;
     pReaderContext->m_pCoreContext = M4OSA_NULL;
     pReaderContext->m_pOsaFileReaderFcts = M4OSA_NULL;
 
@@ -117,7 +117,7 @@
         return M4ERR_PARAMETER;
     }
 
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
 
     return M4NO_ERROR;
 }
@@ -205,7 +205,7 @@
         /* Delete the DSI if needed */
         if(M4OSA_NULL != pC->m_pAudioStream->m_basicProperties.m_pDecoderSpecificInfo)
         {
-            M4OSA_free((M4OSA_MemAddr32)\
+            free(\
                 pC->m_pAudioStream->m_basicProperties.m_pDecoderSpecificInfo);
 
             pC->m_pAudioStream->m_basicProperties.m_decoderSpecificInfoSize = 0;
@@ -213,7 +213,7 @@
         }
 
         /* Finally destroy the stream handler */
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioStream);
+        free(pC->m_pAudioStream);
         pC->m_pAudioStream = M4OSA_NULL;
     }
 
@@ -279,7 +279,7 @@
 
     *pMediaFamily = M4READER_kMediaFamilyAudio;
 
-    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_malloc(sizeof(M4_AudioStreamHandler),
+    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_32bitAlignedMalloc(sizeof(M4_AudioStreamHandler),
                         M4READER_AMR, (M4OSA_Char *)"M4_AudioStreamHandler");
     if (pAudioStreamHandler == M4OSA_NULL)
     {
@@ -303,14 +303,12 @@
     pStreamHandler->m_pDecoderSpecificInfo    = (M4OSA_UInt8*)(streamDesc.decoderSpecificInfo);
     pStreamHandler->m_decoderSpecificInfoSize = streamDesc.decoderSpecificInfoSize;
     pStreamHandler->m_streamId                = streamDesc.streamID;
- // M4OSA_INT64_FROM_DOUBLE(pStreamHandler->m_duration,
- // (M4OSA_Double)(((M4OSA_Float)streamDesc.duration*1000/(M4OSA_Float)(streamDesc.timeScale))));
     pStreamHandler->m_duration                = streamDesc.duration;
     pStreamHandler->m_pUserData               = (void*)streamDesc.timeScale; /*trick to change*/
 
-    if (M4OSA_TIME_COMPARE(streamDesc.duration, pC->m_maxDuration) > 0)
+    if (streamDesc.duration > pC->m_maxDuration)
     {
-        M4OSA_TIME_SET(pC->m_maxDuration, streamDesc.duration);
+        pC->m_maxDuration = streamDesc.duration;
     }
     pStreamHandler->m_averageBitRate          = streamDesc.averageBitrate;
 
@@ -422,7 +420,7 @@
     {
     case M4READER_kOptionID_Duration :
         {
-            M4OSA_TIME_SET(*(M4OSA_Time*)pValue, pC->m_maxDuration);
+            *(M4OSA_Time*)pValue = pC->m_maxDuration;
         }
         break;
 
@@ -523,15 +521,13 @@
     M4SYS_StreamID          streamIdArray[2];
     M4OSA_ERR               err;
     M4SYS_AccessUnit*       pAu;
-    M4OSA_Time                time64;
+    M4OSA_Time              time64 = 0;
     M4AMRR_State            State;
 
     M4OSA_DEBUG_IF1((pC == 0), M4ERR_PARAMETER, "M4READER_AMR_reset: invalid context");
     M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
          "M4READER_AMR_reset: invalid pointer to M4_StreamHandler");
 
-    M4OSA_INT64_FROM_INT32(time64, 0);
-
     if (pStreamHandler == (M4_StreamHandler*)pC->m_pAudioStream)
     {
         pAu = &pC->m_audioAu;
@@ -596,8 +592,7 @@
     M4SYS_StreamID          streamIdArray[2];
     M4OSA_ERR               err;
     M4SYS_AccessUnit*       pAu;
-    M4OSA_Time                time64;
-    M4OSA_Double            timeDouble; /*used for type conversion only*/
+    M4OSA_Time              time64 = (M4OSA_Time)*pTime;
     M4AMRR_State            State;
 
     M4OSA_DEBUG_IF1((pC == 0), M4ERR_PARAMETER, "M4READER_AMR_reset: invalid context");
@@ -605,8 +600,6 @@
          "M4READER_AMR_reset: invalid pointer to M4_StreamHandler");
     M4OSA_DEBUG_IF1((pTime == 0), M4ERR_PARAMETER, "M4READER_3GP_jump: invalid time pointer");
 
-    M4OSA_INT64_FROM_INT32(time64, *pTime);
-
     if (pStreamHandler == (M4_StreamHandler*)pC->m_pAudioStream)
     {
         pAu = &pC->m_audioAu;
@@ -641,8 +634,7 @@
         return err;
     }
 
-    M4OSA_INT64_TO_DOUBLE(timeDouble, time64);
-    *pTime = (M4OSA_Int32)timeDouble;
+    *pTime = (M4OSA_Int32)time64;
 
     return err;
 }
@@ -758,18 +750,18 @@
          "M4READER_AMR_getInterfaces: invalid pointer to M4READER_DataInterface");
 
     *pRdrGlobalInterface =
-         (M4READER_GlobalInterface*)M4OSA_malloc( sizeof(M4READER_GlobalInterface),
+         (M4READER_GlobalInterface*)M4OSA_32bitAlignedMalloc( sizeof(M4READER_GlobalInterface),
              M4READER_AMR, (M4OSA_Char *)"M4READER_GlobalInterface" );
     if (M4OSA_NULL == *pRdrGlobalInterface)
     {
         *pRdrDataInterface = M4OSA_NULL;
         return M4ERR_ALLOC;
     }
-    *pRdrDataInterface = (M4READER_DataInterface*)M4OSA_malloc( sizeof(M4READER_DataInterface),
+    *pRdrDataInterface = (M4READER_DataInterface*)M4OSA_32bitAlignedMalloc( sizeof(M4READER_DataInterface),
          M4READER_AMR, (M4OSA_Char *)"M4READER_DataInterface");
     if (M4OSA_NULL == *pRdrDataInterface)
     {
-        M4OSA_free((M4OSA_MemAddr32)*pRdrGlobalInterface);
+        free(*pRdrGlobalInterface);
         *pRdrGlobalInterface = M4OSA_NULL;
         return M4ERR_ALLOC;
     }
diff --git a/libvideoeditor/vss/src/M4READER_Pcm.c b/libvideoeditor/vss/src/M4READER_Pcm.c
index 5604983..9f2e5b3 100755
--- a/libvideoeditor/vss/src/M4READER_Pcm.c
+++ b/libvideoeditor/vss/src/M4READER_Pcm.c
@@ -66,7 +66,7 @@
     M4OSA_DEBUG_IF1((pContext == 0),       M4ERR_PARAMETER,
          "M4READER_PCM_create: invalid context pointer");
 
-    pReaderContext = (M4READER_PCM_Context*)M4OSA_malloc(sizeof(M4READER_PCM_Context),
+    pReaderContext = (M4READER_PCM_Context*)M4OSA_32bitAlignedMalloc(sizeof(M4READER_PCM_Context),
          M4READER_WAV, (M4OSA_Char *)"M4READER_PCM_Context");
     if (pReaderContext == M4OSA_NULL)
     {
@@ -100,7 +100,7 @@
     M4OSA_DEBUG_IF1((M4OSA_NULL == pC), M4ERR_PARAMETER,
          "M4READER_PCM_destroy: invalid context pointer");
 
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
 
     return M4NO_ERROR;
 }
@@ -163,7 +163,7 @@
                 return err;
             }
         }
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioStream);
+        free(pC->m_pAudioStream);
         pC->m_pAudioStream = M4OSA_NULL;
     }
 
@@ -249,7 +249,7 @@
     switch (optionId)
     {
     case M4READER_kOptionID_Duration:
-        *((M4OSA_UInt64*)pValue) = pContext->m_pAudioStream->m_duration;
+        *((M4OSA_UInt32*)pValue) = pContext->m_pAudioStream->m_duration;
         break;
 
     case M4READER_kOptionID_Version:
@@ -348,7 +348,7 @@
             return M4NO_ERROR;
     }
 
-    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_malloc(sizeof(M4_AudioStreamHandler),
+    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_32bitAlignedMalloc(sizeof(M4_AudioStreamHandler),
          M4READER_WAV, (M4OSA_Char *)"M4_AudioStreamHandler");
     if (pAudioStreamHandler == M4OSA_NULL)
     {
@@ -382,7 +382,7 @@
     pAudioStreamHandler->m_nbChannels        = pDsi->nbChannels;
 
     M4OSA_TIME_TO_MS( fDuration, streamDesc.duration, streamDesc.timeScale);
-    pC->m_pAudioStream->m_duration                = (M4OSA_Int64)fDuration;
+    pC->m_pAudioStream->m_duration                = (M4OSA_Int32)fDuration;
     pC->m_pAudioStream->m_pDecoderSpecificInfo    = (M4OSA_UInt8*)(streamDesc.decoderSpecificInfo);
     pC->m_pAudioStream->m_decoderSpecificInfoSize = streamDesc.decoderSpecificInfoSize;
     pC->m_pAudioStream->m_streamId                = streamDesc.streamID;
@@ -680,18 +680,18 @@
          "M4READER_PCM_getInterfaces: invalid pointer to M4READER_DataInterface");
 
     *pRdrGlobalInterface =
-         (M4READER_GlobalInterface*)M4OSA_malloc( sizeof(M4READER_GlobalInterface), M4READER_WAV,
+         (M4READER_GlobalInterface*)M4OSA_32bitAlignedMalloc( sizeof(M4READER_GlobalInterface), M4READER_WAV,
              (M4OSA_Char *)"M4READER_PCM GlobalInterface");
     if (M4OSA_NULL == *pRdrGlobalInterface)
     {
         return M4ERR_ALLOC;
     }
     *pRdrDataInterface =
-         (M4READER_DataInterface*)M4OSA_malloc( sizeof(M4READER_DataInterface), M4READER_WAV,
+         (M4READER_DataInterface*)M4OSA_32bitAlignedMalloc( sizeof(M4READER_DataInterface), M4READER_WAV,
             (M4OSA_Char *) "M4READER_PCM DataInterface");
     if (M4OSA_NULL == *pRdrDataInterface)
     {
-        M4OSA_free((M4OSA_MemAddr32)*pRdrGlobalInterface);
+        free(*pRdrGlobalInterface);
         return M4ERR_ALLOC;
     }
 
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
index bc75488..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"
 
 /**
@@ -33,30 +32,6 @@
 M4OSA_UInt32 M4VD_EXTERNAL_GetBitsFromMemory(M4VS_Bitstream_ctxt* parsingCtxt,
      M4OSA_UInt32 nb_bits)
 {
-#if 0
-    M4OSA_UInt32    code;
-    M4OSA_UInt32    i;
-
-    code = 0;
-    for (i = 0; i < nb_bits; i++)
-    {
-        if (parsingCtxt->stream_index == 8)
-        {
-            M4OSA_memcpy( (M4OSA_MemAddr8)&(parsingCtxt->stream_byte), parsingCtxt->in,
-                 sizeof(unsigned char));
-            parsingCtxt->in++;
-            //fread(&stream_byte, sizeof(unsigned char),1,in);
-            parsingCtxt->stream_index = 0;
-        }
-        code = (code << 1);
-        code |= ((parsingCtxt->stream_byte & 0x80) >> 7);
-
-        parsingCtxt->stream_byte = (parsingCtxt->stream_byte << 1);
-        parsingCtxt->stream_index++;
-    }
-
-    return code;
-#endif
         return(M4VD_Tools_GetBitsFromMemory(parsingCtxt,nb_bits));
 }
 
@@ -64,44 +39,6 @@
                                                  M4OSA_MemAddr32 dest_bits,
                                                  M4OSA_UInt8 offset, M4OSA_UInt8 nb_bits)
 {
-#if 0
-    M4OSA_UInt8 i,j;
-    M4OSA_UInt32 temp_dest = 0, mask = 0, temp = 1;
-    M4OSA_UInt32 input = bitsToWrite;
-
-    input = (input << (32 - nb_bits - offset));
-
-    /* Put destination buffer to 0 */
-    for(j=0;j<3;j++)
-    {
-        for(i=0;i<8;i++)
-        {
-            if((j*8)+i >= offset && (j*8)+i < nb_bits + offset)
-            {
-                mask |= (temp << ((7*(j+1))-i+j));
-            }
-        }
-    }
-    mask = ~mask;
-    *dest_bits &= mask;
-
-    /* Parse input bits, and fill output buffer */
-    for(j=0;j<3;j++)
-    {
-        for(i=0;i<8;i++)
-        {
-            if((j*8)+i >= offset && (j*8)+i < nb_bits + offset)
-            {
-                temp = ((input & (0x80000000 >> offset)) >> (31-offset));
-                //*dest_bits |= (temp << (31 - i));
-                *dest_bits |= (temp << ((7*(j+1))-i+j));
-                input = (input << 1);
-            }
-        }
-    }
-
-    return M4NO_ERROR;
-#endif
         return (M4VD_Tools_WriteBitsToMemory( bitsToWrite,dest_bits,
                                                 offset,  nb_bits));
 }
@@ -503,18 +440,21 @@
 {
     M4OSA_ERR err = M4NO_ERROR;
     M4OSA_Bool NALSPS_and_Profile0Found = M4OSA_FALSE;
-    M4OSA_UInt16 index;
-    M4OSA_Bool    constraintSet3;
+    M4OSA_UInt16 index = 28; /* the 29th byte is SPS start */
+    M4OSA_Bool constraintSet3;
+
+    if (DSISize <= index) {
+        M4OSA_TRACE1_0("M4DECODER_EXTERNAL_ParseAVCDSI: DSI is invalid");
+        *profile = M4DECODER_AVC_kProfile_and_Level_Out_Of_Range;
+        return M4ERR_PARAMETER;
+    }
 
     /* check for baseline profile */
-    for(index = 0; index < (DSISize-1); index++)
+    if(((pDSI[index] & 0x1f) == 0x07) && (pDSI[index+1] == 0x42))
     {
-        if(((pDSI[index] & 0x1f) == 0x07) && (pDSI[index+1] == 0x42))
-        {
-            NALSPS_and_Profile0Found = M4OSA_TRUE;
-            break;
-        }
+        NALSPS_and_Profile0Found = M4OSA_TRUE;
     }
+
     if(M4OSA_FALSE == NALSPS_and_Profile0Found)
     {
         M4OSA_TRACE1_1("M4DECODER_EXTERNAL_ParseAVCDSI: index bad = %d", index);
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c
deleted file mode 100755
index 009f495..0000000
--- a/libvideoeditor/vss/src/M4VD_EXTERNAL_Interface.c
+++ /dev/null
@@ -1,1155 +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_malloc( 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_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)
-        {
-            M4OSA_free((M4OSA_MemAddr32)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 */
-
-        M4OSA_free((M4OSA_MemAddr32)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_malloc(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_malloc(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)
-    {
-#if 0
-        if (!pStreamContext->m_bForceRender)
-        {
-            /* Targeted time is reached */
-            if(pStreamContext->m_TargetRenderCts - pStreamContext->m_CurrentRenderCts < 1.0)
-             /* some +0.5 issues */
-            {
-                M4OSA_TRACE2_0("M4DECODER_EXTERNAL_AsynchronousRender :\
-                     skip render because synchronisation");
-                pStreamContext->m_uiRenderError = M4WAR_RENDER_FINISHED;
-
-                M4ERR_EXIT(M4NO_ERROR);
-            }
-
-            if ( (M4WAR_NO_MORE_AU == pStreamContext->m_uiDecodeError)
-                && (pStreamContext->m_CurrentDecodeCts \
-                    - pStreamContext->m_CurrentRenderCts < 1.0) )
-            {
-                pStreamContext->m_uiRenderError = M4WAR_RENDER_FINISHED;
-                M4ERR_EXIT(M4NO_ERROR);
-            }
-
-            if(pStreamContext->m_NbDecodedFrames == 0)
-            {
-                pStreamContext->m_uiRenderError = M4WAR_VIDEORENDERER_NO_NEW_FRAME;
-                M4ERR_EXIT(M4NO_ERROR);
-            }
-        }
-#endif
-        /* 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/M4VD_Tools.c b/libvideoeditor/vss/src/M4VD_Tools.c
old mode 100644
new mode 100755
diff --git a/libvideoeditor/vss/src/M4VIFI_xVSS_RGB565toYUV420.c b/libvideoeditor/vss/src/M4VIFI_xVSS_RGB565toYUV420.c
index 8f00d08..881da82 100755
--- a/libvideoeditor/vss/src/M4VIFI_xVSS_RGB565toYUV420.c
+++ b/libvideoeditor/vss/src/M4VIFI_xVSS_RGB565toYUV420.c
@@ -136,16 +136,6 @@
             u16_pix4 = *( (M4VIFI_UInt16 *) (pu8_rgbn + u32_stride_rgb + CST_RGB_16_SIZE));
 
             /* Unpack RGB565 to 8bit R, G, B */
-#if 0
-            /* (x,y) */
-            GET_RGB565(i32_r00,i32_g00,i32_b00,u16_pix1);
-            /* (x+1,y) */
-            GET_RGB565(i32_r10,i32_g10,i32_b10,u16_pix2);
-            /* (x,y+1) */
-            GET_RGB565(i32_r01,i32_g01,i32_b01,u16_pix3);
-            /* (x+1,y+1) */
-            GET_RGB565(i32_r11,i32_g11,i32_b11,u16_pix4);
-#else
             /* (x,y) */
             GET_RGB565(i32_b00,i32_g00,i32_r00,u16_pix1);
             /* (x+1,y) */
@@ -154,8 +144,6 @@
             GET_RGB565(i32_b01,i32_g01,i32_r01,u16_pix3);
             /* (x+1,y+1) */
             GET_RGB565(i32_b11,i32_g11,i32_r11,u16_pix4);
-#endif
-#if 1 /* Solution to avoid green effects due to transparency */
             /* If RGB is transparent color (0, 63, 0), we transform it to white (31,63,31) */
             if(i32_b00 == 0 && i32_g00 == 63 && i32_r00 == 0)
             {
@@ -177,7 +165,6 @@
                 i32_b11 = 31;
                 i32_r11 = 31;
             }
-#endif
             /* Convert RGB value to YUV */
             i32_u00 = U16(i32_r00, i32_g00, i32_b00);
             i32_v00 = V16(i32_r00, i32_g00, i32_b00);
@@ -204,47 +191,8 @@
             pu8_yn[1] = (M4VIFI_UInt8)i32_y10;
             pu8_ys[0] = (M4VIFI_UInt8)i32_y01;
             pu8_ys[1] = (M4VIFI_UInt8)i32_y11;
-#if 0 /* Temporary solution to avoid green effects due to transparency -> To be removed */
-            count_null = 4;
-            /* Store chroma data */
-            if(i32_b00 == 0 && i32_g00 == 63 && i32_r00 == 0)
-            {
-                i32_u00 = 0;
-                i32_v00 = 0;
-                count_null --;
-            }
-            if(i32_b10 == 0 && i32_g10 == 63 && i32_r10 == 0)
-            {
-                i32_u10 = 0;
-                i32_v10 = 0;
-                count_null --;
-            }
-            if(i32_b01 == 0 && i32_g01 == 63 && i32_r01 == 0)
-            {
-                i32_u01 = 0;
-                i32_v01 = 0;
-                count_null --;
-            }
-            if(i32_b11 == 0 && i32_g11 == 63 && i32_r11 == 0)
-            {
-                i32_u11 = 0;
-                i32_v11 = 0;
-                count_null --;
-            }
-
-            if(count_null == 0)
-            {
-#endif
             *pu8_u = (M4VIFI_UInt8)((i32_u00 + i32_u01 + i32_u10 + i32_u11 + 2) >> 2);
             *pu8_v = (M4VIFI_UInt8)((i32_v00 + i32_v01 + i32_v10 + i32_v11 + 2) >> 2);
-#if 0 /* Temporary solution to avoid green effects due to transparency -> To be removed */
-            }
-            else
-            {
-                *pu8_u = (M4VIFI_UInt8)((i32_u00 + i32_u01 + i32_u10 + i32_u11 + 2) / count_null);
-                *pu8_v = (M4VIFI_UInt8)((i32_v00 + i32_v01 + i32_v10 + i32_v11 + 2) / count_null);
-            }
-#endif
             /* Prepare for next column */
             pu8_rgbn += (CST_RGB_16_SIZE<<1);
             /* Update current Y plane line pointer*/
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
index c943513..877dd97 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_AudioMixing.c
@@ -135,7 +135,7 @@
     /**
     * Allocate the VSS audio mixing context and return it to the user */
     pC = (M4VSS3GPP_InternalAudioMixingContext
-        *)M4OSA_malloc(sizeof(M4VSS3GPP_InternalAudioMixingContext),
+        *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_InternalAudioMixingContext),
         M4VSS3GPP,(M4OSA_Char *)"M4VSS3GPP_InternalAudioMixingContext");
     *pContext = pC;
 
@@ -148,8 +148,8 @@
     }
 
     /* Initialization of context Variables */
-    M4OSA_memset((M4OSA_MemAddr8)pC ,
-                 sizeof(M4VSS3GPP_InternalAudioMixingContext),0);
+    memset((void *)pC ,0,
+                 sizeof(M4VSS3GPP_InternalAudioMixingContext));
     /**
     * Copy this setting in context */
     pC->iAddCts = pSettings->uiAddCts;
@@ -232,9 +232,13 @@
     pC->ewc.iOutputDuration = (M4OSA_Int32)pC->pInputClipCtxt->pSettings->
         ClipProperties.uiClipDuration;
     /*gInputParams.lvBTChannelCount*/
-    pC->pLVAudioResampler = (M4OSA_Int32)LVAudioResamplerCreate(16,
+    pC->pLVAudioResampler = LVAudioResamplerCreate(16,
         pC->pAddedClipCtxt->pSettings->ClipProperties.uiNbChannels,
-        /* gInputParams.lvOutSampleRate*/pSettings->outputASF, 1);
+        /* gInputParams.lvOutSampleRate*/(M4OSA_Int32)pSettings->outputASF, 1);
+     if( M4OSA_NULL == pC->pLVAudioResampler )
+     {
+         return M4ERR_ALLOC;
+     }
         LVAudiosetSampleRate(pC->pLVAudioResampler,
         /*gInputParams.lvInSampleRate*/
         pC->pAddedClipCtxt->pSettings->ClipProperties.uiSamplingFrequency);
@@ -570,26 +574,26 @@
 
     if( M4OSA_NULL != pC->SsrcScratch )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->SsrcScratch);
+        free(pC->SsrcScratch);
         pC->SsrcScratch = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->pSsrcBufferIn )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pSsrcBufferIn);
+        free(pC->pSsrcBufferIn);
         pC->pSsrcBufferIn = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->pSsrcBufferOut
         && (M4OSA_TRUE == pC->b_SSRCneeded || pC->ChannelConversion > 0) )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pSsrcBufferOut);
+        free(pC->pSsrcBufferOut);
         pC->pSsrcBufferOut = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->pTempBuffer )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pTempBuffer);
+        free(pC->pTempBuffer);
         pC->pTempBuffer = M4OSA_NULL;
     }
 
@@ -608,7 +612,7 @@
 
     /**
     * Free the context */
-    M4OSA_free((M4OSA_MemAddr32)pContext);
+    free(pContext);
     pContext = M4OSA_NULL;
 
     /**
@@ -992,7 +996,7 @@
                 /**
                 * Allocate and copy the new DSI */
                 pC->ewc.pVideoOutputDsi =
-                    (M4OSA_MemAddr8)M4OSA_malloc(encHeader->Size, M4VSS3GPP,
+                    (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(encHeader->Size, M4VSS3GPP,
                     (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (H264)");
 
                 if( M4OSA_NULL == pC->ewc.pVideoOutputDsi )
@@ -1003,7 +1007,7 @@
                     return M4ERR_ALLOC;
                 }
                 pC->ewc.uiVideoOutputDsiSize = (M4OSA_UInt16)encHeader->Size;
-                M4OSA_memcpy(pC->ewc.pVideoOutputDsi, encHeader->pBuf,
+                memcpy((void *)pC->ewc.pVideoOutputDsi, (void *)encHeader->pBuf,
                     encHeader->Size);
             }
 
@@ -1069,7 +1073,7 @@
                 {
 
                     /*
-                     M4OSA_free((M4OSA_MemAddr32)pC->pAddedClipCtxt->pAudioStream->\
+                     free(pC->pAddedClipCtxt->pAudioStream->\
                        m_basicProperties.m_pDecoderSpecificInfo);
                        */
                     pC->pAddedClipCtxt->pAudioStream->
@@ -1429,25 +1433,6 @@
             }
         }
     }
-#if 0
-    /**
-    * Compute the volume factors */
-    if( (M4OSA_TRUE
-        == pC->bRemoveOriginal) )
-    {
-        /**
-        * In the remove original case, we keep only the added audio */
-        pC->fAddedFactor = 1.0F;
-        pC->fOrigFactor = 0.0F;
-    }
-    else
-    {
-        /**
-        * Compute the factor to apply to sample to do the mixing */
-        pC->fAddedFactor = pSettings->uiAddVolume / 100.0F;
-        pC->fOrigFactor = 1.0F - pC->fAddedFactor;
-    }
-#endif
     if( pC->b_DuckingNeedeed == M4OSA_FALSE)
     {
         /**
@@ -1704,7 +1689,7 @@
         /**
         * Allocate buffer for the input of the SSRC */
         pC->pSsrcBufferIn =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->minimumBufferIn
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->minimumBufferIn
             + pC->pAddedClipCtxt->
             AudioDecBufferOut.
             m_bufferSize,
@@ -1723,7 +1708,7 @@
         * Allocate buffer for the output of the SSRC */
         /* The "3" value below should be optimized ... one day ... */
         pC->pSsrcBufferOut =
-            (M4OSA_MemAddr8)M4OSA_malloc(3 * pC->iSsrcNbSamplOut * sizeof(short)
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(3 * pC->iSsrcNbSamplOut * sizeof(short)
             * pC->ewc.uiNbChannels, M4VSS3GPP, (M4OSA_Char *)"pSsrcBufferOut");
 
         if( M4OSA_NULL == pC->pSsrcBufferOut )
@@ -1741,7 +1726,7 @@
         {
             /* The "3" value below should be optimized ... one day ... */
             pC->pTempBuffer =
-                (M4OSA_MemAddr8)M4OSA_malloc(3 * pC->iSsrcNbSamplOut
+                (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(3 * pC->iSsrcNbSamplOut
                 * sizeof(short) * pC->pAddedClipCtxt->pSettings->
                 ClipProperties.uiNbChannels, M4VSS3GPP, (M4OSA_Char *)"pSsrcBufferOut");
 
@@ -1763,7 +1748,7 @@
         /**
         * Allocate buffer for the input of the SSRC */
         pC->pSsrcBufferIn =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->minimumBufferIn
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->minimumBufferIn
             + pC->pAddedClipCtxt->
             AudioDecBufferOut.
             m_bufferSize,
@@ -1781,7 +1766,7 @@
         /**
         * Allocate buffer for the output of the SSRC */
         /* The "3" value below should be optimized ... one day ... */
-        pC->pSsrcBufferOut = (M4OSA_MemAddr8)M4OSA_malloc(
+        pC->pSsrcBufferOut = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
             pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize,
             M4VSS3GPP, (M4OSA_Char *)"pSsrcBufferOut");
 
@@ -1826,7 +1811,7 @@
         /**
         * Allocate buffer for the input of the SSRC */
         pC->pSsrcBufferIn =
-            (M4OSA_MemAddr8)M4OSA_malloc(2 * minbuffer, M4VSS3GPP,
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(2 * minbuffer, M4VSS3GPP,
             (M4OSA_Char *)"pSsrcBufferIn");
 
         if( M4OSA_NULL == pC->pSsrcBufferIn )
@@ -1935,8 +1920,8 @@
 
     M4OSA_TRACE2_0("A #### silence AU");
 
-    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-        (M4OSA_MemAddr8)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
+    memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+        (void *)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
 
     pC->ewc.WriterAudioAU.size = pC->ewc.uiSilenceFrameSize;
     pC->ewc.WriterAudioAU.CTS =
@@ -2035,8 +2020,8 @@
 
     /**
     * Copy the input AU payload to the output AU */
-    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterVideoAU.dataAddress,
-        (M4OSA_MemAddr8)(pC->pInputClipCtxt->VideoAU.m_dataAddress + offset),
+    memcpy((void *)pC->ewc.WriterVideoAU.dataAddress,
+        (void *)(pC->pInputClipCtxt->VideoAU.m_dataAddress + offset),
         (pC->pInputClipCtxt->VideoAU.m_size));
 
     /**
@@ -2675,8 +2660,8 @@
 
     /**
     * Copy the AU itself */
-    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-        pC->pInputClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
+    memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+        (void *)pC->pInputClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
 
     /**
     * Write the mixed AU */
@@ -2778,57 +2763,6 @@
         pEncOutBuffer.pTableBufferSize[0] = 0;
 
         M4OSA_TRACE2_0("K **** blend AUs");
-#if 0
-
-        {
-            M4OSA_Char filename[13];
-            M4OSA_Context pGIFFileInDebug = M4OSA_NULL;
-            M4OSA_FilePosition pos = 0;
-
-            sprintf(filename, "toto.pcm");
-
-            err = pC->pOsaFileWritPtr->openWrite(&pGIFFileInDebug, filename,
-                M4OSA_kFileWrite | M4OSA_kFileAppend);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't open input gif file %s, error: 0x%x\n",
-                    pFile, err);
-                return err;
-            }
-
-            err = pC->pOsaFileWritPtr->seek(pGIFFileInDebug, M4OSA_kFileSeekEnd,
-                &pos);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't seek input gif file %s, error: 0x%x\n",
-                    pFile, err);
-                return err;
-            }
-
-            err = pC->pOsaFileWritPtr->writeData(pGIFFileInDebug,
-                pC->pSsrcBufferOut,
-                pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't write input gif file %s, error: 0x%x\n",
-                    pFile, err);
-                return err;
-            }
-
-            err = pC->pOsaFileWritPtr->closeWrite(pGIFFileInDebug);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't close input gif file %s, error: 0x%x\n",
-                    pFile, err);
-                return err;
-            }
-        }
-
-#endif
         /**
         * Encode the PCM audio */
 
@@ -2856,7 +2790,7 @@
         {
             tempPosBuffer = pC->pSsrcBufferOut
                 + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
-            M4OSA_memmove(pC->pSsrcBufferOut, tempPosBuffer,
+            memmove((void *)pC->pSsrcBufferOut, (void *)tempPosBuffer,
                 pC->pPosInSsrcBufferOut - tempPosBuffer);
             pC->pPosInSsrcBufferOut -=
                 pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
@@ -2864,7 +2798,7 @@
         else
         {
             tempPosBuffer = pC->pSsrcBufferIn + pC->minimumBufferIn;
-            M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+            memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
                 pC->pPosInSsrcBufferIn - tempPosBuffer);
             pC->pPosInSsrcBufferIn -= pC->minimumBufferIn;
         }
@@ -2950,8 +2884,8 @@
 
         /**
         * Copy the AU itself */
-        M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-            pC->pAddedClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
+        memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+            (void *)pC->pAddedClipCtxt->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
 
         /**
         * Write the mixed AU */
@@ -3112,8 +3046,8 @@
         }
 
         /* Copy decoded data into SSRC buffer in */
-        M4OSA_memcpy(pC->pPosInSsrcBufferIn,
-            pC->pAddedClipCtxt->AudioDecBufferOut.m_dataAddress,
+        memcpy((void *)pC->pPosInSsrcBufferIn,
+            (void *)pC->pAddedClipCtxt->AudioDecBufferOut.m_dataAddress,
             pC->pAddedClipCtxt->AudioDecBufferOut.m_bufferSize);
         /* Update position pointer into SSRC buffer In */
 
@@ -3134,8 +3068,8 @@
                 /* We use ChannelConversion variable because in case 2, we need twice less data */
             {
                 ssrcErr = 0;
-                M4OSA_memset(pC->pPosInTempBuffer,
-                    (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels),0);
+                memset((void *)pC->pPosInTempBuffer,0,
+                    (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels));
 
                 LVAudioresample_LowQuality((short*)pC->pPosInTempBuffer,
                     (short*)pC->pSsrcBufferIn,
@@ -3158,7 +3092,7 @@
                     pC->pSsrcBufferIn + (pC->iSsrcNbSamplIn * sizeof(short)
                     * pC->pAddedClipCtxt->pSettings->
                     ClipProperties.uiNbChannels);
-                M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+                memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
                     pC->pPosInSsrcBufferIn - tempPosBuffer);
                 pC->pPosInSsrcBufferIn -= pC->iSsrcNbSamplIn * sizeof(short)
                     * pC->pAddedClipCtxt->pSettings->
@@ -3171,8 +3105,8 @@
                 < (M4OSA_Int32)pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize )
             {
                 ssrcErr = 0;
-                M4OSA_memset(pC->pPosInSsrcBufferOut,
-                    (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels),0);
+                memset((void *)pC->pPosInSsrcBufferOut,0,
+                    (pC->iSsrcNbSamplOut * sizeof(short) * pC->ewc.uiNbChannels));
 
                 LVAudioresample_LowQuality((short*)pC->pPosInSsrcBufferOut,
                     (short*)pC->pSsrcBufferIn,
@@ -3193,7 +3127,7 @@
                     pC->pSsrcBufferIn + (pC->iSsrcNbSamplIn * sizeof(short)
                     * pC->pAddedClipCtxt->pSettings->
                     ClipProperties.uiNbChannels);
-                M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+                memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
                     pC->pPosInSsrcBufferIn - tempPosBuffer);
                 pC->pPosInSsrcBufferIn -= pC->iSsrcNbSamplIn * sizeof(short)
                     * pC->pAddedClipCtxt->pSettings->
@@ -3220,7 +3154,7 @@
                         * pC->pAddedClipCtxt->pSettings->
                         ClipProperties.
                         uiNbChannels); /* Buffer is in bytes */
-                    M4OSA_memmove(pC->pTempBuffer, tempPosBuffer,
+                    memmove((void *)pC->pTempBuffer, (void *)tempPosBuffer,
                         pC->pPosInTempBuffer - tempPosBuffer);
                     pC->pPosInTempBuffer -=
                         (uiChannelConvertorNbSamples * sizeof(short)
@@ -3242,7 +3176,7 @@
                         + (uiChannelConvertorNbSamples * sizeof(short)
                         * pC->pAddedClipCtxt->pSettings->
                         ClipProperties.uiNbChannels);
-                    M4OSA_memmove(pC->pTempBuffer, tempPosBuffer,
+                    memmove((void *)pC->pTempBuffer, (void *)tempPosBuffer,
                         pC->pPosInTempBuffer - tempPosBuffer);
                     pC->pPosInTempBuffer -=
                         (uiChannelConvertorNbSamples * sizeof(short)
@@ -3278,7 +3212,7 @@
                         * pC->pAddedClipCtxt->pSettings->
                         ClipProperties.
                         uiNbChannels); /* Buffer is in bytes */
-                    M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+                    memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
                         pC->pPosInSsrcBufferIn - tempPosBuffer);
                     pC->pPosInSsrcBufferIn -=
                         (uiChannelConvertorNbSamples * sizeof(short)
@@ -3300,7 +3234,7 @@
                         + (uiChannelConvertorNbSamples * sizeof(short)
                         * pC->pAddedClipCtxt->pSettings->
                         ClipProperties.uiNbChannels);
-                    M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+                    memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
                         pC->pPosInSsrcBufferIn - tempPosBuffer);
                     pC->pPosInSsrcBufferIn -=
                         (uiChannelConvertorNbSamples * sizeof(short)
@@ -3649,7 +3583,7 @@
     {
         tempPosBuffer = pC->pSsrcBufferOut
             + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
-        M4OSA_memmove(pC->pSsrcBufferOut, tempPosBuffer,
+        memmove((void *)pC->pSsrcBufferOut, (void *)tempPosBuffer,
             pC->pPosInSsrcBufferOut - tempPosBuffer);
         pC->pPosInSsrcBufferOut -=
             pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
@@ -3659,7 +3593,7 @@
     {
         tempPosBuffer = pC->pSsrcBufferIn
             + pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
-        M4OSA_memmove(pC->pSsrcBufferIn, tempPosBuffer,
+        memmove((void *)pC->pSsrcBufferIn, (void *)tempPosBuffer,
             pC->pPosInSsrcBufferIn - tempPosBuffer);
         pC->pPosInSsrcBufferIn -=
             pC->pInputClipCtxt->AudioDecBufferOut.m_bufferSize;
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
index 0a3b737..d9b6eb5 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
@@ -93,7 +93,7 @@
     /**
     * Allocate the clip context */
     *hClipCtxt =
-        (M4VSS3GPP_ClipContext *)M4OSA_malloc(sizeof(M4VSS3GPP_ClipContext),
+        (M4VSS3GPP_ClipContext *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_ClipContext),
         M4VSS3GPP, (M4OSA_Char *)"M4VSS3GPP_ClipContext");
 
     if( M4OSA_NULL == *hClipCtxt )
@@ -111,7 +111,7 @@
     pClipCtxt = *hClipCtxt;
 
     /* Inialization of context Variables */
-    M4OSA_memset((M4OSA_MemAddr8)pClipCtxt, sizeof(M4VSS3GPP_ClipContext), 0);
+    memset((void *)pClipCtxt, 0,sizeof(M4VSS3GPP_ClipContext));
 
     pClipCtxt->pSettings = M4OSA_NULL;
 
@@ -266,37 +266,37 @@
 
 
 
-        M4OSA_chrNCopy(pTempFile,pClipSettings->pFile,M4OSA_chrLength(pClipSettings->pFile));
+        M4OSA_chrNCopy(pTempFile,pClipSettings->pFile,strlen(pClipSettings->pFile));
 
 
     switch (pClipCtxt->pSettings->ClipProperties.uiSamplingFrequency)
     {
         case 8000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_8000",6);
+        strncat((char *)pTempFile,(const char *)"_8000",6);
         break;
         case 11025:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_11025",6);
+        strncat((char *)pTempFile,(const char *)"_11025",6);
         break;
         case 12000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_12000",6);
+        strncat((char *)pTempFile,(const char *)"_12000",6);
         break;
         case 16000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_16000",6);
+        strncat((char *)pTempFile,(const char *)"_16000",6);
         break;
         case 22050:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_22050",6);
+        strncat((char *)pTempFile,(const char *)"_22050",6);
         break;
         case 24000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_24000",6);
+        strncat((char *)pTempFile,(const char *)"_24000",6);
         break;
         case 32000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_32000",6);
+        strncat((char *)pTempFile,(const char *)"_32000",6);
         break;
         case 44100:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_44100",6);
+        strncat((char *)pTempFile,(const char *)"_44100",6);
         break;
         case 48000:
-        M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_48000",6);
+        strncat((char *)pTempFile,(const char *)"_48000",6);
         break;
         default:
             M4OSA_TRACE1_1("M4VSS3GPP_intClipOpen: invalid input for BG tracksampling \
@@ -312,10 +312,10 @@
         switch(pClipCtxt->pSettings->ClipProperties.uiNbChannels)
         {
             case 1:
-                M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_1.pcm",6);
+                strncat((char *)pTempFile,(const char *)"_1.pcm",6);
             break;
             case 2:
-                M4OSA_chrNCat(pTempFile,(M4OSA_Char *)"_2.pcm",6);
+                strncat((char *)pTempFile,(const char *)"_2.pcm",6);
             break;
             default:
             M4OSA_TRACE1_1("M4VSS3GPP_intClipOpen: invalid input for BG track no.\
@@ -686,7 +686,7 @@
         pClipCtxt->pSettings->uiEndCutTime = (M4OSA_UInt32)iDuration;
     }
 
-    pClipCtxt->iEndTime = pClipCtxt->pSettings->uiEndCutTime;
+    pClipCtxt->iEndTime = (M4OSA_Int32)pClipCtxt->pSettings->uiEndCutTime;
 
     /**
     * Return with no error */
@@ -719,7 +719,7 @@
       frame eventually)*/
     if( M4OSA_NULL != pClipCtxt->AudioDecBufferOut.m_dataAddress )
     {
-        M4OSA_free((M4OSA_MemAddr32)pClipCtxt->AudioDecBufferOut.m_dataAddress);
+        free(pClipCtxt->AudioDecBufferOut.m_dataAddress);
         pClipCtxt->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
     }
 
@@ -1334,7 +1334,7 @@
         * pClipCtxt->pAudioStream->m_byteSampleSize
         * pClipCtxt->pAudioStream->m_nbChannels;
     pClipCtxt->AudioDecBufferOut.m_dataAddress =
-        (M4OSA_MemAddr8)M4OSA_malloc(pClipCtxt->AudioDecBufferOut.m_bufferSize
+        (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pClipCtxt->AudioDecBufferOut.m_bufferSize
         * sizeof(M4OSA_Int16),
         M4VSS3GPP, (M4OSA_Char *)"AudioDecBufferOut.m_bufferSize");
 
@@ -1375,7 +1375,7 @@
             pClipCtxt->AudioDecBufferOut.m_bufferSize =
                 pClipCtxt->uiSilencePcmSize;
             pClipCtxt->AudioDecBufferOut.m_dataAddress =
-                (M4OSA_MemAddr8)M4OSA_malloc(
+                (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
                 pClipCtxt->AudioDecBufferOut.m_bufferSize
                 * sizeof(M4OSA_Int16),
                 M4VSS3GPP,(M4OSA_Char *) "AudioDecBufferOut.m_bufferSize");
@@ -1390,16 +1390,16 @@
         }
 
         /* Fill it with 0 (= pcm silence) */
-        M4OSA_memset(pClipCtxt->AudioDecBufferOut.m_dataAddress,
-             pClipCtxt->AudioDecBufferOut.m_bufferSize * sizeof(M4OSA_Int16), 0);
+        memset(pClipCtxt->AudioDecBufferOut.m_dataAddress,0,
+             pClipCtxt->AudioDecBufferOut.m_bufferSize * sizeof(M4OSA_Int16));
     }
     else if (pClipCtxt->pSettings->FileType == M4VIDEOEDITING_kFileType_PCM)
     {
         pClipCtxt->AudioDecBufferIn.m_dataAddress = (M4OSA_MemAddr8) pClipCtxt->pAudioFramePtr;
         pClipCtxt->AudioDecBufferIn.m_bufferSize  = pClipCtxt->uiAudioFrameSize;
 
-        M4OSA_memcpy(pClipCtxt->AudioDecBufferOut.m_dataAddress,
-            pClipCtxt->AudioDecBufferIn.m_dataAddress, pClipCtxt->AudioDecBufferIn.m_bufferSize);
+        memcpy((void *)pClipCtxt->AudioDecBufferOut.m_dataAddress,
+            (void *)pClipCtxt->AudioDecBufferIn.m_dataAddress, pClipCtxt->AudioDecBufferIn.m_bufferSize);
         pClipCtxt->AudioDecBufferOut.m_bufferSize = pClipCtxt->AudioDecBufferIn.m_bufferSize;
         /**
         * Return with no error */
@@ -1655,7 +1655,7 @@
     * Free the decoded audio buffer */
     if( M4OSA_NULL != pClipCtxt->AudioDecBufferOut.m_dataAddress )
     {
-        M4OSA_free((M4OSA_MemAddr32)pClipCtxt->AudioDecBufferOut.m_dataAddress);
+        free(pClipCtxt->AudioDecBufferOut.m_dataAddress);
         pClipCtxt->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
     }
 
@@ -1750,7 +1750,7 @@
     * Free the decoded audio buffer */
     if( M4OSA_NULL != pClipCtxt->AudioDecBufferOut.m_dataAddress )
     {
-        M4OSA_free((M4OSA_MemAddr32)pClipCtxt->AudioDecBufferOut.m_dataAddress);
+        free(pClipCtxt->AudioDecBufferOut.m_dataAddress);
         pClipCtxt->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
     }
 
@@ -1812,92 +1812,11 @@
     M4OSA_TRACE3_1("M4VSS3GPP_intClipCleanUp: pClipCtxt=0x%x", pClipCtxt);
     /**
     * Free the clip context */
-    M4OSA_free((M4OSA_MemAddr32)pClipCtxt);
+    free(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_malloc(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);
-        M4OSA_free((M4OSA_MemAddr32)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);
-        M4OSA_free((M4OSA_MemAddr32)shellInterface);
-        M4OSA_free((M4OSA_MemAddr32)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_ClipAnalysis.c b/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
index 97e3e89..3de1322 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_ClipAnalysis.c
@@ -487,8 +487,8 @@
     pClipProperties->bMPEG4rvlc = M4OSA_FALSE;
     pClipProperties->bMPEG4resynchMarker = M4OSA_FALSE;
 
-    M4OSA_memset((M4OSA_MemAddr8) &pClipProperties->ftyp,
-        sizeof(pClipProperties->ftyp), 0);
+    memset((void *) &pClipProperties->ftyp,0,
+        sizeof(pClipProperties->ftyp));
 
     /**
     * Video Analysis */
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Codecs.c b/libvideoeditor/vss/src/M4VSS3GPP_Codecs.c
index 6a523c7..aaa621e 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Codecs.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Codecs.c
@@ -218,7 +218,7 @@
 
 #endif
 
-            M4OSA_free((M4OSA_MemAddr32)pC->pVideoEncoderInterface[MediaType]);
+            free(pC->pVideoEncoderInterface[MediaType]);
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
         }
@@ -277,7 +277,7 @@
 
     if( pC->pAudioEncoderInterface[MediaType] != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pAudioEncoderInterface[MediaType]);
+        free(pC->pAudioEncoderInterface[MediaType]);
         pC->pAudioEncoderInterface[MediaType] = M4OSA_NULL;
     }
     /*
@@ -385,8 +385,7 @@
 
 #endif
 
-            M4OSA_free(
-                (M4OSA_MemAddr32)pC->m_pVideoDecoderItTable[decoderType]);
+            free(pC->m_pVideoDecoderItTable[decoderType]);
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
         }
@@ -397,8 +396,7 @@
         /* oh, and don't forget the user data, too. */
         if( pC->m_pVideoDecoderUserDataTable[decoderType] != M4OSA_NULL )
         {
-            M4OSA_free(
-                (M4OSA_MemAddr32)pC->m_pVideoDecoderUserDataTable[decoderType]);
+            free(pC->m_pVideoDecoderUserDataTable[decoderType]);
             pC->m_pVideoDecoderUserDataTable[decoderType] = M4OSA_NULL;
         }
 #endif /* are external decoders possible? */
@@ -447,12 +445,12 @@
     }
     if(M4OSA_NULL != pC->m_pAudioDecoderItTable[decoderType])
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioDecoderItTable[decoderType]);
+        free(pC->m_pAudioDecoderItTable[decoderType]);
         pC->m_pAudioDecoderItTable[decoderType] = M4OSA_NULL;
 
         if(M4OSA_NULL != pC->m_pAudioDecoderItTable[decoderType])
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioDecoderItTable[decoderType]);
+            free(pC->m_pAudioDecoderItTable[decoderType]);
             pC->m_pAudioDecoderItTable[decoderType] = M4OSA_NULL;
         }
     }
@@ -487,13 +485,13 @@
     {
         if( pC->WriterInterface[i].pGlobalFcts != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->WriterInterface[i].pGlobalFcts);
+            free(pC->WriterInterface[i].pGlobalFcts);
             pC->WriterInterface[i].pGlobalFcts = M4OSA_NULL;
         }
 
         if( pC->WriterInterface[i].pDataFcts != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->WriterInterface[i].pDataFcts);
+            free(pC->WriterInterface[i].pDataFcts);
             pC->WriterInterface[i].pDataFcts = M4OSA_NULL;
         }
     }
@@ -532,7 +530,7 @@
 
 #endif
 
-                M4OSA_free((M4OSA_MemAddr32)pC->pVideoEncoderInterface[i]);
+                free(pC->pVideoEncoderInterface[i]);
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
             }
@@ -557,7 +555,7 @@
 
                 if( M4OSA_FALSE == pC->pAudioEncoderFlag[i] )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)pC->pAudioEncoderInterface[i]);
+                    free(pC->pAudioEncoderInterface[i]);
                 }
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
@@ -595,13 +593,13 @@
     {
         if( pC->m_pReaderGlobalItTable[i] != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderGlobalItTable[i]);
+            free(pC->m_pReaderGlobalItTable[i]);
             pC->m_pReaderGlobalItTable[i] = M4OSA_NULL;
         }
 
         if( pC->m_pReaderDataItTable[i] != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pReaderDataItTable[i]);
+            free(pC->m_pReaderDataItTable[i]);
             pC->m_pReaderDataItTable[i] = M4OSA_NULL;
         }
     }
@@ -641,7 +639,7 @@
 
 #endif
 
-                M4OSA_free((M4OSA_MemAddr32)pC->m_pVideoDecoderItTable[i]);
+                free(pC->m_pVideoDecoderItTable[i]);
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
             }
@@ -649,20 +647,6 @@
 #endif
 
             pC->m_pVideoDecoderItTable[i] = M4OSA_NULL;
-#ifdef M4VSS_ENABLE_EXTERNAL_DECODERS
-#if 0 /* This is to avoid freeing OMX core context, passed as user data */
-
-            if( pC->m_pVideoDecoderUserDataTable[i] != M4OSA_NULL )
-            {
-                M4OSA_free(
-                    (M4OSA_MemAddr32)pC->m_pVideoDecoderUserDataTable[i]);
-                /* there ought to be a better pattern... right? */
-                pC->m_pVideoDecoderUserDataTable[i] = M4OSA_NULL;
-            }
-
-#endif
-
-#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS */
 
         }
     }
@@ -681,7 +665,7 @@
 
                 if( M4OSA_FALSE == pC->m_pAudioDecoderFlagTable[i] )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)pC->m_pAudioDecoderItTable[i]);
+                    free(pC->m_pAudioDecoderItTable[i]);
                 }
 #ifdef M4VSS_SUPPORT_OMX_CODECS
 
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
index d495186..efdda9b 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
@@ -133,11 +133,11 @@
     /**
     * Allocate the VSS context and return it to the user */
     pC = (M4VSS3GPP_InternalEditContext
-        *)M4OSA_malloc(sizeof(M4VSS3GPP_InternalEditContext),
+        *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_InternalEditContext),
         M4VSS3GPP, (M4OSA_Char *)"M4VSS3GPP_InternalContext");
     *pContext = pC;
         /* Inialization of context Variables */
-    M4OSA_memset((M4OSA_MemAddr8)pC, sizeof(M4VSS3GPP_InternalEditContext), 0);
+    memset((void *)pC, 0,sizeof(M4VSS3GPP_InternalEditContext));
 
     if( M4OSA_NULL == pC )
     {
@@ -190,24 +190,6 @@
     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 */
 
@@ -229,6 +211,9 @@
 
     pC->bIsMMS = M4OSA_FALSE;
 
+    pC->iInOutTimeOffset = 0;
+    pC->bEncodeTillEoF = M4OSA_FALSE;
+
     /**
     * Return with no error */
     M4OSA_TRACE3_0("M4VSS3GPP_editInit(): returning M4NO_ERROR");
@@ -275,11 +260,11 @@
 
     if( M4OSA_NULL != pFile )
     {
-        //pClipSettings->pFile = (M4OSA_Char*) M4OSA_malloc(M4OSA_chrLength(pFile)+1, M4VSS3GPP,
+        //pClipSettings->pFile = (M4OSA_Char*) M4OSA_32bitAlignedMalloc(strlen(pFile)+1, M4VSS3GPP,
         // "pClipSettings->pFile");
         /*FB: add clip path size because of utf 16 conversion*/
         pClipSettings->pFile =
-            (M4OSA_Void *)M4OSA_malloc(filePathSize + 1, M4VSS3GPP,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(filePathSize + 1, M4VSS3GPP,
             (M4OSA_Char *)"pClipSettings->pFile");
 
         if( M4OSA_NULL == pClipSettings->pFile )
@@ -288,9 +273,9 @@
                 "M4VSS3GPP_editCreateClipSettings : ERROR allocating filename");
             return M4ERR_ALLOC;
         }
-        //M4OSA_memcpy(pClipSettings->pFile, pFile, M4OSA_chrLength(pFile)+1);
+        //memcpy(pClipSettings->pFile, pFile, strlen(pFile)+1);
         /*FB: add clip path size because of utf 16 conversion*/
-        M4OSA_memcpy(pClipSettings->pFile, pFile, filePathSize + 1);
+        memcpy((void *)pClipSettings->pFile, (void *)pFile, filePathSize + 1);
     }
 
     /*FB: add file path size to support UTF16 conversion*/
@@ -372,19 +357,19 @@
         "M4VSS3GPP_editDuplicateClipSettings: pClipSettingsOrig is NULL");
 
     /* Copy plain structure */
-    M4OSA_memcpy((M4OSA_MemAddr8)pClipSettingsDest,
-        (M4OSA_MemAddr8)pClipSettingsOrig, sizeof(M4VSS3GPP_ClipSettings));
+    memcpy((void *)pClipSettingsDest,
+        (void *)pClipSettingsOrig, sizeof(M4VSS3GPP_ClipSettings));
 
     /* Duplicate filename */
     if( M4OSA_NULL != pClipSettingsOrig->pFile )
     {
         //pClipSettingsDest->pFile =
-        // (M4OSA_Char*) M4OSA_malloc(M4OSA_chrLength(pClipSettingsOrig->pFile)+1, M4VSS3GPP,
+        // (M4OSA_Char*) M4OSA_32bitAlignedMalloc(strlen(pClipSettingsOrig->pFile)+1, M4VSS3GPP,
         // "pClipSettingsDest->pFile");
         /*FB: clip path size is needed for utf 16 conversion*/
         /*FB 2008/10/16: bad allocation size which raises a crash*/
         pClipSettingsDest->pFile =
-            (M4OSA_Char *)M4OSA_malloc(pClipSettingsOrig->filePathSize + 1,
+            (M4OSA_Char *)M4OSA_32bitAlignedMalloc(pClipSettingsOrig->filePathSize + 1,
             M4VSS3GPP, (M4OSA_Char *)"pClipSettingsDest->pFile");
 
         if( M4OSA_NULL == pClipSettingsDest->pFile )
@@ -394,53 +379,16 @@
             return M4ERR_ALLOC;
         }
         /*FB: clip path size is needed for utf 16 conversion*/
-        //M4OSA_memcpy(pClipSettingsDest->pFile, pClipSettingsOrig->pFile,
-        // M4OSA_chrLength(pClipSettingsOrig->pFile)+1);
+        //memcpy(pClipSettingsDest->pFile, pClipSettingsOrig->pFile,
+        // strlen(pClipSettingsOrig->pFile)+1);
         /*FB 2008/10/16: bad allocation size which raises a crash*/
-        M4OSA_memcpy(pClipSettingsDest->pFile, pClipSettingsOrig->pFile,
+        memcpy((void *)pClipSettingsDest->pFile, (void *)pClipSettingsOrig->pFile,
             pClipSettingsOrig->filePathSize/*+1*/);
         ( (M4OSA_Char
             *)pClipSettingsDest->pFile)[pClipSettingsOrig->filePathSize] = '\0';
     }
 
     /* Duplicate effects */
-#if 0
-
-    if( M4OSA_TRUE == bCopyEffects )
-    {
-        if( pClipSettingsOrig->nbEffects > 0 )
-        {
-            pClipSettingsDest->Effects = (M4VSS3GPP_EffectSettings
-                *)M4OSA_malloc(sizeof(M4VSS3GPP_EffectSettings)
-                * pClipSettingsOrig->nbEffects,
-                M4VSS3GPP, "pClipSettingsDest->Effects");
-
-            if( M4OSA_NULL == pClipSettingsDest->Effects )
-            {
-                M4OSA_TRACE1_1(
-                    "M4VSS3GPP_editDuplicateClipSettings : ERROR allocating effects, nb=%lu",
-                    pClipSettingsOrig->nbEffects);
-                pClipSettingsDest->nbEffects = 0;
-                return M4ERR_ALLOC;
-            }
-
-            for ( uiFx = 0; uiFx < pClipSettingsOrig->nbEffects; uiFx++ )
-            {
-                /* Copy plain structure */
-                M4OSA_memcpy(
-                    (M4OSA_MemAddr8) &(pClipSettingsDest->Effects[uiFx]),
-                    (M4OSA_MemAddr8) &(pClipSettingsOrig->Effects[uiFx]),
-                    sizeof(M4VSS3GPP_EffectSettings));
-            }
-        }
-    }
-    else
-    {
-        pClipSettingsDest->nbEffects = 0;
-        pClipSettingsDest->Effects = M4OSA_NULL;
-    }
-
-#endif /* RC */
     /* Return with no error */
 
     M4OSA_TRACE3_0(
@@ -470,14 +418,14 @@
     /* free filename */
     if( M4OSA_NULL != pClipSettings->pFile )
     {
-        M4OSA_free((M4OSA_MemAddr32)pClipSettings->pFile);
+        free(pClipSettings->pFile);
         pClipSettings->pFile = M4OSA_NULL;
     }
 
     /* free effects settings */
     /*    if(M4OSA_NULL != pClipSettings->Effects)
     {
-    M4OSA_free((M4OSA_MemAddr32)pClipSettings->Effects);
+    free(pClipSettings->Effects);
     pClipSettings->Effects = M4OSA_NULL;
     pClipSettings->nbEffects = 0;
     } RC */
@@ -548,7 +496,7 @@
     /**
     * Copy the clip list */
     pC->pClipList =
-        (M4VSS3GPP_ClipSettings *)M4OSA_malloc(sizeof(M4VSS3GPP_ClipSettings)
+        (M4VSS3GPP_ClipSettings *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_ClipSettings)
         * pC->uiClipNumber, M4VSS3GPP, (M4OSA_Char *)"pC->pClipList");
 
     if( M4OSA_NULL == pC->pClipList )
@@ -573,7 +521,7 @@
     {
         pC->nbEffects = pSettings->nbEffects;
         pC->pEffectsList = (M4VSS3GPP_EffectSettings
-            *)M4OSA_malloc(sizeof(M4VSS3GPP_EffectSettings) * pC->nbEffects,
+            *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_EffectSettings) * pC->nbEffects,
             M4VSS3GPP, (M4OSA_Char *)"pC->pEffectsList");
 
         if( M4OSA_NULL == pC->pEffectsList )
@@ -585,15 +533,15 @@
 
         for ( i = 0; i < pC->nbEffects; i++ )
         {
-            M4OSA_memcpy((M4OSA_MemAddr8) &(pC->pEffectsList[i]),
-                (M4OSA_MemAddr8) &(pSettings->Effects[i]),
+            memcpy((void *) &(pC->pEffectsList[i]),
+                (void *) &(pSettings->Effects[i]),
                 sizeof(M4VSS3GPP_EffectSettings));
         }
 
         /**
         * Allocate active effects list RC */
         pC->pActiveEffectsList =
-            (M4OSA_UInt8 *)M4OSA_malloc(sizeof(M4OSA_UInt8) * pC->nbEffects,
+            (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_UInt8) * pC->nbEffects,
             M4VSS3GPP, (M4OSA_Char *)"pC->pActiveEffectsList");
 
         if( M4OSA_NULL == pC->pActiveEffectsList )
@@ -606,7 +554,7 @@
         /**
          * Allocate active effects list */
         pC->pActiveEffectsList1 =
-            (M4OSA_UInt8 *)M4OSA_malloc(sizeof(M4OSA_UInt8) * pC->nbEffects,
+            (M4OSA_UInt8 *)M4OSA_32bitAlignedMalloc(sizeof(M4OSA_UInt8) * pC->nbEffects,
             M4VSS3GPP, (M4OSA_Char *)"pC->pActiveEffectsList");
         if (M4OSA_NULL == pC->pActiveEffectsList1)
         {
@@ -714,7 +662,7 @@
     * We add a transition of duration 0 at the end of the last clip.
     * It will suppress a whole bunch a test latter in the processing... */
     pC->pTransitionList = (M4VSS3GPP_TransitionSettings
-        *)M4OSA_malloc(sizeof(M4VSS3GPP_TransitionSettings)
+        *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_TransitionSettings)
         * (pC->uiClipNumber), M4VSS3GPP, (M4OSA_Char *)"pC->pTransitionList");
 
     if( M4OSA_NULL == pC->pTransitionList )
@@ -728,8 +676,8 @@
     /**< copy transition settings */
     for ( i = 0; i < (pSettings->uiClipNumber - 1); i++ )
     {
-        M4OSA_memcpy((M4OSA_MemAddr8) &(pC->pTransitionList[i]),
-            (M4OSA_MemAddr8)pSettings->pTransitionList[i],
+        memcpy((void *) &(pC->pTransitionList[i]),
+            (void *)pSettings->pTransitionList[i],
             sizeof(M4VSS3GPP_TransitionSettings));
     }
 
@@ -1141,7 +1089,7 @@
 
             /**
             * Free before the error checking anyway */
-            M4OSA_free((M4OSA_MemAddr32)mp3tagBuffer.m_pData);
+            free(mp3tagBuffer.m_pData);
 
             /**
             * Error checking */
@@ -1427,7 +1375,7 @@
     * Free the output video DSI, if it has been created */
     if( M4OSA_NULL != pC->ewc.pVideoOutputDsi )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->ewc.pVideoOutputDsi);
+        free(pC->ewc.pVideoOutputDsi);
         pC->ewc.pVideoOutputDsi = M4OSA_NULL;
     }
 
@@ -1435,7 +1383,7 @@
     * Free the output audio DSI, if it has been created */
     if( M4OSA_NULL != pC->ewc.pAudioOutputDsi )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->ewc.pAudioOutputDsi);
+        free(pC->ewc.pAudioOutputDsi);
         pC->ewc.pAudioOutputDsi = M4OSA_NULL;
     }
 
@@ -1485,75 +1433,75 @@
     * Free the temporary YUV planes */
     if( M4OSA_NULL != pC->yuv1[0].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv1[0].pac_data);
+        free(pC->yuv1[0].pac_data);
         pC->yuv1[0].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv1[1].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv1[1].pac_data);
+        free(pC->yuv1[1].pac_data);
         pC->yuv1[1].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv1[2].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv1[2].pac_data);
+        free(pC->yuv1[2].pac_data);
         pC->yuv1[2].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv2[0].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv2[0].pac_data);
+        free(pC->yuv2[0].pac_data);
         pC->yuv2[0].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv2[1].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv2[1].pac_data);
+        free(pC->yuv2[1].pac_data);
         pC->yuv2[1].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv2[2].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv2[2].pac_data);
+        free(pC->yuv2[2].pac_data);
         pC->yuv2[2].pac_data = M4OSA_NULL;
     }
 
     /* RC */
     if( M4OSA_NULL != pC->yuv3[0].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv3[0].pac_data);
+        free(pC->yuv3[0].pac_data);
         pC->yuv3[0].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv3[1].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv3[1].pac_data);
+        free(pC->yuv3[1].pac_data);
         pC->yuv3[1].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv3[2].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv3[2].pac_data);
+        free(pC->yuv3[2].pac_data);
         pC->yuv3[2].pac_data = M4OSA_NULL;
     }
 
     /* RC */
     if( M4OSA_NULL != pC->yuv4[0].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv4[0].pac_data);
+        free(pC->yuv4[0].pac_data);
         pC->yuv4[0].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv4[1].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv4[1].pac_data);
+        free(pC->yuv4[1].pac_data);
         pC->yuv4[1].pac_data = M4OSA_NULL;
     }
 
     if( M4OSA_NULL != pC->yuv4[2].pac_data )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->yuv4[2].pac_data);
+        free(pC->yuv4[2].pac_data);
         pC->yuv4[2].pac_data = M4OSA_NULL;
     }
 
@@ -1561,7 +1509,7 @@
     * RC Free effects list */
     if( pC->pEffectsList != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pEffectsList);
+        free(pC->pEffectsList);
         pC->pEffectsList = M4OSA_NULL;
     }
 
@@ -1569,14 +1517,14 @@
     * RC Free active effects list */
     if( pC->pActiveEffectsList != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pActiveEffectsList);
+        free(pC->pActiveEffectsList);
         pC->pActiveEffectsList = M4OSA_NULL;
     }
     /**
      *  Free active effects list */
     if(pC->pActiveEffectsList1 != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pActiveEffectsList1);
+        free(pC->pActiveEffectsList1);
         pC->pActiveEffectsList1 = M4OSA_NULL;
     }
     /**
@@ -1638,7 +1586,7 @@
     * Free the video encoder dummy AU */
     if( M4OSA_NULL != pC->ewc.pDummyAuBuffer )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->ewc.pDummyAuBuffer);
+        free(pC->ewc.pDummyAuBuffer);
         pC->ewc.pDummyAuBuffer = M4OSA_NULL;
     }
 
@@ -1684,7 +1632,7 @@
 
     /**
     * Finally, Free context */
-    M4OSA_free((M4OSA_MemAddr32)pC);
+    free(pC);
     pC = M4OSA_NULL;
 
     /**
@@ -1693,119 +1641,6 @@
     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);
-        M4OSA_free((M4OSA_MemAddr32)shellInterface);
-        return err;
-    }
-
-    pC->ShellAPI.pVideoEncoderExternalAPITable[nativeType] = pEncoderInterface;
-    pC->ShellAPI.pVideoEncoderUserDataTable[nativeType] = pUserData;
-
-    return M4NO_ERROR;
-
-#else
-
-    return M4ERR_NOT_IMPLEMENTED;
-
-#endif
-
-}
-
 #ifdef WIN32
 /**
  ******************************************************************************
@@ -2110,83 +1945,6 @@
         uiClipActualDuration = pClip->uiEndCutTime - pClip->uiBeginCutTime;
     }
 
-    if( M4VIDEOEDITING_kMP3 != pClip->ClipProperties.AudioStreamType )
-    {
-#if 0 /*RC*/
-        /**
-        * Check the three effects */
-
-        for ( uiFx = 0; uiFx < pClip->nbEffects; uiFx++ )
-        {
-            pFx = &(pClip->Effects[uiFx]); /**< shortcut */
-
-            /**
-            * No effect cases */
-            if( 0 == pFx->uiDuration )
-            {
-                pFx->VideoEffectType = M4VSS3GPP_kVideoEffectType_None;
-                pFx->AudioEffectType = M4VSS3GPP_kAudioEffectType_None;
-            }
-            else if( ( M4VSS3GPP_kVideoEffectType_None == pFx->VideoEffectType)
-                && (M4VSS3GPP_kAudioEffectType_None == pFx->AudioEffectType) )
-            {
-                pFx->uiStartTime = 0;
-                pFx->uiDuration = 0;
-            }
-
-            /**
-            * We convert all the effects into middle effects, computing the corresponding
-            * start time and duration */
-            if( M4VSS3GPP_kEffectKind_Begin == pFx->EffectKind )
-            {
-                pFx->uiStartTime = 0;
-            }
-            else if( M4VSS3GPP_kEffectKind_End == pFx->EffectKind )
-            {
-                /**
-                * Duration sanity check */
-                if( pFx->uiDuration > uiClipActualDuration )
-                {
-                    pFx->uiDuration = uiClipActualDuration;
-                }
-                /**
-                * Start time computing */
-                pFx->uiStartTime = uiClipActualDuration - pFx->uiDuration;
-            }
-            else if( M4VSS3GPP_kEffectKind_Middle == pFx->EffectKind )
-            {
-                /**
-                * Duration sanity check */
-                if( pFx->uiDuration + pFx->uiStartTime > uiClipActualDuration )
-                {
-                    pFx->uiDuration = uiClipActualDuration - pFx->uiStartTime;
-                }
-            }
-            else
-            {
-                M4OSA_TRACE1_1(
-                    "M4VSS3GPP_intClipSettingsSanityCheck: unknown effect kind (0x%x),\
-                    returning M4VSS3GPP_ERR_INVALID_EFFECT_KIND",
-                    pFx->EffectKind);
-                return M4VSS3GPP_ERR_INVALID_EFFECT_KIND;
-            }
-
-            /**
-            * Check external effect function is set */
-            if( ( pFx->VideoEffectType >= M4VSS3GPP_kVideoEffectType_External)
-                && (M4OSA_NULL == pFx->ExtVideoEffectFct) )
-            {
-                M4OSA_TRACE1_0(
-                    "M4VSS3GPP_intClipSettingsSanityCheck:\
-                    returning M4VSS3GPP_ERR_EXTERNAL_EFFECT_NULL");
-                return M4VSS3GPP_ERR_EXTERNAL_EFFECT_NULL;
-            }
-        }
-
-#endif
-
-    }
-
     return M4NO_ERROR;
 }
 
@@ -2260,7 +2018,7 @@
             M4VSS3GPP_editFreeClipSettings(&(pC->pClipList[i]));
         }
 
-        M4OSA_free((M4OSA_MemAddr32)pC->pClipList);
+        free(pC->pClipList);
         pC->pClipList = M4OSA_NULL;
     }
 
@@ -2268,7 +2026,7 @@
     * Free the transition list */
     if( M4OSA_NULL != pC->pTransitionList )
     {
-        M4OSA_free((M4OSA_MemAddr32)pC->pTransitionList);
+        free(pC->pTransitionList);
         pC->pTransitionList = M4OSA_NULL;
     }
 }
@@ -2732,7 +2490,7 @@
         * H263 output DSI is always 7 bytes */
         pC->ewc.uiVideoOutputDsiSize = 7;
         pC->ewc.pVideoOutputDsi =
-            (M4OSA_MemAddr8)M4OSA_malloc(pC->ewc.uiVideoOutputDsiSize,
+            (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(pC->ewc.uiVideoOutputDsiSize,
             M4VSS3GPP, (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (H263)");
 
         if( M4OSA_NULL == pC->ewc.pVideoOutputDsi )
@@ -2932,7 +2690,7 @@
 
         /**
         * Allocate and copy the new DSI */
-        pC->ewc.pVideoOutputDsi = (M4OSA_MemAddr8)M4OSA_malloc(
+        pC->ewc.pVideoOutputDsi = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
             pStreamForDsi->m_decoderSpecificInfoSize,
             M4VSS3GPP, (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (MPEG4)");
 
@@ -2945,8 +2703,8 @@
         }
         pC->ewc.uiVideoOutputDsiSize =
             (M4OSA_UInt16)pStreamForDsi->m_decoderSpecificInfoSize;
-        M4OSA_memcpy(pC->ewc.pVideoOutputDsi,
-            (M4OSA_MemAddr8)pStreamForDsi->m_pDecoderSpecificInfo,
+        memcpy((void *)pC->ewc.pVideoOutputDsi,
+            (void *)pStreamForDsi->m_pDecoderSpecificInfo,
             pC->ewc.uiVideoOutputDsiSize);
 
         /**
@@ -3020,7 +2778,7 @@
                 /**
                 * Allocate and copy the new DSI */
                 pC->ewc.pVideoOutputDsi =
-                    (M4OSA_MemAddr8)M4OSA_malloc(encHeader->Size, M4VSS3GPP,
+                    (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(encHeader->Size, M4VSS3GPP,
                     (M4OSA_Char *)"pC->ewc.pVideoOutputDsi (H264)");
 
                 if( M4OSA_NULL == pC->ewc.pVideoOutputDsi )
@@ -3031,7 +2789,7 @@
                     return M4ERR_ALLOC;
                 }
                 pC->ewc.uiVideoOutputDsiSize = (M4OSA_UInt16)encHeader->Size;
-                M4OSA_memcpy(pC->ewc.pVideoOutputDsi, encHeader->pBuf,
+                memcpy((void *)pC->ewc.pVideoOutputDsi, (void *)encHeader->pBuf,
                     encHeader->Size);
             }
 
@@ -3102,7 +2860,7 @@
 
         /**
         * Allocate and copy the new DSI */
-        pC->ewc.pAudioOutputDsi = (M4OSA_MemAddr8)M4OSA_malloc(
+        pC->ewc.pAudioOutputDsi = (M4OSA_MemAddr8)M4OSA_32bitAlignedMalloc(
             pStreamForDsi->m_decoderSpecificInfoSize,
             M4VSS3GPP, (M4OSA_Char *)"pC->ewc.pAudioOutputDsi");
 
@@ -3115,8 +2873,8 @@
         }
         pC->ewc.uiAudioOutputDsiSize =
             (M4OSA_UInt16)pStreamForDsi->m_decoderSpecificInfoSize;
-        M4OSA_memcpy(pC->ewc.pAudioOutputDsi,
-            (M4OSA_MemAddr8)pStreamForDsi->m_pDecoderSpecificInfo,
+        memcpy((void *)pC->ewc.pAudioOutputDsi,
+            (void *)pStreamForDsi->m_pDecoderSpecificInfo,
             pC->ewc.uiAudioOutputDsiSize);
 
         /**
@@ -3289,8 +3047,9 @@
             }
         }
     }
-    /* The flag is set to false at the beginning of every clip */
+    /* The flags are set to false at the beginning of every clip */
     pC->m_bClipExternalHasStarted = M4OSA_FALSE;
+    pC->bEncodeTillEoF = M4OSA_FALSE;
 
     /**
     * Return with no error */
@@ -3413,49 +3172,6 @@
     * 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);
 
@@ -3705,431 +3421,3 @@
     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/M4VSS3GPP_EditAudio.c b/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
index b118244..103a5ea 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_EditAudio.c
@@ -170,7 +170,7 @@
                     (M4OSA_MemAddr8)mp3tagBuffer.m_pData, mp3tagBuffer.m_uiBufferSize);
                 /**
                 * Free before the error checking anyway */
-                M4OSA_free((M4OSA_MemAddr32)mp3tagBuffer.m_pData);
+                free(mp3tagBuffer.m_pData);
 
                 /**
                 * Error checking */
@@ -322,8 +322,8 @@
                     /**
                     * Copy a silence AU to the output */
                     pC->ewc.WriterAudioAU.size = pC->ewc.uiSilenceFrameSize;
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-                        (M4OSA_MemAddr8)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
+                    memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+                        (void *)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
                     M4OSA_TRACE2_0("A #### silence AU");
                 }
                 else if( (M4OSA_UInt32)pC->pC1->uiAudioFrameSize
@@ -333,8 +333,8 @@
                     * Copy the input AU to the output AU */
                     pC->ewc.WriterAudioAU.size =
                         (M4OSA_UInt32)pC->pC1->uiAudioFrameSize;
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-                        pC->pC1->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
+                    memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+                        (void *)pC->pC1->pAudioFramePtr, pC->ewc.WriterAudioAU.size);
                 }
                 else
                 {
@@ -650,8 +650,8 @@
                     /**
                     * Copy a silence AMR AU to the output */
                     pC->ewc.WriterAudioAU.size = pC->ewc.uiSilenceFrameSize;
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterAudioAU.dataAddress,
-                        (M4OSA_MemAddr8)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
+                    memcpy((void *)pC->ewc.WriterAudioAU.dataAddress,
+                        (void *)pC->ewc.pSilenceFrameData, pC->ewc.uiSilenceFrameSize);
                     M4OSA_TRACE2_0("G #### silence AU");
                 }
                 else
@@ -1501,26 +1501,6 @@
             * If the announced duration is smaller than the real one, the end effect
                       won't be applied at
             * the very end of the clip. To solve this issue we force the end effect. */
-#if 0
-
-            else if( ( M4VSS3GPP_kEffectKind_End == pFx->EffectKind)
-                && (t >= (M4OSA_Int32)(BC + pFx->uiStartTime)) )
-            {
-                /**
-                * Set the active effect */
-                *piClipActiveEffect =
-                    pC->pClipList[uiClipIndex].nbEffects - 1 - uiFxIndex;
-
-                /**
-                * The third effect has the highest priority, then the second one,
-                   then the first one.
-                * Hence, as soon as we found an active effect, we can get out of this loop */
-                uiFxIndex = pC->
-                    pClipList[
-                        uiClipIndex].nbEffects; /** get out of the for loop */
-            }
-
-#endif                                                    /* RC */
 
         }
     }
@@ -1786,8 +1766,8 @@
             {
                 /**
                 * Copy the input PCM to the output buffer */
-                M4OSA_memcpy((M4OSA_MemAddr8)pPCMdata1,
-                    (M4OSA_MemAddr8)pPCMdata2, uiPCMsize);
+                memcpy((void *)pPCMdata1,
+                    (void *)pPCMdata2, uiPCMsize);
             }
             /**
             * the output must be put in the first buffer.
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
index 9870426..f69f14b 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
@@ -93,12 +93,18 @@
     M4OSA_UInt16 offset;
 
     /**
-    * Check if we reached end cut */
-    // Decorrelate input and output encoding timestamp to handle encoder prefetch
-    if ( ((M4OSA_Int32)(pC->ewc.dInputVidCts) - pC->pC1->iVoffset) >= pC->pC1->iEndTime )
+     * Check if we reached end cut. Decorrelate input and output encoding
+     * timestamp to handle encoder prefetch
+     */
+    if ( ((M4OSA_Int32)(pC->ewc.dInputVidCts) - pC->pC1->iVoffset
+        + pC->iInOutTimeOffset) >= pC->pC1->iEndTime )
     {
         /* Re-adjust video to precise cut time */
-        // Decorrelate input and output encoding timestamp to handle encoder prefetch
+        pC->iInOutTimeOffset = ((M4OSA_Int32)(pC->ewc.dInputVidCts))
+            - pC->pC1->iVoffset + pC->iInOutTimeOffset - pC->pC1->iEndTime;
+        if ( pC->iInOutTimeOffset < 0 ) {
+            pC->iInOutTimeOffset = 0;
+        }
 
         /**
         * Video is done for this clip */
@@ -263,8 +269,8 @@
                         return M4VSS3GPP_ERR_INPUT_VIDEO_AU_TOO_LARGE;
                     }
 
-                    M4OSA_memcpy((M4OSA_MemAddr8)pC->ewc.WriterVideoAU.dataAddress,
-                        (pC->pC1->VideoAU.m_dataAddress + offset),
+                    memcpy((void *)pC->ewc.WriterVideoAU.dataAddress,
+                        (void *)(pC->pC1->VideoAU.m_dataAddress + offset),
                         (pC->ewc.WriterVideoAU.size));
 
                     /**
@@ -723,11 +729,15 @@
         to catch all P-frames after the cut) */
         else if( M4OSA_TRUE == pC->bClip1AtBeginCut )
         {
-            if( ( M4VSS3GPP_kEditVideoState_BEGIN_CUT == previousVstate)
-                || (M4VSS3GPP_kEditVideoState_AFTER_CUT == previousVstate) )
+            if(pC->pC1->pSettings->ClipProperties.VideoStreamType == M4VIDEOEDITING_kH264) {
+                pC->Vstate = M4VSS3GPP_kEditVideoState_DECODE_ENCODE;
+                pC->bEncodeTillEoF = M4OSA_TRUE;
+            } else if( ( M4VSS3GPP_kEditVideoState_BEGIN_CUT == previousVstate)
+                || (M4VSS3GPP_kEditVideoState_AFTER_CUT == previousVstate) ) {
                 pC->Vstate = M4VSS3GPP_kEditVideoState_AFTER_CUT;
-            else
+            } else {
                 pC->Vstate = M4VSS3GPP_kEditVideoState_BEGIN_CUT;
+            }
         }
         /* Else we are in default copy/paste mode */
         else
@@ -771,7 +781,8 @@
                 }
             }
             else if(!((pC->m_bClipExternalHasStarted == M4OSA_TRUE) &&
-                    (pC->Vstate == M4VSS3GPP_kEditVideoState_DECODE_ENCODE)))
+                    (pC->Vstate == M4VSS3GPP_kEditVideoState_DECODE_ENCODE)) &&
+                    pC->bEncodeTillEoF == M4OSA_FALSE)
             {
                 /**
                  * Test if we go into copy/paste mode or into decode/encode mode
@@ -829,7 +840,7 @@
         || (M4VSS3GPP_kEditVideoState_TRANSITION
         == previousVstate)) /**< encode mode */
         && (M4VSS3GPP_kEditVideoState_READ_WRITE == pC->Vstate) /**< read mode */
-        )
+        && (pC->bEncodeTillEoF == M4OSA_FALSE) )
     {
         pC->Vstate = M4VSS3GPP_kEditVideoState_BEGIN_CUT;
     }
@@ -988,12 +999,12 @@
         /**
         * We must fill the input of the encoder with a dummy image, because
         * encoding noise leads to a huge video AU, and thus a writer buffer overflow. */
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[0].pac_data,
-            pPlaneOut[0].u_stride * pPlaneOut[0].u_height, 0);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[1].pac_data,
-            pPlaneOut[1].u_stride * pPlaneOut[1].u_height, 0);
-        M4OSA_memset((M4OSA_MemAddr8)pPlaneOut[2].pac_data,
-            pPlaneOut[2].u_stride * pPlaneOut[2].u_height, 0);
+        memset((void *)pPlaneOut[0].pac_data,0,
+            pPlaneOut[0].u_stride * pPlaneOut[0].u_height);
+        memset((void *)pPlaneOut[1].pac_data,0,
+            pPlaneOut[1].u_stride * pPlaneOut[1].u_height);
+        memset((void *)pPlaneOut[2].pac_data,0,
+            pPlaneOut[2].u_stride * pPlaneOut[2].u_height);
 
         M4OSA_TRACE3_0("M4VSS3GPP_intVPP: returning M4NO_ERROR (abort)");
         return M4NO_ERROR;
@@ -1141,14 +1152,14 @@
         else
         {
             /* Copy last decoded plane to output plane */
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[0].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[0].pac_data,
+            memcpy((void *)pTmp[0].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[0].pac_data,
                 (pTmp[0].u_height * pTmp[0].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[1].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[1].pac_data,
+            memcpy((void *)pTmp[1].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[1].pac_data,
                 (pTmp[1].u_height * pTmp[1].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[2].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[2].pac_data,
+            memcpy((void *)pTmp[2].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[2].pac_data,
                 (pTmp[2].u_height * pTmp[2].u_width));
             pC->pC1->lastDecodedPlane = pTmp;
         }
@@ -1207,14 +1218,14 @@
         else
         {
             /* Copy last decoded plane to output plane */
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[0].pac_data,
-                (M4OSA_MemAddr8)pC->pC2->lastDecodedPlane[0].pac_data,
+            memcpy((void *)pTmp[0].pac_data,
+                (void *)pC->pC2->lastDecodedPlane[0].pac_data,
                 (pTmp[0].u_height * pTmp[0].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[1].pac_data,
-                (M4OSA_MemAddr8)pC->pC2->lastDecodedPlane[1].pac_data,
+            memcpy((void *)pTmp[1].pac_data,
+                (void *)pC->pC2->lastDecodedPlane[1].pac_data,
                 (pTmp[1].u_height * pTmp[1].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[2].pac_data,
-                (M4OSA_MemAddr8)pC->pC2->lastDecodedPlane[2].pac_data,
+            memcpy((void *)pTmp[2].pac_data,
+                (void *)pC->pC2->lastDecodedPlane[2].pac_data,
                 (pTmp[2].u_height * pTmp[2].u_width));
             pC->pC2->lastDecodedPlane = pTmp;
         }
@@ -1237,14 +1248,14 @@
         {
             if (pTemp2[i].pac_data != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pTemp2[i].pac_data);
+                free(pTemp2[i].pac_data);
                 pTemp2[i].pac_data = M4OSA_NULL;
             }
 
 
             if (pTemp1[i].pac_data != M4OSA_NULL)
             {
-                    M4OSA_free((M4OSA_MemAddr32)pTemp1[i].pac_data);
+                    free(pTemp1[i].pac_data);
                     pTemp1[i].pac_data = M4OSA_NULL;
                 }
             }
@@ -1315,14 +1326,14 @@
         else
         {
             /* Copy last decoded plane to output plane */
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[0].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[0].pac_data,
+            memcpy((void *)pTmp[0].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[0].pac_data,
                 (pTmp[0].u_height * pTmp[0].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[1].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[1].pac_data,
+            memcpy((void *)pTmp[1].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[1].pac_data,
                 (pTmp[1].u_height * pTmp[1].u_width));
-            M4OSA_memcpy((M4OSA_MemAddr8)pTmp[2].pac_data,
-                (M4OSA_MemAddr8)pC->pC1->lastDecodedPlane[2].pac_data,
+            memcpy((void *)pTmp[2].pac_data,
+                (void *)pC->pC1->lastDecodedPlane[2].pac_data,
                 (pTmp[2].u_height * pTmp[2].u_width));
             pC->pC1->lastDecodedPlane = pTmp;
         }
@@ -1769,8 +1780,8 @@
 
             while( i-- > 0 )
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)pPlaneOut[i].pac_data,
-                 (M4OSA_MemAddr8)pPlane[i].pac_data,
+                memcpy((void *)pPlaneOut[i].pac_data,
+                 (void *)pPlane[i].pac_data,
                     pPlaneOut[i].u_stride * pPlaneOut[i].u_height);
             }
             break;
@@ -1974,9 +1985,11 @@
 
              if(uiClipNumber ==1)
              {
-                if ((t >= (M4OSA_Int32)(pFx->uiStartTime)) &&                  /**< Are we after the start time of the effect? */
-                    (t <  (M4OSA_Int32)(pFx->uiStartTime + pFx->uiDuration)) ) /**< Are we into the effect duration? */
-                {
+                /**< Are we after the start time of the effect?
+                 * or Are we into the effect duration?
+                 */
+                if ( (t >= (M4OSA_Int32)(pFx->uiStartTime)) &&
+                    (t <= (M4OSA_Int32)(pFx->uiStartTime + pFx->uiDuration)) ) {
                     /**
                      * Set the active effect(s) */
                     pC->pActiveEffectsList[i] = pC->nbEffects-1-uiFxIndex;
@@ -1993,17 +2006,19 @@
                     }
 
                     /**
-                     * The third effect has the highest priority, then the second one, then the first one.
-                     * Hence, as soon as we found an active effect, we can get out of this loop */
-
+                     * The third effect has the highest priority, then the
+                     * second one, then the first one. Hence, as soon as we
+                     * found an active effect, we can get out of this loop.
+                     */
                 }
             }
             else
             {
-                if ((t + pC->pTransitionList[uiClipIndex].uiTransitionDuration >=
-                   (M4OSA_Int32)(pFx->uiStartTime)) && (t + pC->pTransitionList[uiClipIndex].uiTransitionDuration
-                    <  (M4OSA_Int32)(pFx->uiStartTime + pFx->uiDuration)) ) /**< Are we into the effect duration? */
-                 {
+                /**< Are we into the effect duration? */
+                if ( ((M4OSA_Int32)(t + pC->pTransitionList[uiClipIndex].uiTransitionDuration)
+                    >= (M4OSA_Int32)(pFx->uiStartTime))
+                    && ( (M4OSA_Int32)(t + pC->pTransitionList[uiClipIndex].uiTransitionDuration)
+                    <= (M4OSA_Int32)(pFx->uiStartTime + pFx->uiDuration)) ) {
                     /**
                      * Set the active effect(s) */
                     pC->pActiveEffectsList1[i] = pC->nbEffects-1-uiFxIndex;
@@ -2204,16 +2219,6 @@
         /* Compute max bitrate depending on input files bitrates and transitions */
         if( pC->Vstate == M4VSS3GPP_kEditVideoState_TRANSITION )
         {
-#if 0
-            /* Max of the two blended files */
-            if( pC->pC1->pSettings->ClipProperties.uiVideoBitrate
-                > pC->pC2->pSettings->ClipProperties.uiVideoBitrate )
-                EncParams.Bitrate =
-                pC->pC1->pSettings->ClipProperties.uiVideoBitrate;
-            else
-                EncParams.Bitrate =
-                pC->pC2->pSettings->ClipProperties.uiVideoBitrate;
-#endif
             EncParams.Bitrate = pC->ewc.uiVideoBitrate;
         }
         else
@@ -2525,7 +2530,7 @@
     pPlanes[0].u_height = uiHeight;
     pPlanes[0].u_stride = uiWidth;
     pPlanes[0].u_topleft = 0;
-    pPlanes[0].pac_data = (M4VIFI_UInt8 *)M4OSA_malloc(pPlanes[0].u_stride
+    pPlanes[0].pac_data = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pPlanes[0].u_stride
         * pPlanes[0].u_height, M4VSS3GPP, (M4OSA_Char *)"pPlanes[0].pac_data");
 
     if( M4OSA_NULL == pPlanes[0].pac_data )
@@ -2540,7 +2545,7 @@
     pPlanes[1].u_height = pPlanes[0].u_height >> 1;
     pPlanes[1].u_stride = pPlanes[1].u_width;
     pPlanes[1].u_topleft = 0;
-    pPlanes[1].pac_data = (M4VIFI_UInt8 *)M4OSA_malloc(pPlanes[1].u_stride
+    pPlanes[1].pac_data = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pPlanes[1].u_stride
         * pPlanes[1].u_height, M4VSS3GPP,(M4OSA_Char *) "pPlanes[1].pac_data");
 
     if( M4OSA_NULL == pPlanes[1].pac_data )
@@ -2555,7 +2560,7 @@
     pPlanes[2].u_height = pPlanes[1].u_height;
     pPlanes[2].u_stride = pPlanes[2].u_width;
     pPlanes[2].u_topleft = 0;
-    pPlanes[2].pac_data = (M4VIFI_UInt8 *)M4OSA_malloc(pPlanes[2].u_stride
+    pPlanes[2].pac_data = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(pPlanes[2].u_stride
         * pPlanes[2].u_height, M4VSS3GPP, (M4OSA_Char *)"pPlanes[2].pac_data");
 
     if( M4OSA_NULL == pPlanes[2].pac_data )
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_MediaAndCodecSubscription.c b/libvideoeditor/vss/src/M4VSS3GPP_MediaAndCodecSubscription.c
index f7226a3..df14a54 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_MediaAndCodecSubscription.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_MediaAndCodecSubscription.c
@@ -305,7 +305,7 @@
     err = M4VSS3GPP_registerAudioDecoder( pContext, audioDecoderType, pAudioDecoderInterface);
     M4OSA_DEBUG_IF1((err != M4NO_ERROR), err,
         "M4VSS3GPP_subscribeMediaAndCodec: can't register MP3 decoder");
-#endif  /* M4VSS_SUPPORT_AUDEC_MP3 */`
+#endif  /* M4VSS_SUPPORT_AUDEC_MP3 */
 
 
     /* --- NULL --- */
diff --git a/libvideoeditor/vss/src/M4xVSS_API.c b/libvideoeditor/vss/src/M4xVSS_API.c
index 42c24ed..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
@@ -84,7 +83,7 @@
         return M4ERR_PARAMETER;
     }
 
-    xVSS_context = (M4xVSS_Context *)M4OSA_malloc(sizeof(M4xVSS_Context), M4VS,
+    xVSS_context = (M4xVSS_Context *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_Context), M4VS,
         (M4OSA_Char *)"Context of the xVSS layer");
 
     if( xVSS_context == M4OSA_NULL )
@@ -110,7 +109,7 @@
             xVSS_context->UTFConversionContext.m_TempOutConversionSize =
                 UTF_CONVERSION_BUFFER_SIZE;
             xVSS_context->UTFConversionContext.pTempOutConversionBuffer =
-                (M4OSA_Void *)M4OSA_malloc(UTF_CONVERSION_BUFFER_SIZE
+                (M4OSA_Void *)M4OSA_32bitAlignedMalloc(UTF_CONVERSION_BUFFER_SIZE
                 * sizeof(M4OSA_UInt8),
                 M4VA, (M4OSA_Char *)"M4xVSS_Init: UTF conversion buffer");
 
@@ -118,9 +117,9 @@
                 == xVSS_context->UTFConversionContext.pTempOutConversionBuffer )
             {
                 M4OSA_TRACE1_0("Allocation error in M4xVSS_Init");
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pTempPath);
+                free(xVSS_context->pTempPath);
                 xVSS_context->pTempPath = M4OSA_NULL;
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context);
+                free(xVSS_context);
                 xVSS_context = M4OSA_NULL;
                 return M4ERR_ALLOC;
             }
@@ -129,9 +128,9 @@
         {
             M4OSA_TRACE1_0("M4xVSS_Init: one UTF conversion pointer is null and the other\
                            is not null");
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pTempPath);
+            free(xVSS_context->pTempPath);
             xVSS_context->pTempPath = M4OSA_NULL;
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context);
+            free(xVSS_context);
             xVSS_context = M4OSA_NULL;
             return M4ERR_PARAMETER;
         }
@@ -151,7 +150,7 @@
         (the conversion customer format into UTF8
         is done in VA/VAL)*/
         xVSS_context->pTempPath =
-            (M4OSA_Void *)M4OSA_malloc(M4OSA_chrLength(pParams->pTempPath) + 1,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(strlen(pParams->pTempPath) + 1,
             M4VS, (M4OSA_Char *)"xVSS Path for temporary files");
 
         if( xVSS_context->pTempPath == M4OSA_NULL )
@@ -159,28 +158,28 @@
             M4OSA_TRACE1_0("Allocation error in M4xVSS_Init");
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pTempPath, pParams->pTempPath,
-            M4OSA_chrLength(pParams->pTempPath) + 1);
+        memcpy((void *)xVSS_context->pTempPath, (void *)pParams->pTempPath,
+            strlen(pParams->pTempPath) + 1);
         /* TODO: Check that no previous xVSS temporary files are present ? */
     }
     else
     {
         M4OSA_TRACE1_0("Path for temporary files is NULL");
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context);
+        free(xVSS_context);
         xVSS_context = M4OSA_NULL;
         return M4ERR_PARAMETER;
     }
 
     xVSS_context->pSettings =
-        (M4VSS3GPP_EditSettings *)M4OSA_malloc(sizeof(M4VSS3GPP_EditSettings),
+        (M4VSS3GPP_EditSettings *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_EditSettings),
         M4VS, (M4OSA_Char *)"Copy of VSS structure");
 
     if( xVSS_context->pSettings == M4OSA_NULL )
     {
         M4OSA_TRACE1_0("Allocation error in M4xVSS_Init");
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pTempPath);
+        free(xVSS_context->pTempPath);
         xVSS_context->pTempPath = M4OSA_NULL;
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context);
+        free(xVSS_context);
         xVSS_context = M4OSA_NULL;
         return M4ERR_ALLOC;
     }
@@ -218,23 +217,6 @@
     /*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;
 
@@ -641,8 +623,8 @@
         if( xVSS_context->pSettings->xVSS.pBGMtrack != M4OSA_NULL \
             && pSettings->xVSS.pBGMtrack != M4OSA_NULL )
         {
-            M4OSA_chrCompare(xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
-                pSettings->xVSS.pBGMtrack->pFile, (M4OSA_Int32 *) &pCmpResult);
+            pCmpResult = strcmp((const char *)xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
+                (const char *)pSettings->xVSS.pBGMtrack->pFile);
 
             if( pCmpResult == 0 )
             {
@@ -662,8 +644,7 @@
                     /* We need to unallocate PCM preview file path in internal context */
                     if( xVSS_context->pcmPreviewFile != M4OSA_NULL )
                     {
-                        M4OSA_free(
-                            (M4OSA_MemAddr32)xVSS_context->pcmPreviewFile);
+                        free(xVSS_context->pcmPreviewFile);
                         xVSS_context->pcmPreviewFile = M4OSA_NULL;
                     }
                 }
@@ -673,7 +654,7 @@
                 /* We need to unallocate PCM preview file path in internal context */
                 if( xVSS_context->pcmPreviewFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pcmPreviewFile);
+                    free(xVSS_context->pcmPreviewFile);
                     xVSS_context->pcmPreviewFile = M4OSA_NULL;
                 }
             }
@@ -703,15 +684,15 @@
                 {
                     if( pParams->pFileIn != M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams->pFileIn);
+                        free(pParams->pFileIn);
                         pParams->pFileIn = M4OSA_NULL;
                     }
 
                     if( pParams->pFileOut != M4OSA_NULL )
                     {
                         /* Delete temporary file */
-                        M4OSA_fileExtraDelete(pParams->pFileOut);
-                        M4OSA_free((M4OSA_MemAddr32)pParams->pFileOut);
+                        remove((const char *)pParams->pFileOut);
+                        free(pParams->pFileOut);
                         pParams->pFileOut = M4OSA_NULL;
                     }
 
@@ -720,8 +701,8 @@
                         /* Delete temporary file */
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
 
-                        M4OSA_fileExtraDelete(pParams->pFileTemp);
-                        M4OSA_free((M4OSA_MemAddr32)pParams->pFileTemp);
+                        remove((const char *)pParams->pFileTemp);
+                        free(pParams->pFileTemp);
 
 #endif /*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
 
@@ -729,7 +710,7 @@
                     }
                     pParams_sauv = pParams;
                     pParams = pParams->pNext;
-                    M4OSA_free((M4OSA_MemAddr32)pParams_sauv);
+                    free(pParams_sauv);
                     pParams_sauv = M4OSA_NULL;
                 }
                 xVSS_context->pPTo3GPPparamsList = M4OSA_NULL;
@@ -748,15 +729,15 @@
                     {
                         if( pParams->pFileIn != M4OSA_NULL )
                         {
-                            M4OSA_free((M4OSA_MemAddr32)pParams->pFileIn);
+                            free(pParams->pFileIn);
                             pParams->pFileIn = M4OSA_NULL;
                         }
 
                         if( pParams->pFileOut != M4OSA_NULL )
                         {
                             /* Delete temporary file */
-                            M4OSA_fileExtraDelete(pParams->pFileOut);
-                            M4OSA_free((M4OSA_MemAddr32)pParams->pFileOut);
+                            remove((const char *)pParams->pFileOut);
+                            free(pParams->pFileOut);
                             pParams->pFileOut = M4OSA_NULL;
                         }
 
@@ -765,8 +746,8 @@
                             /* Delete temporary file */
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
 
-                            M4OSA_fileExtraDelete(pParams->pFileTemp);
-                            M4OSA_free((M4OSA_MemAddr32)pParams->pFileTemp);
+                            remove((const char *)pParams->pFileTemp);
+                            free(pParams->pFileTemp);
 
 #endif /*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
 
@@ -774,7 +755,7 @@
                         }
                         pParams_sauv = pParams;
                         pParams = pParams->pNext;
-                        M4OSA_free((M4OSA_MemAddr32)pParams_sauv);
+                        free(pParams_sauv);
                         pParams_sauv = M4OSA_NULL;
                     }
                     else
@@ -802,7 +783,7 @@
         /*Unallocate output file path*/
         if( xVSS_context->pSettings->pOutputFile != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->pOutputFile);
+            free(xVSS_context->pSettings->pOutputFile);
             xVSS_context->pSettings->pOutputFile = M4OSA_NULL;
         }
         xVSS_context->pSettings->uiOutputPathSize = 0;
@@ -860,7 +841,7 @@
             pSettings->uiOutputPathSize = length;
         }
 
-        xVSS_context->pSettings->pOutputFile = (M4OSA_Void *)M4OSA_malloc \
+        xVSS_context->pSettings->pOutputFile = (M4OSA_Void *)M4OSA_32bitAlignedMalloc \
             (pSettings->uiOutputPathSize + 1, M4VS,
             (M4OSA_Char *)"output file path");
 
@@ -873,8 +854,8 @@
             /**/
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->pOutputFile,
-            (M4OSA_MemAddr8)pDecodedPath, pSettings->uiOutputPathSize + 1);
+        memcpy((void *)xVSS_context->pSettings->pOutputFile,
+            (void *)pDecodedPath, pSettings->uiOutputPathSize + 1);
         xVSS_context->pSettings->uiOutputPathSize = pSettings->uiOutputPathSize;
         xVSS_context->pOutputFile = xVSS_context->pSettings->pOutputFile;
     }
@@ -1056,19 +1037,18 @@
     {
         if( xVSS_context->pSettings->pClipList != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pSettings->pClipList));
+            free((xVSS_context->pSettings->pClipList));
             xVSS_context->pSettings->pClipList = M4OSA_NULL;
         }
 
         if( xVSS_context->pSettings->pTransitionList != M4OSA_NULL )
         {
-            M4OSA_free(
-                (M4OSA_MemAddr32)(xVSS_context->pSettings->pTransitionList));
+            free(xVSS_context->pSettings->pTransitionList);
             xVSS_context->pSettings->pTransitionList = M4OSA_NULL;
         }
 
         xVSS_context->pSettings->pClipList =
-            (M4VSS3GPP_ClipSettings ** )M4OSA_malloc \
+            (M4VSS3GPP_ClipSettings ** )M4OSA_32bitAlignedMalloc \
             (sizeof(M4VSS3GPP_ClipSettings *)*xVSS_context->pSettings->uiClipNumber,
             M4VS, (M4OSA_Char *)"xVSS, copy of pClipList");
 
@@ -1082,15 +1062,15 @@
             return M4ERR_ALLOC;
         }
         /* Set clip list to NULL */
-        M4OSA_memset((M4OSA_MemAddr8)xVSS_context->pSettings->pClipList,
+        memset((void *)xVSS_context->pSettings->pClipList,0,
             sizeof(M4VSS3GPP_ClipSettings *)
-            *xVSS_context->pSettings->uiClipNumber, 0);
+            *xVSS_context->pSettings->uiClipNumber);
 
         if( xVSS_context->pSettings->uiClipNumber > 1 )
         {
             xVSS_context->pSettings->pTransitionList =
                 (M4VSS3GPP_TransitionSettings ** ) \
-                M4OSA_malloc(sizeof(M4VSS3GPP_TransitionSettings *)                \
+                M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_TransitionSettings *)                \
                 *(xVSS_context->pSettings->uiClipNumber - 1), M4VS, (M4OSA_Char *) \
                 "xVSS, copy of pTransitionList");
 
@@ -1104,10 +1084,10 @@
                 return M4ERR_ALLOC;
             }
             /* Set transition list to NULL */
-            M4OSA_memset(
-                (M4OSA_MemAddr8)xVSS_context->pSettings->pTransitionList,
+            memset(
+                (void *)xVSS_context->pSettings->pTransitionList,0,
                 sizeof(M4VSS3GPP_TransitionSettings *)
-                *(xVSS_context->pSettings->uiClipNumber - 1), 0);
+                *(xVSS_context->pSettings->uiClipNumber - 1));
         }
         else
         {
@@ -1131,7 +1111,7 @@
     if( 0 < xVSS_context->pSettings->nbEffects )
     {
         xVSS_context->pSettings->Effects =
-            (M4VSS3GPP_EffectSettings *)M4OSA_malloc \
+            (M4VSS3GPP_EffectSettings *)M4OSA_32bitAlignedMalloc \
             (xVSS_context->pSettings->nbEffects * sizeof(M4VSS3GPP_EffectSettings),
             M4VS, (M4OSA_Char *)"effects settings");
 
@@ -1184,7 +1164,7 @@
     {
         /* Allocate current clip */
         xVSS_context->pSettings->pClipList[i] =
-            (M4VSS3GPP_ClipSettings *)M4OSA_malloc \
+            (M4VSS3GPP_ClipSettings *)M4OSA_32bitAlignedMalloc \
             (sizeof(M4VSS3GPP_ClipSettings), M4VS, (M4OSA_Char *)"clip settings");
 
         if( xVSS_context->pSettings->pClipList[i] == M4OSA_NULL )
@@ -1219,7 +1199,7 @@
         {
             xVSS_context->pSettings->pTransitionList[i] =
                 (M4VSS3GPP_TransitionSettings
-                *)M4OSA_malloc(sizeof(M4VSS3GPP_TransitionSettings),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_TransitionSettings),
                 M4VS, (M4OSA_Char *)"transition settings");
 
             if( xVSS_context->pSettings->pTransitionList[i] == M4OSA_NULL )
@@ -1232,9 +1212,9 @@
                 return M4ERR_ALLOC;
             }
 
-            M4OSA_memcpy(
-                (M4OSA_MemAddr8)xVSS_context->pSettings->pTransitionList[i],
-                (M4OSA_MemAddr8)pSettings->pTransitionList[i],
+            memcpy(
+                (void *)xVSS_context->pSettings->pTransitionList[i],
+                (void *)pSettings->pTransitionList[i],
                 sizeof(M4VSS3GPP_TransitionSettings));
             /* Initialize external effect context to NULL, to know if input jpg has already been
             decoded or not */
@@ -1250,7 +1230,7 @@
                     provided one */
                     xVSS_context->pSettings->pTransitionList[i]->      \
                      xVSS.transitionSpecific.pAlphaMagicSettings =
-                        (M4xVSS_AlphaMagicSettings *)M4OSA_malloc \
+                        (M4xVSS_AlphaMagicSettings *)M4OSA_32bitAlignedMalloc \
                         (sizeof(M4xVSS_AlphaMagicSettings), M4VS,
                         (M4OSA_Char *)"Input Alpha magic settings structure");
 
@@ -1267,18 +1247,18 @@
                     }
                     /* Copy data from the provided alpha magic settings structure tou our
                     structure */
-                    M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->
+                    memcpy((void *)xVSS_context->pSettings->
                         pTransitionList[i]-> \
                         xVSS.transitionSpecific.pAlphaMagicSettings,
-                        (M4OSA_MemAddr8)pSettings->pTransitionList[i]-> \
+                        (void *)pSettings->pTransitionList[i]-> \
                         xVSS.transitionSpecific.pAlphaMagicSettings,
                         sizeof(M4xVSS_AlphaMagicSettings));
 
                     /* Allocate our alpha magic input filename */
                     xVSS_context->pSettings->pTransitionList[i]-> \
                         xVSS.transitionSpecific.pAlphaMagicSettings->
-                        pAlphaFilePath = M4OSA_malloc(
-                        (M4OSA_chrLength(pSettings->pTransitionList[i]-> \
+                        pAlphaFilePath = M4OSA_32bitAlignedMalloc(
+                        (strlen(pSettings->pTransitionList[i]-> \
                         xVSS.transitionSpecific.pAlphaMagicSettings->pAlphaFilePath)
                         + 1), M4VS, (M4OSA_Char *)"Alpha magic file path");
 
@@ -1301,7 +1281,7 @@
                         pAlphaFilePath,
                         pSettings->pTransitionList[i]->xVSS.
                         transitionSpecific.pAlphaMagicSettings->
-                        pAlphaFilePath, M4OSA_chrLength(
+                        pAlphaFilePath, strlen(
                         pSettings->pTransitionList[i]->xVSS.
                         transitionSpecific.pAlphaMagicSettings->
                         pAlphaFilePath) + 1);
@@ -1314,14 +1294,13 @@
                             == M4xVSS_kVideoTransitionType_AlphaMagic )
                         {
                             M4OSA_UInt32 pCmpResult = 0;
-                            M4OSA_chrCompare(xVSS_context->pSettings->
+                            pCmpResult = strcmp((const char *)xVSS_context->pSettings->
                                 pTransitionList[i]->xVSS.
                                 transitionSpecific.pAlphaMagicSettings->
-                                pAlphaFilePath, xVSS_context->pSettings->
+                                pAlphaFilePath, (const char *)xVSS_context->pSettings->
                                 pTransitionList[j]->xVSS.
                                 transitionSpecific.
-                                pAlphaMagicSettings->pAlphaFilePath,
-                                (M4OSA_Int32 *) &pCmpResult);
+                                pAlphaMagicSettings->pAlphaFilePath);
 
                             if( pCmpResult == 0 )
                             {
@@ -1330,7 +1309,7 @@
 
                                 alphaSettings =
                                     (M4xVSS_internal_AlphaMagicSettings
-                                    *)M4OSA_malloc(
+                                    *)M4OSA_32bitAlignedMalloc(
                                     sizeof(
                                     M4xVSS_internal_AlphaMagicSettings),
                                     M4VS,
@@ -1428,7 +1407,7 @@
                             " TransitionListM4xVSS_SendCommand height! State is %d",
                             height_ARGB888);
                         /* Allocate output plane */
-                        outputPlane = (M4VIFI_ImagePlane *)M4OSA_malloc(3
+                        outputPlane = (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(3
                             * sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char
                             *)
                             "Output plane for Alpha magic transition");
@@ -1449,7 +1428,7 @@
                         outputPlane[0].u_topleft = 0;
                         outputPlane[0].u_stride = width;
                         outputPlane[0].pac_data = (M4VIFI_UInt8
-                            *)M4OSA_malloc(( width * height * 3)
+                            *)M4OSA_32bitAlignedMalloc(( width * height * 3)
                             >> 1,
                             M4VS,
                             (M4OSA_Char
@@ -1459,7 +1438,7 @@
 
                         if( outputPlane[0].pac_data == M4OSA_NULL )
                         {
-                            M4OSA_free((M4OSA_MemAddr32)outputPlane);
+                            free(outputPlane);
                             outputPlane = M4OSA_NULL;
                             M4OSA_TRACE1_0(
                                 "Allocation error in M4xVSS_SendCommand");
@@ -1526,10 +1505,9 @@
 
                         if( err != M4NO_ERROR )
                         {
-                            M4OSA_free(
-                                (M4OSA_MemAddr32)outputPlane[0].pac_data);
+                            free(outputPlane[0].pac_data);
                             outputPlane[0].pac_data = M4OSA_NULL;
-                            M4OSA_free((M4OSA_MemAddr32)outputPlane);
+                            free(outputPlane);
                             outputPlane = M4OSA_NULL;
                             M4xVSS_freeCommand(xVSS_context);
                             M4OSA_TRACE1_1(
@@ -1540,7 +1518,7 @@
 
                         /* Allocate alpha settings structure */
                         alphaSettings =
-                            (M4xVSS_internal_AlphaMagicSettings *)M4OSA_malloc(
+                            (M4xVSS_internal_AlphaMagicSettings *)M4OSA_32bitAlignedMalloc(
                             sizeof(M4xVSS_internal_AlphaMagicSettings),
                             M4VS, (M4OSA_Char
                             *)"Alpha magic settings structure 2");
@@ -1600,7 +1578,7 @@
                     {
                         M4xVSS_internal_SlideTransitionSettings *slideSettings;
                         slideSettings =
-                            (M4xVSS_internal_SlideTransitionSettings *)M4OSA_malloc(
+                            (M4xVSS_internal_SlideTransitionSettings *)M4OSA_32bitAlignedMalloc(
                             sizeof(M4xVSS_internal_SlideTransitionSettings),
                             M4VS, (M4OSA_Char
                             *)"Internal slide transition settings");
@@ -1664,483 +1642,6 @@
                 pTransitionList[i]->uiTransitionDuration;
         }
 
-        /************************
-        JPG input file type case
-        *************************/
-#if 0
-
-        if( xVSS_context->pSettings->pClipList[i]->FileType
-            == M4VIDEOEDITING_kFileType_JPG )
-        {
-            M4OSA_Char out_img[64];
-            M4OSA_Char out_img_tmp[64];
-            M4xVSS_Pto3GPP_params *pParams;
-            M4OSA_Context pJPEGFileIn;
-            /*UTF conversion support*/
-            M4OSA_Void *pDecodedPath = pSettings->pClipList[i]->pFile;
-
-            /* Parse Pto3GPP params chained list to know if input file has already been
-            converted */
-            if( xVSS_context->pPTo3GPPparamsList != M4OSA_NULL )
-            {
-                M4OSA_UInt32 pCmpResult = 0;
-
-                pParams = xVSS_context->pPTo3GPPparamsList;
-                /* We parse all Pto3gpp Param chained list */
-                while( pParams != M4OSA_NULL )
-                {
-                    M4OSA_chrCompare(pSettings->pClipList[i]->pFile,
-                        pParams->pFileIn, (M4OSA_Int32 *) &pCmpResult);
-
-                    if( pCmpResult == 0
-                        && (pSettings->pClipList[i]->uiEndCutTime
-                        == pParams->duration
-                        || pSettings->pClipList[i]->xVSS.uiDuration
-                        == pParams->duration)
-                        && pSettings->pClipList[i]->xVSS.MediaRendering
-                        == pParams->MediaRendering )
-                    {
-                        /* Replace JPG filename with existing 3GP filename */
-                        goto replaceJPG_3GP;
-                    }
-                    /* We need to update this variable, in case some pictures have been added
-                     between two */
-                    /* calls to M4xVSS_sendCommand */
-                    pPto3GPP_last = pParams;
-                    pParams = pParams->pNext;
-                }
-            }
-
-            /* Construct output temporary 3GP filename */
-            err = M4OSA_chrSPrintf(out_img, 63, (M4OSA_Char *)"%simg%d.3gp",
-                xVSS_context->pTempPath, xVSS_context->tempFileIndex);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_1("Error in M4OSA_chrSPrintf: 0x%x", err);
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return err;
-            }
-
-#ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
-
-            err = M4OSA_chrSPrintf(out_img_tmp, 63, "%simg%d.tmp",
-                xVSS_context->pTempPath, xVSS_context->tempFileIndex);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_1("Error in M4OSA_chrSPrintf: 0x%x", err);
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return err;
-            }
-
-#endif /*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
-
-            xVSS_context->tempFileIndex++;
-
-            /* Allocate last element Pto3GPP params structure */
-            pParams = (M4xVSS_Pto3GPP_params
-                *)M4OSA_malloc(sizeof(M4xVSS_Pto3GPP_params),
-                M4VS, (M4OSA_Char *)"Element of Pto3GPP Params");
-
-            if( pParams == M4OSA_NULL )
-            {
-                M4OSA_TRACE1_0(
-                    "M4xVSS_sendCommand: Problem when allocating one element Pto3GPP Params");
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return M4ERR_ALLOC;
-            }
-
-            /* Initializes pfilexxx members of pParams to be able to free them correctly */
-            pParams->pFileIn = M4OSA_NULL;
-            pParams->pFileOut = M4OSA_NULL;
-            pParams->pFileTemp = M4OSA_NULL;
-            pParams->pNext = M4OSA_NULL;
-            pParams->MediaRendering = M4xVSS_kResizing;
-
-            if( xVSS_context->pPTo3GPPparamsList
-                == M4OSA_NULL ) /* Means it is the first element of the list */
-            {
-                /* Initialize the xVSS context with the first element of the list */
-                xVSS_context->pPTo3GPPparamsList = pParams;
-
-                /* Save this element in case of other file to convert */
-                pPto3GPP_last = pParams;
-            }
-            else
-            {
-                /* Update next pointer of the previous last element of the chain */
-                pPto3GPP_last->pNext = pParams;
-
-                /* Update save of last element of the chain */
-                pPto3GPP_last = pParams;
-            }
-
-            /* Fill the last M4xVSS_Pto3GPP_params element */
-            pParams->duration =
-                xVSS_context->pSettings->pClipList[i]->uiEndCutTime;
-            /* If duration is filled, let's use it instead of EndCutTime */
-            if( xVSS_context->pSettings->pClipList[i]->xVSS.uiDuration != 0 )
-            {
-                pParams->duration =
-                    xVSS_context->pSettings->pClipList[i]->xVSS.uiDuration;
-            }
-
-            pParams->InputFileType = M4VIDEOEDITING_kFileType_JPG;
-
-            /**
-            * UTF conversion: convert into the customer format, before being used*/
-            pDecodedPath = xVSS_context->pSettings->pClipList[i]->pFile;
-            length = M4OSA_chrLength(pDecodedPath);
-
-            /**
-            * UTF conversion: convert into the customer format, before being used*/
-            if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
-                != M4OSA_NULL && xVSS_context->
-                UTFConversionContext.pTempOutConversionBuffer
-                != M4OSA_NULL )
-            {
-                err = M4xVSS_internalConvertFromUTF8(xVSS_context, (M4OSA_Void
-                    *)xVSS_context->pSettings->pClipList[i]->pFile,
-                    (M4OSA_Void *)xVSS_context->
-                    UTFConversionContext.pTempOutConversionBuffer,
-                    &length);
-
-                if( err != M4NO_ERROR )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4xVSS_SendCommand: pConvFromUTF8Fct returns err: 0x%x",
-                        err);
-                    /* Free Send command */
-                    M4xVSS_freeCommand(xVSS_context);
-                    return err;
-                }
-                pDecodedPath =
-                    xVSS_context->UTFConversionContext.pTempOutConversionBuffer;
-            }
-
-            /**
-            * End of the UTF conversion, use the converted file path*/
-            pParams->pFileIn = (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS,
-                (M4OSA_Char *)"Pto3GPP Params: file in");
-
-            if( pParams->pFileIn == M4OSA_NULL )
-            {
-                M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return M4ERR_ALLOC;
-            }
-            M4OSA_memcpy(pParams->pFileIn, pDecodedPath,
-                (length + 1)); /* Copy input file path */
-
-            /* Check that JPG file is present on the FS (P4ME00002974) by just opening and
-            closing it */
-            err =
-                xVSS_context->pFileReadPtr->openRead(&pJPEGFileIn, pDecodedPath,
-                M4OSA_kFileRead);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't open input jpg file %s, error: 0x%x\n",
-                    pDecodedPath, err);
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                return err;
-            }
-            err = xVSS_context->pFileReadPtr->closeRead(pJPEGFileIn);
-
-            if( err != M4NO_ERROR )
-            {
-                M4OSA_TRACE1_2("Can't close input jpg file %s, error: 0x%x\n",
-                    pDecodedPath, err);
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                return err;
-            }
-
-            /**
-            * UTF conversion: convert into the customer format, before being used*/
-            pDecodedPath = out_img;
-            length = M4OSA_chrLength(pDecodedPath);
-
-            if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
-                != M4OSA_NULL && xVSS_context->
-                UTFConversionContext.pTempOutConversionBuffer
-                != M4OSA_NULL )
-            {
-                err = M4xVSS_internalConvertFromUTF8(xVSS_context,
-                    (M4OSA_Void *)out_img, (M4OSA_Void *)xVSS_context->
-                    UTFConversionContext.pTempOutConversionBuffer, &length);
-
-                if( err != M4NO_ERROR )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4xVSS_SendCommand: pConvFromUTF8Fct returns err: 0x%x",
-                        err);
-                    /* Free Send command */
-                    M4xVSS_freeCommand(xVSS_context);
-                    return err;
-                }
-                pDecodedPath =
-                    xVSS_context->UTFConversionContext.pTempOutConversionBuffer;
-            }
-
-            /**
-            * End of the UTF conversion, use the converted file path*/
-            pParams->pFileOut = (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
-                (M4OSA_Char *)"Pto3GPP Params: file out");
-
-            if( pParams->pFileOut == M4OSA_NULL )
-            {
-                M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return M4ERR_ALLOC;
-            }
-            M4OSA_memcpy(pParams->pFileOut, pDecodedPath,
-                (length + 1)); /* Copy output file path */
-
-#ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
-            /**
-            * UTF conversion: convert into the customer format, before being used*/
-
-            pDecodedPath = out_img_tmp;
-            length = M4OSA_chrLength(pDecodedPath);
-
-            if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
-                != M4OSA_NULL && xVSS_context->
-                UTFConversionContext.pTempOutConversionBuffer
-                != M4OSA_NULL )
-            {
-                err = M4xVSS_internalConvertFromUTF8(xVSS_context,
-                    (M4OSA_Void *)out_img_tmp, (M4OSA_Void *)xVSS_context->
-                    UTFConversionContext.pTempOutConversionBuffer, &length);
-
-                if( err != M4NO_ERROR )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4xVSS_SendCommand: M4xVSS_internalConvertFromUTF8 returns err: 0x%x",
-                        err);
-                    /* Free Send command */
-                    M4xVSS_freeCommand(xVSS_context);
-                    return err;
-                }
-                pDecodedPath =
-                    xVSS_context->UTFConversionContext.pTempOutConversionBuffer;
-            }
-
-            /**
-            * End of the UTF conversion, use the converted file path*/
-            pParams->pFileTemp = (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
-                (M4OSA_Char *)"Pto3GPP Params: file temp");
-
-            if( pParams->pFileTemp == M4OSA_NULL )
-            {
-                M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return M4ERR_ALLOC;
-            }
-            M4OSA_memcpy(pParams->pFileTemp, pDecodedPath,
-                (length + 1)); /* Copy temporary file path */
-
-#endif                         /*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
-
-            /* Fill PanAndZoom settings if needed */
-
-            if( M4OSA_TRUE
-                == xVSS_context->pSettings->pClipList[i]->xVSS.isPanZoom )
-            {
-                pParams->isPanZoom =
-                    xVSS_context->pSettings->pClipList[i]->xVSS.isPanZoom;
-                /* Check that Pan & Zoom parameters are corrects */
-                if( xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXa > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXa
-                    <= 0 || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftXa > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftXa < 0
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftYa > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftYa < 0
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXb
-                    > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXb
-                    <= 0 || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftXb > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftXb < 0
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftYb > 1000
-                    || xVSS_context->pSettings->pClipList[i]->xVSS.
-                    PanZoomTopleftYb < 0 )
-                {
-                    M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-                    M4xVSS_freeCommand(xVSS_context);
-                    return M4ERR_PARAMETER;
-                }
-
-                pParams->PanZoomXa =
-                    xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXa;
-                pParams->PanZoomTopleftXa =
-                    xVSS_context->pSettings->
-                    pClipList[i]->xVSS.PanZoomTopleftXa;
-                pParams->PanZoomTopleftYa =
-                    xVSS_context->pSettings->
-                    pClipList[i]->xVSS.PanZoomTopleftYa;
-                pParams->PanZoomXb =
-                    xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXb;
-                pParams->PanZoomTopleftXb =
-                    xVSS_context->pSettings->
-                    pClipList[i]->xVSS.PanZoomTopleftXb;
-                pParams->PanZoomTopleftYb =
-                    xVSS_context->pSettings->
-                    pClipList[i]->xVSS.PanZoomTopleftYb;
-            }
-            else
-            {
-                pParams->isPanZoom = M4OSA_FALSE;
-            }
-            /*+ PR No: blrnxpsw#223*/
-            /*Intializing the Video Frame Rate as it may not be intialized*/
-            /*Other changes made is @ M4xVSS_Internal.c @ line 1518 in
-            M4xVSS_internalStartConvertPictureTo3gp*/
-            switch( xVSS_context->pSettings->videoFrameRate )
-            {
-                case M4VIDEOEDITING_k30_FPS:
-                    pParams->framerate = 33;
-                    break;
-
-                case M4VIDEOEDITING_k25_FPS:
-                    pParams->framerate = 40;
-                    break;
-
-                case M4VIDEOEDITING_k20_FPS:
-                    pParams->framerate = 50;
-                    break;
-
-                case M4VIDEOEDITING_k15_FPS:
-                    pParams->framerate = 66;
-                    break;
-
-                case M4VIDEOEDITING_k12_5_FPS:
-                    pParams->framerate = 80;
-                    break;
-
-                case M4VIDEOEDITING_k10_FPS:
-                    pParams->framerate = 100;
-                    break;
-
-                case M4VIDEOEDITING_k7_5_FPS:
-                    pParams->framerate = 133;
-                    break;
-
-                case M4VIDEOEDITING_k5_FPS:
-                    pParams->framerate = 200;
-                    break;
-
-                default:
-                    /*Making Default Frame Rate @ 15 FPS*/
-                    pParams->framerate = 66;
-                    break;
-            }
-            /*-PR No: blrnxpsw#223*/
-            if( xVSS_context->pSettings->pClipList[i]->xVSS.MediaRendering
-                == M4xVSS_kCropping
-                || xVSS_context->pSettings->pClipList[i]->xVSS.
-                MediaRendering == M4xVSS_kBlackBorders
-                || xVSS_context->pSettings->pClipList[i]->xVSS.
-                MediaRendering == M4xVSS_kResizing )
-            {
-                pParams->MediaRendering =
-                    xVSS_context->pSettings->pClipList[i]->xVSS.MediaRendering;
-            }
-
-            pParams->pNext = M4OSA_NULL;
-            pParams->isCreated = M4OSA_FALSE;
-            xVSS_context->nbStepTotal++;
-
-replaceJPG_3GP:
-            /* Update total duration */
-            totalDuration += pParams->duration;
-
-            /* Replacing in VSS structure the JPG file by the 3gp file */
-            xVSS_context->pSettings->pClipList[i]->FileType =
-                M4VIDEOEDITING_kFileType_3GPP;
-
-            if( xVSS_context->pSettings->pClipList[i]->pFile != M4OSA_NULL )
-            {
-                M4OSA_free(xVSS_context->pSettings->pClipList[i]->pFile);
-                xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_NULL;
-            }
-
-            /**
-            * UTF conversion: convert into UTF8, before being used*/
-            pDecodedPath = pParams->pFileOut;
-
-            if( xVSS_context->UTFConversionContext.pConvToUTF8Fct != M4OSA_NULL
-                && xVSS_context->UTFConversionContext.pTempOutConversionBuffer
-                != M4OSA_NULL )
-            {
-                err = M4xVSS_internalConvertToUTF8(xVSS_context,
-                    (M4OSA_Void *)pParams->pFileOut,
-                    (M4OSA_Void *)xVSS_context->
-                    UTFConversionContext.pTempOutConversionBuffer,
-                    &length);
-
-                if( err != M4NO_ERROR )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4xVSS_SendCommand: M4xVSS_internalConvertToUTF8 returns err: 0x%x",
-                        err);
-                    /* Free Send command */
-                    M4xVSS_freeCommand(xVSS_context);
-                    return err;
-                }
-                pDecodedPath =
-                    xVSS_context->UTFConversionContext.pTempOutConversionBuffer;
-            }
-            else
-            {
-                length = M4OSA_chrLength(pDecodedPath);
-            }
-            /**
-            * End of the UTF conversion, use the converted file path*/
-            xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_malloc((length
-                + 1), M4VS, (M4OSA_Char *)"xVSS file path of jpg to 3gp");
-
-            if( xVSS_context->pSettings->pClipList[i]->pFile == M4OSA_NULL )
-            {
-                M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-                /*FB: to avoid leaks when there is an error in the send command*/
-                /* Free Send command */
-                M4xVSS_freeCommand(xVSS_context);
-                /**/
-                return M4ERR_ALLOC;
-            }
-            M4OSA_memcpy(xVSS_context->pSettings->pClipList[i]->pFile,
-                pDecodedPath, (length + 1));
-            /*FB: add file path size because of UTF16 conversion*/
-            xVSS_context->pSettings->pClipList[i]->filePathSize = length+1;
-        }
-#endif
 
         if( xVSS_context->pSettings->pClipList[i]->FileType
             == M4VIDEOEDITING_kFileType_ARGB8888 )
@@ -2162,8 +1663,8 @@
                 /* We parse all Pto3gpp Param chained list */
                 while( pParams != M4OSA_NULL )
                 {
-                    M4OSA_chrCompare(pSettings->pClipList[i]->pFile,
-                        pParams->pFileIn, (M4OSA_Int32 *)&pCmpResult);
+                    pCmpResult = strcmp((const char *)pSettings->pClipList[i]->pFile,
+                        (const char *)pParams->pFileIn);
 
                     if( pCmpResult == 0
                         && (pSettings->pClipList[i]->uiEndCutTime
@@ -2222,7 +1723,7 @@
 
             /* Allocate last element Pto3GPP params structure */
             pParams = (M4xVSS_Pto3GPP_params
-                *)M4OSA_malloc(sizeof(M4xVSS_Pto3GPP_params),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_Pto3GPP_params),
                 M4VS, (M4OSA_Char *)"Element of Pto3GPP Params");
 
             if( pParams == M4OSA_NULL )
@@ -2284,7 +1785,7 @@
                     /**
                     * UTF conversion: convert into the customer format, before being used*/
                     pDecodedPath = xVSS_context->pSettings->pClipList[i]->pFile;
-                    length = M4OSA_chrLength(pDecodedPath);
+                    length = strlen(pDecodedPath);
 
                     /**
                     * UTF conversion: convert into the customer format, before being used*/
@@ -2314,7 +1815,7 @@
 
                     /**
                     * End of the UTF conversion, use the converted file path*/
-                    pParams->pFileIn = (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS,
+                    pParams->pFileIn = (M4OSA_Void *)M4OSA_32bitAlignedMalloc(length + 1, M4VS,
                         (M4OSA_Char *)"Pto3GPP Params: file in");
 
                     if( pParams->pFileIn == M4OSA_NULL )
@@ -2326,7 +1827,7 @@
                         /**/
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy(pParams->pFileIn, pDecodedPath,
+                    memcpy((void *)pParams->pFileIn, (void *)pDecodedPath,
                         (length + 1)); /* Copy input file path */
 
                     /* Check that JPG file is present on the FS (P4ME00002974) by just opening
@@ -2357,7 +1858,7 @@
                     /**
                     * UTF conversion: convert into the customer format, before being used*/
                     pDecodedPath = out_img;
-                    length = M4OSA_chrLength(pDecodedPath);
+                    length = strlen(pDecodedPath);
 
                     if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                         != M4OSA_NULL && xVSS_context->
@@ -2383,7 +1884,7 @@
 
                     /**
                     * End of the UTF conversion, use the converted file path*/
-                    pParams->pFileOut = (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+                    pParams->pFileOut = (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
                         (M4OSA_Char *)"Pto3GPP Params: file out");
 
                     if( pParams->pFileOut == M4OSA_NULL )
@@ -2395,7 +1896,7 @@
                         /**/
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy(pParams->pFileOut, pDecodedPath,
+                    memcpy((void *)pParams->pFileOut, (void *)pDecodedPath,
                         (length + 1)); /* Copy output file path */
 
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
@@ -2403,7 +1904,7 @@
                     * UTF conversion: convert into the customer format, before being used*/
 
                     pDecodedPath = out_img_tmp;
-                    length = M4OSA_chrLength(pDecodedPath);
+                    length = strlen(pDecodedPath);
 
                     if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                         != M4OSA_NULL && xVSS_context->
@@ -2429,7 +1930,7 @@
 
                     /**
                     * End of the UTF conversion, use the converted file path*/
-                    pParams->pFileTemp = (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+                    pParams->pFileTemp = (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
                         (M4OSA_Char *)"Pto3GPP Params: file temp");
 
                     if( pParams->pFileTemp == M4OSA_NULL )
@@ -2441,7 +1942,7 @@
                         /**/
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy(pParams->pFileTemp, pDecodedPath,
+                    memcpy((void *)pParams->pFileTemp, (void *)pDecodedPath,
                         (length + 1)); /* Copy temporary file path */
 
 #endif                         /*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
@@ -2459,22 +1960,14 @@
                             <= 0 || xVSS_context->pSettings->pClipList[i]->xVSS.
                             PanZoomTopleftXa > 1000
                             || xVSS_context->pSettings->pClipList[i]->xVSS.
-                            PanZoomTopleftXa < 0
-                            || xVSS_context->pSettings->pClipList[i]->xVSS.
                             PanZoomTopleftYa > 1000
-                            || xVSS_context->pSettings->pClipList[i]->xVSS.
-                            PanZoomTopleftYa < 0
                             || xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXb
                             > 1000
                             || xVSS_context->pSettings->pClipList[i]->xVSS.PanZoomXb
                             <= 0 || xVSS_context->pSettings->pClipList[i]->xVSS.
                             PanZoomTopleftXb > 1000
                             || xVSS_context->pSettings->pClipList[i]->xVSS.
-                            PanZoomTopleftXb < 0
-                            || xVSS_context->pSettings->pClipList[i]->xVSS.
-                            PanZoomTopleftYb > 1000
-                            || xVSS_context->pSettings->pClipList[i]->xVSS.
-                            PanZoomTopleftYb < 0 )
+                            PanZoomTopleftYb > 1000)
                         {
                             M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
                             M4xVSS_freeCommand(xVSS_context);
@@ -2571,7 +2064,7 @@
 
                     if( xVSS_context->pSettings->pClipList[i]->pFile != M4OSA_NULL )
                     {
-                        M4OSA_free(xVSS_context->pSettings->pClipList[i]->pFile);
+                        free(xVSS_context->pSettings->pClipList[i]->pFile);
                         xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_NULL;
                     }
 
@@ -2603,11 +2096,11 @@
                     }
                     else
                     {
-                        length = M4OSA_chrLength(pDecodedPath);
+                        length = strlen(pDecodedPath);
                     }
                     /**
                     * End of the UTF conversion, use the converted file path*/
-                    xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_malloc((length
+                    xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_32bitAlignedMalloc((length
                         + 1), M4VS, (M4OSA_Char *)"xVSS file path of ARGB to 3gp");
 
                     if( xVSS_context->pSettings->pClipList[i]->pFile == M4OSA_NULL )
@@ -2619,8 +2112,8 @@
                         /**/
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy(xVSS_context->pSettings->pClipList[i]->pFile,
-                        pDecodedPath, (length + 1));
+                    memcpy((void *)xVSS_context->pSettings->pClipList[i]->pFile,
+                        (void *)pDecodedPath, (length + 1));
                     /*FB: add file path size because of UTF16 conversion*/
                     xVSS_context->pSettings->pClipList[i]->filePathSize = length+1;
         }
@@ -2647,16 +2140,10 @@
             M4OSA_Bool audioIsDifferent = M4OSA_FALSE;
             M4OSA_Bool videoIsDifferent = M4OSA_FALSE;
             M4OSA_Bool bAudioMono;
-#ifdef TIMESCALE_BUG
-
-            M4OSA_Bool timescaleDifferent = M4OSA_FALSE;
-
-#endif
-
             /* Initialize file properties structure */
 
-            M4OSA_memset((M4OSA_MemAddr8) &fileProperties,
-                sizeof(M4VIDEOEDITING_ClipProperties), 0);
+            memset((void *) &fileProperties,0,
+                sizeof(M4VIDEOEDITING_ClipProperties));
 
             //fileProperties.AudioStreamType = M4VIDEOEDITING_kNoneAudio;
 
@@ -2754,8 +2241,8 @@
 
                     /**
                     * End of the UTF conversion, use the converted file path*/
-                    M4OSA_chrCompare(pSettings->pClipList[i]->pFile,
-                        pDecodedPath, (M4OSA_Int32 *) &pCmpResult);
+                    pCmpResult = strcmp((const char *)pSettings->pClipList[i]->pFile,
+                        (const char *)pDecodedPath);
 
                     /* If input filenames are the same, and if this is not a BGM, we can reuse
                     the transcoded file */
@@ -2891,16 +2378,6 @@
                     i);
             }
 
-#ifdef TIMESCALE_BUG
-            /* Check timescale */
-
-            if( fileProperties.VideoStreamType == M4VIDEOEDITING_kMPEG4 //&&
-                /* !!!!!!!!!!!! Add condition to update timescale !!!!!!!!!!!!!!!!!!!!!!!!! */ )
-            {
-                timescaleDifferent = M4OSA_TRUE;
-            }
-
-#endif
             /* If the output video format/size is not the same as provided video,
             let's transcode it */
 
@@ -2955,14 +2432,7 @@
                 }
             }
 
-            if( videoIsDifferent == M4OSA_TRUE || audioIsDifferent == M4OSA_TRUE
-#ifdef TIMESCALE_BUG
-
-                || timescaleDifferent == M4OSA_TRUE
-
-#endif
-
-                )
+            if( videoIsDifferent == M4OSA_TRUE || audioIsDifferent == M4OSA_TRUE)
             {
                 M4OSA_Char out_3gp[M4XVSS_MAX_PATH_LEN];
                 M4OSA_Char out_3gp_tmp[M4XVSS_MAX_PATH_LEN];
@@ -2993,7 +2463,7 @@
                 xVSS_context->tempFileIndex++;
 
                 pParams =
-                    (M4xVSS_MCS_params *)M4OSA_malloc(sizeof(M4xVSS_MCS_params),
+                    (M4xVSS_MCS_params *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_MCS_params),
                     M4VS, (M4OSA_Char *)"Element of MCS Params (for 3GP)");
 
                 if( pParams == M4OSA_NULL )
@@ -3027,25 +2497,6 @@
                 pParams->InputFileType = M4VIDEOEDITING_kFileType_3GPP;
                 pParams->OutputFileType = M4VIDEOEDITING_kFileType_3GPP;
 
-#ifdef TIMESCALE_BUG
-                /* Check if timescale only needs to be modified */
-
-                if( timescaleDifferent == M4OSA_TRUE
-                    && videoIsDifferent == M4OSA_FALSE )
-                {
-                    pParams->OutputVideoTimescale = 30;
-                    pParams->OutputVideoFormat = M4VIDEOEDITING_kNullVideo;
-                    pParams->OutputVideoFrameRate =
-                        M4VIDEOEDITING_k15_FPS; /* Must be set, otherwise,
-                                                    MCS returns an error ... */
-                }
-                else
-                {
-                    pParams->OutputVideoTimescale = 0;
-                }
-
-#endif
-
                 pParams->OutputVideoTimescale = xVSS_context->targetedTimescale;
 
                 /* We do not need to reencode video if its parameters do not differ */
@@ -3262,7 +2713,7 @@
                 /**
                 * UTF conversion: convert into the customer format, before being used*/
                 pDecodedPath = xVSS_context->pSettings->pClipList[i]->pFile;
-                length = M4OSA_chrLength(pDecodedPath);
+                length = strlen(pDecodedPath);
 
                 if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                     != M4OSA_NULL && xVSS_context->
@@ -3292,7 +2743,7 @@
                 /**
                 * End of the UTF conversion, use the converted file path*/
                 pParams->pFileIn =
-                    (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+                    (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
                     (M4OSA_Char *)"MCS 3GP Params: file in");
 
                 if( pParams->pFileIn == M4OSA_NULL )
@@ -3304,13 +2755,13 @@
                     /**/
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy(pParams->pFileIn, pDecodedPath,
+                memcpy((void *)pParams->pFileIn, (void *)pDecodedPath,
                     (length + 1)); /* Copy input file path */
 
                 /**
                 * UTF conversion: convert into the customer format, before being used*/
                 pDecodedPath = out_3gp;
-                length = M4OSA_chrLength(pDecodedPath);
+                length = strlen(pDecodedPath);
 
                 if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                     != M4OSA_NULL && xVSS_context->
@@ -3338,7 +2789,7 @@
                 /**
                 * End of the UTF conversion, use the converted file path*/
                 pParams->pFileOut =
-                    (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+                    (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
                     (M4OSA_Char *)"MCS 3GP Params: file out");
 
                 if( pParams->pFileOut == M4OSA_NULL )
@@ -3350,7 +2801,7 @@
                     /**/
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy(pParams->pFileOut, pDecodedPath,
+                memcpy((void *)pParams->pFileOut, (void *)pDecodedPath,
                     (length + 1)); /* Copy output file path */
 
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
@@ -3358,7 +2809,7 @@
                 * UTF conversion: convert into the customer format, before being used*/
 
                 pDecodedPath = out_3gp_tmp;
-                length = M4OSA_chrLength(pDecodedPath);
+                length = strlen(pDecodedPath);
 
                 if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                     != M4OSA_NULL && xVSS_context->
@@ -3387,7 +2838,7 @@
                 /**
                 * End of the UTF conversion, use the converted file path*/
                 pParams->pFileTemp =
-                    (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+                    (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
                     (M4OSA_Char *)"MCS 3GP Params: file temp");
 
                 if( pParams->pFileTemp == M4OSA_NULL )
@@ -3399,7 +2850,7 @@
                     /**/
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy(pParams->pFileTemp, pDecodedPath,
+                memcpy((void *)pParams->pFileTemp, (void *)pDecodedPath,
                     (length + 1)); /* Copy temporary file path */
 
 #else
@@ -3451,7 +2902,7 @@
 
                 if( xVSS_context->pSettings->pClipList[i]->pFile != M4OSA_NULL )
                 {
-                    M4OSA_free(xVSS_context->pSettings->pClipList[i]->pFile);
+                    free(xVSS_context->pSettings->pClipList[i]->pFile);
                     xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_NULL;
                 }
 
@@ -3484,11 +2935,11 @@
                 }
                 else
                 {
-                    length = M4OSA_chrLength(pDecodedPath);
+                    length = strlen(pDecodedPath);
                 }
                 /**
                 * End of the UTF conversion, use the converted file path*/
-                xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_malloc(
+                xVSS_context->pSettings->pClipList[i]->pFile = M4OSA_32bitAlignedMalloc(
                     (length + 1),
                     M4VS, (M4OSA_Char *)"xVSS file path of 3gp to 3gp");
 
@@ -3501,8 +2952,8 @@
                     /**/
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy(xVSS_context->pSettings->pClipList[i]->pFile,
-                    pDecodedPath, (length + 1));
+                memcpy((void *)xVSS_context->pSettings->pClipList[i]->pFile,
+                    (void *)pDecodedPath, (length + 1));
                 /*FB: add file path size because of UTF 16 conversion*/
                 xVSS_context->pSettings->pClipList[i]->filePathSize = length+1;
 
@@ -3527,15 +2978,6 @@
                 masterClip = i;
                 xVSS_context->pSettings->uiMasterClip = i;
             }
-#if 0 /* Changed to be able to mix with video only files */
-
-            if( xVSS_context->pSettings->uiMasterClip == 0
-                && fileProperties.AudioStreamType != M4VIDEOEDITING_kNoneAudio )
-            {
-                xVSS_context->pSettings->uiMasterClip = i;
-            }
-
-#endif
 
         }
         /**************************
@@ -3559,8 +3001,8 @@
     for ( j = 0; j < xVSS_context->pSettings->nbEffects; j++ )
     {
         /* Copy effect to "local" structure */
-        M4OSA_memcpy((M4OSA_MemAddr8) &(xVSS_context->pSettings->Effects[j]),
-            (M4OSA_MemAddr8) &(pSettings->Effects[j]),
+        memcpy((void *) &(xVSS_context->pSettings->Effects[j]),
+            (void *) &(pSettings->Effects[j]),
             sizeof(M4VSS3GPP_EffectSettings));
 
         /* Prevent from bad initializing of effect percentage time */
@@ -3613,8 +3055,8 @@
             if( pSettings->Effects[j].xVSS.pFramingFilePath != M4OSA_NULL )
             {
                 xVSS_context->pSettings->
-                    Effects[j].xVSS.pFramingFilePath = M4OSA_malloc(
-                    M4OSA_chrLength(pSettings->Effects[j].xVSS.pFramingFilePath)
+                    Effects[j].xVSS.pFramingFilePath = M4OSA_32bitAlignedMalloc(
+                    strlen(pSettings->Effects[j].xVSS.pFramingFilePath)
                     + 1, M4VS, (M4OSA_Char *)"Local Framing file path");
 
                 if( xVSS_context->pSettings->Effects[j].xVSS.pFramingFilePath
@@ -3627,10 +3069,10 @@
                     /**/
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->
+                memcpy((void *)xVSS_context->pSettings->
                     Effects[j].xVSS.pFramingFilePath,
-                    (M4OSA_MemAddr8)pSettings->
-                    Effects[j].xVSS.pFramingFilePath, M4OSA_chrLength(
+                    (void *)pSettings->
+                    Effects[j].xVSS.pFramingFilePath, strlen(
                     pSettings->Effects[j].xVSS.pFramingFilePath) + 1);
 
                 pExt2 =
@@ -3640,7 +3082,7 @@
 #ifdef DECODE_GIF_ON_SAVING
 
             framingCtx = (M4xVSS_FramingContext
-                *)M4OSA_malloc(sizeof(M4xVSS_FramingContext),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingContext),
                 M4VS, (M4OSA_Char *)"Context of the framing effect");
 
             if( framingCtx == M4OSA_NULL )
@@ -3689,32 +3131,27 @@
 
             /*Alpha blending*/
             /*Check if the alpha blending parameters are corrects*/
-            if( pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime < 0
-                || pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime > 100 )
+            if( pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime > 100 )
             {
                 pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime = 0;
             }
 
-            if( pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime < 0
-                || pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime > 100 )
+            if( pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime > 100 )
             {
                 pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime = 0;
             }
 
-            if( pSettings->Effects[j].xVSS.uialphaBlendingEnd < 0
-                || pSettings->Effects[j].xVSS.uialphaBlendingEnd > 100 )
+            if( pSettings->Effects[j].xVSS.uialphaBlendingEnd > 100 )
             {
                 pSettings->Effects[j].xVSS.uialphaBlendingEnd = 100;
             }
 
-            if( pSettings->Effects[j].xVSS.uialphaBlendingMiddle < 0
-                || pSettings->Effects[j].xVSS.uialphaBlendingMiddle > 100 )
+            if( pSettings->Effects[j].xVSS.uialphaBlendingMiddle > 100 )
             {
                 pSettings->Effects[j].xVSS.uialphaBlendingMiddle = 100;
             }
 
-            if( pSettings->Effects[j].xVSS.uialphaBlendingStart < 0
-                || pSettings->Effects[j].xVSS.uialphaBlendingStart > 100 )
+            if( pSettings->Effects[j].xVSS.uialphaBlendingStart > 100 )
             {
                 pSettings->Effects[j].xVSS.uialphaBlendingStart = 100;
             }
@@ -3724,7 +3161,7 @@
             {
                 /*Allocate the alpha blending structure*/
                 framingCtx->alphaBlendingStruct =
-                    (M4xVSS_internalEffectsAlphaBlending *)M4OSA_malloc(
+                    (M4xVSS_internalEffectsAlphaBlending *)M4OSA_32bitAlignedMalloc(
                     sizeof(M4xVSS_internalEffectsAlphaBlending),
                     M4VS, (M4OSA_Char *)"alpha blending structure");
 
@@ -3759,7 +3196,7 @@
             * UTF conversion: convert into the customer format, before being used*/
             pDecodedPath =
                 xVSS_context->pSettings->Effects[j].xVSS.pFramingFilePath;
-            length = M4OSA_chrLength(pDecodedPath);
+            length = strlen(pDecodedPath);
 
             if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                 != M4OSA_NULL && xVSS_context->
@@ -3788,7 +3225,7 @@
 
             /**
             * End of the UTF conversion, use the converted file path*/
-            framingCtx->pEffectFilePath = M4OSA_malloc(length + 1, M4VS,
+            framingCtx->pEffectFilePath = M4OSA_32bitAlignedMalloc(length + 1, M4VS,
                 (M4OSA_Char *)"Local Framing file path");
 
             if( framingCtx->pEffectFilePath == M4OSA_NULL )
@@ -3800,8 +3237,8 @@
                 /**/
                 return M4ERR_ALLOC;
             }
-            M4OSA_memcpy((M4OSA_MemAddr8)framingCtx->pEffectFilePath,
-                (M4OSA_MemAddr8)pDecodedPath, length + 1);
+            memcpy((void *)framingCtx->pEffectFilePath,
+                (void *)pDecodedPath, length + 1);
 
             /* Save framing structure associated with corresponding effect */
             xVSS_context->pSettings->Effects[j].pExtVideoEffectFctCtxt =
@@ -3810,7 +3247,7 @@
 #else
 
             framingCtx = (M4xVSS_FramingStruct
-                *)M4OSA_malloc(sizeof(M4xVSS_FramingStruct),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct),
                 M4VS, (M4OSA_Char *)"Context of the framing effect");
 
             if( framingCtx == M4OSA_NULL )
@@ -3841,10 +3278,10 @@
             if( pExt2 != M4OSA_NULL )
             {
                 /* Decode the image associated to the effect, and fill framing structure */
-                pExt2 += (M4OSA_chrLength(pExt2) - 4);
+                pExt2 += (strlen((const char *)pExt2) - 4);
 
-                M4OSA_chrCompare(pExt2,(M4OSA_Char *)".rgb", &result1);
-                M4OSA_chrCompare(pExt2,(M4OSA_Char *)".RGB", &result2);
+                result1 = strcmp((const char *)pExt2,(const char *)".rgb");
+                result2 = strcmp((const char *)pExt2,(const char *)".RGB");
 
                 if( 0 == result1 || 0 == result2 )
                 {
@@ -3852,7 +3289,7 @@
 
                     framingCtx->aFramingCtx =
                         (M4xVSS_FramingStruct
-                        *)M4OSA_malloc(sizeof(M4xVSS_FramingStruct),
+                        *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct),
                         M4VS,
                         (M4OSA_Char
                         *)
@@ -3924,7 +3361,7 @@
 #ifdef DECODE_GIF_ON_SAVING
 
                 framingCtx->aFramingCtx = (M4xVSS_FramingStruct
-                    *)M4OSA_malloc(sizeof(M4xVSS_FramingStruct),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct),
                     M4VS, (M4OSA_Char *)"Context of the framing effect");
 
                 if( framingCtx->aFramingCtx == M4OSA_NULL )
@@ -4022,7 +3459,7 @@
 #ifdef DECODE_GIF_ON_SAVING
 
                 framingCtx = (M4xVSS_FramingContext
-                    *)M4OSA_malloc(sizeof(M4xVSS_FramingContext),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingContext),
                     M4VS, (M4OSA_Char *)"Context of the framing effect");
 
                 if( framingCtx == M4OSA_NULL )
@@ -4060,7 +3497,7 @@
                     framingCtx;
 
                 framingCtx->aFramingCtx = (M4xVSS_FramingStruct
-                    *)M4OSA_malloc(sizeof(M4xVSS_FramingStruct),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct),
                     M4VS, (M4OSA_Char *)"Context of the framing effect");
 
                 if( framingCtx->aFramingCtx == M4OSA_NULL )
@@ -4088,34 +3525,27 @@
 
                 /*Alpha blending*/
                 /*Check if the alpha blending parameters are corrects*/
-                if( pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime < 0
-                    || pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime
-                > 100 )
+                if( pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime > 100 )
                 {
                     pSettings->Effects[j].xVSS.uialphaBlendingFadeInTime = 0;
                 }
 
-                if( pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime < 0
-                    || pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime
-                > 100 )
+                if( pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime > 100 )
                 {
                     pSettings->Effects[j].xVSS.uialphaBlendingFadeOutTime = 0;
                 }
 
-                if( pSettings->Effects[j].xVSS.uialphaBlendingEnd < 0
-                    || pSettings->Effects[j].xVSS.uialphaBlendingEnd > 100 )
+                if( pSettings->Effects[j].xVSS.uialphaBlendingEnd > 100 )
                 {
                     pSettings->Effects[j].xVSS.uialphaBlendingEnd = 100;
                 }
 
-                if( pSettings->Effects[j].xVSS.uialphaBlendingMiddle < 0
-                    || pSettings->Effects[j].xVSS.uialphaBlendingMiddle > 100 )
+                if( pSettings->Effects[j].xVSS.uialphaBlendingMiddle > 100 )
                 {
                     pSettings->Effects[j].xVSS.uialphaBlendingMiddle = 100;
                 }
 
-                if( pSettings->Effects[j].xVSS.uialphaBlendingStart < 0
-                    || pSettings->Effects[j].xVSS.uialphaBlendingStart > 100 )
+                if( pSettings->Effects[j].xVSS.uialphaBlendingStart > 100 )
                 {
                     pSettings->Effects[j].xVSS.uialphaBlendingStart = 100;
                 }
@@ -4126,7 +3556,7 @@
                 {
                     /*Allocate the alpha blending structure*/
                     framingCtx->alphaBlendingStruct =
-                        (M4xVSS_internalEffectsAlphaBlending *)M4OSA_malloc(
+                        (M4xVSS_internalEffectsAlphaBlending *)M4OSA_32bitAlignedMalloc(
                         sizeof(M4xVSS_internalEffectsAlphaBlending),
                         M4VS, (M4OSA_Char *)"alpha blending structure");
 
@@ -4160,7 +3590,7 @@
 #else
 
                 framingCtx = (M4xVSS_FramingStruct
-                    *)M4OSA_malloc(sizeof(M4xVSS_FramingStruct),
+                    *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FramingStruct),
                     M4VS, (M4OSA_Char
                     *)"Context of the framing effect (for text)");
 
@@ -4236,12 +3666,12 @@
                 * End of the UTF conversion, use the converted file path*/
 
                 xVSS_context->pSettings->
-                    Effects[j].xVSS.pTextBuffer = M4OSA_malloc(
+                    Effects[j].xVSS.pTextBuffer = M4OSA_32bitAlignedMalloc(
                     xVSS_context->pSettings->Effects[j].xVSS.textBufferSize + 1,
                     M4VS, (M4OSA_Char *)"Local text buffer effect");
 
                 //xVSS_context->pSettings->Effects[j].xVSS.pTextBuffer =
-                // M4OSA_malloc(M4OSA_chrLength(pSettings->Effects[j].xVSS.pTextBuffer)+1,
+                // M4OSA_32bitAlignedMalloc(strlen(pSettings->Effects[j].xVSS.pTextBuffer)+1,
                 // M4VS, "Local text buffer effect");
                 if( xVSS_context->pSettings->Effects[j].xVSS.pTextBuffer
                     == M4OSA_NULL )
@@ -4256,18 +3686,18 @@
 
                 if( pSettings->Effects[j].xVSS.pTextBuffer != M4OSA_NULL )
                 {
-                    //M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->Effects[j]
+                    //memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->Effects[j]
                     //.xVSS.pTextBuffer, (M4OSA_MemAddr8)pSettings->Effects[j].xVSS.pTextBuffer,
-                    // M4OSA_chrLength(pSettings->Effects[j].xVSS.pTextBuffer)+1);
-                    M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->
+                    // strlen(pSettings->Effects[j].xVSS.pTextBuffer)+1);
+                    memcpy((void *)xVSS_context->pSettings->
                         Effects[j].xVSS.pTextBuffer,
-                        (M4OSA_MemAddr8)pDecodedPath, xVSS_context->pSettings->
+                        (void *)pDecodedPath, xVSS_context->pSettings->
                         Effects[j].xVSS.textBufferSize + 1);
                 }
 
                 /*Allocate the text RGB buffer*/
                 framingCtx->aFramingCtx->FramingRgb =
-                    (M4VIFI_ImagePlane *)M4OSA_malloc(sizeof(M4VIFI_ImagePlane),
+                    (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),
                     M4VS,
                     (M4OSA_Char *)"RGB structure for the text effect");
 
@@ -4305,7 +3735,7 @@
                     2 * framingCtx->aFramingCtx->FramingRgb->u_width;
                 framingCtx->aFramingCtx->FramingRgb->u_topleft = 0;
                 framingCtx->aFramingCtx->FramingRgb->pac_data =
-                    (M4VIFI_UInt8 *)M4OSA_malloc(
+                    (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(
                     framingCtx->aFramingCtx->FramingRgb->u_height
                     * framingCtx->aFramingCtx->FramingRgb->u_stride,
                     M4VS, (M4OSA_Char *)"Text RGB plane->pac_data");
@@ -4435,7 +3865,7 @@
             }
 
             fiftiesCtx = (M4xVSS_FiftiesStruct
-                *)M4OSA_malloc(sizeof(M4xVSS_FiftiesStruct),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_FiftiesStruct),
                 M4VS, (M4OSA_Char *)"Context of the fifties effect");
 
             if( fiftiesCtx == M4OSA_NULL )
@@ -4476,7 +3906,7 @@
             M4xVSS_ColorStruct *ColorCtx;
 
             ColorCtx =
-                (M4xVSS_ColorStruct *)M4OSA_malloc(sizeof(M4xVSS_ColorStruct),
+                (M4xVSS_ColorStruct *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_ColorStruct),
                 M4VS, (M4OSA_Char *)"Context of the color effect");
 
             if( ColorCtx == M4OSA_NULL )
@@ -4535,19 +3965,17 @@
         {
             if( xVSS_context->pSettings->xVSS.pBGMtrack->pFile != M4OSA_NULL )
             {
-                M4OSA_free(
-                    (M4OSA_MemAddr32)xVSS_context->pSettings->xVSS.pBGMtrack->
+                free(xVSS_context->pSettings->xVSS.pBGMtrack->
                     pFile);
                 xVSS_context->pSettings->xVSS.pBGMtrack->pFile = M4OSA_NULL;
             }
-            M4OSA_free(
-                (M4OSA_MemAddr32)xVSS_context->pSettings->xVSS.pBGMtrack);
+            free(xVSS_context->pSettings->xVSS.pBGMtrack);
             xVSS_context->pSettings->xVSS.pBGMtrack = M4OSA_NULL;
         }
 
         /* Allocate BGM */
         xVSS_context->pSettings->xVSS.pBGMtrack =
-            (M4xVSS_BGMSettings *)M4OSA_malloc(sizeof(M4xVSS_BGMSettings), M4VS,
+            (M4xVSS_BGMSettings *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_BGMSettings), M4VS,
             (M4OSA_Char *)"xVSS_context->pSettings->xVSS.pBGMtrack");
 
         if( xVSS_context->pSettings->xVSS.pBGMtrack == M4OSA_NULL )
@@ -4558,12 +3986,12 @@
         }
 
         /* Copy input structure to our structure */
-        M4OSA_memcpy((M4OSA_MemAddr8)xVSS_context->pSettings->xVSS.pBGMtrack,
-            (M4OSA_MemAddr8)pSettings->xVSS.pBGMtrack,
+        memcpy((void *)xVSS_context->pSettings->xVSS.pBGMtrack,
+            (void *)pSettings->xVSS.pBGMtrack,
             sizeof(M4xVSS_BGMSettings));
         /* Allocate file name, and copy file name buffer to our structure */
         xVSS_context->pSettings->xVSS.pBGMtrack->pFile =
-            M4OSA_malloc((M4OSA_chrLength(pSettings->xVSS.pBGMtrack->pFile)
+            M4OSA_32bitAlignedMalloc((strlen(pSettings->xVSS.pBGMtrack->pFile)
             + 1), M4VS, (M4OSA_Char *)"xVSS BGM file path");
 
         if( xVSS_context->pSettings->xVSS.pBGMtrack->pFile == M4OSA_NULL )
@@ -4572,15 +4000,15 @@
             M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
-            pSettings->xVSS.pBGMtrack->pFile,
-            M4OSA_chrLength(pSettings->xVSS.pBGMtrack->pFile) + 1);
+        memcpy((void *)xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
+            (void *)pSettings->xVSS.pBGMtrack->pFile,
+            strlen(pSettings->xVSS.pBGMtrack->pFile) + 1);
 
 #ifdef PREVIEW_ENABLED
         /* Decode BGM track to pcm output file */
 
         pParams =
-            (M4xVSS_MCS_params *)M4OSA_malloc(sizeof(M4xVSS_MCS_params), M4VS,
+            (M4xVSS_MCS_params *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_MCS_params), M4VS,
             (M4OSA_Char *)"Element of MCS Params (for BGM)");
 
         if( pParams == M4OSA_NULL )
@@ -4605,13 +4033,6 @@
             /* Initialize the xVSS context with the first element of the list */
             xVSS_context->pMCSparamsList = pParams;
 
-#if 0 /* Not necessary, BGM is the last element of transcoding */
-            /* Save this element in case of other file to convert (can't happen, BGM ...) */
-
-            pMCS_last = pParams;
-
-#endif
-
         }
         else
         {
@@ -4626,15 +4047,15 @@
                     /* Remove this element */
                     if( pParams_temp->pFileIn != M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp->pFileIn);
+                        free(pParams_temp->pFileIn);
                         pParams_temp->pFileIn = M4OSA_NULL;
                     }
 
                     if( pParams_temp->pFileOut != M4OSA_NULL )
                     {
                         /* Remove PCM temporary file */
-                        M4OSA_fileExtraDelete(pParams_temp->pFileOut);
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp->pFileOut);
+                        remove((const char *)pParams_temp->pFileOut);
+                        free(pParams_temp->pFileOut);
                         pParams_temp->pFileOut = M4OSA_NULL;
                     }
                     /* Chain previous element with next element = remove BGM chained
@@ -4665,13 +4086,13 @@
                     if( pParams_temp->pNext != M4OSA_NULL )
                     {
                         pParams_prev = pParams_temp->pNext;
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp);
+                        free(pParams_temp);
                         pParams_temp = M4OSA_NULL;
                         pParams_temp = pParams_prev;
                     }
                     else
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp);
+                        free(pParams_temp);
                         pParams_temp = M4OSA_NULL;
                     }
                 }
@@ -4697,13 +4118,6 @@
                 pMCS_last->pNext = pParams;
             }
 
-#if 0 /* Not necessary, BGM is the last element of transcoding */
-            /* Update save of last element of the chain (not necessary, BGM ...) */
-
-            pMCS_last = pParams;
-
-#endif
-
         }
 
         /* Fill the last M4xVSS_MCS_params element */
@@ -4763,7 +4177,7 @@
         /* Prepare output filename */
         /* 21 is the size of "preview_16000_2.pcm" + \0 */
         out_pcm =
-            (M4OSA_Char *)M4OSA_malloc(M4OSA_chrLength(xVSS_context->pTempPath)
+            (M4OSA_Char *)M4OSA_32bitAlignedMalloc(strlen(xVSS_context->pTempPath)
             + 21, M4VS, (M4OSA_Char *)"Temp char* for pcmPreviewFile");
 
         if( out_pcm == M4OSA_NULL )
@@ -4775,7 +4189,7 @@
 
         /* Copy temporary path to final preview path string */
         M4OSA_chrNCopy(out_pcm, xVSS_context->pTempPath,
-            M4OSA_chrLength(xVSS_context->pTempPath) + 1);
+            strlen(xVSS_context->pTempPath) + 1);
 
         /* Depending of the output sample frequency and nb of channels, we construct preview
         output filename */
@@ -4785,12 +4199,12 @@
             /* Construct output temporary PCM filename */
             if( xVSS_context->pSettings->xVSS.bAudioMono == M4OSA_TRUE )
             {
-                M4OSA_chrNCat(out_pcm, (M4OSA_Char *)"preview_16000_1.pcm\0",
+                strncat((char *)out_pcm, (const char *)"preview_16000_1.pcm\0",
                     20);
             }
             else
             {
-                M4OSA_chrNCat(out_pcm, (M4OSA_Char *)"preview_16000_2.pcm\0",
+                strncat((char *)out_pcm, (const char *)"preview_16000_2.pcm\0",
                     20);
             }
         }
@@ -4798,13 +4212,13 @@
             == M4VIDEOEDITING_kAMR_NB )
         {
             /* Construct output temporary PCM filename */
-            M4OSA_chrNCat(out_pcm, (M4OSA_Char *)"preview_08000_1.pcm\0", 20);
+            strncat((char *)out_pcm, (const char *)"preview_08000_1.pcm\0", 20);
         }
         else
         {
             if( out_pcm != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)out_pcm);
+                free(out_pcm);
                 out_pcm = M4OSA_NULL;
             }
             M4xVSS_freeCommand(xVSS_context);
@@ -4817,7 +4231,7 @@
         /**
         * UTF conversion: convert into the customer format, before being used*/
         pDecodedPath = out_pcm;
-        length = M4OSA_chrLength(pDecodedPath);
+        length = strlen(pDecodedPath);
 
         if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct != M4OSA_NULL
             && xVSS_context->UTFConversionContext.pTempOutConversionBuffer
@@ -4843,13 +4257,13 @@
         /**
         * End of the UTF conversion, use the converted file path*/
         xVSS_context->pcmPreviewFile =
-            (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(length + 1, M4VS,
             (M4OSA_Char *)"pcmPreviewFile");
 
         if( xVSS_context->pcmPreviewFile == M4OSA_NULL )
         {
             M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
-            M4OSA_free((M4OSA_MemAddr32)out_pcm);
+            free(out_pcm);
             out_pcm = M4OSA_NULL;
             /*FB: to avoid leaks when there is an error in the send command*/
             /* Free Send command */
@@ -4857,16 +4271,16 @@
             /**/
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pcmPreviewFile, pDecodedPath, length + 1);
+        memcpy((void *)xVSS_context->pcmPreviewFile, (void *)pDecodedPath, length + 1);
 
         /* Free temporary output filename */
         if( out_pcm != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)out_pcm);
+            free(out_pcm);
             out_pcm = M4OSA_NULL;
         }
 
-        pParams->pFileOut = M4OSA_malloc((length + 1), M4VS,
+        pParams->pFileOut = M4OSA_32bitAlignedMalloc((length + 1), M4VS,
             (M4OSA_Char *)"MCS BGM Params: file out");
 
         if( pParams->pFileOut == M4OSA_NULL )
@@ -4877,43 +4291,14 @@
         }
         pParams->pFileTemp = M4OSA_NULL;
 
-        M4OSA_memcpy(pParams->pFileOut, xVSS_context->pcmPreviewFile,
+        memcpy((void *)pParams->pFileOut,(void *) xVSS_context->pcmPreviewFile,
             (length + 1)); /* Copy output file path */
 
-#if 0
-
-        xVSS_context->pcmPreviewFile =
-            (M4OSA_Char *)M4OSA_malloc(M4OSA_chrLength(out_pcm) + 1, M4VS,
-            "pcmPreviewFile");
-
-        if( xVSS_context->pcmPreviewFile == M4OSA_NULL )
-        {
-            M4OSA_TRACE1_0("Allocation error in M4xVSS_Init");
-            M4OSA_free((M4OSA_MemAddr32)out_pcm);
-            out_pcm = M4OSA_NULL;
-            /*FB: to avoid leaks when there is an error in the send command*/
-            /* Free Send command */
-            M4xVSS_freeCommand(xVSS_context);
-            /**/
-            return M4ERR_ALLOC;
-        }
-        M4OSA_chrNCopy(xVSS_context->pcmPreviewFile, out_pcm,
-            M4OSA_chrLength(out_pcm) + 1);
-
-        /* Free temporary output filename */
-        if( out_pcm != M4OSA_NULL )
-        {
-            M4OSA_free((M4OSA_MemAddr32)out_pcm);
-            out_pcm = M4OSA_NULL;
-        }
-
-#endif
-
         /**
         * UTF conversion: convert into the customer format, before being used*/
 
         pDecodedPath = xVSS_context->pSettings->xVSS.pBGMtrack->pFile;
-        length = M4OSA_chrLength(pDecodedPath);
+        length = strlen(pDecodedPath);
 
         if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct != M4OSA_NULL
             && xVSS_context->UTFConversionContext.pTempOutConversionBuffer
@@ -4939,7 +4324,7 @@
 
         /**
         * End of the UTF conversion, use the converted file path*/
-        pParams->pFileIn = (M4OSA_Void *)M4OSA_malloc((length + 1), M4VS,
+        pParams->pFileIn = (M4OSA_Void *)M4OSA_32bitAlignedMalloc((length + 1), M4VS,
             (M4OSA_Char *)"MCS BGM Params: file in");
 
         if( pParams->pFileIn == M4OSA_NULL )
@@ -4948,7 +4333,7 @@
             M4OSA_TRACE1_0("Allocation error in M4xVSS_SendCommand");
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(pParams->pFileIn, pDecodedPath,
+        memcpy((void *)pParams->pFileIn, (void *)pDecodedPath,
             (length + 1)); /* Copy input file path */
 
         pParams->isBGM = M4OSA_TRUE;
@@ -5024,13 +4409,13 @@
                     /* Remove this element */
                     if( pParams_temp->pFileIn != M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp->pFileIn);
+                        free(pParams_temp->pFileIn);
                         pParams_temp->pFileIn = M4OSA_NULL;
                     }
 
                     if( pParams_temp->pFileOut != M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp->pFileOut);
+                        free(pParams_temp->pFileOut);
                         pParams_temp->pFileOut = M4OSA_NULL;
                     }
                     /* Chain previous element with next element */
@@ -5045,7 +4430,7 @@
                     if( pParams_temp == xVSS_context->pMCSparamsList
                         && pParams_temp->pNext == M4OSA_NULL )
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp);
+                        free(pParams_temp);
                         xVSS_context->pMCSparamsList = M4OSA_NULL;
                     }
                     /* In that case, BGM pointer is the first one, but there are others
@@ -5054,14 +4439,14 @@
                     else if( pParams_temp->pNext != M4OSA_NULL )
                     {
                         xVSS_context->pMCSparamsList = pParams_temp->pNext;
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp);
+                        free(pParams_temp);
                         pParams_temp = M4OSA_NULL;
                     }
                     /* In all other cases, nothing else to do except freeing the chained
                     list element */
                     else
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pParams_temp);
+                        free(pParams_temp);
                         pParams_temp = M4OSA_NULL;
                     }
                     break;
@@ -5079,33 +4464,15 @@
                 if( xVSS_context->pSettings->xVSS.pBGMtrack->pFile
                     != M4OSA_NULL )
                 {
-                    M4OSA_free(xVSS_context->pSettings->xVSS.pBGMtrack->pFile);
+                    free(xVSS_context->pSettings->xVSS.pBGMtrack->pFile);
                     xVSS_context->pSettings->xVSS.pBGMtrack->pFile = M4OSA_NULL;
                 }
-                M4OSA_free(
-                    (M4OSA_MemAddr32)xVSS_context->pSettings->xVSS.pBGMtrack);
+                free(xVSS_context->pSettings->xVSS.pBGMtrack);
                 xVSS_context->pSettings->xVSS.pBGMtrack = M4OSA_NULL;
             }
         }
     }
 
-    /* Default behaviour, if no audio/video output format is set, we put H263/AMR by default */
-#if 0
-
-    if( xVSS_context->pSettings->xVSS.outputVideoFormat
-        == M4VIDEOEDITING_kNoneVideo )
-    {
-        xVSS_context->pSettings->xVSS.outputVideoFormat = M4VIDEOEDITING_kH263;
-    }
-
-    if( xVSS_context->pSettings->xVSS.outputAudioFormat
-        == M4VIDEOEDITING_kNoneAudio )
-    {
-        xVSS_context->pSettings->xVSS.outputAudioFormat =
-            M4VIDEOEDITING_kAMR_NB;
-    }
-
-#endif
     /* Changed to be able to mix with video only files -> in case no master clip is found
     (i.e only JPG input or video only input) */
     /* and if there is a BGM, we force the added volume to 100 (i.e replace audio) */
@@ -5145,7 +4512,7 @@
                     * UTF conversion: convert into the customer format, before being used*/
                     pDecodedPath =
                         xVSS_context->pSettings->xVSS.pBGMtrack->pFile;
-                    length = M4OSA_chrLength(pDecodedPath);
+                    length = strlen(pDecodedPath);
 
                     if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                         != M4OSA_NULL && xVSS_context->
@@ -5386,7 +4753,7 @@
         if( xVSS_context->pSettings->pOutputFile != M4OSA_NULL )
         {
             /*it means that pOutputFile has been allocated in M4xVSS_sendCommand()*/
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->pOutputFile);
+            free(xVSS_context->pSettings->pOutputFile);
             xVSS_context->pSettings->pOutputFile = M4OSA_NULL;
             xVSS_context->pSettings->uiOutputPathSize = 0;
         }
@@ -5415,7 +4782,7 @@
         }
 
         xVSS_context->pOutputFile =
-            (M4OSA_Void *)M4OSA_malloc(filePathSize + 1, M4VS,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(filePathSize + 1, M4VS,
             (M4OSA_Char *)"M4xVSS_SaveStart: output file");
 
         if( xVSS_context->pOutputFile == M4OSA_NULL )
@@ -5423,7 +4790,7 @@
             M4OSA_TRACE1_0("Allocation error in M4xVSS_SaveStart");
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pOutputFile, pDecodedPath, filePathSize + 1);
+        memcpy((void *)xVSS_context->pOutputFile, (void *)pDecodedPath, filePathSize + 1);
         xVSS_context->pOutputFile[filePathSize] = '\0';
         xVSS_context->pSettings->pOutputFile = xVSS_context->pOutputFile;
         xVSS_context->pSettings->uiOutputPathSize = filePathSize;
@@ -5435,7 +4802,7 @@
     /*FB: Add for UTF conversion: copy the pSettings structure into a new pCurrentEditSettings*/
     /*It is the same principle as in the PreviewStart()*/
     pEditSavingSettings =
-        (M4VSS3GPP_EditSettings *)M4OSA_malloc(sizeof(M4VSS3GPP_EditSettings),
+        (M4VSS3GPP_EditSettings *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_EditSettings),
         M4VS, (M4OSA_Char *)"Saving, copy of VSS structure");
 
     if( pEditSavingSettings == M4OSA_NULL )
@@ -5444,15 +4811,15 @@
 
         if( xVSS_context->pOutputFile != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+            free(xVSS_context->pOutputFile);
             xVSS_context->pOutputFile = M4OSA_NULL;
         }
         return M4ERR_ALLOC;
     }
 
     /* Copy settings from input structure */
-    M4OSA_memcpy((M4OSA_MemAddr8) &(pEditSavingSettings->xVSS),
-        (M4OSA_MemAddr8) &(xVSS_context->pSettings->xVSS),
+    memcpy((void *) &(pEditSavingSettings->xVSS),
+        (void *) &(xVSS_context->pSettings->xVSS),
         sizeof(M4xVSS_EditSettings));
 
     /* Initialize pEditSavingSettings structure */
@@ -5466,7 +4833,7 @@
 
     /* Allocate savingSettings.pClipList/pTransitions structure */
     pEditSavingSettings->pClipList = (M4VSS3GPP_ClipSettings *
-        * )M4OSA_malloc(sizeof(M4VSS3GPP_ClipSettings *)
+        * )M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_ClipSettings *)
         *pEditSavingSettings->uiClipNumber,
         M4VS, (M4OSA_Char *)"xVSS, saving , copy of pClipList");
 
@@ -5476,7 +4843,7 @@
 
         if( xVSS_context->pOutputFile != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+            free(xVSS_context->pOutputFile);
             xVSS_context->pOutputFile = M4OSA_NULL;
         }
         return M4ERR_ALLOC;
@@ -5485,7 +4852,7 @@
     if( pEditSavingSettings->uiClipNumber > 1 )
     {
         pEditSavingSettings->pTransitionList = (M4VSS3GPP_TransitionSettings *
-            * )M4OSA_malloc(sizeof(M4VSS3GPP_TransitionSettings *)
+            * )M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_TransitionSettings *)
             *(pEditSavingSettings->uiClipNumber - 1),
             M4VS, (M4OSA_Char *)"xVSS, saving, copy of pTransitionList");
 
@@ -5495,7 +4862,7 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
@@ -5509,7 +4876,7 @@
     for ( i = 0; i < pEditSavingSettings->uiClipNumber; i++ )
     {
         pEditSavingSettings->pClipList[i] = (M4VSS3GPP_ClipSettings
-            *)M4OSA_malloc(sizeof(M4VSS3GPP_ClipSettings),
+            *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_ClipSettings),
             M4VS, (M4OSA_Char *)"saving clip settings");
 
         if( pEditSavingSettings->pClipList[i] == M4OSA_NULL )
@@ -5518,7 +4885,7 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
@@ -5529,7 +4896,7 @@
         {
             pEditSavingSettings->pTransitionList[i] =
                 (M4VSS3GPP_TransitionSettings
-                *)M4OSA_malloc(sizeof(M4VSS3GPP_TransitionSettings),
+                *)M4OSA_32bitAlignedMalloc(sizeof(M4VSS3GPP_TransitionSettings),
                 M4VS, (M4OSA_Char *)"saving transition settings");
 
             if( pEditSavingSettings->pTransitionList[i] == M4OSA_NULL )
@@ -5538,7 +4905,7 @@
 
                 if( xVSS_context->pOutputFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                    free(xVSS_context->pOutputFile);
                     xVSS_context->pOutputFile = M4OSA_NULL;
                 }
                 return M4ERR_ALLOC;
@@ -5566,7 +4933,7 @@
             /**
             * UTF conversion: convert into the customer format, before being used*/
             pDecodedPath = pEditSavingSettings->pClipList[i]->pFile;
-            length = M4OSA_chrLength(pDecodedPath);
+            length = strlen(pDecodedPath);
 
             if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct
                 != M4OSA_NULL && xVSS_context->
@@ -5588,8 +4955,7 @@
 
                     if( xVSS_context->pOutputFile != M4OSA_NULL )
                     {
-                        M4OSA_free(
-                            (M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                        free(xVSS_context->pOutputFile);
                         xVSS_context->pOutputFile = M4OSA_NULL;
                     }
                     return err;
@@ -5599,10 +4965,10 @@
 
                 /**
                 * End of the UTF conversion, use the converted file path*/
-                M4OSA_free((M4OSA_MemAddr32)
+                free(
                     pEditSavingSettings->pClipList[i]->pFile);
                 pEditSavingSettings->pClipList[i]->pFile = (M4OSA_Void
-                    *)M4OSA_malloc((length + 1),
+                    *)M4OSA_32bitAlignedMalloc((length + 1),
                     M4VS, (M4OSA_Char *)"saving transition settings");
 
                 if( pEditSavingSettings->pClipList[i]->pFile == M4OSA_NULL )
@@ -5611,14 +4977,13 @@
 
                     if( xVSS_context->pOutputFile != M4OSA_NULL )
                     {
-                        M4OSA_free(
-                            (M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                        free(xVSS_context->pOutputFile);
                         xVSS_context->pOutputFile = M4OSA_NULL;
                     }
                     return M4ERR_ALLOC;
                 }
-                M4OSA_memcpy(pEditSavingSettings->pClipList[i]->pFile,
-                    pDecodedPath, length + 1);
+                memcpy((void *)pEditSavingSettings->pClipList[i]->pFile,
+                    (void *)pDecodedPath, length + 1);
             }
             /*FB: add file path size because of UTF 16 conversion*/
             pEditSavingSettings->pClipList[i]->filePathSize = length+1;
@@ -5627,9 +4992,9 @@
                 < xVSS_context->pSettings->uiClipNumber
                 - 1 ) /* Because there is 1 less transition than clip number */
             {
-                M4OSA_memcpy(
-                    (M4OSA_MemAddr8)pEditSavingSettings->pTransitionList[i],
-                    (M4OSA_MemAddr8)xVSS_context->pSettings->
+                memcpy(
+                    (void *)pEditSavingSettings->pTransitionList[i],
+                    (void *)xVSS_context->pSettings->
                     pTransitionList[i],
                     sizeof(M4VSS3GPP_TransitionSettings));
             }
@@ -5642,7 +5007,7 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_PARAMETER;
@@ -5664,7 +5029,7 @@
     if( nbEffects != 0 )
     {
         pEditSavingSettings->Effects =
-            (M4VSS3GPP_EffectSettings *)M4OSA_malloc(nbEffects
+            (M4VSS3GPP_EffectSettings *)M4OSA_32bitAlignedMalloc(nbEffects
             * sizeof(M4VSS3GPP_EffectSettings), M4VS, (M4OSA_Char
             *)"Saving settings, effects table of structure settings");
 
@@ -5674,7 +5039,7 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
@@ -5682,8 +5047,8 @@
 
         /* Just copy effect structure to saving structure, as effects time are now */
         /* relative to output clip time*/
-        M4OSA_memcpy((M4OSA_MemAddr8)pEditSavingSettings->Effects,
-            (M4OSA_MemAddr8)xVSS_context->pSettings->Effects,
+        memcpy((void *)pEditSavingSettings->Effects,
+            (void *)xVSS_context->pSettings->Effects,
             nbEffects * sizeof(M4VSS3GPP_EffectSettings));
     }
     else
@@ -5711,7 +5076,7 @@
 
         /**/
         pEditSavingSettings->xVSS.pBGMtrack =
-            (M4xVSS_BGMSettings *)M4OSA_malloc(sizeof(M4xVSS_BGMSettings), M4VS,
+            (M4xVSS_BGMSettings *)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_BGMSettings), M4VS,
             (M4OSA_Char
             *)"Saving settings, effects table of structure settings");
 
@@ -5721,7 +5086,7 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
@@ -5729,13 +5094,13 @@
 
         /* Just copy effect structure to saving structure, as effects time are now */
         /* relative to output clip time*/
-        M4OSA_memcpy((M4OSA_MemAddr8)pEditSavingSettings->xVSS.pBGMtrack,
-            (M4OSA_MemAddr8)xVSS_context->pSettings->xVSS.pBGMtrack,
+        memcpy((void *)pEditSavingSettings->xVSS.pBGMtrack,
+            (void *)xVSS_context->pSettings->xVSS.pBGMtrack,
             sizeof(M4xVSS_BGMSettings));
 
         /* Allocate file name, and copy file name buffer to our structure */
-        pEditSavingSettings->xVSS.pBGMtrack->pFile = M4OSA_malloc(
-            (M4OSA_chrLength(xVSS_context->pSettings->xVSS.pBGMtrack->pFile)
+        pEditSavingSettings->xVSS.pBGMtrack->pFile = M4OSA_32bitAlignedMalloc(
+            (strlen(xVSS_context->pSettings->xVSS.pBGMtrack->pFile)
             + 1),
             M4VS, (M4OSA_Char *)"Saving struct xVSS BGM file path");
 
@@ -5746,14 +5111,14 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(pEditSavingSettings->xVSS.pBGMtrack->pFile,
-            xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
-            M4OSA_chrLength(xVSS_context->pSettings->xVSS.pBGMtrack->pFile)
+        memcpy((void *)pEditSavingSettings->xVSS.pBGMtrack->pFile,
+            (void *)xVSS_context->pSettings->xVSS.pBGMtrack->pFile,
+            strlen(xVSS_context->pSettings->xVSS.pBGMtrack->pFile)
             + 1);
 
         /*Copy BGM track file path*/
@@ -5777,7 +5142,7 @@
 
                 if( xVSS_context->pOutputFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                    free(xVSS_context->pOutputFile);
                     xVSS_context->pOutputFile = M4OSA_NULL;
                 }
                 return err;
@@ -5785,10 +5150,9 @@
             pDecodedPath =
                 xVSS_context->UTFConversionContext.pTempOutConversionBuffer;
 
-            M4OSA_free(
-                (M4OSA_MemAddr32)pEditSavingSettings->xVSS.pBGMtrack->pFile);
+            free(pEditSavingSettings->xVSS.pBGMtrack->pFile);
             pEditSavingSettings->xVSS.pBGMtrack->pFile =
-                (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS, (M4OSA_Char
+                (M4OSA_Void *)M4OSA_32bitAlignedMalloc(length + 1, M4VS, (M4OSA_Char
                 *)"M4xVSS_SaveStart: Temp filename in case of BGM");
 
             if( pEditSavingSettings->xVSS.pBGMtrack->pFile == M4OSA_NULL )
@@ -5797,13 +5161,13 @@
 
                 if( xVSS_context->pOutputFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                    free(xVSS_context->pOutputFile);
                     xVSS_context->pOutputFile = M4OSA_NULL;
                 }
                 return M4ERR_ALLOC;
             }
-            M4OSA_memcpy(pEditSavingSettings->xVSS.pBGMtrack->pFile,
-                pDecodedPath, length + 1);
+            memcpy((void *)pEditSavingSettings->xVSS.pBGMtrack->pFile,
+                (void *)pDecodedPath, length + 1);
         }
 
         /**/
@@ -5812,13 +5176,13 @@
         M4OSA_chrNCopy(out_3gp_tmp, xVSS_context->pTempPath, M4XVSS_MAX_PATH_LEN - 1);
 
         /* Construct output temporary 3GP filename */
-        M4OSA_chrNCat(out_3gp, (M4OSA_Char *)"savetemp.3gp\0", 13);
-        M4OSA_chrNCat(out_3gp_tmp, (M4OSA_Char *)"savetemp.tmp\0", 13);
+        strncat((char *)out_3gp, (const char *)"savetemp.3gp\0", 13);
+        strncat((char *)out_3gp_tmp, (const char *)"savetemp.tmp\0", 13);
 
         /**
         * UTF conversion: convert into the customer format, before being used*/
         pDecodedPath = out_3gp;
-        length = M4OSA_chrLength(pDecodedPath);
+        length = strlen(pDecodedPath);
 
         if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct != M4OSA_NULL
             && xVSS_context->UTFConversionContext.pTempOutConversionBuffer
@@ -5836,7 +5200,7 @@
 
                 if( xVSS_context->pOutputFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                    free(xVSS_context->pOutputFile);
                     xVSS_context->pOutputFile = M4OSA_NULL;
                 }
                 return err;
@@ -5848,7 +5212,7 @@
         /**
         * End of the UTF conversion, use the converted file path*/
         xVSS_context->pCurrentEditSettings->pOutputFile =
-            (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(length + 1, M4VS,
             (M4OSA_Char *)"M4xVSS_SaveStart: Temp filename in case of BGM");
 
         if( xVSS_context->pCurrentEditSettings->pOutputFile == M4OSA_NULL )
@@ -5857,19 +5221,19 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pCurrentEditSettings->pOutputFile,
-            pDecodedPath, length + 1);
+        memcpy((void *)xVSS_context->pCurrentEditSettings->pOutputFile,
+            (void *)pDecodedPath, length + 1);
         xVSS_context->pCurrentEditSettings->uiOutputPathSize = length + 1;
 
         /**
         * UTF conversion: convert into the customer format, before being used*/
         pDecodedPath = out_3gp_tmp;
-        length = M4OSA_chrLength(pDecodedPath);
+        length = strlen(pDecodedPath);
 
         if( xVSS_context->UTFConversionContext.pConvFromUTF8Fct != M4OSA_NULL
             && xVSS_context->UTFConversionContext.pTempOutConversionBuffer
@@ -5887,7 +5251,7 @@
 
                 if( xVSS_context->pOutputFile != M4OSA_NULL )
                 {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                    free(xVSS_context->pOutputFile);
                     xVSS_context->pOutputFile = M4OSA_NULL;
                 }
                 return err;
@@ -5899,7 +5263,7 @@
         /**
         * End of the UTF conversion, use the converted file path*/
         xVSS_context->pCurrentEditSettings->pTemporaryFile =
-            (M4OSA_Void *)M4OSA_malloc(length + 1, M4VS,
+            (M4OSA_Void *)M4OSA_32bitAlignedMalloc(length + 1, M4VS,
             (M4OSA_Char *)"M4xVSS_SaveStart: Temporary file");
 
         if( xVSS_context->pCurrentEditSettings->pTemporaryFile == M4OSA_NULL )
@@ -5908,13 +5272,13 @@
 
             if( xVSS_context->pOutputFile != M4OSA_NULL )
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             return M4ERR_ALLOC;
         }
-        M4OSA_memcpy(xVSS_context->pCurrentEditSettings->pTemporaryFile,
-            pDecodedPath, length + 1);
+        memcpy((void *)xVSS_context->pCurrentEditSettings->pTemporaryFile,
+            (void *)pDecodedPath, length + 1);
 
         /* Put nb of step for progression monitoring to 2, because audio mixing is needed */
         xVSS_context->nbStepTotal = 2;
@@ -5944,7 +5308,7 @@
         if( xVSS_context->pCurrentEditSettings->pOutputFile != M4OSA_NULL
             && xVSS_context->pSettings->xVSS.pBGMtrack == M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings->
+            free(xVSS_context->pCurrentEditSettings->
                 pOutputFile);
             xVSS_context->pCurrentEditSettings->pOutputFile = M4OSA_NULL;
             xVSS_context->pOutputFile = M4OSA_NULL;
@@ -5953,14 +5317,14 @@
         if( xVSS_context->pCurrentEditSettings->pTemporaryFile != M4OSA_NULL
             && xVSS_context->pSettings->xVSS.pBGMtrack != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings->
+            free(xVSS_context->pCurrentEditSettings->
                 pTemporaryFile);
             xVSS_context->pCurrentEditSettings->pTemporaryFile = M4OSA_NULL;
         }
 
         if( xVSS_context->pOutputFile != M4OSA_NULL )
         {
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+            free(xVSS_context->pOutputFile);
             xVSS_context->pOutputFile = M4OSA_NULL;
         }
         /* TODO: Translate error code of VSS to an xVSS error code */
@@ -6009,7 +5373,7 @@
 
     if( xVSS_context->pOutputFile != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+        free(xVSS_context->pOutputFile);
         xVSS_context->pOutputFile = M4OSA_NULL;
     }
 
@@ -6091,9 +5455,9 @@
                                 - 1].filePathSize
                                 == pVSSContext->pClipList[i].filePathSize )
                             {
-                                cmpResult = M4OSA_memcmp(pVSSContext->
+                                cmpResult = memcmp((void *)pVSSContext->
                                     pClipList[pVSSContext->uiCurrentClip
-                                    - 1].pFile, pVSSContext->pClipList[i].pFile,
+                                    - 1].pFile, (void *)pVSSContext->pClipList[i].pFile,
                                     pVSSContext->
                                     pClipList[pVSSContext->uiCurrentClip
                                     - 1].filePathSize);
@@ -6125,45 +5489,45 @@
                                     - 1].pFile, (M4OSA_Void *)xVSS_context->
                                     UTFConversionContext.
                                     pTempOutConversionBuffer, &ConvertedSize);
-                                err = M4OSA_chrFindPattern(xVSS_context->
+                                toto = (M4OSA_Char *)strstr((const char *)xVSS_context->
                                     UTFConversionContext.
                                     pTempOutConversionBuffer,
-                                    xVSS_context->pTempPath, &toto);
+                                    (const char *)xVSS_context->pTempPath);
                                 pTmpStr =
                                     xVSS_context->UTFConversionContext.
                                     pTempOutConversionBuffer;
                             }
                             else
                             {
-                                err = M4OSA_chrFindPattern(pVSSContext->
+                                toto = (M4OSA_Char *)strstr((const char *)pVSSContext->
                                     pClipList[pVSSContext->uiCurrentClip
-                                    - 1].pFile, xVSS_context->pTempPath, &toto);
+                                    - 1].pFile, (const char *)xVSS_context->pTempPath);
                                 pTmpStr = pVSSContext->
                                     pClipList[pVSSContext->uiCurrentClip
                                     - 1].pFile;
                             }
 
-                            if( err == M4NO_ERROR )
+                            if( toto != M4OSA_NULL )
                             {
                                 /* As temporary files can be imgXXX.3gp or vidXXX.3gp */
                                 pTmpStr +=
-                                    (M4OSA_chrLength(pTmpStr)
+                                    (strlen((const char *)pTmpStr)
                                     - 10); /* Because temporary files have a length at most of
                                     10 bytes */
-                                err = M4OSA_chrFindPattern(pTmpStr,
-                                    (M4OSA_Char *)"img", &toto);
+                                toto = (M4OSA_Char *)strstr((const char *)pTmpStr,
+                                    (const char *)"img");
 
-                                if( err != M4NO_ERROR )
+                                if( toto != M4OSA_NULL )
                                 {
-                                    err = M4OSA_chrFindPattern(pTmpStr,
-                                        (M4OSA_Char *)"vid", &toto);
+                                    toto = (M4OSA_Char *)strstr((const char *)pTmpStr,
+                                        (const char *)"vid");
                                 }
 
                                 if( err
                                     == M4NO_ERROR ) /* It means the file is a temporary file, we
                                     can delete it */
                                 {
-                                    M4OSA_fileExtraDelete(pVSSContext->
+                                    remove((const char *)pVSSContext->
                                         pClipList[pVSSContext->uiCurrentClip
                                         - 1].pFile);
                                 }
@@ -6595,12 +5959,12 @@
                 if( xVSS_context->pSettings->xVSS.pBGMtrack != M4OSA_NULL ) {
                     /*if(M4OSA_NULL != xVSS_context->pSettings->pOutputFile)
                     {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->pOutputFile);
+                    free(xVSS_context->pSettings->pOutputFile);
                     xVSS_context->pSettings->pOutputFile = M4OSA_NULL;
                     }*/
                     /*if(M4OSA_NULL != xVSS_context->pSettings->pTemporaryFile)
                     {
-                    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->pTemporaryFile);
+                    free(xVSS_context->pSettings->pTemporaryFile);
                     xVSS_context->pSettings->pTemporaryFile = M4OSA_NULL;
                     }*/
                 }
@@ -6700,84 +6064,25 @@
     if( xVSS_context->UTFConversionContext.pTempOutConversionBuffer
         != M4OSA_NULL )
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->
+        free(xVSS_context->
             UTFConversionContext.pTempOutConversionBuffer);
         xVSS_context->UTFConversionContext.pTempOutConversionBuffer =
             M4OSA_NULL;
     }
 
-    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pTempPath);
+    free(xVSS_context->pTempPath);
     xVSS_context->pTempPath = M4OSA_NULL;
 
-    M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings);
+    free(xVSS_context->pSettings);
     xVSS_context->pSettings = M4OSA_NULL;
 
-    M4OSA_free((M4OSA_MemAddr32)xVSS_context);
+    free(xVSS_context);
     xVSS_context = M4OSA_NULL;
     M4OSA_TRACE3_0("M4xVSS_CleanUp:leaving ");
 
     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 71a8929..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 @@
         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,
@@ -171,9 +132,6 @@
         break;
     }
     /**/
-#ifdef TIMESCALE_BUG
-    Params.OutputVideoTimescale = xVSS_context->pMCScurrentParams->OutputVideoTimescale;
-#endif
     // new params after integrating MCS 2.0
     // Set the number of audio effects; 0 for now.
     Params.nbEffects = 0;
@@ -306,7 +264,7 @@
     M4OSA_ERR err=M4NO_ERROR;
 
 
-    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_malloc(frameSize_argb,
+    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_32bitAlignedMalloc(frameSize_argb,
          M4VS, (M4OSA_Char*)"Image argb data");
         M4OSA_TRACE1_0("M4xVSS_internalConvertAndResizeARGB8888toYUV420 Entering :");
     if(pTmpData == M4OSA_NULL) {
@@ -323,7 +281,7 @@
     {
         M4OSA_TRACE1_2("M4xVSS_internalConvertAndResizeARGB8888toYUV420 :\
             Can't open input ARGB8888 file %s, error: 0x%x\n",pFileIn, err);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         goto cleanup;
     }
@@ -334,7 +292,7 @@
         M4OSA_TRACE1_2("M4xVSS_internalConvertAndResizeARGB8888toYUV420 Can't close ARGB8888\
              file %s, error: 0x%x\n",pFileIn, err);
         pFileReadPtr->closeRead(pARGBIn);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         goto cleanup;
     }
@@ -344,18 +302,18 @@
     {
         M4OSA_TRACE1_2("M4xVSS_internalConvertAndResizeARGB8888toYUV420 Can't close ARGB8888 \
              file %s, error: 0x%x\n",pFileIn, err);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         goto cleanup;
     }
 
-    rgbPlane1.pac_data = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS,
+    rgbPlane1.pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS,
          (M4OSA_Char*)"Image clip RGB888 data");
     if(rgbPlane1.pac_data == M4OSA_NULL)
     {
         M4OSA_TRACE1_0("M4xVSS_internalConvertAndResizeARGB8888toYUV420 \
             Failed to allocate memory for Image clip");
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         return M4ERR_ALLOC;
     }
 
@@ -371,19 +329,19 @@
         rgbPlane1.pac_data[j] = pTmpData[i];
         j++;
     }
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
 
     /* To Check if resizing is required with color conversion */
     if(width != pImagePlanes->u_width || height != pImagePlanes->u_height)
     {
         M4OSA_TRACE1_0("M4xVSS_internalConvertAndResizeARGB8888toYUV420 Resizing :");
         frameSize =  ( pImagePlanes->u_width * pImagePlanes->u_height * 3);
-        rgbPlane2.pac_data = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS,
+        rgbPlane2.pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS,
              (M4OSA_Char*)"Image clip RGB888 data");
         if(rgbPlane2.pac_data == M4OSA_NULL)
         {
             M4OSA_TRACE1_0("Failed to allocate memory for Image clip");
-            M4OSA_free((M4OSA_MemAddr32)pTmpData);
+            free(pTmpData);
             return M4ERR_ALLOC;
         }
             rgbPlane2.u_height =  pImagePlanes->u_height;
@@ -396,8 +354,8 @@
         if(err != M4NO_ERROR)
         {
             M4OSA_TRACE1_1("error when converting from Resize RGB888 to RGB888: 0x%x\n", err);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane2.pac_data);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane1.pac_data);
+            free(rgbPlane2.pac_data);
+            free(rgbPlane1.pac_data);
             return err;
         }
         /*Converting Resized RGB888 to YUV420 */
@@ -405,12 +363,12 @@
         if(err != M4NO_ERROR)
         {
             M4OSA_TRACE1_1("error when converting from RGB888 to YUV: 0x%x\n", err);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane2.pac_data);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane1.pac_data);
+            free(rgbPlane2.pac_data);
+            free(rgbPlane1.pac_data);
             return err;
         }
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane2.pac_data);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane1.pac_data);
+            free(rgbPlane2.pac_data);
+            free(rgbPlane1.pac_data);
 
             M4OSA_TRACE1_0("RGB to YUV done");
 
@@ -424,7 +382,7 @@
         {
             M4OSA_TRACE1_1("error when converting from RGB to YUV: 0x%x\n", err);
         }
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane1.pac_data);
+            free(rgbPlane1.pac_data);
 
             M4OSA_TRACE1_0("RGB to YUV done");
     }
@@ -463,7 +421,7 @@
     M4OSA_ERR err = M4NO_ERROR;
     M4VIFI_ImagePlane *yuvPlane = M4OSA_NULL;
 
-    yuvPlane = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane),
+    yuvPlane = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane),
                 M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");
     if(yuvPlane == M4OSA_NULL) {
         M4OSA_TRACE1_0("M4xVSS_internalConvertAndResizeARGB8888toYUV420 :\
@@ -474,7 +432,7 @@
     yuvPlane[0].u_width = width;
     yuvPlane[0].u_stride = width;
     yuvPlane[0].u_topleft = 0;
-    yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc(yuvPlane[0].u_height \
+    yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(yuvPlane[0].u_height \
         * yuvPlane[0].u_width * 1.5, M4VS, (M4OSA_Char*)"imageClip YUV data");
 
     yuvPlane[1].u_height = yuvPlane[0].u_height >>1;
@@ -495,7 +453,7 @@
     if(err != M4NO_ERROR)
     {
         M4OSA_TRACE1_1("M4xVSS_internalConvertAndResizeARGB8888toYUV420 return error: 0x%x\n", err);
-        M4OSA_free((M4OSA_MemAddr32)yuvPlane);
+        free(yuvPlane);
         return err;
     }
 
@@ -600,9 +558,9 @@
                         (contigous planes in memory) */
                     if(pC->m_pDecodedPlane->pac_data != M4OSA_NULL)
                     {
-                        M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane->pac_data);
+                        free(pC->m_pDecodedPlane->pac_data);
                     }
-                    M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane);
+                    free(pC->m_pDecodedPlane);
                     pC->m_pDecodedPlane = M4OSA_NULL;
                 }
                 return err;
@@ -629,49 +587,6 @@
             /*Save ratio values, they can be reused if the new ratios are 0*/
             tempPanzoomXa = (M4OSA_UInt8)pC->m_pPto3GPPparams->PanZoomXa;
             tempPanzoomXb = (M4OSA_UInt8)pC->m_pPto3GPPparams->PanZoomXb;
-#if 0
-            /**
-             * Check size of output JPEG is compatible with pan & zoom parameters
-               First, check final (b) parameters */
-            if(pC->m_pPto3GPPparams->PanZoomXb + pC->m_pPto3GPPparams->PanZoomTopleftXb > 100 )
-            {
-                M4OSA_TRACE1_1("WARNING : Bad final Pan & Zoom settings !!!\
-                    New final Zoom ratio is: %d", (100 - pC->m_pPto3GPPparams->PanZoomTopleftXb));
-                /* We do not change the topleft parameter as it may correspond to a precise area
-                of the picture -> only the zoom ratio is modified */
-                pC->m_pPto3GPPparams->PanZoomXb = 100 - pC->m_pPto3GPPparams->PanZoomTopleftXb;
-            }
-
-            if(pC->m_pPto3GPPparams->PanZoomXb + pC->m_pPto3GPPparams->PanZoomTopleftYb > 100 )
-            {
-                M4OSA_TRACE1_1("WARNING : Bad final Pan & Zoom settings \
-                    !!! New final Zoom ratio is: %d",
-                    (100 - pC->m_pPto3GPPparams->PanZoomTopleftYb));
-                /* We do not change the topleft parameter as it may correspond to a
-                precise area of the picture -> only the zoom ratio is modified */
-                pC->m_pPto3GPPparams->PanZoomXb = 100 - pC->m_pPto3GPPparams->PanZoomTopleftYb;
-            }
-
-            /**
-             * Then, check initial (a) parameters */
-            if(pC->m_pPto3GPPparams->PanZoomXa + pC->m_pPto3GPPparams->PanZoomTopleftXa > 100 )
-            {
-                M4OSA_TRACE1_1("WARNING : Bad initial Pan & Zoom settings !!! \
-                    New initial Zoom ratio is: %d",(100 - pC->m_pPto3GPPparams->PanZoomTopleftXa));
-                /* We do not change the topleft parameter as it may correspond to a precise
-                area of the picture-> only the zoom ratio is modified */
-                pC->m_pPto3GPPparams->PanZoomXa = 100 - pC->m_pPto3GPPparams->PanZoomTopleftXa;
-            }
-
-            if(pC->m_pPto3GPPparams->PanZoomXa + pC->m_pPto3GPPparams->PanZoomTopleftYa > 100 )
-            {
-                M4OSA_TRACE1_1("WARNING : Bad initial Pan & Zoom settings !!! New initial\
-                     Zoom ratio is: %d", (100 - pC->m_pPto3GPPparams->PanZoomTopleftYa));
-                /* We do not change the topleft parameter as it may correspond to a precise
-                area of the picture-> only the zoom ratio is modified */
-                pC->m_pPto3GPPparams->PanZoomXa = 100 - pC->m_pPto3GPPparams->PanZoomTopleftYa;
-            }
-#endif
             /*Check that the ratio is not 0*/
             /*Check (a) parameters*/
             if(pC->m_pPto3GPPparams->PanZoomXa == 0)
@@ -878,12 +793,12 @@
 
         if(pC->m_mediaRendering == M4xVSS_kBlackBorders)
         {
-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanes[0].pac_data,
-                (pImagePlanes[0].u_height*pImagePlanes[0].u_stride),Y_PLANE_BORDER_VALUE);
-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanes[1].pac_data,
-                (pImagePlanes[1].u_height*pImagePlanes[1].u_stride),U_PLANE_BORDER_VALUE);
-            M4OSA_memset((M4OSA_MemAddr8)pImagePlanes[2].pac_data,
-                (pImagePlanes[2].u_height*pImagePlanes[2].u_stride),V_PLANE_BORDER_VALUE);
+            memset((void *)pImagePlanes[0].pac_data,Y_PLANE_BORDER_VALUE,
+                (pImagePlanes[0].u_height*pImagePlanes[0].u_stride));
+            memset((void *)pImagePlanes[1].pac_data,U_PLANE_BORDER_VALUE,
+                (pImagePlanes[1].u_height*pImagePlanes[1].u_stride));
+            memset((void *)pImagePlanes[2].pac_data,V_PLANE_BORDER_VALUE,
+                (pImagePlanes[2].u_height*pImagePlanes[2].u_stride));
 
             /**
             First without pan&zoom*/
@@ -1471,8 +1386,8 @@
             err = M4AIR_create(&pC->m_air_context, M4AIR_kYUV420P);
             if(err != M4NO_ERROR)
             {
-                M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane[0].pac_data);
-                M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane);
+                free(pC->m_pDecodedPlane[0].pac_data);
+                free(pC->m_pDecodedPlane);
                 pC->m_pDecodedPlane = M4OSA_NULL;
                 M4OSA_TRACE1_1("M4xVSS_PictureCallbackFct:\
                      Error when initializing AIR: 0x%x", err);
@@ -1486,8 +1401,8 @@
             M4OSA_TRACE1_1("M4xVSS_PictureCallbackFct:\
                  Error when configuring AIR: 0x%x", err);
             M4AIR_cleanUp(pC->m_air_context);
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane[0].pac_data);
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane);
+            free(pC->m_pDecodedPlane[0].pac_data);
+            free(pC->m_pDecodedPlane);
             pC->m_pDecodedPlane = M4OSA_NULL;
             return err;
         }
@@ -1497,8 +1412,8 @@
         {
             M4OSA_TRACE1_1("M4xVSS_PictureCallbackFct: Error when getting AIR plane: 0x%x", err);
             M4AIR_cleanUp(pC->m_air_context);
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane[0].pac_data);
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane);
+            free(pC->m_pDecodedPlane[0].pac_data);
+            free(pC->m_pDecodedPlane);
             pC->m_pDecodedPlane = M4OSA_NULL;
             return err;
         }
@@ -1533,8 +1448,8 @@
         }
         if(M4OSA_NULL != pC->m_pDecodedPlane)
         {
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane[0].pac_data);
-            M4OSA_free((M4OSA_MemAddr32)pC->m_pDecodedPlane);
+            free(pC->m_pDecodedPlane[0].pac_data);
+            free(pC->m_pDecodedPlane);
             pC->m_pDecodedPlane = M4OSA_NULL;
         }
         return M4PTO3GPP_WAR_LAST_PICTURE;
@@ -1596,25 +1511,7 @@
         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_malloc(sizeof(M4xVSS_PictureCallbackCtxt),
+    pCallBackCtxt = (M4xVSS_PictureCallbackCtxt*)M4OSA_32bitAlignedMalloc(sizeof(M4xVSS_PictureCallbackCtxt),
          M4VS,(M4OSA_Char *) "Pto3gpp callback struct");
     if(pCallBackCtxt == M4OSA_NULL)
     {
@@ -1628,7 +1525,7 @@
     /**
      * Generate "dummy" amr file containing silence in temporary folder */
     M4OSA_chrNCopy(out_amr, xVSS_context->pTempPath, M4XVSS_MAX_PATH_LEN - 1);
-    M4OSA_chrNCat(out_amr, (M4OSA_Char *)"dummy.amr\0", 10);
+    strncat((char *)out_amr, (const char *)"dummy.amr\0", 10);
 
     /**
      * UTF conversion: convert the temporary path into the customer format*/
@@ -1739,7 +1636,7 @@
         M4OSA_TRACE1_1("M4PTO3GPP_Open returned: 0x%x\n",err);
         if(pCallBackCtxt != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)pCallBackCtxt);
+            free(pCallBackCtxt);
             pCallBackCtxt = M4OSA_NULL;
         }
         M4PTO3GPP_CleanUp(pM4PTO3GPP_Ctxt);
@@ -1777,7 +1674,7 @@
     * Free the PTO3GPP callback context */
     if(M4OSA_NULL != xVSS_context->pCallBackCtxt)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCallBackCtxt);
+        free(xVSS_context->pCallBackCtxt);
         xVSS_context->pCallBackCtxt = M4OSA_NULL;
     }
 
@@ -1803,7 +1700,7 @@
     /**
      * Remove dummy.amr file */
     M4OSA_chrNCopy(out_amr, xVSS_context->pTempPath, M4XVSS_MAX_PATH_LEN - 1);
-    M4OSA_chrNCat(out_amr, (M4OSA_Char *)"dummy.amr\0", 10);
+    strncat((char *)out_amr, (const char *)"dummy.amr\0", 10);
 
     /**
      * UTF conversion: convert the temporary path into the customer format*/
@@ -1825,10 +1722,10 @@
     }
     /**
     * End of the conversion, now use the decoded path*/
-    M4OSA_fileExtraDelete(pDecodedPath);
+    remove((const char *)pDecodedPath);
 
     /*Commented because of the use of the UTF conversion*/
-/*    M4OSA_fileExtraDelete(out_amr);
+/*    remove(out_amr);
  */
 
     xVSS_context->pM4PTO3GPP_Ctxt = M4OSA_NULL;
@@ -1856,7 +1753,7 @@
 
     /**
      * Allocate output YUV planes */
-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane),
+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane),
          M4VS, (M4OSA_Char *)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");
     if(framingCtx->FramingYuv == M4OSA_NULL)
     {
@@ -1868,7 +1765,7 @@
     framingCtx->FramingYuv[0].u_topleft = 0;
     framingCtx->FramingYuv[0].u_stride = framingCtx->FramingRgb->u_width;
     framingCtx->FramingYuv[0].pac_data =
-         (M4VIFI_UInt8*)M4OSA_malloc((framingCtx->FramingYuv[0].u_width\
+         (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc((framingCtx->FramingYuv[0].u_width\
             *framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char *)\
                 "Alloc for the Convertion output YUV");;
     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)
@@ -1982,7 +1879,7 @@
     M4OSA_TRACE1_2("M4xVSS_internalConvertARGB888toYUV420_FrammingEffect width and height %d %d ",
         framingCtx->width,framingCtx->height);
 
-    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_malloc(frameSize_argb, M4VS, (M4OSA_Char*)\
+    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_32bitAlignedMalloc(frameSize_argb, M4VS, (M4OSA_Char*)\
         "Image argb data");
     if(pTmpData == M4OSA_NULL) {
         M4OSA_TRACE1_0("Failed to allocate memory for Image clip");
@@ -2002,7 +1899,7 @@
         {
             M4OSA_TRACE1_1("M4xVSS_internalDecodePNG:\
                  M4xVSS_internalConvertFromUTF8 returns err: 0x%x",err);
-            M4OSA_free((M4OSA_MemAddr32)pTmpData);
+            free(pTmpData);
             pTmpData = M4OSA_NULL;
             return err;
         }
@@ -2018,7 +1915,7 @@
     if(err != M4NO_ERROR)
     {
         M4OSA_TRACE1_2("Can't open input ARGB8888 file %s, error: 0x%x\n",pFile, err);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         return err;
     }
@@ -2027,7 +1924,7 @@
     if(err != M4NO_ERROR)
     {
         xVSS_context->pFileReadPtr->closeRead(pARGBIn);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         return err;
     }
@@ -2037,7 +1934,7 @@
     if(err != M4NO_ERROR)
     {
         M4OSA_TRACE1_2("Can't close input png file %s, error: 0x%x\n",pFile, err);
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         pTmpData = M4OSA_NULL;
         return err;
     }
@@ -2049,12 +1946,12 @@
     rgbPlane.u_topleft = 0;
 
     frameSize = (rgbPlane.u_width * rgbPlane.u_height * 3); //Size of RGB888 data
-    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_malloc(((frameSize)+ (2 * framingCtx->width)),
+    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(((frameSize)+ (2 * framingCtx->width)),
          M4VS, (M4OSA_Char*)"Image clip RGB888 data");
     if(rgbPlane.pac_data == M4OSA_NULL)
     {
         M4OSA_TRACE1_0("Failed to allocate memory for Image clip");
-        M4OSA_free((M4OSA_MemAddr32)pTmpData);
+        free(pTmpData);
         return M4ERR_ALLOC;
     }
 
@@ -2087,18 +1984,18 @@
         j++;
     }
 
-    M4OSA_free((M4OSA_MemAddr32)pTmpData);
+    free(pTmpData);
     pTmpData = M4OSA_NULL;
 
     /* convert RGB888 to RGB565 */
 
     /* allocate temp RGB 565 buffer */
-    TempPacData = (M4VIFI_UInt8*)M4OSA_malloc(frameSize +
+    TempPacData = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize +
                        (4 * (framingCtx->width + framingCtx->height + 1)),
                         M4VS, (M4OSA_Char*)"Image clip RGB565 data");
     if (TempPacData == M4OSA_NULL) {
         M4OSA_TRACE1_0("Failed to allocate memory for Image clip RGB565 data");
-        M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);
+        free(rgbPlane.pac_data);
         return M4ERR_ALLOC;
     }
 
@@ -2113,7 +2010,7 @@
     }
 
     /* free the RBG888 and assign RGB565 */
-    M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);
+    free(rgbPlane.pac_data);
     rgbPlane.pac_data = TempPacData;
 
     /**
@@ -2150,14 +2047,14 @@
         /**
          * We need to allocate a new RGB output buffer in which all decoded data
           + white line will be copied */
-        newRGBpac_data = (M4VIFI_UInt8*)M4OSA_malloc(rgbPlane.u_height*rgbPlane.u_width*2\
+        newRGBpac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(rgbPlane.u_height*rgbPlane.u_width*2\
             *sizeof(M4VIFI_UInt8), M4VS, (M4OSA_Char *)"New Framing GIF Output pac_data RGB");
 
         if(newRGBpac_data == M4OSA_NULL)
         {
             M4OSA_TRACE1_0("Allocation error in \
                 M4xVSS_internalConvertARGB888toYUV420_FrammingEffect");
-            M4OSA_free((M4OSA_MemAddr8)rgbPlane.pac_data);
+            free(rgbPlane.pac_data);
             return M4ERR_ALLOC;
         }
 
@@ -2166,7 +2063,7 @@
 
         for(i=0;i<rgbPlane.u_height;i++)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)output_pac_data, (M4OSA_MemAddr8)input_pac_data,
+            memcpy((void *)output_pac_data, (void *)input_pac_data,
                  (rgbPlane.u_width-1)*2);
 
             output_pac_data += ((rgbPlane.u_width-1)*2);
@@ -2176,7 +2073,7 @@
 
             input_pac_data += ((rgbPlane.u_width-1)*2);
         }
-        M4OSA_free((M4OSA_MemAddr8)rgbPlane.pac_data);
+        free(rgbPlane.pac_data);
         rgbPlane.pac_data = newRGBpac_data;
     }
 
@@ -2265,7 +2162,7 @@
 
     /**
      * Allocate output planes structures */
-    framingCtx->FramingRgb = (M4VIFI_ImagePlane*)M4OSA_malloc(sizeof(M4VIFI_ImagePlane), M4VS,
+    framingCtx->FramingRgb = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane), M4VS,
          (M4OSA_Char *)"Framing Output plane RGB");
     if(framingCtx->FramingRgb == M4OSA_NULL)
     {
@@ -2289,7 +2186,7 @@
         framingCtx->FramingRgb->u_topleft = 0;
 
         framingCtx->FramingRgb->pac_data =
-             (M4VIFI_UInt8*)M4OSA_malloc(framingCtx->FramingRgb->u_height*framingCtx->\
+             (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(framingCtx->FramingRgb->u_height*framingCtx->\
                 FramingRgb->u_width*2*sizeof(M4VIFI_UInt8), M4VS,
                   (M4OSA_Char *)"Framing Output pac_data RGB");
 
@@ -2297,8 +2194,8 @@
         {
             M4OSA_TRACE1_0("Allocation error in \
                 M4xVSS_internalConvertARGB888toYUV420_FrammingEffect");
-            M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb);
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);
+            free(framingCtx->FramingRgb);
+            free(rgbPlane.pac_data);
             return M4ERR_ALLOC;
         }
 
@@ -2318,7 +2215,7 @@
 
         if(rgbPlane.pac_data != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);
+            free(rgbPlane.pac_data);
             rgbPlane.pac_data = M4OSA_NULL;
         }
     }
@@ -2350,12 +2247,12 @@
     /**
      * Convert  RGB output to YUV 420 to be able to merge it with output video in framing
      effect */
-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS,
+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS,
          (M4OSA_Char *)"Framing Output plane YUV");
     if(framingCtx->FramingYuv == M4OSA_NULL)
     {
         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertARGB888toYUV420_FrammingEffect");
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb->pac_data);
+        free(framingCtx->FramingRgb->pac_data);
         return M4ERR_ALLOC;
     }
 
@@ -2364,14 +2261,14 @@
     framingCtx->FramingYuv[0].u_height = ((height+1)>>1)<<1;
     framingCtx->FramingYuv[0].u_topleft = 0;
     framingCtx->FramingYuv[0].u_stride = ((width+1)>>1)<<1;
-    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc
+    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc
         ((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height), M4VS,
             (M4OSA_Char *)"Alloc for the output Y");
     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)
     {
         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertARGB888toYUV420_FrammingEffect");
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb->pac_data);
+        free(framingCtx->FramingYuv);
+        free(framingCtx->FramingRgb->pac_data);
         return M4ERR_ALLOC;
     }
     framingCtx->FramingYuv[1].u_width = (((width+1)>>1)<<1)>>1;
@@ -2380,13 +2277,13 @@
     framingCtx->FramingYuv[1].u_stride = (((width+1)>>1)<<1)>>1;
 
 
-    framingCtx->FramingYuv[1].pac_data = (M4VIFI_UInt8*)M4OSA_malloc(
+    framingCtx->FramingYuv[1].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(
         framingCtx->FramingYuv[1].u_width * framingCtx->FramingYuv[1].u_height, M4VS,
         (M4OSA_Char *)"Alloc for the output U");
     if (framingCtx->FramingYuv[1].pac_data == M4OSA_NULL) {
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv[0].pac_data);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb->pac_data);
+        free(framingCtx->FramingYuv[0].pac_data);
+        free(framingCtx->FramingYuv);
+        free(framingCtx->FramingRgb->pac_data);
         return M4ERR_ALLOC;
     }
 
@@ -2396,14 +2293,14 @@
     framingCtx->FramingYuv[2].u_stride = (((width+1)>>1)<<1)>>1;
 
 
-    framingCtx->FramingYuv[2].pac_data = (M4VIFI_UInt8*)M4OSA_malloc(
+    framingCtx->FramingYuv[2].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(
         framingCtx->FramingYuv[2].u_width * framingCtx->FramingYuv[0].u_height, M4VS,
         (M4OSA_Char *)"Alloc for the  output V");
     if (framingCtx->FramingYuv[2].pac_data == M4OSA_NULL) {
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv[1].pac_data);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv[0].pac_data);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv);
-        M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb->pac_data);
+        free(framingCtx->FramingYuv[1].pac_data);
+        free(framingCtx->FramingYuv[0].pac_data);
+        free(framingCtx->FramingYuv);
+        free(framingCtx->FramingRgb->pac_data);
         return M4ERR_ALLOC;
     }
 
@@ -2417,7 +2314,6 @@
     {
         M4OSA_TRACE1_1("SPS png: error when converting from RGB to YUV: 0x%x\n", err);
     }
-
     M4OSA_TRACE3_0("M4xVSS_internalConvertARGB888toYUV420_FrammingEffect:  Leaving ");
     return err;
 }
@@ -2453,44 +2349,6 @@
         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)
     {
@@ -2732,7 +2590,7 @@
 
     /**
      * Allocate audio mixing settings structure and fill it with BGM parameters */
-    pAudioMixSettings = (M4VSS3GPP_AudioMixingSettings*)M4OSA_malloc
+    pAudioMixSettings = (M4VSS3GPP_AudioMixingSettings*)M4OSA_32bitAlignedMalloc
         (sizeof(M4VSS3GPP_AudioMixingSettings), M4VS, (M4OSA_Char *)"pAudioMixSettings");
     if(pAudioMixSettings == M4OSA_NULL)
     {
@@ -2871,7 +2729,7 @@
      * Free VSS audio mixing settings */
     if(xVSS_context->pAudioMixSettings != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pAudioMixSettings);
+        free(xVSS_context->pAudioMixSettings);
         xVSS_context->pAudioMixSettings = M4OSA_NULL;
     }
 
@@ -2902,14 +2760,14 @@
     {
         M4xVSS_FreeClipSettings(xVSS_context->pCurrentEditSettings->pClipList[i]);
 
-        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pClipList[i]));
+        free((xVSS_context->pCurrentEditSettings->pClipList[i]));
         xVSS_context->pCurrentEditSettings->pClipList[i] = M4OSA_NULL;
 
         /**
          * Because there is 1 less transition than clip number */
         if(i != xVSS_context->pCurrentEditSettings->uiClipNumber-1)
         {
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pTransitionList[i]));
+            free((xVSS_context->pCurrentEditSettings->pTransitionList[i]));
             xVSS_context->pCurrentEditSettings->pTransitionList[i] = M4OSA_NULL;
         }
     }
@@ -2918,12 +2776,12 @@
      * Free clip/transition list */
     if(xVSS_context->pCurrentEditSettings->pClipList != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pClipList));
+        free((xVSS_context->pCurrentEditSettings->pClipList));
         xVSS_context->pCurrentEditSettings->pClipList = M4OSA_NULL;
     }
     if(xVSS_context->pCurrentEditSettings->pTransitionList != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pTransitionList));
+        free((xVSS_context->pCurrentEditSettings->pTransitionList));
         xVSS_context->pCurrentEditSettings->pTransitionList = M4OSA_NULL;
     }
 
@@ -2931,7 +2789,7 @@
      * Free output preview file path */
     if(xVSS_context->pCurrentEditSettings->pOutputFile != M4OSA_NULL)
     {
-        M4OSA_free(xVSS_context->pCurrentEditSettings->pOutputFile);
+        free(xVSS_context->pCurrentEditSettings->pOutputFile);
         xVSS_context->pCurrentEditSettings->pOutputFile = M4OSA_NULL;
     }
 
@@ -2939,8 +2797,8 @@
      * Free temporary preview file path */
     if(xVSS_context->pCurrentEditSettings->pTemporaryFile != M4OSA_NULL)
     {
-        M4OSA_fileExtraDelete(xVSS_context->pCurrentEditSettings->pTemporaryFile);
-        M4OSA_free(xVSS_context->pCurrentEditSettings->pTemporaryFile);
+        remove((const char *)xVSS_context->pCurrentEditSettings->pTemporaryFile);
+        free(xVSS_context->pCurrentEditSettings->pTemporaryFile);
         xVSS_context->pCurrentEditSettings->pTemporaryFile = M4OSA_NULL;
     }
 
@@ -2950,10 +2808,10 @@
     {
         if(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile != M4OSA_NULL)
         {
-            M4OSA_free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile);
+            free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile);
             xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile = M4OSA_NULL;
         }
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack);
+        free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack);
         xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack = M4OSA_NULL;
     }
 
@@ -2961,7 +2819,7 @@
      * Free current edit settings structure */
     if(xVSS_context->pCurrentEditSettings != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings);
+        free(xVSS_context->pCurrentEditSettings);
         xVSS_context->pCurrentEditSettings = M4OSA_NULL;
     }
 
@@ -2969,7 +2827,7 @@
      * Free preview effects given to application */
     if(M4OSA_NULL != xVSS_context->pPreviewSettings->Effects)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pPreviewSettings->Effects);
+        free(xVSS_context->pPreviewSettings->Effects);
         xVSS_context->pPreviewSettings->Effects = M4OSA_NULL;
         xVSS_context->pPreviewSettings->nbEffects = 0;
     }
@@ -3004,14 +2862,14 @@
         {
             M4xVSS_FreeClipSettings(xVSS_context->pCurrentEditSettings->pClipList[i]);
 
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pClipList[i]));
+            free((xVSS_context->pCurrentEditSettings->pClipList[i]));
             xVSS_context->pCurrentEditSettings->pClipList[i] = M4OSA_NULL;
 
             /**
              * Because there is 1 less transition than clip number */
             if(i != xVSS_context->pCurrentEditSettings->uiClipNumber-1)
             {
-                M4OSA_free((M4OSA_MemAddr32)\
+                free(\
                     (xVSS_context->pCurrentEditSettings->pTransitionList[i]));
                 xVSS_context->pCurrentEditSettings->pTransitionList[i] = M4OSA_NULL;
             }
@@ -3021,18 +2879,18 @@
          * Free clip/transition list */
         if(xVSS_context->pCurrentEditSettings->pClipList != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pClipList));
+            free((xVSS_context->pCurrentEditSettings->pClipList));
             xVSS_context->pCurrentEditSettings->pClipList = M4OSA_NULL;
         }
         if(xVSS_context->pCurrentEditSettings->pTransitionList != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->pTransitionList));
+            free((xVSS_context->pCurrentEditSettings->pTransitionList));
             xVSS_context->pCurrentEditSettings->pTransitionList = M4OSA_NULL;
         }
 
         if(xVSS_context->pCurrentEditSettings->Effects != M4OSA_NULL)
         {
-            M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pCurrentEditSettings->Effects));
+            free((xVSS_context->pCurrentEditSettings->Effects));
             xVSS_context->pCurrentEditSettings->Effects = M4OSA_NULL;
             xVSS_context->pCurrentEditSettings->nbEffects = 0;
         }
@@ -3043,12 +2901,12 @@
         {
             if(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack != M4OSA_NULL)
             {
-                M4OSA_fileExtraDelete(xVSS_context->pCurrentEditSettings->pOutputFile);
-                M4OSA_free(xVSS_context->pCurrentEditSettings->pOutputFile);
+                remove((const char *)xVSS_context->pCurrentEditSettings->pOutputFile);
+                free(xVSS_context->pCurrentEditSettings->pOutputFile);
             }
             if(xVSS_context->pOutputFile != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)xVSS_context->pOutputFile);
+                free(xVSS_context->pOutputFile);
                 xVSS_context->pOutputFile = M4OSA_NULL;
             }
             xVSS_context->pSettings->pOutputFile = M4OSA_NULL;
@@ -3059,8 +2917,8 @@
          * Free temporary saving file path */
         if(xVSS_context->pCurrentEditSettings->pTemporaryFile != M4OSA_NULL)
         {
-            M4OSA_fileExtraDelete(xVSS_context->pCurrentEditSettings->pTemporaryFile);
-            M4OSA_free(xVSS_context->pCurrentEditSettings->pTemporaryFile);
+            remove((const char *)xVSS_context->pCurrentEditSettings->pTemporaryFile);
+            free(xVSS_context->pCurrentEditSettings->pTemporaryFile);
             xVSS_context->pCurrentEditSettings->pTemporaryFile = M4OSA_NULL;
         }
 
@@ -3070,16 +2928,16 @@
         {
             if(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile != M4OSA_NULL)
             {
-                M4OSA_free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile);
+                free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile);
                 xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack->pFile = M4OSA_NULL;
             }
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack);
+            free(xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack);
             xVSS_context->pCurrentEditSettings->xVSS.pBGMtrack = M4OSA_NULL;
         }
 
         /**
          * Free current edit settings structure */
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pCurrentEditSettings);
+        free(xVSS_context->pCurrentEditSettings);
         xVSS_context->pCurrentEditSettings = M4OSA_NULL;
     }
 
@@ -3113,7 +2971,7 @@
         {
             M4xVSS_FreeClipSettings(pSettings->pClipList[i]);
 
-            M4OSA_free((M4OSA_MemAddr32)(pSettings->pClipList[i]));
+            free((pSettings->pClipList[i]));
             pSettings->pClipList[i] = M4OSA_NULL;
         }
 
@@ -3133,19 +2991,19 @@
                         if(pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt\
                              != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)(((M4xVSS_internal_AlphaMagicSettings*)\
+                            free((((M4xVSS_internal_AlphaMagicSettings*)\
                                 pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt)->\
                                     pPlane->pac_data));
                             ((M4xVSS_internal_AlphaMagicSettings*)pSettings->pTransitionList[i\
                                 ]->pExtVideoTransitionFctCtxt)->pPlane->pac_data = M4OSA_NULL;
 
-                            M4OSA_free((M4OSA_MemAddr32)(((M4xVSS_internal_AlphaMagicSettings*)\
+                            free((((M4xVSS_internal_AlphaMagicSettings*)\
                                 pSettings->pTransitionList[i]->\
                                     pExtVideoTransitionFctCtxt)->pPlane));
                             ((M4xVSS_internal_AlphaMagicSettings*)pSettings->pTransitionList[i]\
                                 ->pExtVideoTransitionFctCtxt)->pPlane = M4OSA_NULL;
 
-                            M4OSA_free((M4OSA_MemAddr32)(pSettings->pTransitionList[i]->\
+                            free((pSettings->pTransitionList[i]->\
                                 pExtVideoTransitionFctCtxt));
                             pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt = M4OSA_NULL;
 
@@ -3157,17 +3015,17 @@
                                      M4xVSS_kVideoTransitionType_AlphaMagic)
                                     {
                                         M4OSA_UInt32 pCmpResult=0;
-                                        M4OSA_chrCompare(pSettings->pTransitionList[i]->\
+                                        pCmpResult = strcmp((const char *)pSettings->pTransitionList[i]->\
                                             xVSS.transitionSpecific.pAlphaMagicSettings->\
                                                 pAlphaFilePath,
-                                                pSettings->pTransitionList[j]->\
+                                                (const char *)pSettings->pTransitionList[j]->\
                                                 xVSS.transitionSpecific.pAlphaMagicSettings->\
-                                                pAlphaFilePath, (M4OSA_Int32 *)&pCmpResult);
+                                                pAlphaFilePath);
                                         if(pCmpResult == 0)
                                         {
                                             /* Free extra internal alpha magic structure and put
                                             it to NULL to avoid refreeing it */
-                                            M4OSA_free((M4OSA_MemAddr32)(pSettings->\
+                                            free((pSettings->\
                                                 pTransitionList[j]->pExtVideoTransitionFctCtxt));
                                             pSettings->pTransitionList[j]->\
                                                 pExtVideoTransitionFctCtxt = M4OSA_NULL;
@@ -3184,7 +3042,7 @@
                                 xVSS.transitionSpecific.pAlphaMagicSettings->\
                                     pAlphaFilePath != M4OSA_NULL)
                             {
-                                M4OSA_free((M4OSA_MemAddr32)pSettings->\
+                                free(pSettings->\
                                     pTransitionList[i]->\
                                         xVSS.transitionSpecific.pAlphaMagicSettings->\
                                             pAlphaFilePath);
@@ -3192,7 +3050,7 @@
                                     xVSS.transitionSpecific.pAlphaMagicSettings->\
                                         pAlphaFilePath = M4OSA_NULL;
                             }
-                            M4OSA_free((M4OSA_MemAddr32)pSettings->pTransitionList[i]->\
+                            free(pSettings->pTransitionList[i]->\
                                 xVSS.transitionSpecific.pAlphaMagicSettings);
                             pSettings->pTransitionList[i]->\
                                 xVSS.transitionSpecific.pAlphaMagicSettings = M4OSA_NULL;
@@ -3206,14 +3064,14 @@
                         if (M4OSA_NULL != pSettings->pTransitionList[i]->\
                             xVSS.transitionSpecific.pSlideTransitionSettings)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)pSettings->pTransitionList[i]->\
+                            free(pSettings->pTransitionList[i]->\
                                 xVSS.transitionSpecific.pSlideTransitionSettings);
                             pSettings->pTransitionList[i]->\
                                 xVSS.transitionSpecific.pSlideTransitionSettings = M4OSA_NULL;
                         }
                         if(pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)(pSettings->pTransitionList[i]->\
+                            free((pSettings->pTransitionList[i]->\
                                 pExtVideoTransitionFctCtxt));
                             pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt = M4OSA_NULL;
                         }
@@ -3224,7 +3082,7 @@
                 }
                 /**
                  * Free transition settings structure */
-                M4OSA_free((M4OSA_MemAddr32)(pSettings->pTransitionList[i]));
+                free((pSettings->pTransitionList[i]));
                 pSettings->pTransitionList[i] = M4OSA_NULL;
             }
         }
@@ -3234,7 +3092,7 @@
      * Free clip list */
     if(pSettings->pClipList != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)(pSettings->pClipList));
+        free((pSettings->pClipList));
         pSettings->pClipList = M4OSA_NULL;
     }
 
@@ -3242,7 +3100,7 @@
      * Free transition list */
     if(pSettings->pTransitionList != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)(pSettings->pTransitionList));
+        free((pSettings->pTransitionList));
         pSettings->pTransitionList = M4OSA_NULL;
     }
 
@@ -3271,62 +3129,58 @@
                 {
                     if(framingCtx->aFramingCtx != M4OSA_NULL)
                     {
-                        if(pSettings->Effects[i].xVSS.pFramingBuffer == M4OSA_NULL)
                         {
                             if(framingCtx->aFramingCtx->FramingRgb != M4OSA_NULL)
                             {
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->\
+                                free(framingCtx->aFramingCtx->\
                                     FramingRgb->pac_data);
                                 framingCtx->aFramingCtx->FramingRgb->pac_data = M4OSA_NULL;
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->FramingRgb);
+                                free(framingCtx->aFramingCtx->FramingRgb);
                                 framingCtx->aFramingCtx->FramingRgb = M4OSA_NULL;
                             }
                         }
                         if(framingCtx->aFramingCtx->FramingYuv != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->\
+                            free(framingCtx->aFramingCtx->\
                                 FramingYuv[0].pac_data);
                             framingCtx->aFramingCtx->FramingYuv[0].pac_data = M4OSA_NULL;
-                           M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->\
+                           free(framingCtx->aFramingCtx->\
                                 FramingYuv[1].pac_data);
                             framingCtx->aFramingCtx->FramingYuv[1].pac_data = M4OSA_NULL;
-                           M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->\
+                           free(framingCtx->aFramingCtx->\
                                 FramingYuv[2].pac_data);
                             framingCtx->aFramingCtx->FramingYuv[2].pac_data = M4OSA_NULL;
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx->FramingYuv);
+                            free(framingCtx->aFramingCtx->FramingYuv);
                             framingCtx->aFramingCtx->FramingYuv = M4OSA_NULL;
                         }
-                        M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx);
+                        free(framingCtx->aFramingCtx);
                         framingCtx->aFramingCtx = M4OSA_NULL;
                     }
                     if(framingCtx->aFramingCtx_last != M4OSA_NULL)
                     {
-                        if(pSettings->Effects[i].xVSS.pFramingBuffer == M4OSA_NULL)
+                        if(framingCtx->aFramingCtx_last->FramingRgb != M4OSA_NULL)
                         {
-                            if(framingCtx->aFramingCtx_last->FramingRgb != M4OSA_NULL)
-                            {
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx_last->\
-                                    FramingRgb->pac_data);
-                                framingCtx->aFramingCtx_last->FramingRgb->pac_data = M4OSA_NULL;
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx_last->\
-                                    FramingRgb);
-                                framingCtx->aFramingCtx_last->FramingRgb = M4OSA_NULL;
-                            }
+                            free(framingCtx->aFramingCtx_last->\
+                                FramingRgb->pac_data);
+                            framingCtx->aFramingCtx_last->FramingRgb->pac_data = M4OSA_NULL;
+                            free(framingCtx->aFramingCtx_last->\
+                                FramingRgb);
+                            framingCtx->aFramingCtx_last->FramingRgb = M4OSA_NULL;
                         }
                         if(framingCtx->aFramingCtx_last->FramingYuv != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx_last->\
+                            free(framingCtx->aFramingCtx_last->\
                                 FramingYuv[0].pac_data);
                             framingCtx->aFramingCtx_last->FramingYuv[0].pac_data = M4OSA_NULL;
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx_last->FramingYuv);
+                            free(framingCtx->aFramingCtx_last->FramingYuv);
                             framingCtx->aFramingCtx_last->FramingYuv = M4OSA_NULL;
                         }
-                        M4OSA_free((M4OSA_MemAddr32)framingCtx->aFramingCtx_last);
+                        free(framingCtx->aFramingCtx_last);
                         framingCtx->aFramingCtx_last = M4OSA_NULL;
                     }
                     if(framingCtx->pEffectFilePath != M4OSA_NULL)
                     {
-                        M4OSA_free((M4OSA_MemAddr32)framingCtx->pEffectFilePath);
+                        free(framingCtx->pEffectFilePath);
                         framingCtx->pEffectFilePath = M4OSA_NULL;
                     }
                     /*In case there are still allocated*/
@@ -3334,22 +3188,15 @@
                     {
                     //    M4SPS_destroy(framingCtx->pSPSContext);
                         framingCtx->pSPSContext = M4OSA_NULL;
-#if 0
-                        if(framingCtx->inputStream.data_buffer  != M4OSA_NULL)
-                        {
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->inputStream.data_buffer);
-                            framingCtx->inputStream.data_buffer = M4OSA_NULL;
-                        }
-#endif
                     }
                     /*Alpha blending structure*/
                     if(framingCtx->alphaBlendingStruct  != M4OSA_NULL)
                     {
-                        M4OSA_free((M4OSA_MemAddr32)framingCtx->alphaBlendingStruct);
+                        free(framingCtx->alphaBlendingStruct);
                         framingCtx->alphaBlendingStruct = M4OSA_NULL;
                     }
 
-                    M4OSA_free((M4OSA_MemAddr32)framingCtx);
+                    free(framingCtx);
                     framingCtx = M4OSA_NULL;
                 }
 #else
@@ -3358,25 +3205,22 @@
                     if(framingCtx != M4OSA_NULL) /* Bugfix 1.2.0: crash, trying to free non
                     existant pointer */
                     {
-                        if(pSettings->Effects[i].xVSS.pFramingBuffer == M4OSA_NULL)
+                        if(framingCtx->FramingRgb != M4OSA_NULL)
                         {
-                            if(framingCtx->FramingRgb != M4OSA_NULL)
-                            {
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb->pac_data);
-                                framingCtx->FramingRgb->pac_data = M4OSA_NULL;
-                                M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingRgb);
-                                framingCtx->FramingRgb = M4OSA_NULL;
-                            }
+                            free(framingCtx->FramingRgb->pac_data);
+                            framingCtx->FramingRgb->pac_data = M4OSA_NULL;
+                            free(framingCtx->FramingRgb);
+                            framingCtx->FramingRgb = M4OSA_NULL;
                         }
                         if(framingCtx->FramingYuv != M4OSA_NULL)
                         {
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv[0].pac_data);
+                            free(framingCtx->FramingYuv[0].pac_data);
                             framingCtx->FramingYuv[0].pac_data = M4OSA_NULL;
-                            M4OSA_free((M4OSA_MemAddr32)framingCtx->FramingYuv);
+                            free(framingCtx->FramingYuv);
                             framingCtx->FramingYuv = M4OSA_NULL;
                         }
                         framingCtx_save = framingCtx->pNext;
-                        M4OSA_free((M4OSA_MemAddr32)framingCtx);
+                        free(framingCtx);
                         framingCtx = M4OSA_NULL;
                         framingCtx = framingCtx_save;
                     }
@@ -3395,7 +3239,7 @@
 
                 if(FiftiesCtx != M4OSA_NULL)
                 {
-                    M4OSA_free((M4OSA_MemAddr32)FiftiesCtx);
+                    free(FiftiesCtx);
                     FiftiesCtx = M4OSA_NULL;
                 }
 
@@ -3413,7 +3257,7 @@
 
                 if(ColorCtx != M4OSA_NULL)
                 {
-                    M4OSA_free((M4OSA_MemAddr32)ColorCtx);
+                    free(ColorCtx);
                     ColorCtx = M4OSA_NULL;
                 }
             }
@@ -3421,21 +3265,21 @@
             /* Free simple fields */
             if(pSettings->Effects[i].xVSS.pFramingFilePath != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pSettings->Effects[i].xVSS.pFramingFilePath);
+                free(pSettings->Effects[i].xVSS.pFramingFilePath);
                 pSettings->Effects[i].xVSS.pFramingFilePath = M4OSA_NULL;
             }
             if(pSettings->Effects[i].xVSS.pFramingBuffer != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pSettings->Effects[i].xVSS.pFramingBuffer);
+                free(pSettings->Effects[i].xVSS.pFramingBuffer);
                 pSettings->Effects[i].xVSS.pFramingBuffer = M4OSA_NULL;
             }
             if(pSettings->Effects[i].xVSS.pTextBuffer != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pSettings->Effects[i].xVSS.pTextBuffer);
+                free(pSettings->Effects[i].xVSS.pTextBuffer);
                 pSettings->Effects[i].xVSS.pTextBuffer = M4OSA_NULL;
             }
         }
-        M4OSA_free((M4OSA_MemAddr32)pSettings->Effects);
+        free(pSettings->Effects);
         pSettings->Effects = M4OSA_NULL;
     }
 
@@ -3452,93 +3296,12 @@
     {
         if(xVSS_context->pSettings->xVSS.pBGMtrack->pFile != M4OSA_NULL)
         {
-            M4OSA_free(xVSS_context->pSettings->xVSS.pBGMtrack->pFile);
+            free(xVSS_context->pSettings->xVSS.pBGMtrack->pFile);
             xVSS_context->pSettings->xVSS.pBGMtrack->pFile = M4OSA_NULL;
         }
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->xVSS.pBGMtrack);
+        free(xVSS_context->pSettings->xVSS.pBGMtrack);
         xVSS_context->pSettings->xVSS.pBGMtrack = M4OSA_NULL;
     }
-#if 0
-    /* Parse transitions to free internal "alpha magic" settings structure */
-    /**
-     * In case there is twice or more the same Alpha Magic effect, the effect context
-     * may be freed twice or more.
-     * So, we parse all remaining transition settings to know if the context can be
-     * "re-freed", and if yes, we put its context to NULL to avoid freeing it again */
-    for(i=0; i<xVSS_context->pSettings->uiClipNumber-1; i++)
-    {
-        if(xVSS_context->pSettings->pTransitionList[i] != M4OSA_NULL)
-        {
-            switch (xVSS_context->pSettings->pTransitionList[i]->VideoTransitionType)
-            {
-                case M4xVSS_kVideoTransitionType_AlphaMagic:
-                    /**
-                     * In case of Alpha Magic transition, some extra parameters need to be freed */
-                    if(xVSS_context->pSettings->pTransitionList[i]->\
-                        pExtVideoTransitionFctCtxt != M4OSA_NULL)
-                    {
-                        M4OSA_free((M4OSA_MemAddr32)(((M4xVSS_internal_AlphaMagicSettings*)\
-                            xVSS_context->pSettings->pTransitionList[i]->\
-                                pExtVideoTransitionFctCtxt)->pPlane->pac_data));
-                        ((M4xVSS_internal_AlphaMagicSettings*)xVSS_context->\
-                            pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt)->\
-                                pPlane->pac_data = M4OSA_NULL;
-
-                        M4OSA_free((M4OSA_MemAddr32)(((M4xVSS_internal_AlphaMagicSettings*)\
-                            xVSS_context->pSettings->pTransitionList[i]->\
-                                pExtVideoTransitionFctCtxt)->pPlane));
-                        ((M4xVSS_internal_AlphaMagicSettings*)xVSS_context->\
-                            pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt)->\
-                                pPlane = M4OSA_NULL;
-
-                        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pSettings->\
-                            pTransitionList[i]->pExtVideoTransitionFctCtxt));
-                        xVSS_context->pSettings->pTransitionList[i]->pExtVideoTransitionFctCtxt
-                             = M4OSA_NULL;
-
-                        for(j=i+1;j<xVSS_context->pSettings->uiClipNumber-1;j++)
-                        {
-                            if(xVSS_context->pSettings->pTransitionList[j] != M4OSA_NULL)
-                            {
-                                if(xVSS_context->pSettings->pTransitionList[j]->\
-                                    VideoTransitionType == M4xVSS_kVideoTransitionType_AlphaMagic)
-                                {
-                                    M4OSA_UInt32 pCmpResult=0;
-                                    M4OSA_chrCompare(xVSS_context->pSettings->pTransitionList[i]->\
-                                        xVSS.transitionSpecific.pAlphaMagicSettings->\
-                                            pAlphaFilePath,
-                                        xVSS_context->pSettings->pTransitionList[j]->\
-                                            xVSS.transitionSpecific.pAlphaMagicSettings->\
-                                                pAlphaFilePath, &pCmpResult);
-                                    if(pCmpResult == 0)
-                                        {
-                                        /* Free extra internal alpha magic structure and put it
-                                         to NULL to avoid refreeing it */
-                                        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pSettings->\
-                                            pTransitionList[j]->pExtVideoTransitionFctCtxt));
-                                        xVSS_context->pSettings->pTransitionList[j]->\
-                                            pExtVideoTransitionFctCtxt = M4OSA_NULL;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                break;
-
-                case M4xVSS_kVideoTransitionType_SlideTransition:
-                    if(xVSS_context->pSettings->pTransitionList[i]->\
-                        pExtVideoTransitionFctCtxt != M4OSA_NULL)
-                    {
-                        M4OSA_free((M4OSA_MemAddr32)(xVSS_context->pSettings->\
-                            pTransitionList[i]->pExtVideoTransitionFctCtxt));
-                        xVSS_context->pSettings->pTransitionList[i]->\
-                            pExtVideoTransitionFctCtxt = M4OSA_NULL;
-                    }
-                break;
-            }
-        }
-    }
-#endif
 
     M4xVSS_freeSettings(xVSS_context->pSettings);
 
@@ -3551,28 +3314,28 @@
         {
             if(pParams->pFileIn != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileIn);
+                free(pParams->pFileIn);
                 pParams->pFileIn = M4OSA_NULL;
             }
             if(pParams->pFileOut != M4OSA_NULL)
             {
                 /* Delete temporary file */
-                M4OSA_fileExtraDelete(pParams->pFileOut);
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileOut);
+                remove((const char *)pParams->pFileOut);
+                free(pParams->pFileOut);
                 pParams->pFileOut = M4OSA_NULL;
             }
             if(pParams->pFileTemp != M4OSA_NULL)
             {
                 /* Delete temporary file */
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
-                M4OSA_fileExtraDelete(pParams->pFileTemp);
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileTemp);
+                remove((const char *)pParams->pFileTemp);
+                free(pParams->pFileTemp);
 #endif/*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
                 pParams->pFileTemp = M4OSA_NULL;
             }
             pParams_sauv = pParams;
             pParams = pParams->pNext;
-            M4OSA_free((M4OSA_MemAddr32)pParams_sauv);
+            free(pParams_sauv);
             pParams_sauv = M4OSA_NULL;
         }
     }
@@ -3586,41 +3349,41 @@
         {
             if(pParams->pFileIn != M4OSA_NULL)
             {
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileIn);
+                free(pParams->pFileIn);
                 pParams->pFileIn = M4OSA_NULL;
             }
             if(pParams->pFileOut != M4OSA_NULL)
             {
                 /* Delete temporary file */
-                M4OSA_fileExtraDelete(pParams->pFileOut);
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileOut);
+                remove((const char *)pParams->pFileOut);
+                free(pParams->pFileOut);
                 pParams->pFileOut = M4OSA_NULL;
             }
             if(pParams->pFileTemp != M4OSA_NULL)
             {
                 /* Delete temporary file */
 #ifdef M4xVSS_RESERVED_MOOV_DISK_SPACE
-                M4OSA_fileExtraDelete(pParams->pFileTemp);
-                M4OSA_free((M4OSA_MemAddr32)pParams->pFileTemp);
+                remove((const char *)pParams->pFileTemp);
+                free(pParams->pFileTemp);
 #endif/*M4xVSS_RESERVED_MOOV_DISK_SPACE*/
                 pParams->pFileTemp = M4OSA_NULL;
             }
             pParams_sauv = pParams;
             pParams = pParams->pNext;
-            M4OSA_free((M4OSA_MemAddr32)pParams_sauv);
+            free(pParams_sauv);
             pParams_sauv = M4OSA_NULL;
         }
     }
 
     if(xVSS_context->pcmPreviewFile != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pcmPreviewFile);
+        free(xVSS_context->pcmPreviewFile);
         xVSS_context->pcmPreviewFile = M4OSA_NULL;
     }
     if(xVSS_context->pSettings->pOutputFile != M4OSA_NULL
         && xVSS_context->pOutputFile != M4OSA_NULL)
     {
-        M4OSA_free((M4OSA_MemAddr32)xVSS_context->pSettings->pOutputFile);
+        free(xVSS_context->pSettings->pOutputFile);
         xVSS_context->pSettings->pOutputFile = M4OSA_NULL;
         xVSS_context->pOutputFile = M4OSA_NULL;
     }
@@ -3860,32 +3623,32 @@
                 switch (ColorContext->colorEffectType)
                 {
                     case M4xVSS_kVideoEffectType_BlackAndWhite:
-                        M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                         PlaneIn[plane_number].u_width, 128);
+                        memset((void *)p_buf_dest,128,
+                         PlaneIn[plane_number].u_width);
                         break;
                     case M4xVSS_kVideoEffectType_Pink:
-                        M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                         PlaneIn[plane_number].u_width, 255);
+                        memset((void *)p_buf_dest,255,
+                         PlaneIn[plane_number].u_width);
                         break;
                     case M4xVSS_kVideoEffectType_Green:
-                        M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                         PlaneIn[plane_number].u_width, 0);
+                        memset((void *)p_buf_dest,0,
+                         PlaneIn[plane_number].u_width);
                         break;
                     case M4xVSS_kVideoEffectType_Sepia:
                         if(plane_number==1)
                         {
-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                             PlaneIn[plane_number].u_width, 117);
+                            memset((void *)p_buf_dest,117,
+                             PlaneIn[plane_number].u_width);
                         }
                         else
                         {
-                            M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                             PlaneIn[plane_number].u_width, 139);
+                            memset((void *)p_buf_dest,139,
+                             PlaneIn[plane_number].u_width);
                         }
                         break;
                     case M4xVSS_kVideoEffectType_Negative:
-                        M4OSA_memcpy((M4OSA_MemAddr8)p_buf_dest,
-                         (M4OSA_MemAddr8)p_buf_src ,PlaneOut[plane_number].u_width);
+                        memcpy((void *)p_buf_dest,
+                         (void *)p_buf_src ,PlaneOut[plane_number].u_width);
                         break;
 
                     case M4xVSS_kVideoEffectType_ColorRGB16:
@@ -3902,15 +3665,15 @@
                             {
                                 /*then convert to u*/
                                 u = U16(r, g, b);
-                                M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                                 PlaneIn[plane_number].u_width, (M4OSA_UInt8)u);
+                                memset((void *)p_buf_dest,(M4OSA_UInt8)u,
+                                 PlaneIn[plane_number].u_width);
                             }
                             if(plane_number==2)
                             {
                                 /*then convert to v*/
                                 v = V16(r, g, b);
-                                M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                                 PlaneIn[plane_number].u_width, (M4OSA_UInt8)v);
+                                memset((void *)p_buf_dest, (M4OSA_UInt8)v,
+                                 PlaneIn[plane_number].u_width);
                             }
                         }
                         break;
@@ -3933,15 +3696,15 @@
                             {
                                 /*then convert to u*/
                                 u = U16(r, g, b);
-                                M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                                 PlaneIn[plane_number].u_width, (M4OSA_UInt8)u);
+                                memset((void *)p_buf_dest,(M4OSA_UInt8)u,
+                                 PlaneIn[plane_number].u_width);
                             }
                             if(plane_number==2)
                             {
                                 /*then convert to v*/
                                 v = V16(r, g, b);
-                                M4OSA_memset((M4OSA_MemAddr8)p_buf_dest,
-                                 PlaneIn[plane_number].u_width, (M4OSA_UInt8)v);
+                                memset((void *)p_buf_dest,(M4OSA_UInt8)v,
+                                 PlaneIn[plane_number].u_width);
                             }
                         }
                         break;
@@ -3964,8 +3727,8 @@
                     }
                     break;
                 default:
-                    M4OSA_memcpy((M4OSA_MemAddr8)p_buf_dest,
-                     (M4OSA_MemAddr8)p_buf_src ,PlaneOut[plane_number].u_width);
+                    memcpy((void *)p_buf_dest,
+                     (void *)p_buf_src ,PlaneOut[plane_number].u_width);
                     break;
                 }
             }
@@ -4031,22 +3794,6 @@
 #ifdef DECODE_GIF_ON_SAVING
     M4OSA_ERR err;
     Framing = (M4xVSS_FramingStruct *)((M4xVSS_FramingContext*)userData)->aFramingCtx;
-#if 0
-    if(Framing == M4OSA_NULL)
-    {
-        ((M4xVSS_FramingContext*)userData)->clipTime = pProgress->uiOutputTime;
-        err = M4xVSS_internalDecodeGIF(userData);
-        if(M4NO_ERROR != err)
-        {
-            M4OSA_TRACE1_1("M4VSS3GPP_externalVideoEffectFraming:\
-             Error in M4xVSS_internalDecodeGIF: 0x%x", err);
-            return err;
-        }
-        Framing = (M4xVSS_FramingStruct *)((M4xVSS_FramingContext*)userData)->aFramingCtx;
-        /* Initializes first GIF time */
-        ((M4xVSS_FramingContext*)userData)->current_gif_time = pProgress->uiOutputTime;
-    }
-#endif
     currentFraming = (M4xVSS_FramingStruct *)Framing;
     FramingRGB = Framing->FramingRgb->pac_data;
 #endif /*DECODE_GIF_ON_SAVING*/
@@ -4072,40 +3819,6 @@
     /**
      * If the current clip time has reach the duration of one frame of the framing picture
      * we need to step to next framing picture */
-#if 0
-    if(((M4xVSS_FramingContext*)userData)->b_animated == M4OSA_TRUE)
-    {
-        while((((M4xVSS_FramingContext*)userData)->current_gif_time + currentFraming->duration)\
-         < pProgress->uiOutputTime)
-        {
-#ifdef DECODE_GIF_ON_SAVING
-            ((M4xVSS_FramingContext*)userData)->clipTime = pProgress->uiOutputTime;
-            err = M4xVSS_internalDecodeGIF(userData);
-            if(M4NO_ERROR != err)
-            {
-                M4OSA_TRACE1_1("M4VSS3GPP_externalVideoEffectFraming:\
-                 Error in M4xVSS_internalDecodeGIF: 0x%x", err);
-                return err;
-            }
-            if(currentFraming->duration != 0)
-            {
-                ((M4xVSS_FramingContext*)userData)->current_gif_time += currentFraming->duration;
-            }
-            else
-            {
-                ((M4xVSS_FramingContext*)userData)->current_gif_time \
-                 += pProgress->uiOutputTime - Framing->previousClipTime;
-            }
-            Framing = (M4xVSS_FramingStruct *)((M4xVSS_FramingContext*)userData)->aFramingCtx;
-            currentFraming = (M4xVSS_FramingStruct *)Framing;
-            FramingRGB = Framing->FramingRgb->pac_data;
-#else
-            Framing->pCurrent = currentFraming->pNext;
-            currentFraming = Framing->pCurrent;
-#endif /*DECODE_GIF_ON_SAVING*/
-        }
-    }
-#endif
 
     Framing->previousClipTime = pProgress->uiOutputTime;
     FramingRGB = currentFraming->FramingRgb->pac_data;
@@ -4132,14 +3845,18 @@
 
                 if(alphaBlendingStruct != M4OSA_NULL)
                 {
-                    if(pProgress->uiProgress >= 0 && pProgress->uiProgress \
+                    if(pProgress->uiProgress \
                     < (M4OSA_UInt32)(alphaBlendingStruct->m_fadeInTime*10))
                     {
-                        alphaBlending = ((M4OSA_Float)(alphaBlendingStruct->m_middle\
-                         - alphaBlendingStruct->m_start)\
-                            *pProgress->uiProgress/(alphaBlendingStruct->m_fadeInTime*10));
-                        alphaBlending += alphaBlendingStruct->m_start;
-                        alphaBlending /= 100;
+                        if(alphaBlendingStruct->m_fadeInTime == 0) {
+                            alphaBlending = alphaBlendingStruct->m_start / 100;
+                        } else {
+                            alphaBlending = ((M4OSA_Float)(alphaBlendingStruct->m_middle\
+                             - alphaBlendingStruct->m_start)\
+                                *pProgress->uiProgress/(alphaBlendingStruct->m_fadeInTime*10));
+                            alphaBlending += alphaBlendingStruct->m_start;
+                            alphaBlending /= 100;
+                        }
                     }
                     else if(pProgress->uiProgress >= (M4OSA_UInt32)(alphaBlendingStruct->\
                     m_fadeInTime*10) && pProgress->uiProgress < 1000\
@@ -4151,11 +3868,15 @@
                     else if(pProgress->uiProgress >= 1000 - (M4OSA_UInt32)\
                     (alphaBlendingStruct->m_fadeOutTime*10))
                     {
-                        alphaBlending = ((M4OSA_Float)(alphaBlendingStruct->m_middle \
-                        - alphaBlendingStruct->m_end))*(1000 - pProgress->uiProgress)\
-                        /(alphaBlendingStruct->m_fadeOutTime*10);
-                        alphaBlending += alphaBlendingStruct->m_end;
-                        alphaBlending /= 100;
+                        if(alphaBlendingStruct->m_fadeOutTime == 0) {
+                            alphaBlending = alphaBlendingStruct->m_end / 100;
+                        } else {
+                            alphaBlending = ((M4OSA_Float)(alphaBlendingStruct->m_middle \
+                            - alphaBlendingStruct->m_end))*(1000 - pProgress->uiProgress)\
+                            /(alphaBlendingStruct->m_fadeOutTime*10);
+                            alphaBlending += alphaBlendingStruct->m_end;
+                            alphaBlending /= 100;
+                        }
                     }
                 }
                 /**/
@@ -4213,15 +3934,6 @@
         }
     }
 
-#ifdef DECODE_GIF_ON_SAVING
-#if 0
-    if(pProgress->bIsLast == M4OSA_TRUE
-        && (M4OSA_Bool)((M4xVSS_FramingContext*)userData)->b_IsFileGif == M4OSA_TRUE)
-    {
-        M4xVSS_internalDecodeGIF_Cleaning((M4xVSS_FramingContext*)userData);
-    }
-#endif
-#endif /*DECODE_GIF_ON_SAVING*/
 
     return M4VIFI_OK;
 }
@@ -4302,11 +4014,9 @@
         for (x = 0; x < pPlaneOut[plane_number].u_height; x++)
         {
             if (1 == plane_number)
-                M4OSA_memset((M4OSA_MemAddr8)pOutCr, pPlaneIn[plane_number].u_width,
-                     117); /* U value */
+                memset((void *)pOutCr, 117,pPlaneIn[plane_number].u_width); /* U value */
             else
-                M4OSA_memset((M4OSA_MemAddr8)pOutCr, pPlaneIn[plane_number].u_width,
-                     139); /* V value */
+                memset((void *)pOutCr, 139,pPlaneIn[plane_number].u_width); /* V value */
 
             pInCr  += pPlaneIn[plane_number].u_stride;
             pOutCr += pPlaneOut[plane_number].u_stride;
@@ -4700,7 +4410,7 @@
 
     for (y=0; y<height; y++)
     {
-        M4OSA_memcpy((M4OSA_MemAddr8)destWalk, (M4OSA_MemAddr8)sourceWalk, width);
+        memcpy((void *)destWalk, (void *)sourceWalk, width);
         destWalk += destStride;
         sourceWalk += sourceStride;
     }
@@ -4742,7 +4452,7 @@
         /* First the part from the top source clip frame. */
         for (y=0; y<topPartHeight; y++)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)destWalk, (M4OSA_MemAddr8)sourceWalk, width);
+            memcpy((void *)destWalk, (void *)sourceWalk, width);
             destWalk += destStride;
             sourceWalk += sourceStride;
         }
@@ -4755,7 +4465,7 @@
 
         for (y=0; y<bottomPartHeight; y++)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)destWalk, (M4OSA_MemAddr8)sourceWalk, width);
+            memcpy((void *)destWalk, (void *)sourceWalk, width);
             destWalk += destStride;
             sourceWalk += sourceStride;
         }
@@ -4828,10 +4538,10 @@
 
         for (y=0; y<height; y++)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)destWalkLeft, (M4OSA_MemAddr8)leftWalk, leftPartWidth);
+            memcpy((void *)destWalkLeft, (void *)leftWalk, leftPartWidth);
             leftWalk += leftStride;
 
-            M4OSA_memcpy((M4OSA_MemAddr8)destWalkRight, (M4OSA_MemAddr8)rightWalk, rightPartWidth);
+            memcpy((void *)destWalkRight, (void *)rightWalk, rightPartWidth);
             rightWalk += rightStride;
 
             destWalkLeft += destStride;
@@ -4997,8 +4707,8 @@
     {
         M4OSA_UInt32 ConvertedSize = xVSS_context->UTFConversionContext.m_TempOutConversionSize;
 
-        M4OSA_memset((M4OSA_MemAddr8)xVSS_context->UTFConversionContext.pTempOutConversionBuffer
-            ,(M4OSA_UInt32)xVSS_context->UTFConversionContext.m_TempOutConversionSize,0);
+        memset((void *)xVSS_context->UTFConversionContext.pTempOutConversionBuffer,0
+            ,(M4OSA_UInt32)xVSS_context->UTFConversionContext.m_TempOutConversionSize);
 
         err = xVSS_context->UTFConversionContext.pConvToUTF8Fct((M4OSA_Void*)pBufferIn,
             (M4OSA_UInt8*)xVSS_context->UTFConversionContext.pTempOutConversionBuffer,
@@ -5008,12 +4718,12 @@
             M4OSA_TRACE2_1("M4xVSS_internalConvertToUTF8: pConvToUTF8Fct return 0x%x",err);
 
             /*free too small buffer*/
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->\
+            free(xVSS_context->\
                 UTFConversionContext.pTempOutConversionBuffer);
 
             /*re-allocate the buffer*/
             xVSS_context->UTFConversionContext.pTempOutConversionBuffer    =
-                 (M4OSA_Void*)M4OSA_malloc(ConvertedSize*sizeof(M4OSA_UInt8), M4VA,
+                 (M4OSA_Void*)M4OSA_32bitAlignedMalloc(ConvertedSize*sizeof(M4OSA_UInt8), M4VA,
                      (M4OSA_Char *)"M4xVSS_internalConvertToUTF8: UTF conversion buffer");
             if(M4OSA_NULL == xVSS_context->UTFConversionContext.pTempOutConversionBuffer)
             {
@@ -5022,9 +4732,9 @@
             }
             xVSS_context->UTFConversionContext.m_TempOutConversionSize = ConvertedSize;
 
-            M4OSA_memset((M4OSA_MemAddr8)xVSS_context->\
-                UTFConversionContext.pTempOutConversionBuffer,(M4OSA_UInt32)xVSS_context->\
-                    UTFConversionContext.m_TempOutConversionSize,0);
+            memset((void *)xVSS_context->\
+                UTFConversionContext.pTempOutConversionBuffer,0,(M4OSA_UInt32)xVSS_context->\
+                    UTFConversionContext.m_TempOutConversionSize);
 
             err = xVSS_context->UTFConversionContext.pConvToUTF8Fct((M4OSA_Void*)pBufferIn,
                 (M4OSA_Void*)xVSS_context->UTFConversionContext.pTempOutConversionBuffer,
@@ -5075,9 +4785,9 @@
     {
         M4OSA_UInt32 ConvertedSize = xVSS_context->UTFConversionContext.m_TempOutConversionSize;
 
-        M4OSA_memset((M4OSA_MemAddr8)xVSS_context->\
-            UTFConversionContext.pTempOutConversionBuffer,(M4OSA_UInt32)xVSS_context->\
-                UTFConversionContext.m_TempOutConversionSize,0);
+        memset((void *)xVSS_context->\
+            UTFConversionContext.pTempOutConversionBuffer,0,(M4OSA_UInt32)xVSS_context->\
+                UTFConversionContext.m_TempOutConversionSize);
 
         err = xVSS_context->UTFConversionContext.pConvFromUTF8Fct\
             ((M4OSA_Void*)pBufferIn,(M4OSA_UInt8*)xVSS_context->\
@@ -5087,12 +4797,12 @@
             M4OSA_TRACE2_1("M4xVSS_internalConvertFromUTF8: pConvFromUTF8Fct return 0x%x",err);
 
             /*free too small buffer*/
-            M4OSA_free((M4OSA_MemAddr32)xVSS_context->\
+            free(xVSS_context->\
                 UTFConversionContext.pTempOutConversionBuffer);
 
             /*re-allocate the buffer*/
             xVSS_context->UTFConversionContext.pTempOutConversionBuffer    =
-                (M4OSA_Void*)M4OSA_malloc(ConvertedSize*sizeof(M4OSA_UInt8), M4VA,
+                (M4OSA_Void*)M4OSA_32bitAlignedMalloc(ConvertedSize*sizeof(M4OSA_UInt8), M4VA,
                      (M4OSA_Char *)"M4xVSS_internalConvertFromUTF8: UTF conversion buffer");
             if(M4OSA_NULL == xVSS_context->UTFConversionContext.pTempOutConversionBuffer)
             {
@@ -5101,9 +4811,9 @@
             }
             xVSS_context->UTFConversionContext.m_TempOutConversionSize = ConvertedSize;
 
-            M4OSA_memset((M4OSA_MemAddr8)xVSS_context->\
-                UTFConversionContext.pTempOutConversionBuffer,(M4OSA_UInt32)xVSS_context->\
-                    UTFConversionContext.m_TempOutConversionSize,0);
+            memset((void *)xVSS_context->\
+                UTFConversionContext.pTempOutConversionBuffer,0,(M4OSA_UInt32)xVSS_context->\
+                    UTFConversionContext.m_TempOutConversionSize);
 
             err = xVSS_context->UTFConversionContext.pConvFromUTF8Fct((M4OSA_Void*)pBufferIn,
                 (M4OSA_Void*)xVSS_context->UTFConversionContext.pTempOutConversionBuffer,
diff --git a/libvideoeditor/vss/src/VideoEditorResampler.cpp b/libvideoeditor/vss/src/VideoEditorResampler.cpp
index c4d1a8a..c967aaf 100755
--- a/libvideoeditor/vss/src/VideoEditorResampler.cpp
+++ b/libvideoeditor/vss/src/VideoEditorResampler.cpp
@@ -48,6 +48,7 @@
     M4OSA_Int32 outSamplingRate;
     M4OSA_Int32 inSamplingRate;
 
+    int16_t *mTmpInBuffer;
 };
 
 #define MAX_SAMPLEDURATION_FOR_CONVERTION 40 //ms
@@ -55,9 +56,9 @@
 status_t VideoEditorResampler::getNextBuffer(AudioBufferProvider::Buffer *pBuffer) {
 
     uint32_t dataSize = pBuffer->frameCount * this->nbChannels * sizeof(int16_t);
-    int16_t *pTmpInBuffer = (int16_t*)malloc(dataSize);
-    memcpy(pTmpInBuffer, this->mInput, dataSize);
-    pBuffer->raw = (void*)pTmpInBuffer;
+    mTmpInBuffer = (int16_t*)malloc(dataSize);
+    memcpy(mTmpInBuffer, this->mInput, dataSize);
+    pBuffer->raw = (void*)mTmpInBuffer;
 
     return OK;
 }
@@ -67,32 +68,34 @@
     if(pBuffer->raw != NULL) {
         free(pBuffer->raw);
         pBuffer->raw = NULL;
+        mTmpInBuffer = NULL;
     }
     pBuffer->frameCount = 0;
 }
 
 extern "C" {
 
-M4OSA_Int32 LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
+M4OSA_Context  LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChannelCount,
                                      M4OSA_Int32 sampleRate, M4OSA_Int32 quality) {
 
     VideoEditorResampler *context = new VideoEditorResampler();
     context->mResampler = AudioResampler::create(
         bitDepth, inChannelCount, sampleRate, AudioResampler::DEFAULT);
     if (context->mResampler == NULL) {
-        return NO_MEMORY;
+        return NULL;
     }
     context->mResampler->setSampleRate(android::VideoEditorResampler::kFreq32000Hz);
     context->mResampler->setVolume(0x1000, 0x1000);
     context->nbChannels = inChannelCount;
     context->outSamplingRate = sampleRate;
     context->mInput = NULL;
+    context->mTmpInBuffer = NULL;
 
-    return ((M4OSA_Int32)context);
+    return ((M4OSA_Context )context);
 }
 
 
-void LVAudiosetSampleRate(M4OSA_Int32 resamplerContext, M4OSA_Int32 inSampleRate) {
+void LVAudiosetSampleRate(M4OSA_Context resamplerContext, M4OSA_Int32 inSampleRate) {
 
     VideoEditorResampler *context =
       (VideoEditorResampler *)resamplerContext;
@@ -107,18 +110,23 @@
                                    context->nbChannels * sizeof(int16_t)) / 1000);
 }
 
-void LVAudiosetVolume(M4OSA_Int32 resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) {
+void LVAudiosetVolume(M4OSA_Context resamplerContext, M4OSA_Int16 left, M4OSA_Int16 right) {
 
     VideoEditorResampler *context =
        (VideoEditorResampler *)resamplerContext;
     context->mResampler->setVolume(left,right);
 }
 
-void LVDestroy(M4OSA_Int32 resamplerContext) {
+void LVDestroy(M4OSA_Context resamplerContext) {
 
     VideoEditorResampler *context =
        (VideoEditorResampler *)resamplerContext;
 
+    if (context->mTmpInBuffer != NULL) {
+        free(context->mTmpInBuffer);
+        context->mTmpInBuffer = NULL;
+    }
+
     if (context->mInput != NULL) {
         free(context->mInput);
         context->mInput = NULL;
@@ -136,7 +144,7 @@
 }
 
 void LVAudioresample_LowQuality(M4OSA_Int16* out, M4OSA_Int16* input,
-                                     M4OSA_Int32 outFrameCount, M4OSA_Int32 resamplerContext) {
+                                     M4OSA_Int32 outFrameCount, M4OSA_Context resamplerContext) {
 
     VideoEditorResampler *context =
       (VideoEditorResampler *)resamplerContext;
diff --git a/libvideoeditor/vss/stagefrightshells/inc/VideoEditorUtils.h b/libvideoeditor/vss/stagefrightshells/inc/VideoEditorUtils.h
index e06fcbc..86d676e 100755
--- a/libvideoeditor/vss/stagefrightshells/inc/VideoEditorUtils.h
+++ b/libvideoeditor/vss/stagefrightshells/inc/VideoEditorUtils.h
@@ -61,7 +61,7 @@
 #define SAFE_FREE(p) \
 { \
     if(M4OSA_NULL != (p)) { \
-        M4OSA_free((M4OSA_MemAddr32)(p)) ; \
+        free((p)) ; \
         (p) = M4OSA_NULL ; \
     } \
 }
@@ -75,9 +75,9 @@
  */
 #define SAFE_MALLOC(p, type, count, comment) \
 { \
-    (p) = (type*)M4OSA_malloc(sizeof(type)*(count), 0xFF,(M4OSA_Char*)comment);\
+    (p) = (type*)M4OSA_32bitAlignedMalloc(sizeof(type)*(count), 0xFF,(M4OSA_Char*)comment);\
     VIDEOEDITOR_CHECK(M4OSA_NULL != (p), M4ERR_ALLOC); \
-    M4OSA_memset((M4OSA_MemAddr8)(p), sizeof(type)*(count), 0); \
+    memset((void *)(p), 0,sizeof(type)*(count)); \
 }
 
 
diff --git a/libvideoeditor/vss/stagefrightshells/src/Android.mk b/libvideoeditor/vss/stagefrightshells/src/Android.mk
index d9947b8..48e3cd8 100755
--- a/libvideoeditor/vss/stagefrightshells/src/Android.mk
+++ b/libvideoeditor/vss/stagefrightshells/src/Android.mk
@@ -56,15 +56,13 @@
     libbinder \
     libstagefright \
     libstagefright_omx \
-    libsurfaceflinger_client \
+    libgui \
     libvideoeditorplayer
 
 LOCAL_CFLAGS += \
 
 
 
-LOCAL_LDFLAGS += -fuse-ld=bfd
-
 LOCAL_STATIC_LIBRARIES := \
     libvideoeditor_osal \
     libstagefright_color_conversion
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
index eb48717..ea4abce 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
@@ -134,7 +134,7 @@
     VideoEditor3gpReader_BitStreamParserContext* pStreamContext;
 
     *pContext=M4OSA_NULL;
-    pStreamContext = (VideoEditor3gpReader_BitStreamParserContext*)M4OSA_malloc(
+    pStreamContext = (VideoEditor3gpReader_BitStreamParserContext*)M4OSA_32bitAlignedMalloc(
         sizeof(VideoEditor3gpReader_BitStreamParserContext), M4READER_3GP,
             (M4OSA_Char*)"3GP BitStreamParser Context");
     if (M4OSA_NULL == pStreamContext) {
@@ -156,7 +156,7 @@
  **********************************************************************
 */
 static void VideoEditor3gpReader_BitStreamParserCleanUp(void* pContext) {
-    M4OSA_free((M4OSA_Int32*)pContext);
+    free((M4OSA_Int32*)pContext);
 }
 /**
  *****************************************************************************
@@ -406,7 +406,8 @@
     pC->mVideoSeeking = M4OSA_FALSE;
     pC->mVideoSeekTime = 0;
 
-    M4OSA_INT64_FROM_INT32(pC->mMaxDuration, 0);
+    pC->mMaxDuration = 0;
+
     *pContext=pC;
 
 cleanUp:
@@ -467,6 +468,8 @@
 *                                       the media to open
 * @return   M4NO_ERROR                  there is no error
 * @return   M4ERR_PARAMETER             the context is NULL
+* @return   M4ERR_UNSUPPORTED_MEDIA_TYPE
+*                                       the media is DRM protected
 ************************************************************************
 */
 
@@ -499,6 +502,14 @@
         return M4ERR_PARAMETER;
     }
 
+    int32_t isDRMProtected = 0;
+    sp<MetaData> meta = pC->mExtractor->getMetaData();
+    meta->findInt32(kKeyIsDRM, &isDRMProtected);
+    if (isDRMProtected) {
+        LOGV("VideoEditorMp3Reader_open error - DRM Protected");
+        return M4ERR_UNSUPPORTED_MEDIA_TYPE;
+    }
+
     LOGV("VideoEditor3gpReader_open end ");
     return err;
 }
@@ -528,7 +539,7 @@
         LOGV("VideoEditor3gpReader_close Audio");
 
         if (M4OSA_NULL != pC->mAudioStreamHandler->m_pDecoderSpecificInfo) {
-            M4OSA_free((M4OSA_MemAddr32)pC->mAudioStreamHandler->\
+            free(pC->mAudioStreamHandler->\
                 m_pDecoderSpecificInfo);
             pC->mAudioStreamHandler->m_decoderSpecificInfoSize = 0;
             pC->mAudioStreamHandler->m_pDecoderSpecificInfo = M4OSA_NULL;
@@ -541,24 +552,24 @@
 
             pAU = (M4_AccessUnit*)pAudioSbrUserData->m_pFirstAU;
             if (M4OSA_NULL != pAU) {
-                M4OSA_free((M4OSA_MemAddr32)pAU);
+                free(pAU);
             }
 
             if (M4OSA_NULL != pAudioSbrUserData->m_pAacDecoderUserConfig) {
-                M4OSA_free((M4OSA_MemAddr32)pAudioSbrUserData->\
+                free(pAudioSbrUserData->\
                     m_pAacDecoderUserConfig);
             }
-            M4OSA_free((M4OSA_MemAddr32)pAudioSbrUserData);
+            free(pAudioSbrUserData);
             pC->mAudioStreamHandler->m_pUserData = M4OSA_NULL;
         }
 
         if (pC->mAudioStreamHandler->m_pESDSInfo != M4OSA_NULL) {
-            M4OSA_free((M4OSA_MemAddr32)pC->mAudioStreamHandler->m_pESDSInfo);
+            free(pC->mAudioStreamHandler->m_pESDSInfo);
             pC->mAudioStreamHandler->m_pESDSInfo = M4OSA_NULL;
             pC->mAudioStreamHandler->m_ESDSInfoSize = 0;
         }
         /* Finally destroy the stream handler */
-        M4OSA_free((M4OSA_MemAddr32)pC->mAudioStreamHandler);
+        free(pC->mAudioStreamHandler);
         pC->mAudioStreamHandler = M4OSA_NULL;
 
         pC->mAudioSource->stop();
@@ -568,27 +579,27 @@
         LOGV("VideoEditor3gpReader_close Video ");
 
         if(M4OSA_NULL != pC->mVideoStreamHandler->m_pDecoderSpecificInfo) {
-            M4OSA_free((M4OSA_MemAddr32)pC->mVideoStreamHandler->\
+            free(pC->mVideoStreamHandler->\
                 m_pDecoderSpecificInfo);
             pC->mVideoStreamHandler->m_decoderSpecificInfoSize = 0;
             pC->mVideoStreamHandler->m_pDecoderSpecificInfo = M4OSA_NULL;
         }
 
         if(M4OSA_NULL != pC->mVideoStreamHandler->m_pH264DecoderSpecificInfo) {
-            M4OSA_free((M4OSA_MemAddr32)pC->mVideoStreamHandler->\
+            free(pC->mVideoStreamHandler->\
                 m_pH264DecoderSpecificInfo);
             pC->mVideoStreamHandler->m_H264decoderSpecificInfoSize = 0;
             pC->mVideoStreamHandler->m_pH264DecoderSpecificInfo = M4OSA_NULL;
         }
 
         if(pC->mVideoStreamHandler->m_pESDSInfo != M4OSA_NULL) {
-            M4OSA_free((M4OSA_MemAddr32)pC->mVideoStreamHandler->m_pESDSInfo);
+            free(pC->mVideoStreamHandler->m_pESDSInfo);
             pC->mVideoStreamHandler->m_pESDSInfo = M4OSA_NULL;
             pC->mVideoStreamHandler->m_ESDSInfoSize = 0;
         }
 
         /* Finally destroy the stream handler */
-        M4OSA_free((M4OSA_MemAddr32)pC->mVideoStreamHandler);
+        free(pC->mVideoStreamHandler);
         pC->mVideoStreamHandler = M4OSA_NULL;
 
         pC->mVideoSource->stop();
@@ -636,7 +647,7 @@
     case M4READER_kOptionID_Duration:
         {
             LOGV("VideoEditor3gpReader_getOption duration %d",pC->mMaxDuration);
-            M4OSA_TIME_SET(*(M4OSA_Time*)pValue, pC->mMaxDuration);
+            *(M4OSA_Time*)pValue = pC->mMaxDuration;
         }
         break;
     case M4READER_kOptionID_Version:
@@ -670,7 +681,6 @@
     break;
     case M4READER_3GP_kOptionID_H263Properties:
         {
-#if 0
             if(M4OSA_NULL == pC->mVideoStreamHandler) {
                 LOGV("VideoEditor3gpReader_getOption no videoStream retrieved");
 
@@ -678,7 +688,7 @@
                 break;
             }
             if((M4DA_StreamTypeVideoH263 != pC->mVideoStreamHandler->\
-                mStreamType) || (pC->mVideoStreamHandler->\
+                m_streamType) || (pC->mVideoStreamHandler->\
                 m_decoderSpecificInfoSize < 7)) {
                 LOGV("VideoEditor3gpReader_getOption DSI Size %d",
                     pC->mVideoStreamHandler->m_decoderSpecificInfoSize);
@@ -693,7 +703,6 @@
                 pC->mVideoStreamHandler->m_pDecoderSpecificInfo[6];
             ((M4READER_3GP_H263Properties *)pValue)->uiLevel =
                 pC->mVideoStreamHandler->m_pDecoderSpecificInfo[5];
-#endif
             LOGV("VideoEditor3gpReader_getOption M4READER_3GP_kOptionID_\
             H263Properties end");
         }
@@ -851,7 +860,6 @@
     M4OSA_ERR err = M4NO_ERROR;
     M4SYS_AccessUnit* pAu;
     M4OSA_Time time64;
-    M4OSA_Double timeDouble;
 
     M4OSA_DEBUG_IF1((pC == 0), M4ERR_PARAMETER,
         "VideoEditor3gpReader_jump: invalid context");
@@ -865,7 +873,7 @@
     if (*pTime == (pStreamHandler->m_duration)) {
         *pTime -= 1;
     }
-    M4OSA_INT64_FROM_INT32(time64, *pTime);
+    time64 = (M4OSA_Time)*pTime;
 
     LOGV("VideoEditor3gpReader_jump time us %ld ", time64);
 
@@ -898,8 +906,7 @@
     time64 = time64 / 1000; /* Convert the time into milli sec */
     LOGV("VideoEditor3gpReader_jump time ms before seekset %ld ", time64);
 
-    M4OSA_INT64_TO_DOUBLE(timeDouble, time64);
-    *pTime = (M4OSA_Int32)timeDouble;
+    *pTime = (M4OSA_Int32)time64;
 
     LOGV("VideoEditor3gpReader_jump end");
     err = M4NO_ERROR;
@@ -921,15 +928,13 @@
     M4OSA_ERR err = M4NO_ERROR;
     M4SYS_StreamID streamIdArray[2];
     M4SYS_AccessUnit* pAu;
-    M4OSA_Time time64;
+    M4OSA_Time time64 = 0;
 
     M4OSA_DEBUG_IF1((pC == 0), M4ERR_PARAMETER,
         "VideoEditor3gpReader_reset: invalid context");
     M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
         "VideoEditor3gpReader_reset: invalid pointer to M4_StreamHandler");
 
-    M4OSA_INT64_FROM_INT32(time64, 0);
-
     LOGV("VideoEditor3gpReader_reset begin");
 
     if (pStreamHandler == (M4_StreamHandler*)pC->mAudioStreamHandler) {
@@ -1073,13 +1078,13 @@
         if( (pAu->dataAddress == NULL) ||  (pAu->size < \
             mMediaBuffer->range_length())) {
             if(pAu->dataAddress != NULL) {
-                M4OSA_free((M4OSA_Int32*)pAu->dataAddress);
+                free((M4OSA_Int32*)pAu->dataAddress);
                 pAu->dataAddress = NULL;
             }
             LOGV("Buffer lenght = %d ,%d",(mMediaBuffer->range_length() +\
                 3) & ~0x3,(mMediaBuffer->range_length()));
 
-            pAu->dataAddress = (M4OSA_Int32*)M4OSA_malloc(
+            pAu->dataAddress = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(
                 (mMediaBuffer->range_length() + 3) & ~0x3,M4READER_3GP,
                     (M4OSA_Char*)"pAccessUnit->m_dataAddress" );
             if(pAu->dataAddress == NULL) {
@@ -1089,8 +1094,8 @@
         }
         pAu->size = mMediaBuffer->range_length();
 
-        memcpy((M4OSA_MemAddr8)pAu->dataAddress,
-            (const char *)mMediaBuffer->data() + mMediaBuffer->range_offset(),
+        memcpy((void *)pAu->dataAddress,
+            (void *)((const char *)mMediaBuffer->data() + mMediaBuffer->range_offset()),
             mMediaBuffer->range_length());
 
         if( (pStreamHandler == (M4_StreamHandler*)pC->mVideoStreamHandler)  &&
@@ -1262,7 +1267,7 @@
                      uiTotalSizeOfPPS;
             /**
              * Allocate the buffer */
-            pAvcSpecInfo =(struct _avcSpecificInfo*)M4OSA_malloc(uiSpecInfoSize,
+            pAvcSpecInfo =(struct _avcSpecificInfo*)M4OSA_32bitAlignedMalloc(uiSpecInfoSize,
                 M4READER_3GP, (M4OSA_Char*)"MPEG-4 AVC DecoderSpecific");
             if (M4OSA_NULL == pAvcSpecInfo) {
                 VideoEditor3gpReader_BitStreamParserCleanUp(pBitParserContext);
@@ -1304,7 +1309,7 @@
             pDecoderConfigLocal, decoderConfigSizeLocal);
 
         if (M4OSA_NULL == pBitParserContext) {
-            M4OSA_free((M4OSA_MemAddr32)pAvcSpecInfo);
+            free(pAvcSpecInfo);
             return M4ERR_ALLOC;
         }
 
@@ -1366,15 +1371,15 @@
         pStreamHandler->m_pDecoderSpecificInfo = (M4OSA_UInt8*)pAvcSpecInfo;
     }
     pStreamHandler->m_H264decoderSpecificInfoSize  =  decoderConfigSizeLocal;
-    pStreamHandler->m_pH264DecoderSpecificInfo  = (M4OSA_UInt8*)M4OSA_malloc(
+    pStreamHandler->m_pH264DecoderSpecificInfo  = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
         decoderConfigSizeLocal, M4READER_3GP,
         (M4OSA_Char*)"MPEG-4 AVC DecoderSpecific");
     if (M4OSA_NULL == pStreamHandler->m_pH264DecoderSpecificInfo) {
         goto cleanup;
     }
 
-    M4OSA_memcpy((M4OSA_MemAddr8 ) pStreamHandler->m_pH264DecoderSpecificInfo,
-        (M4OSA_MemAddr8 )pDecoderConfigLocal,
+    memcpy((void * ) pStreamHandler->m_pH264DecoderSpecificInfo,
+        (void * )pDecoderConfigLocal,
         pStreamHandler->m_H264decoderSpecificInfoSize);
     return M4NO_ERROR;
 cleanup:
@@ -1468,7 +1473,7 @@
                 pC->mStreamType = streamType;
                 pC->mStreamId = pC->mCurrTrack;
 
-                pVideoStreamHandler = (M4_VideoStreamHandler*)M4OSA_malloc
+                pVideoStreamHandler = (M4_VideoStreamHandler*)M4OSA_32bitAlignedMalloc
                     (sizeof(M4_VideoStreamHandler), M4READER_3GP,
                     (M4OSA_Char*)"M4_VideoStreamHandler");
                 if (M4OSA_NULL == pVideoStreamHandler) {
@@ -1520,31 +1525,29 @@
 
                 /* Get the DSI info */
                 if(M4DA_StreamTypeVideoH263 == streamType) {
-                    if (meta->findData(kKeyESDS, &type, &data, &size)) {
-                        ESDS esds((const char *)data, size);
-                        CHECK_EQ(esds.InitCheck(), OK);
-
-                        esds.getCodecSpecificInfo(
-                            &codec_specific_data, &codec_specific_data_size);
-                        (*pStreamHandler)->m_decoderSpecificInfoSize =
-                            codec_specific_data_size;
+                    if (meta->findData(kKeyD263, &type, &data, &size)) {
+                        (*pStreamHandler)->m_decoderSpecificInfoSize = size;
                         if ((*pStreamHandler)->m_decoderSpecificInfoSize != 0) {
-                            DecoderSpecific = (M4OSA_UInt8*)M4OSA_malloc(
+                            DecoderSpecific = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                                 (*pStreamHandler)->m_decoderSpecificInfoSize,
                                 M4READER_3GP,(M4OSA_Char*)"H263 DSI");
                             if (M4OSA_NULL == DecoderSpecific) {
                                 return M4ERR_ALLOC;
                             }
-                            M4OSA_memcpy((M4OSA_MemAddr8)DecoderSpecific,
-                                (M4OSA_MemAddr8)codec_specific_data,
-                                codec_specific_data_size);
+                            memcpy((void *)DecoderSpecific,
+                                (void *)data, size);
                             (*pStreamHandler)->m_pDecoderSpecificInfo =
                                 DecoderSpecific;
                         }
                         else {
                             (*pStreamHandler)->m_pDecoderSpecificInfo =
                                 M4OSA_NULL;
+                            (*pStreamHandler)->m_decoderSpecificInfoSize = 0;
                         }
+                        (*pStreamHandler)->m_pESDSInfo = M4OSA_NULL;
+                        (*pStreamHandler)->m_ESDSInfoSize = 0;
+                        (*pStreamHandler)->m_pH264DecoderSpecificInfo = M4OSA_NULL;
+                        (*pStreamHandler)->m_H264decoderSpecificInfoSize = 0;
                     } else {
                         LOGV("VE_getNextStreamHandler: H263 dsi not found");
                         (*pStreamHandler)->m_pDecoderSpecificInfo = M4OSA_NULL;
@@ -1560,15 +1563,15 @@
                     if(meta->findData(kKeyAVCC, &type, &data, &size)) {
                         decoderSpecificInfoSize = size;
                         if (decoderSpecificInfoSize != 0) {
-                            DecoderSpecificInfo = (M4OSA_Int8*)M4OSA_malloc(
+                            DecoderSpecificInfo = (M4OSA_Int8*)M4OSA_32bitAlignedMalloc(
                                 decoderSpecificInfoSize, M4READER_3GP,
                                 (M4OSA_Char*)"H264 DecoderSpecific" );
                             if (M4OSA_NULL == DecoderSpecificInfo) {
                                 LOGV("VideoEditor3gp_getNextStream is NULL ");
                                 return M4ERR_ALLOC;
                             }
-                            M4OSA_memcpy((M4OSA_MemAddr8)DecoderSpecificInfo,
-                                (M4OSA_MemAddr8)data, decoderSpecificInfoSize);
+                            memcpy((void *)DecoderSpecificInfo,
+                                (void *)data, decoderSpecificInfoSize);
                         } else {
                             LOGV("DSI Size %d", decoderSpecificInfoSize);
                             DecoderSpecificInfo = M4OSA_NULL;
@@ -1588,7 +1591,7 @@
                         m_H264decoderSpecificInfoSize);
 
                     if(M4OSA_NULL != DecoderSpecificInfo) {
-                        M4OSA_free((M4OSA_MemAddr32)DecoderSpecificInfo);
+                        free(DecoderSpecificInfo);
                         DecoderSpecificInfo = M4OSA_NULL;
                     }
                 } else if( (M4DA_StreamTypeVideoMpeg4 == streamType) ) {
@@ -1598,13 +1601,13 @@
 
                         (*pStreamHandler)->m_ESDSInfoSize = size;
                         (*pStreamHandler)->m_pESDSInfo = (M4OSA_UInt8*)\
-                        M4OSA_malloc((*pStreamHandler)->m_ESDSInfoSize,
+                        M4OSA_32bitAlignedMalloc((*pStreamHandler)->m_ESDSInfoSize,
                         M4READER_3GP, (M4OSA_Char*)"H263 DecoderSpecific" );
                         if (M4OSA_NULL == (*pStreamHandler)->m_pESDSInfo) {
                             return M4ERR_ALLOC;
                         }
-                        M4OSA_memcpy((M4OSA_MemAddr8)(*pStreamHandler)->\
-                            m_pESDSInfo, (M4OSA_MemAddr8)data, size);
+                        memcpy((void *)(*pStreamHandler)->\
+                            m_pESDSInfo, (void *)data, size);
 
                         esds.getCodecSpecificInfo(&codec_specific_data,
                             &codec_specific_data_size);
@@ -1614,14 +1617,14 @@
                         (*pStreamHandler)->m_decoderSpecificInfoSize =
                             codec_specific_data_size;
                         if ((*pStreamHandler)->m_decoderSpecificInfoSize != 0) {
-                            DecoderSpecific = (M4OSA_UInt8*)M4OSA_malloc(
+                            DecoderSpecific = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                                 (*pStreamHandler)->m_decoderSpecificInfoSize,
                                 M4READER_3GP, (M4OSA_Char*)" DecoderSpecific" );
                             if (M4OSA_NULL == DecoderSpecific) {
                                 return M4ERR_ALLOC;
                             }
-                            M4OSA_memcpy((M4OSA_MemAddr8)DecoderSpecific,
-                                (M4OSA_MemAddr8)codec_specific_data,
+                            memcpy((void *)DecoderSpecific,
+                                (void *)codec_specific_data,
                                 codec_specific_data_size);
                             (*pStreamHandler)->m_pDecoderSpecificInfo =
                                 DecoderSpecific;
@@ -1666,7 +1669,7 @@
 
                 LOGV("VE streamtype %d ,id %d",  streamType, pC->mCurrTrack);
 
-                pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_malloc
+                pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_32bitAlignedMalloc
                     (sizeof(M4_AudioStreamHandler), M4READER_3GP,
                     (M4OSA_Char*)"M4_AudioStreamHandler");
                 if (M4OSA_NULL == pAudioStreamHandler) {
@@ -1715,14 +1718,14 @@
                         codec_specific_data_size;
 
                     if ((*pStreamHandler)->m_decoderSpecificInfoSize != 0) {
-                        DecoderSpecific = (M4OSA_UInt8*)M4OSA_malloc(
+                        DecoderSpecific = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                             (*pStreamHandler)->m_decoderSpecificInfoSize,
                             M4READER_3GP, (M4OSA_Char*)"H263 DecoderSpecific" );
                         if (M4OSA_NULL == DecoderSpecific) {
                             return M4ERR_ALLOC;
                         }
-                        M4OSA_memcpy((M4OSA_MemAddr8)DecoderSpecific,
-                            (M4OSA_MemAddr8)codec_specific_data,
+                        memcpy((void *)DecoderSpecific,
+                            (void *)codec_specific_data,
                             codec_specific_data_size);
                         (*pStreamHandler)->m_pDecoderSpecificInfo =
                             DecoderSpecific;
@@ -1733,7 +1736,7 @@
                     M4OSA_UChar AmrDsi[] =
                         {'P','H','L','P',0x00, 0x00, 0x80, 0x00, 0x01,};
                     (*pStreamHandler)->m_decoderSpecificInfoSize = 9;
-                    DecoderSpecific = (M4OSA_UInt8*)M4OSA_malloc(
+                    DecoderSpecific = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                         (*pStreamHandler)->m_decoderSpecificInfoSize,
                         M4READER_3GP, (M4OSA_Char*)"H263 DecoderSpecific" );
                     if (M4OSA_NULL == DecoderSpecific) {
@@ -1757,14 +1760,14 @@
                     CHECK_EQ(esds.InitCheck(), OK);
 
                     (*pStreamHandler)->m_ESDSInfoSize = size;
-                    (*pStreamHandler)->m_pESDSInfo = (M4OSA_UInt8*)M4OSA_malloc(
+                    (*pStreamHandler)->m_pESDSInfo = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                         (*pStreamHandler)->m_ESDSInfoSize, M4READER_3GP,
                         (M4OSA_Char*)"H263 DecoderSpecific" );
                     if (M4OSA_NULL == (*pStreamHandler)->m_pESDSInfo) {
                         return M4ERR_ALLOC;
                     }
-                    M4OSA_memcpy((M4OSA_MemAddr8)(*pStreamHandler)->m_pESDSInfo,
-                    (M4OSA_MemAddr8)data, size);
+                    memcpy((void *)(*pStreamHandler)->m_pESDSInfo,
+                    (void *)data, size);
                     esds.getCodecSpecificInfo(&codec_specific_data,
                         &codec_specific_data_size);
 
@@ -1774,14 +1777,14 @@
                     (*pStreamHandler)->m_decoderSpecificInfoSize =
                         codec_specific_data_size;
                     if ((*pStreamHandler)->m_decoderSpecificInfoSize != 0) {
-                        DecoderSpecific = (M4OSA_UInt8*)M4OSA_malloc(
+                        DecoderSpecific = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(
                             (*pStreamHandler)->m_decoderSpecificInfoSize,
                             M4READER_3GP, (M4OSA_Char*)"H263 DecoderSpecific" );
                         if (M4OSA_NULL == DecoderSpecific) {
                             return M4ERR_ALLOC;
                         }
-                        M4OSA_memcpy((M4OSA_MemAddr8)DecoderSpecific,
-                            (M4OSA_MemAddr8)codec_specific_data,
+                        memcpy((void *)DecoderSpecific,
+                            (void *)codec_specific_data,
                             codec_specific_data_size);
                         (*pStreamHandler)->m_pDecoderSpecificInfo =
                             DecoderSpecific;
@@ -1818,7 +1821,7 @@
         if(M4DA_StreamTypeAudioAac == (*pStreamHandler)->m_streamType) {
             M4READER_AudioSbrUserdata*  pAudioSbrUserdata;
 
-            pAudioSbrUserdata = (M4READER_AudioSbrUserdata*)M4OSA_malloc(
+            pAudioSbrUserdata = (M4READER_AudioSbrUserdata*)M4OSA_32bitAlignedMalloc(
                 sizeof(M4READER_AudioSbrUserdata),M4READER_3GP,
                 (M4OSA_Char*)"M4READER_AudioSbrUserdata");
             if (M4OSA_NULL == pAudioSbrUserdata) {
@@ -1828,7 +1831,7 @@
             (*pStreamHandler)->m_pUserData = pAudioSbrUserdata;
             pAudioSbrUserdata->m_bIsSbrEnabled = M4OSA_FALSE;
 
-            pAudioSbrUserdata->m_pFirstAU = (M4_AccessUnit*)M4OSA_malloc(
+            pAudioSbrUserdata->m_pFirstAU = (M4_AccessUnit*)M4OSA_32bitAlignedMalloc(
                 sizeof(M4_AccessUnit),M4READER_3GP, (M4OSA_Char*)"1st AAC AU");
             if (M4OSA_NULL == pAudioSbrUserdata->m_pFirstAU) {
                 pAudioSbrUserdata->m_pAacDecoderUserConfig = M4OSA_NULL;
@@ -1836,7 +1839,7 @@
                 goto Error;
             }
             pAudioSbrUserdata->m_pAacDecoderUserConfig = (M4_AacDecoderConfig*)\
-                M4OSA_malloc(sizeof(M4_AacDecoderConfig),M4READER_3GP,
+                M4OSA_32bitAlignedMalloc(sizeof(M4_AacDecoderConfig),M4READER_3GP,
                 (M4OSA_Char*)"m_pAacDecoderUserConfig");
             if (M4OSA_NULL == pAudioSbrUserdata->m_pAacDecoderUserConfig) {
                 err = M4ERR_ALLOC;
@@ -1899,8 +1902,8 @@
     if (*pTime == (pStreamHandler->m_duration)) {
         *pTime -= 1;
     }
-    M4OSA_INT64_FROM_INT32(time64, *pTime);
-    time64 = time64 * 1000;
+
+    time64 = (M4OSA_Time)*pTime * 1000;
 
     LOGV("VideoEditor3gpReader_getPrevRapTime seek time: %ld",time64);
     options.setSeekTo(time64, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
@@ -1915,7 +1918,7 @@
     LOGV("VideoEditor3gpReader_getPrevRapTime read time %ld, %x", tempTime64,
         mMediaBuffer);
 
-    (*pTime) =  (tempTime64) / 1000;
+    *pTime = (M4OSA_Int32)(tempTime64 / 1000);
 
     if(mMediaBuffer != M4OSA_NULL) {
         LOGV(" mMediaBuffer size = %d length %d", mMediaBuffer->size(),
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
index a1f62cb..928f8ea 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
@@ -487,8 +487,8 @@
 
             // Copy the stream properties into userdata
             if( M4OSA_NULL != pUserData ) {
-                M4OSA_memcpy((M4OSA_MemAddr8)pUserData,
-                    (M4OSA_MemAddr8)&aacProperties,
+                memcpy((void *)pUserData,
+                    (void *)&aacProperties,
                     sizeof(AAC_DEC_STREAM_PROPS));
             }
             break;
@@ -604,8 +604,8 @@
 
     if( M4OSA_NULL != pInputBuffer ) {
         buffer = new MediaBuffer((size_t)pInputBuffer->m_bufferSize);
-        M4OSA_memcpy((M4OSA_Int8*)buffer->data() + buffer->range_offset(),
-            pInputBuffer->m_dataAddress, pInputBuffer->m_bufferSize);
+        memcpy((void *)((M4OSA_Int8*)buffer->data() + buffer->range_offset()),
+            (void *)pInputBuffer->m_dataAddress, pInputBuffer->m_bufferSize);
     }
     nbBuffer = pDecoderContext->mDecoderSource->storeBuffer(buffer);
 
@@ -647,8 +647,8 @@
         (M4OSA_UInt32)pDecoderContext->mNbOutputChannels ) {
         // Just copy the PCMs
         pOuputBuffer->m_bufferSize = (M4OSA_UInt32)buffer->range_length();
-        M4OSA_memcpy(pOuputBuffer->m_dataAddress,
-            ((M4OSA_MemAddr8)buffer->data())+buffer->range_offset(),
+        memcpy((void *)pOuputBuffer->m_dataAddress,
+            (void *)(((M4OSA_MemAddr8)buffer->data())+buffer->range_offset()),
             buffer->range_length());
     } else if( pDecoderContext->mAudioStreamHandler->m_nbChannels <
         (M4OSA_UInt32)pDecoderContext->mNbOutputChannels ) {
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioEncoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioEncoder.cpp
index 718881f..bcae1a8 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioEncoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioEncoder.cpp
@@ -459,8 +459,8 @@
         SAFE_MALLOC(pEncoderContext->mDSI.pInfo, M4OSA_Int8,
             pEncoderContext->mDSI.infoSize, "Encoder header");
 
-        M4OSA_memcpy(pEncoderContext->mDSI.pInfo,
-            (M4OSA_MemAddr8)(buffer->data())+buffer->range_offset(),
+        memcpy((void *)pEncoderContext->mDSI.pInfo,
+            (void *)((M4OSA_MemAddr8)(buffer->data())+buffer->range_offset()),
             pEncoderContext->mDSI.infoSize);
 
         buffer->release();
@@ -499,7 +499,7 @@
             // Let the MediaBuffer own the data so we don't have to free it
             buffer = new MediaBuffer((size_t)pInBuffer->pTableBufferSize[0]);
             pData = (M4OSA_Int8*)buffer->data() + buffer->range_offset();
-            M4OSA_memcpy(pData, pInBuffer->pTableBuffer[0],
+            memcpy((void *)pData, (void *)pInBuffer->pTableBuffer[0],
                 pInBuffer->pTableBufferSize[0]);
             break;
         default:
@@ -568,8 +568,8 @@
         pEncoderContext->mLastOutputCts = i64Tmp;
 
         // Format the AU
-        M4OSA_memcpy(pOutBuffer->pTableBuffer[0],
-            (M4OSA_MemAddr8)(buffer->data())+buffer->range_offset(),
+        memcpy((void *)pOutBuffer->pTableBuffer[0],
+            (void *)((M4OSA_MemAddr8)(buffer->data())+buffer->range_offset()),
             buffer->range_length());
         pOutBuffer->pTableBufferSize[0] = (M4OSA_UInt32)buffer->range_length();
     }
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c b/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
index 9f50a58..37f960a 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
@@ -32,7 +32,7 @@
 { \
     if(M4OSA_NULL != p) \
     { \
-        M4OSA_free((M4OSA_MemAddr32)p); \
+        free(p); \
         p = M4OSA_NULL; \
     } \
 }
@@ -59,7 +59,7 @@
         ppool, nbBuffers);
 
     pool = M4OSA_NULL;
-    pool = (VIDEOEDITOR_BUFFER_Pool*)M4OSA_malloc(
+    pool = (VIDEOEDITOR_BUFFER_Pool*)M4OSA_32bitAlignedMalloc(
             sizeof(VIDEOEDITOR_BUFFER_Pool), VIDEOEDITOR_BUFFER_EXTERNAL,
             (M4OSA_Char*)("VIDEOEDITOR_BUFFER_allocatePool: pool"));
     if (M4OSA_NULL == pool)
@@ -70,7 +70,7 @@
 
     LOGV("VIDEOEDITOR_BUFFER_allocatePool : Allocating Pool buffers");
     pool->pNXPBuffer = M4OSA_NULL;
-    pool->pNXPBuffer = (VIDEOEDITOR_BUFFER_Buffer*)M4OSA_malloc(
+    pool->pNXPBuffer = (VIDEOEDITOR_BUFFER_Buffer*)M4OSA_32bitAlignedMalloc(
                             sizeof(VIDEOEDITOR_BUFFER_Buffer)*nbBuffers,
                             VIDEOEDITOR_BUFFER_EXTERNAL,
                             (M4OSA_Char*)("BUFFER_allocatePool: pNXPBuffer"));
@@ -82,7 +82,7 @@
 
     LOGV("VIDEOEDITOR_BUFFER_allocatePool : Allocating Pool name buffer");
     pool->poolName = M4OSA_NULL;
-    pool->poolName = (M4OSA_Char*)M4OSA_malloc(
+    pool->poolName = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(
         VIDEOEDITOR_BUFFEPOOL_MAX_NAME_SIZE,VIDEOEDITOR_BUFFER_EXTERNAL,
         (M4OSA_Char*)("VIDEOEDITOR_BUFFER_allocatePool: poolname"));
     if(pool->poolName == M4OSA_NULL)
@@ -93,8 +93,8 @@
 
     LOGV("VIDEOEDITOR_BUFFER_allocatePool : Assigning Pool name buffer");
 
-    M4OSA_memset(pool->poolName, VIDEOEDITOR_BUFFEPOOL_MAX_NAME_SIZE, 0);
-    M4OSA_memcpy(pool->poolName, poolName,
+    memset((void *)pool->poolName, 0,VIDEOEDITOR_BUFFEPOOL_MAX_NAME_SIZE);
+    memcpy((void *)pool->poolName, (void *)poolName,
         VIDEOEDITOR_BUFFEPOOL_MAX_NAME_SIZE-1);
 
     pool->NB = nbBuffers;
@@ -134,7 +134,7 @@
     {
         if(M4OSA_NULL != ppool->pNXPBuffer[j].pData)
         {
-            M4OSA_free((M4OSA_MemAddr32)ppool->pNXPBuffer[j].pData);
+            free(ppool->pNXPBuffer[j].pData);
             ppool->pNXPBuffer[j].pData = M4OSA_NULL;
         }
     }
@@ -208,20 +208,20 @@
 
     /**
      * Initialize all the buffers in the pool */
-    for(index = 0; index< pool->NB; index++)
+    for(index = 0; index < pool->NB; index++)
     {
         pool->pNXPBuffer[index].pData = M4OSA_NULL;
-        pool->pNXPBuffer[index].pData = (M4OSA_Void*)M4OSA_malloc(
+        pool->pNXPBuffer[index].pData = (M4OSA_Void*)M4OSA_32bitAlignedMalloc(
             lSize, VIDEOEDITOR_BUFFER_EXTERNAL,
             (M4OSA_Char*)("BUFFER_initPoolBuffers: Buffer data"));
         if(M4OSA_NULL == pool->pNXPBuffer[index].pData)
         {
             for (j = 0; j < index; j++)
             {
-                if(M4OSA_NULL != pool->pNXPBuffer[index].pData)
+                if(M4OSA_NULL != pool->pNXPBuffer[j].pData)
                 {
-                    M4OSA_free((M4OSA_MemAddr32)pool->pNXPBuffer[index].pData);
-                    pool->pNXPBuffer[index].pData = M4OSA_NULL;
+                    free(pool->pNXPBuffer[j].pData);
+                    pool->pNXPBuffer[j].pData = M4OSA_NULL;
                 }
             }
             err = M4ERR_ALLOC;
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
index 322881a..1ae567e 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
@@ -97,7 +97,7 @@
 
     pReaderContext->mAudioStreamHandler  = M4OSA_NULL;
     pReaderContext->mAudioAu.dataAddress = M4OSA_NULL;
-    M4OSA_INT64_FROM_INT32(pReaderContext->mMaxDuration, 0);
+    pReaderContext->mMaxDuration = 0;
     *pContext = pReaderContext;
 
 cleanUp:
@@ -147,7 +147,8 @@
 
  * @return    M4NO_ERROR                     there is no error
  * @return    M4ERR_PARAMETER                the context is NULL
- * @return    M4ERR_BAD_CONTEXT            provided context is not a valid one
+ * @return    M4ERR_BAD_CONTEXT              provided context is not a valid one
+ * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE   the media is DRM protected
  ******************************************************************************
 */
 M4OSA_ERR VideoEditorMp3Reader_open(M4OSA_Context context,
@@ -184,6 +185,14 @@
     }
     pReaderContext->mStreamNumber = 0;
 
+    int32_t isDRMProtected = 0;
+    sp<MetaData> meta = pReaderContext->mExtractor->getMetaData();
+    meta->findInt32(kKeyIsDRM, &isDRMProtected);
+    if (isDRMProtected) {
+        LOGV("VideoEditorMp3Reader_open error - DRM Protected");
+        return M4ERR_UNSUPPORTED_MEDIA_TYPE;
+    }
+
     LOGV("VideoEditorMp3Reader_open end");
     return err;
 }
@@ -209,7 +218,7 @@
     if (pReaderContext->mAudioStreamHandler != NULL) {
         if (M4OSA_NULL != pReaderContext->mAudioStreamHandler->\
         m_basicProperties.m_pDecoderSpecificInfo) {
-            M4OSA_free((M4OSA_MemAddr32)pReaderContext->mAudioStreamHandler->\
+            free(pReaderContext->mAudioStreamHandler->\
                 m_basicProperties.m_pDecoderSpecificInfo);
             pReaderContext->mAudioStreamHandler->m_basicProperties.\
                 m_decoderSpecificInfoSize = 0;
@@ -218,11 +227,11 @@
         }
 
         /* Finally destroy the stream handler */
-        M4OSA_free((M4OSA_MemAddr32)pReaderContext->mAudioStreamHandler);
+        free(pReaderContext->mAudioStreamHandler);
         pReaderContext->mAudioStreamHandler = M4OSA_NULL;
 
         if (pReaderContext->mAudioAu.dataAddress != NULL) {
-            M4OSA_free((M4OSA_MemAddr32)pReaderContext->mAudioAu.dataAddress);
+            free(pReaderContext->mAudioAu.dataAddress);
             pReaderContext->mAudioAu.dataAddress = NULL;
         }
     }
@@ -268,7 +277,7 @@
     case M4READER_kOptionID_Duration:
         {
             LOGV("Mp3Reader duration=%ld",pReaderContext->mMaxDuration);
-            M4OSA_TIME_SET(*(M4OSA_Time*)pValue, pReaderContext->mMaxDuration);
+            *(M4OSA_Time*)pValue = pReaderContext->mMaxDuration;
         }
         break;
 
@@ -363,8 +372,7 @@
     M4SYS_StreamID streamIdArray[2];
     M4OSA_ERR err = M4NO_ERROR;
     M4SYS_AccessUnit* pAu;
-    M4OSA_Time time64;
-    M4OSA_Double timeDouble;
+    M4OSA_Time time64 = (M4OSA_Time)*pTime;
 
     LOGV("VideoEditorMp3Reader_jump begin");
     M4OSA_DEBUG_IF1((pReaderContext == 0), M4ERR_PARAMETER,
@@ -374,8 +382,6 @@
     M4OSA_DEBUG_IF1((pTime == 0), M4ERR_PARAMETER,
         "VideoEditorMp3Reader_jump: invalid time pointer");
 
-    M4OSA_INT64_FROM_INT32(time64, *pTime);
-
     if(pStreamHandler == (M4_StreamHandler*)pReaderContext->\
         mAudioStreamHandler){
         pAu = &pReaderContext->mAudioAu;
@@ -399,8 +405,7 @@
     pReaderContext->mSeekTime = time64;
 
     time64 = time64 / 1000; /* Convert the time into milli sec */
-    M4OSA_INT64_TO_DOUBLE(timeDouble, time64);
-    *pTime = (M4OSA_Int32)timeDouble;
+    *pTime = (M4OSA_Int32)time64;
     LOGV("VideoEditorMp3Reader_jump end ");
     return err;
 }
@@ -494,7 +499,7 @@
     streamDesc.maxBitrate = streamDesc.averageBitrate;
 
     /*    Allocate the audio stream handler and set its parameters    */
-    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_malloc(
+    pAudioStreamHandler = (M4_AudioStreamHandler*)M4OSA_32bitAlignedMalloc(
         sizeof(M4_AudioStreamHandler), M4READER_MP3,
         (M4OSA_Char*)"M4_AudioStreamHandler");
 
@@ -614,7 +619,7 @@
     M4OSA_ERR err = M4NO_ERROR;
     M4SYS_StreamID streamIdArray[2];
     M4SYS_AccessUnit* pAu;
-    M4OSA_Time time64;
+    M4OSA_Time time64 = 0;
 
     LOGV("VideoEditorMp3Reader_reset start");
     M4OSA_DEBUG_IF1((pReaderContext == 0), M4ERR_PARAMETER,
@@ -622,8 +627,6 @@
     M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
         "VideoEditorMp3Reader_reset: invalid pointer to M4_StreamHandler");
 
-    M4OSA_INT64_FROM_INT32(time64, 0);
-
     if (pStreamHandler == (M4_StreamHandler*)pReaderContext->\
         mAudioStreamHandler) {
         pAu = &pReaderContext->mAudioAu;
@@ -691,10 +694,10 @@
         if ((pAu->dataAddress == NULL) ||
             (pAu->size < mAudioBuffer->range_length())) {
             if (pAu->dataAddress != NULL) {
-                M4OSA_free((M4OSA_Int32*)pAu->dataAddress);
+                free((M4OSA_Int32*)pAu->dataAddress);
                 pAu->dataAddress = NULL;
             }
-            pAu->dataAddress = (M4OSA_Int32*)M4OSA_malloc(
+            pAu->dataAddress = (M4OSA_Int32*)M4OSA_32bitAlignedMalloc(
                 (mAudioBuffer->range_length() + 3) & ~0x3,
                 M4READER_MP3, (M4OSA_Char*)"pAccessUnit->m_dataAddress" );
 
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
index a8b9c0c..3b3f89f 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
@@ -200,7 +200,7 @@
             ? (M4OSA_UInt32)mMaxAUSize : pAccessUnit->m_size;
         LOGV("VideoDecoderSource:Read() copying AU to i/p buffer of decoder,"
             "Bufer Add = 0x%x, size = %d", mBuffer->data(), lSize);
-        M4OSA_memcpy((M4OSA_MemAddr8)mBuffer->data(),pAccessUnit->m_dataAddress,
+        memcpy((void *)mBuffer->data(),(void *)pAccessUnit->m_dataAddress,
             lSize);
 
         mBuffer->set_range(0, lSize);
@@ -612,7 +612,7 @@
         (uint16_t *) &(PlaneOut[2].pac_data[PlaneOut[2].u_topleft]);
 
     /* Y copying */
-    memcpy(outy, inyuv, outYsize);
+    memcpy((void *)outy, (void *)inyuv, outYsize);
 
     /* U & V copying */
     uint32_t *inyuv_4 = (uint32_t *) (inyuv + outYsize);
@@ -745,9 +745,9 @@
         cropRight = vWidth - 1;
         cropBottom = vHeight - 1;
 
-        LOGI("got dimensions only %d x %d", width, height);
+        LOGV("got dimensions only %d x %d", width, height);
     } else {
-        LOGI("got crop rect %d, %d, %d, %d",
+        LOGV("got crop rect %d, %d, %d, %d",
              cropLeft, cropTop, cropRight, cropBottom);
     }
 
@@ -1304,7 +1304,6 @@
         } else if ( INFO_FORMAT_CHANGED == errStatus ) {
             LOGV("VideoDecoder_decode:source returns INFO_FORMAT_CHANGED:TODO");
 
-#if 1
             LOGV("VideoDecoder_decode : source returns INFO_FORMAT_CHANGED");
             lerr = VideoEditorVideoDecoder_configureFromMetadata(
                 pDecShellContext,
@@ -1314,7 +1313,6 @@
                     "VideoDecoder_configureFromMetadata returns 0x%X", lerr);
                 break;
             }
-#endif
             continue;
         }
 
@@ -1379,15 +1377,15 @@
                 {
                     M4OSA_MemAddr8 pTmpBuff = (M4OSA_MemAddr8)pDecoderBuffer->data() + pDecoderBuffer->range_offset();
 
-                    M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData, pTmpBuff, yPlaneSize);
+                    memcpy((void *)tmpDecBuffer->pData, (void *)pTmpBuff, yPlaneSize);
 
                     offsetSrc += pDecShellContext->mGivenWidth * pDecShellContext->mGivenHeight;
-                    M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize,
-                        pTmpBuff + offsetSrc, uvPlaneSize);
+                    memcpy((void *)((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize),
+                        (void *)(pTmpBuff + offsetSrc), uvPlaneSize);
 
                     offsetSrc += (pDecShellContext->mGivenWidth >> 1) * (pDecShellContext->mGivenHeight >> 1);
-                    M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize + uvPlaneSize,
-                        pTmpBuff + offsetSrc, uvPlaneSize);
+                    memcpy((void *)((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize + uvPlaneSize),
+                        (void *)(pTmpBuff + offsetSrc), uvPlaneSize);
                 }
                 else
                 {
@@ -1397,7 +1395,7 @@
 
                     for ( index = 0; index < height; index++)
                     {
-                        memcpy(pTmpBuffDst, pTmpBuff, width);
+                        memcpy((void *)pTmpBuffDst, (void *)pTmpBuff, width);
                         pTmpBuffDst += width;
                         pTmpBuff += pDecShellContext->mGivenWidth;
                     }
@@ -1405,7 +1403,7 @@
                     pTmpBuff += (pDecShellContext->mGivenWidth * ( pDecShellContext->mGivenHeight - height));
                     for ( index = 0; index < height >> 1; index++)
                     {
-                        memcpy(pTmpBuffDst, pTmpBuff, width >> 1);
+                        memcpy((void *)pTmpBuffDst, (void *)pTmpBuff, width >> 1);
                         pTmpBuffDst += width >> 1;
                         pTmpBuff += pDecShellContext->mGivenWidth >> 1;
                     }
@@ -1413,7 +1411,7 @@
                     pTmpBuff += ((pDecShellContext->mGivenWidth * (pDecShellContext->mGivenHeight - height)) / 4);
                     for ( index = 0; index < height >> 1; index++)
                     {
-                        memcpy(pTmpBuffDst, pTmpBuff, width >> 1);
+                        memcpy((void *)pTmpBuffDst, (void *)pTmpBuff, width >> 1);
                         pTmpBuffDst += width >> 1;
                         pTmpBuff += pDecShellContext->mGivenWidth >> 1;
                     }
@@ -1554,13 +1552,13 @@
         M4OSA_UInt32 tempHeight =
             pDecShellContext->m_pVideoStreamhandler->m_videoHeight;
 
-        M4OSA_memcpy((M4OSA_MemAddr8) pOutputPlane[0].pac_data, tempBuffPtr,
+        memcpy((void *) pOutputPlane[0].pac_data, (void *)tempBuffPtr,
             tempWidth * tempHeight);
         tempBuffPtr += (tempWidth * tempHeight);
-        M4OSA_memcpy((M4OSA_MemAddr8) pOutputPlane[1].pac_data, tempBuffPtr,
+        memcpy((void *) pOutputPlane[1].pac_data, (void *)tempBuffPtr,
             (tempWidth/2) * (tempHeight/2));
         tempBuffPtr += ((tempWidth/2) * (tempHeight/2));
-        M4OSA_memcpy((M4OSA_MemAddr8) pOutputPlane[2].pac_data, tempBuffPtr,
+        memcpy((void *) pOutputPlane[2].pac_data, (void *)tempBuffPtr,
             (tempWidth/2) * (tempHeight/2));
     }
 
@@ -1585,7 +1583,7 @@
         M4DECODER_VideoType *pDecoderType, M4OSA_Context *pDecInterface) {
     M4DECODER_VideoInterface* pDecoderInterface = M4OSA_NULL;
 
-    pDecoderInterface = (M4DECODER_VideoInterface*)M4OSA_malloc(
+    pDecoderInterface = (M4DECODER_VideoInterface*)M4OSA_32bitAlignedMalloc(
         sizeof(M4DECODER_VideoInterface), M4DECODER_EXTERNAL,
         (M4OSA_Char*)"VideoEditorVideoDecoder_getInterface" );
     if (M4OSA_NULL == pDecoderInterface) {
@@ -1609,7 +1607,7 @@
         M4DECODER_VideoType *pDecoderType, M4OSA_Context *pDecInterface) {
     M4DECODER_VideoInterface* pDecoderInterface = M4OSA_NULL;
 
-    pDecoderInterface = (M4DECODER_VideoInterface*)M4OSA_malloc(
+    pDecoderInterface = (M4DECODER_VideoInterface*)M4OSA_32bitAlignedMalloc(
         sizeof(M4DECODER_VideoInterface), M4DECODER_EXTERNAL,
         (M4OSA_Char*)"VideoEditorVideoDecoder_getInterface" );
     if (M4OSA_NULL == pDecoderInterface) {
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
index 3112f71..0a595a2 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
@@ -102,7 +102,7 @@
 };
 
 sp<VideoEditorVideoEncoderSource> VideoEditorVideoEncoderSource::Create() {
-

+
     sp<VideoEditorVideoEncoderSource> aSource =
         new VideoEditorVideoEncoderSource();
     return aSource;
@@ -118,7 +118,7 @@
 }
 
 VideoEditorVideoEncoderSource::~VideoEditorVideoEncoderSource() {
-

+
     // Safety clean up
     if( STARTED == mState ) {
         stop();
@@ -173,7 +173,7 @@
 
     LOGW("VideoEditorVideoEncoderSource::getFormat:THIS IS NOT IMPLEMENTED");
     return NULL;
-}

+}
 
 status_t VideoEditorVideoEncoderSource::read(MediaBuffer **buffer,
         const ReadOptions *options) {
@@ -201,7 +201,7 @@
     }
     *buffer = mFirstBufferLink->buffer;
     tmpLink = mFirstBufferLink;
-    mFirstBufferLink = mFirstBufferLink->nextLink;

+    mFirstBufferLink = mFirstBufferLink->nextLink;
 
     if ( NULL == mFirstBufferLink ) {
         mLastBufferLink = NULL;
@@ -235,7 +235,7 @@
     }
     LOGV("VideoEditorVideoEncoderSource::storeBuffer() end");
     return mNbBuffer;
-}

+}
 
 /**
  ******************************************************************************
@@ -250,7 +250,7 @@
     STARTED   = 0x4,
     BUFFERING = 0x8,
     READING   = 0x10
-} VideoEditorVideoEncoder_State;

+} VideoEditorVideoEncoder_State;
 
 typedef struct {
     VideoEditorVideoEncoder_State     mState;
@@ -299,7 +299,7 @@
     sp<VideoEditorVideoEncoderSource> encoderSource = NULL;
     sp<MediaSource> encoder = NULL;;
     OMXClient client;
-

+
     LOGV("VideoEditorVideoEncoder_getDSI begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext,       M4ERR_PARAMETER);
@@ -360,8 +360,8 @@
             (M4OSA_UInt32)outputBuffer->range_length();
         SAFE_MALLOC(pEncoderContext->mHeader.pBuf, M4OSA_Int8,
             pEncoderContext->mHeader.Size, "Encoder header");
-        M4OSA_memcpy(pEncoderContext->mHeader.pBuf,
-            (M4OSA_MemAddr8)(outputBuffer->data())+outputBuffer->range_offset(),
+        memcpy((void *)pEncoderContext->mHeader.pBuf,
+            (void *)((M4OSA_MemAddr8)(outputBuffer->data())+outputBuffer->range_offset()),
             pEncoderContext->mHeader.Size);
         outputBuffer->release();
     }
@@ -389,7 +389,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_cleanup(M4ENCODER_Context pContext) {
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_cleanup begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -407,7 +407,7 @@
         LOGV("VideoEditorVideoEncoder_cleanup no error");
     } else {
         LOGV("VideoEditorVideoEncoder_cleanup ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_cleanup end");
     return err;
 }
@@ -416,11 +416,11 @@
         M4ENCODER_Context* pContext,
         M4WRITER_DataInterface* pWriterDataInterface,
         M4VPP_apply_fct* pVPPfct, M4VPP_Context pVPPctxt,
-        M4OSA_Void* pExternalAPI, M4OSA_Void* pUserData) {

+        M4OSA_Void* pExternalAPI, M4OSA_Void* pUserData) {
 
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_init begin: format  %d", format);
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -446,7 +446,7 @@
         VideoEditorVideoEncoder_cleanup(pEncoderContext);
         *pContext = M4OSA_NULL;
         LOGV("VideoEditorVideoEncoder_init ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_init end");
     return err;
 }
@@ -454,7 +454,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_init_H263(M4ENCODER_Context* pContext,
         M4WRITER_DataInterface* pWriterDataInterface, M4VPP_apply_fct* pVPPfct,
         M4VPP_Context pVPPctxt, M4OSA_Void* pExternalAPI, M4OSA_Void* pUserData)
-        {

+        {
 
     return VideoEditorVideoEncoder_init(M4ENCODER_kH263, pContext,
         pWriterDataInterface, pVPPfct, pVPPctxt, pExternalAPI, pUserData);
@@ -464,7 +464,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_init_MPEG4(M4ENCODER_Context* pContext,
         M4WRITER_DataInterface* pWriterDataInterface, M4VPP_apply_fct* pVPPfct,
         M4VPP_Context pVPPctxt, M4OSA_Void* pExternalAPI, M4OSA_Void* pUserData)
-        {

+        {
 
     return VideoEditorVideoEncoder_init(M4ENCODER_kMPEG4, pContext,
         pWriterDataInterface, pVPPfct, pVPPctxt, pExternalAPI, pUserData);
@@ -474,7 +474,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_init_H264(M4ENCODER_Context* pContext,
         M4WRITER_DataInterface* pWriterDataInterface, M4VPP_apply_fct* pVPPfct,
         M4VPP_Context pVPPctxt, M4OSA_Void* pExternalAPI, M4OSA_Void* pUserData)
-        {

+        {
 
     return VideoEditorVideoEncoder_init(M4ENCODER_kH264, pContext,
         pWriterDataInterface, pVPPfct, pVPPctxt, pExternalAPI, pUserData);
@@ -483,7 +483,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_close(M4ENCODER_Context pContext) {
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_close begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -507,7 +507,7 @@
         LOGV("VideoEditorVideoEncoder_close no error");
     } else {
         LOGV("VideoEditorVideoEncoder_close ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_close end");
     return err;
 }
@@ -524,7 +524,7 @@
     int32_t iProfile = 0;
     int32_t iFrameRate = 0;
     uint32_t codecFlags = 0;
-

+
     LOGV(">>> VideoEditorVideoEncoder_open begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -664,7 +664,7 @@
     } else {
         VideoEditorVideoEncoder_close(pEncoderContext);
         LOGV("VideoEditorVideoEncoder_open ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_open end");
     return err;
 }
@@ -679,7 +679,7 @@
     M4VIFI_ImagePlane pOutPlane[3];
     MediaBuffer* buffer = NULL;
     int32_t nbBuffer = 0;
-

+
     LOGV("VideoEditorVideoEncoder_processInputBuffer begin: cts  %f", Cts);
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -765,11 +765,11 @@
     if ( OMX_COLOR_FormatYUV420SemiPlanar == \
             pEncoderContext->mEncoderColorFormat ) {
         // Y plane has not been allocated
-        if ( pOutPlane[1].pac_data ) {

-            SAFE_FREE(pOutPlane[1].pac_data);

+        if ( pOutPlane[1].pac_data ) {
+            SAFE_FREE(pOutPlane[1].pac_data);
         }
-        if ( pOutPlane[2].pac_data ) {

-            SAFE_FREE(pOutPlane[2].pac_data);

+        if ( pOutPlane[2].pac_data ) {
+            SAFE_FREE(pOutPlane[2].pac_data);
         }
     }
     if ( (M4NO_ERROR == err) || (M4WAR_SF_LOW_BUFFER == err) ) {
@@ -779,7 +779,7 @@
             buffer->release();
         }
         LOGV("VideoEditorVideoEncoder_processInputBuffer ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_processInputBuffer end");
     return err;
 }
@@ -792,7 +792,7 @@
     int32_t i32Tmp = 0;
     int64_t i64Tmp = 0;
     status_t result = OK;
-

+
     LOGV("VideoEditorVideoEncoder_processOutputBuffer begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -809,7 +809,6 @@
     VIDEOEDITOR_CHECK(0 == ((M4OSA_UInt32)buffer->data())%4, M4ERR_PARAMETER);
     VIDEOEDITOR_CHECK(buffer->meta_data().get(), M4ERR_PARAMETER);
     if ( buffer->meta_data()->findInt32(kKeyIsCodecConfig, &i32Tmp) && i32Tmp ){
-#if 1
         {   // Display the DSI
             LOGV("VideoEditorVideoEncoder_processOutputBuffer DSI %d",
                 buffer->range_length());
@@ -818,7 +817,6 @@
                 LOGV("DSI [%d] %.2X", i, tmp[i]);
             }
         }
-#endif
 
 #ifndef VIDEOEDITOR_ENCODER_GET_DSI_AT_CREATION
         VIDEOEDITOR_CHECK(M4OSA_NULL == pEncoderContext->mHeader.pBuf,
@@ -835,8 +833,8 @@
                 (M4OSA_UInt32)buffer->range_length();
             SAFE_MALLOC(pEncoderContext->mHeader.pBuf, M4OSA_Int8,
                 pEncoderContext->mHeader.Size, "Encoder header");
-            M4OSA_memcpy(pEncoderContext->mHeader.pBuf,
-                (M4OSA_MemAddr8)(buffer->data())+buffer->range_offset(),
+            memcpy((void *)pEncoderContext->mHeader.pBuf,
+                (void *)((M4OSA_MemAddr8)(buffer->data())+buffer->range_offset()),
                 pEncoderContext->mHeader.Size);
         }
 #endif /* VIDEOEDITOR_ENCODER_GET_DSI_AT_CREATION */
@@ -846,8 +844,8 @@
             M4ERR_STATE);
 
         pEncoderContext->mNbOutputFrames++;
-        if ( 0 > pEncoderContext->mFirstOutputCts ) {

-            pEncoderContext->mFirstOutputCts = i64Tmp;

+        if ( 0 > pEncoderContext->mFirstOutputCts ) {
+            pEncoderContext->mFirstOutputCts = i64Tmp;
         }
         pEncoderContext->mLastOutputCts = i64Tmp;
 
@@ -897,9 +895,9 @@
         pEncoderContext->mAccessUnit->size = (M4OSA_UInt32)outputSize;
         } else {
             // The AU can just be copied
-            M4OSA_memcpy((M4OSA_MemAddr8)pEncoderContext->mAccessUnit->\
-                dataAddress, (M4OSA_MemAddr8)(buffer->data())+buffer->\
-                range_offset(), buffer->range_length());
+            memcpy((void *)pEncoderContext->mAccessUnit->\
+                dataAddress, (void *)((M4OSA_MemAddr8)(buffer->data())+buffer->\
+                range_offset()), buffer->range_length());
             pEncoderContext->mAccessUnit->size =
                 (M4OSA_UInt32)buffer->range_length();
         }
@@ -913,9 +911,9 @@
         pEncoderContext->mAccessUnit->CTS = Cts;
         pEncoderContext->mAccessUnit->DTS = Cts;
 
-        LOGV("VideoEditorVideoEncoder_processOutputBuffer: AU @ 0x%X 0x%X %d %d",

+        LOGV("VideoEditorVideoEncoder_processOutputBuffer: AU @ 0x%X 0x%X %d %d",
             pEncoderContext->mAccessUnit->dataAddress,
-            *pEncoderContext->mAccessUnit->dataAddress,

+            *pEncoderContext->mAccessUnit->dataAddress,
             pEncoderContext->mAccessUnit->size,
             pEncoderContext->mAccessUnit->CTS);
 
@@ -935,7 +933,7 @@
         SAFE_FREE(pEncoderContext->mHeader.pBuf);
         pEncoderContext->mHeader.Size = 0;
         LOGV("VideoEditorVideoEncoder_processOutputBuffer ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_processOutputBuffer end");
     return err;
 }
@@ -947,20 +945,20 @@
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
     status_t result = OK;
     MediaBuffer* outputBuffer = NULL;
-

+
     LOGV("VideoEditorVideoEncoder_encode 0x%X %f %d", pInPlane, Cts, FrameMode);
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
 
     pEncoderContext = (VideoEditorVideoEncoder_Context*)pContext;
-    if ( STARTED == pEncoderContext->mState ) {

-        pEncoderContext->mState = BUFFERING;

+    if ( STARTED == pEncoderContext->mState ) {
+        pEncoderContext->mState = BUFFERING;
     }
     VIDEOEDITOR_CHECK(
         (BUFFERING | READING) & pEncoderContext->mState, M4ERR_STATE);
 
     pEncoderContext->mNbInputFrames++;
-    if ( 0 > pEncoderContext->mFirstInputCts ) {

-        pEncoderContext->mFirstInputCts = Cts;

+    if ( 0 > pEncoderContext->mFirstInputCts ) {
+        pEncoderContext->mFirstInputCts = Cts;
     }
     pEncoderContext->mLastInputCts = Cts;
 
@@ -992,13 +990,13 @@
     }
     // Read
     result = pEncoderContext->mEncoder->read(&outputBuffer, NULL);
-    if( OK != result ) {

-        LOGV("VideoEditorVideoEncoder_encode: encoder returns 0x%X", result);

-    }

+    if( OK != result ) {
+        LOGV("VideoEditorVideoEncoder_encode: encoder returns 0x%X", result);
+    }
 
     if( ERROR_END_OF_STREAM == result ) {
-        if( outputBuffer != NULL ) {

-            LOGV("VideoEditorVideoEncoder_encode : EOS w/ buffer");

+        if( outputBuffer != NULL ) {
+            LOGV("VideoEditorVideoEncoder_encode : EOS w/ buffer");
         }
         VIDEOEDITOR_CHECK(0 == VIDEOEDITOR_MIN_BUFFER_NB, M4ERR_STATE);
         // No output provided here, just exit
@@ -1017,7 +1015,7 @@
         LOGV("VideoEditorVideoEncoder_encode no error");
     } else {
         LOGV("VideoEditorVideoEncoder_encode ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_encode end");
     return err;
 }
@@ -1026,7 +1024,7 @@
     M4OSA_ERR                  err             = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
     status_t                   result          = OK;
-

+
     LOGV("VideoEditorVideoEncoder_start begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -1052,7 +1050,7 @@
         LOGV("VideoEditorVideoEncoder_start no error");
     } else {
         LOGV("VideoEditorVideoEncoder_start ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_start end");
     return err;
 }
@@ -1062,7 +1060,7 @@
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
     MediaBuffer* outputBuffer = NULL;
     status_t result = OK;
-

+
     LOGV("VideoEditorVideoEncoder_stop begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -1102,7 +1100,7 @@
         LOGV("VideoEditorVideoEncoder_stop no error");
     } else {
         LOGV("VideoEditorVideoEncoder_stop ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_stop end");
     return err;
 }
@@ -1110,7 +1108,7 @@
 M4OSA_ERR VideoEditorVideoEncoder_regulBitRate(M4ENCODER_Context pContext) {
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_regulBitRate begin");
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -1123,7 +1121,7 @@
         LOGV("VideoEditorVideoEncoder_regulBitRate no error");
     } else {
         LOGV("VideoEditorVideoEncoder_regulBitRate ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_regulBitRate end");
     return err;
 }
@@ -1132,7 +1130,7 @@
         M4OSA_UInt32 optionID, M4OSA_DataOption optionValue) {
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_setOption start optionID 0x%X", optionID);
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -1160,7 +1158,7 @@
         LOGV("VideoEditorVideoEncoder_setOption no error");
     } else {
         LOGV("VideoEditorVideoEncoder_setOption ERROR 0x%X", err);
-    }

+    }
     LOGV("VideoEditorVideoEncoder_setOption end");
     return err;
 }
@@ -1169,7 +1167,7 @@
         M4OSA_UInt32 optionID, M4OSA_DataOption optionValue) {
     M4OSA_ERR err = M4NO_ERROR;
     VideoEditorVideoEncoder_Context* pEncoderContext = M4OSA_NULL;
-

+
     LOGV("VideoEditorVideoEncoder_getOption begin optinId 0x%X", optionID);
     // Input parameters check
     VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
@@ -1195,7 +1193,7 @@
         LOGV("VideoEditorVideoEncoder_getOption ERROR 0x%X", err);
     }
     return err;
-}

+}
 
 M4OSA_ERR VideoEditorVideoEncoder_getInterface(M4ENCODER_Format format,
         M4ENCODER_Format* pFormat,
@@ -1215,23 +1213,23 @@
     *pFormat = format;
 
     switch( format ) {
-        case M4ENCODER_kH263:

-            {

+        case M4ENCODER_kH263:
+            {
                 (*pEncoderInterface)->pFctInit =
-                    VideoEditorVideoEncoder_init_H263;

-                break;

+                    VideoEditorVideoEncoder_init_H263;
+                break;
             }
-        case M4ENCODER_kMPEG4:

-            {

+        case M4ENCODER_kMPEG4:
+            {
                 (*pEncoderInterface)->pFctInit =
-                    VideoEditorVideoEncoder_init_MPEG4;

-                break;

+                    VideoEditorVideoEncoder_init_MPEG4;
+                break;
             }
-        case M4ENCODER_kH264:

-            {

+        case M4ENCODER_kH264:
+            {
                 (*pEncoderInterface)->pFctInit =
-                    VideoEditorVideoEncoder_init_H264;

-                break;

+                    VideoEditorVideoEncoder_init_H264;
+                break;
             }
         default:
             LOGV("VideoEditorVideoEncoder_getInterface : unsupported format %d",
diff --git a/libvideoeditor/vss/video_filters/src/Android.mk b/libvideoeditor/vss/video_filters/src/Android.mk
index 480548f..a933f97 100755
--- a/libvideoeditor/vss/video_filters/src/Android.mk
+++ b/libvideoeditor/vss/video_filters/src/Android.mk
@@ -57,9 +57,5 @@
 
 LOCAL_CFLAGS += -Wno-multichar
 
-# Don't prelink this library.  For more efficient code, you may want
-# to add this library to the prelink map and set this to true.
-LOCAL_PRELINK_MODULE := false
-
 include $(BUILD_STATIC_LIBRARY)
 
diff --git a/libvideoeditor/vss/video_filters/src/M4VFL_transition.c b/libvideoeditor/vss/video_filters/src/M4VFL_transition.c
index 7d7ca44..62fff27 100755
--- a/libvideoeditor/vss/video_filters/src/M4VFL_transition.c
+++ b/libvideoeditor/vss/video_filters/src/M4VFL_transition.c
@@ -41,7 +41,6 @@
 unsigned char M4VFL_modifyLumaByStep(M4ViComImagePlane *plane_in, M4ViComImagePlane *plane_out,
                                      M4VFL_ModifLumParam *lum_param, void *user_data)
 {
-#if 1
     unsigned short *p_src, *p_dest, *p_src_line, *p_dest_line;
     unsigned long pix_src;
     unsigned long u_outpx, u_outpx2;
@@ -71,7 +70,7 @@
         /* very specific case : set luma plane to 16 */
         for (j = u_height; j != 0; j--)
         {
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 16);
+            memset((void *)p_dest,16, u_width);
             p_dest += u_stride_out;
         }
         return 0;
@@ -121,82 +120,6 @@
         p_dest_line += u_stride_out;
         p_src_line += u_stride;
     }
-#else /* if 0 */
-    unsigned char *p_src, *p_dest, *p_src_line, *p_dest_line;
-    unsigned long u_width, u_stride, u_stride_out,u_height, pix;
-    unsigned long lf1, lf2, lf3;
-    long i, j;
-
-    u_width = plane_in[0].u_width;
-    u_height = plane_in[0].u_height;
-    u_stride = (plane_in[0].u_stride);
-    u_stride_out = (plane_out[0].u_stride);
-    p_dest = (unsigned char *) &plane_out[0].pac_data[plane_out[0].u_topleft];
-    p_src = (unsigned char *) &plane_in[0].pac_data[plane_in[0].u_topleft];
-    p_dest_line = p_dest;
-    p_src_line = p_src;
-
-    switch(lum_param->lum_factor)
-    {
-    case 0:
-        /* very specific case : set luma plane to 16 */
-        for (j = u_height; j != 0; j--)
-        {
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 16);
-            p_dest += u_stride_out;
-        }
-        return 0;
-
-    case 1:
-        /* 0.25 */
-        lf1 = 6; lf2 = 6; lf3 = 7;
-        break;
-    case 2:
-        /* 0.375 */
-        lf1 = 7; lf2 = 7; lf3 = 7;
-        break;
-    case 3:
-        /* 0.5 */
-        lf1 = 7; lf2 = 7; lf3 = 8;
-        break;
-    case 4:
-        /* 0.625 */
-        lf1 = 7; lf2 = 8; lf3 = 8;
-        break;
-    case 5:
-        /* 0.75 */
-        lf1 = 8; lf2 = 8; lf3 = 8;
-        break;
-    case 6:
-        /* 0.875 */
-        lf1 = 9; lf2 = 8; lf3 = 7;
-        break;
-    default:
-        lf1 = 8; lf2 = 8; lf3 = 9;
-        break;
-    }
-
-    if (lum_param->copy_chroma != 0)
-    {
-        /* copy chroma plane */
-
-    }
-
-
-    for (j = u_height; j != 0; j--)
-    {
-        p_dest = p_dest_line;
-        p_src = p_src_line;
-        for (i = (u_width); i != 0; i--)
-        {
-            pix = (unsigned long) *p_src++;
-            *p_dest++ = (unsigned char) (((pix << lf1) + (pix << lf2) + (pix << lf3) ) >>\
-                 LUM_FACTOR_MAX);
-        }
-        p_dest_line += u_stride_out;
-        p_src_line += u_stride;
-    }
-#endif /* if 0 */
     return 0;
 }
 
@@ -230,8 +153,8 @@
         {
             for (i = u_width; i != 0; i--)
             {
-                M4OSA_memcpy((M4OSA_MemAddr8)p_cdest_line, (M4OSA_MemAddr8)p_csrc_line, u_width);
-                M4OSA_memcpy((M4OSA_MemAddr8)p_cdest,(M4OSA_MemAddr8) p_csrc, u_width);
+                memcpy((void *)p_cdest_line, (void *)p_csrc_line, u_width);
+                memcpy((void *)p_cdest,(void *) p_csrc, u_width);
             }
             p_cdest_line += u_stride_out;
             p_cdest += u_stride_out;
@@ -321,12 +244,12 @@
 
     for (j = (nb_black_lines >> 1); j != 0; j--)
     { /* set black lines */
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest, 0,u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest, 0,u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);
-        M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);
+        memset((void *)p_destu, 128,u_widthuv);
+        memset((void *)p_destv, 128,u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
     }
@@ -343,14 +266,14 @@
     /* copy other lines from source */
     for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)
     {
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);
+        memcpy((void *)p_dest, (void *)p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+        memcpy((void *)p_dest,(void *) p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destu,(M4OSA_MemAddr8) p_srcu, u_widthuv);
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destv, (M4OSA_MemAddr8)p_srcv, u_widthuv);
+        memcpy((void *)p_destu,(void *) p_srcu, u_widthuv);
+        memcpy((void *)p_destv, (void *)p_srcv, u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
         p_srcu += u_stride_uv;
@@ -393,42 +316,32 @@
 
     for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)
     {
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest, 0,u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest,0, u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);
-        M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);
+        memset((void *)p_destu, 128,u_widthuv);
+        memset((void *)p_destv, 128,u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
     }
 
     for (j = (nb_black_lines >> 1); j != 0; j--)
     {
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+        memcpy((void *)p_dest,(void *) p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+        memcpy((void *)p_dest,(void *) p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destu,(M4OSA_MemAddr8) p_srcu, u_widthuv);
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destv, (M4OSA_MemAddr8)p_srcv, u_widthuv);
+        memcpy((void *)p_destu,(void *) p_srcu, u_widthuv);
+        memcpy((void *)p_destv, (void *)p_srcv, u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
         p_srcu += u_stride_uv;
         p_srcv += u_stride_uv;
     }
 
-/*    p_destu = (unsigned char *) &plane_out[1].pac_data[plane_out[1].u_topleft];
-    p_destv = (unsigned char *) &plane_out[2].pac_data[plane_out[2].u_topleft];
-    for (j = (u_height >> 1); j != 0; j--)
-    {
-        M4OSA_memset(p_destu, u_widthuv, 128);
-        M4OSA_memset(p_destv, u_widthuv, 128);
-        p_destu += u_stride_out_uv;
-        p_destv += u_stride_out_uv;
-    }
-*/
     return 0;
 }
 
@@ -461,14 +374,14 @@
 
     for (j = (nb_black_lines >> 1); j != 0; j--)
     {
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+        memcpy((void *)p_dest,(void *) p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+        memcpy((void *)p_dest,(void *) p_src, u_width);
         p_dest += u_stride_out;
         p_src += u_stride;
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destu,(M4OSA_MemAddr8) p_srcu, u_widthuv);
-        M4OSA_memcpy((M4OSA_MemAddr8)p_destv,(M4OSA_MemAddr8) p_srcv, u_widthuv);
+        memcpy((void *)p_destu,(void *) p_srcu, u_widthuv);
+        memcpy((void *)p_destv,(void *) p_srcv, u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
         p_srcu += u_stride_uv;
@@ -477,12 +390,12 @@
 
     for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)
     {
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest, 0,u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+        memset((void *)p_dest, 0,u_width);
         p_dest += u_stride_out;
-        M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);
-        M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);
+        memset((void *)p_destu, 128,u_widthuv);
+        memset((void *)p_destv, 128,u_widthuv);
         p_destu += u_stride_out_uv;
         p_destv += u_stride_out_uv;
     }
@@ -541,12 +454,12 @@
         /* write black lines */
         for (j = (nb_black_lines >> 1); j != 0; j--)
         {
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+            memset((void *)p_dest, 0,u_width);
             p_dest += u_stride_out;
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+            memset((void *)p_dest, 0,u_width);
             p_dest += u_stride_out;
-            M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);
-            M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);
+            memset((void *)p_destu, 128,u_widthuv);
+            memset((void *)p_destv, 128,u_widthuv);
             p_destu += u_stride_out_uv;
             p_destv += u_stride_out_uv;
         }
@@ -554,14 +467,14 @@
         /* copy from source image */
         for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);
+            memcpy((void *)p_dest, (void *)p_src, u_width);
             p_dest += u_stride_out;
             p_src += u_stride;
-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+            memcpy((void *)p_dest,(void *) p_src, u_width);
             p_dest += u_stride_out;
             p_src += u_stride;
-            M4OSA_memcpy((M4OSA_MemAddr8)p_destu,(M4OSA_MemAddr8) p_srcu, u_widthuv);
-            M4OSA_memcpy((M4OSA_MemAddr8)p_destv, (M4OSA_MemAddr8)p_srcv, u_widthuv);
+            memcpy((void *)p_destu,(void *) p_srcu, u_widthuv);
+            memcpy((void *)p_destv, (void *)p_srcv, u_widthuv);
             p_destu += u_stride_out_uv;
             p_destv += u_stride_out_uv;
             p_srcu += u_stride_uv;
@@ -578,14 +491,14 @@
         /* copy from source image image */
         for (j = (nb_black_lines >> 1); j != 0; j--)
         {
-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest, (M4OSA_MemAddr8)p_src, u_width);
+            memcpy((void *)p_dest, (void *)p_src, u_width);
             p_dest += u_stride_out;
             p_src += u_stride;
-            M4OSA_memcpy((M4OSA_MemAddr8)p_dest,(M4OSA_MemAddr8) p_src, u_width);
+            memcpy((void *)p_dest,(void *) p_src, u_width);
             p_dest += u_stride_out;
             p_src += u_stride;
-            M4OSA_memcpy((M4OSA_MemAddr8)p_destu,(M4OSA_MemAddr8) p_srcu, u_widthuv);
-            M4OSA_memcpy((M4OSA_MemAddr8)p_destv,(M4OSA_MemAddr8) p_srcv, u_widthuv);
+            memcpy((void *)p_destu,(void *) p_srcu, u_widthuv);
+            memcpy((void *)p_destv,(void *) p_srcv, u_widthuv);
             p_destu += u_stride_out_uv;
             p_destv += u_stride_out_uv;
             p_srcu += u_stride_uv;
@@ -596,12 +509,12 @@
         /* the pointers to p_dest, p_destu and p_destv are used through the two loops "for" */
         for (j = (u_height - nb_black_lines) >> 1; j != 0; j--)
         {
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+            memset((void *)p_dest, 0,u_width);
             p_dest += u_stride_out;
-            M4OSA_memset((M4OSA_MemAddr8)p_dest, u_width, 0);
+            memset((void *)p_dest, 0,u_width);
             p_dest += u_stride_out;
-            M4OSA_memset((M4OSA_MemAddr8)p_destu, u_widthuv, 128);
-            M4OSA_memset((M4OSA_MemAddr8)p_destv, u_widthuv, 128);
+            memset((void *)p_destu, 128,u_widthuv);
+            memset((void *)p_destv, 128,u_widthuv);
             p_destu += u_stride_out_uv;
             p_destv += u_stride_out_uv;
         }
diff --git a/libvideoeditor/vss/video_filters/src/M4VIFI_RGB565toYUV420.c b/libvideoeditor/vss/video_filters/src/M4VIFI_RGB565toYUV420.c
old mode 100644
new mode 100755
diff --git a/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB565toRGB565.c b/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB565toRGB565.c
old mode 100644
new mode 100755
diff --git a/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB888toRGB888.c b/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB888toRGB888.c
index a21e1d0..ebd8b19 100755
--- a/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB888toRGB888.c
+++ b/libvideoeditor/vss/video_filters/src/M4VIFI_ResizeRGB888toRGB888.c
@@ -78,13 +78,13 @@
     M4VIFI_UInt32    i32_b03, i32_g03, i32_r03;
 
     /* Check for the YUV width and height are even */
-    if( (IS_EVEN(pPlaneIn->u_height) == FALSE)    ||
+    if ((IS_EVEN(pPlaneIn->u_height) == FALSE)    ||
         (IS_EVEN(pPlaneOut->u_height) == FALSE))
     {
         return M4VIFI_ILLEGAL_FRAME_HEIGHT;
     }
 
-    if( (IS_EVEN(pPlaneIn->u_width) == FALSE) ||
+    if ((IS_EVEN(pPlaneIn->u_width) == FALSE) ||
         (IS_EVEN(pPlaneOut->u_width) == FALSE))
     {
         return M4VIFI_ILLEGAL_FRAME_WIDTH;
@@ -197,12 +197,47 @@
                 pu8_src_bottom = pu8_src_top + (u32_stride_in);
                 u32_x_frac = (u32_x_accum >> 12)&15; /* Horizontal weight factor */
 
-                /* Weighted combination */
-                GET_RGB24(i32_b00,i32_g00,i32_r00,pu8_src_top,0);
-                GET_RGB24(i32_b01,i32_g01,i32_r01,pu8_src_top,3);
-                GET_RGB24(i32_b02,i32_g02,i32_r02,pu8_src_bottom,0);
-                GET_RGB24(i32_b03,i32_g03,i32_r03,pu8_src_bottom,3);
-
+                if ((u32_width == 1) && (u32_width_in == u32_width_out)) {
+                    /*
+                       When input height is equal to output height and input width
+                       equal to output width, replicate the corner pixels for
+                       interpolation
+                    */
+                    if ((u32_height == 1) && (u32_height_in == u32_height_out)) {
+                        GET_RGB24(i32_b00,i32_g00,i32_r00,pu8_src_top,0);
+                        GET_RGB24(i32_b01,i32_g01,i32_r01,pu8_src_top,0);
+                        GET_RGB24(i32_b02,i32_g02,i32_r02,pu8_src_top,0);
+                        GET_RGB24(i32_b03,i32_g03,i32_r03,pu8_src_top,0);
+                    }
+                    /*
+                       When input height is not equal to output height and
+                       input width equal to output width, replicate the
+                       column for interpolation
+                    */
+                    else {
+                        GET_RGB24(i32_b00,i32_g00,i32_r00,pu8_src_top,0);
+                        GET_RGB24(i32_b01,i32_g01,i32_r01,pu8_src_top,0);
+                        GET_RGB24(i32_b02,i32_g02,i32_r02,pu8_src_bottom,0);
+                        GET_RGB24(i32_b03,i32_g03,i32_r03,pu8_src_bottom,0);
+                    }
+                } else {
+                    /*
+                       When input height is equal to output height and
+                       input width not equal to output width, replicate the
+                       row for interpolation
+                    */
+                    if ((u32_height == 1) && (u32_height_in == u32_height_out)) {
+                        GET_RGB24(i32_b00,i32_g00,i32_r00,pu8_src_top,0);
+                        GET_RGB24(i32_b01,i32_g01,i32_r01,pu8_src_top,3);
+                        GET_RGB24(i32_b02,i32_g02,i32_r02,pu8_src_top,0);
+                        GET_RGB24(i32_b03,i32_g03,i32_r03,pu8_src_top,3);
+                    } else {
+                        GET_RGB24(i32_b00,i32_g00,i32_r00,pu8_src_top,0);
+                        GET_RGB24(i32_b01,i32_g01,i32_r01,pu8_src_top,3);
+                        GET_RGB24(i32_b02,i32_g02,i32_r02,pu8_src_bottom,0);
+                        GET_RGB24(i32_b03,i32_g03,i32_r03,pu8_src_bottom,3);
+                    }
+                }
                 u32_Rtemp_value = (M4VIFI_UInt8)(((i32_r00*(16-u32_x_frac) +
                                  i32_r01*u32_x_frac)*(16-u32_y_frac) +
                                 (i32_r02*(16-u32_x_frac) +