OSDN Git Service

Remove old-style software decoders.
authorAndreas Huber <andih@google.com>
Wed, 13 Jul 2011 19:38:46 +0000 (12:38 -0700)
committerAndreas Huber <andih@google.com>
Wed, 13 Jul 2011 21:14:08 +0000 (14:14 -0700)
Change-Id: Ie0729d6a65470ffdc38229791f25a75a22c724d8

22 files changed:
media/libstagefright/Android.mk
media/libstagefright/OMXCodec.cpp
media/libstagefright/ThreadedSource.cpp [deleted file]
media/libstagefright/codecs/aacdec/AACDecoder.cpp [deleted file]
media/libstagefright/codecs/aacdec/Android.mk
media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp [deleted file]
media/libstagefright/codecs/amrnb/dec/Android.mk
media/libstagefright/codecs/amrwb/AMRWBDecoder.cpp [deleted file]
media/libstagefright/codecs/amrwb/Android.mk
media/libstagefright/codecs/avc/dec/AVCDecoder.cpp [deleted file]
media/libstagefright/codecs/avc/dec/Android.mk
media/libstagefright/codecs/g711/dec/Android.mk
media/libstagefright/codecs/g711/dec/G711Decoder.cpp [deleted file]
media/libstagefright/codecs/m4v_h263/dec/Android.mk
media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp [deleted file]
media/libstagefright/codecs/mp3dec/Android.mk
media/libstagefright/codecs/mp3dec/MP3Decoder.cpp [deleted file]
media/libstagefright/codecs/on2/dec/Android.mk
media/libstagefright/codecs/on2/dec/VPXDecoder.cpp [deleted file]
media/libstagefright/codecs/vorbis/dec/Android.mk
media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp [deleted file]
media/libstagefright/include/ThreadedSource.h [deleted file]

index 7b3b95b..0b998b9 100644 (file)
@@ -3,8 +3,6 @@ include $(CLEAR_VARS)
 
 include frameworks/base/media/libstagefright/codecs/common/Config.mk
 
-BUILD_WITH_SOFTWARE_DECODERS := false
-
 LOCAL_SRC_FILES:=                         \
         ACodec.cpp                        \
         AACExtractor.cpp                  \
@@ -96,26 +94,6 @@ LOCAL_STATIC_LIBRARIES := \
         libstagefright_id3 \
         libFLAC \
 
-ifeq ($(BUILD_WITH_SOFTWARE_DECODERS),true)
-
-LOCAL_SRC_FILES += \
-        ThreadedSource.cpp                \
-
-LOCAL_STATIC_LIBRARIES += \
-        libstagefright_aacdec \
-        libstagefright_amrnbdec \
-        libstagefright_amrwbdec \
-        libstagefright_avcdec \
-        libstagefright_g711dec \
-        libstagefright_mp3dec \
-        libstagefright_m4vh263dec \
-        libstagefright_vorbisdec \
-        libstagefright_vpxdec \
-        libvpx \
-
-endif
-
-
 ################################################################################
 
 # The following was shamelessly copied from external/webkit/Android.mk and
@@ -177,10 +155,6 @@ LOCAL_SHARED_LIBRARIES += \
 
 LOCAL_CFLAGS += -Wno-multichar
 
-ifeq ($(BUILD_WITH_SOFTWARE_DECODERS),true)
-    LOCAL_CFLAGS += -DHAVE_SOFTWARE_DECODERS
-endif
-
 LOCAL_MODULE:= libstagefright
 
 include $(BUILD_SHARED_LIBRARY)
index 3b05752..b7b0dc0 100755 (executable)
 #define LOG_TAG "OMXCodec"
 #include <utils/Log.h>
 
-#include "include/AACDecoder.h"
 #include "include/AACEncoder.h"
-#include "include/AMRNBDecoder.h"
 #include "include/AMRNBEncoder.h"
-#include "include/AMRWBDecoder.h"
 #include "include/AMRWBEncoder.h"
-#include "include/AVCDecoder.h"
 #include "include/AVCEncoder.h"
-#include "include/G711Decoder.h"
-#include "include/M4vH263Decoder.h"
 #include "include/M4vH263Encoder.h"
-#include "include/MP3Decoder.h"
-#include "include/VorbisDecoder.h"
-#include "include/VPXDecoder.h"
 
 #include "include/ESDS.h"
 
 #include <OMX_Audio.h>
 #include <OMX_Component.h>
 
-#if HAVE_SOFTWARE_DECODERS
-#include "include/ThreadedSource.h"
-#endif
-
 #include "include/avc_utils.h"
 
 namespace android {
@@ -79,24 +66,6 @@ FACTORY_CREATE_ENCODER(AACEncoder)
 FACTORY_CREATE_ENCODER(AVCEncoder)
 FACTORY_CREATE_ENCODER(M4vH263Encoder)
 
-#if HAVE_SOFTWARE_DECODERS
-
-#define FACTORY_CREATE(name) \
-static sp<MediaSource> Make##name(const sp<MediaSource> &source) { \
-    return new name(source); \
-}
-
-FACTORY_CREATE(AMRNBDecoder)
-FACTORY_CREATE(AMRWBDecoder)
-FACTORY_CREATE(AACDecoder)
-FACTORY_CREATE(AVCDecoder)
-FACTORY_CREATE(G711Decoder)
-FACTORY_CREATE(MP3Decoder)
-FACTORY_CREATE(M4vH263Decoder)
-FACTORY_CREATE(VorbisDecoder)
-FACTORY_CREATE(VPXDecoder)
-#endif
-
 static sp<MediaSource> InstantiateSoftwareEncoder(
         const char *name, const sp<MediaSource> &source,
         const sp<MetaData> &meta) {
@@ -122,40 +91,6 @@ static sp<MediaSource> InstantiateSoftwareEncoder(
     return NULL;
 }
 
-static sp<MediaSource> InstantiateSoftwareCodec(
-        const char *name, const sp<MediaSource> &source) {
-#if HAVE_SOFTWARE_DECODERS
-    struct FactoryInfo {
-        const char *name;
-        sp<MediaSource> (*CreateFunc)(const sp<MediaSource> &);
-    };
-
-    static const FactoryInfo kFactoryInfo[] = {
-        FACTORY_REF(AMRNBDecoder)
-        FACTORY_REF(AMRWBDecoder)
-        FACTORY_REF(AACDecoder)
-        FACTORY_REF(AVCDecoder)
-        FACTORY_REF(G711Decoder)
-        FACTORY_REF(MP3Decoder)
-        FACTORY_REF(M4vH263Decoder)
-        FACTORY_REF(VorbisDecoder)
-        FACTORY_REF(VPXDecoder)
-    };
-    for (size_t i = 0;
-         i < sizeof(kFactoryInfo) / sizeof(kFactoryInfo[0]); ++i) {
-        if (!strcmp(name, kFactoryInfo[i].name)) {
-            if (!strcmp(name, "VPXDecoder")) {
-                return new ThreadedSource(
-                        (*kFactoryInfo[i].CreateFunc)(source));
-            }
-            return (*kFactoryInfo[i].CreateFunc)(source);
-        }
-    }
-#endif
-
-    return NULL;
-}
-
 #undef FACTORY_REF
 #undef FACTORY_CREATE
 
@@ -163,23 +98,17 @@ static const CodecInfo kDecoderInfo[] = {
     { MEDIA_MIMETYPE_IMAGE_JPEG, "OMX.TI.JPEG.decode" },
 //    { MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.TI.MP3.decode" },
     { MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.google.mp3.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_MPEG, "MP3Decoder" },
 //    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.TI.AMR.decode" },
 //    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.Nvidia.amr.decoder" },
     { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.google.amrnb.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "AMRNBDecoder" },
 //    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.Nvidia.amrwb.decoder" },
     { MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.TI.WBAMR.decode" },
     { MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.google.amrwb.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "AMRWBDecoder" },
 //    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.Nvidia.aac.decoder" },
     { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.decode" },
     { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.google.aac.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder" },
     { MEDIA_MIMETYPE_AUDIO_G711_ALAW, "OMX.google.g711.alaw.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_G711_ALAW, "G711Decoder" },
     { MEDIA_MIMETYPE_AUDIO_G711_MLAW, "OMX.google.g711.mlaw.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_G711_MLAW, "G711Decoder" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.DUCATI1.VIDEO.DECODER" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.Nvidia.mp4.decode" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.7x30.video.decoder.mpeg4" },
@@ -187,14 +116,12 @@ static const CodecInfo kDecoderInfo[] = {
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.SEC.MPEG4.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.google.mpeg4.decoder" },
-    { MEDIA_MIMETYPE_VIDEO_MPEG4, "M4vH263Decoder" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.DUCATI1.VIDEO.DECODER" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.Nvidia.h263.decode" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.7x30.video.decoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.video.decoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.SEC.H263.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.google.h263.decoder" },
-    { MEDIA_MIMETYPE_VIDEO_H263, "M4vH263Decoder" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.DUCATI1.VIDEO.DECODER" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.Nvidia.h264.decode" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.7x30.video.decoder.avc" },
@@ -203,11 +130,8 @@ static const CodecInfo kDecoderInfo[] = {
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.SEC.AVC.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.google.h264.decoder" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.google.avc.decoder" },
-    { MEDIA_MIMETYPE_VIDEO_AVC, "AVCDecoder" },
     { MEDIA_MIMETYPE_AUDIO_VORBIS, "OMX.google.vorbis.decoder" },
-    { MEDIA_MIMETYPE_AUDIO_VORBIS, "VorbisDecoder" },
     { MEDIA_MIMETYPE_VIDEO_VPX, "OMX.google.vpx.decoder" },
-    { MEDIA_MIMETYPE_VIDEO_VPX, "VPXDecoder" },
     { MEDIA_MIMETYPE_VIDEO_MPEG2, "OMX.Nvidia.mpeg2v.decode" },
 };
 
@@ -518,14 +442,15 @@ sp<MediaSource> OMXCodec::Create(
     for (size_t i = 0; i < matchingCodecs.size(); ++i) {
         componentName = matchingCodecs[i].string();
 
-        sp<MediaSource> softwareCodec = createEncoder?
-            InstantiateSoftwareEncoder(componentName, source, meta):
-            InstantiateSoftwareCodec(componentName, source);
+        if (createEncoder) {
+            sp<MediaSource> softwareCodec =
+                InstantiateSoftwareEncoder(componentName, source, meta);
 
-        if (softwareCodec != NULL) {
-            LOGV("Successfully allocated software codec '%s'", componentName);
+            if (softwareCodec != NULL) {
+                LOGV("Successfully allocated software codec '%s'", componentName);
 
-            return softwareCodec;
+                return softwareCodec;
+            }
         }
 
         LOGV("Attempting to allocate OMX node '%s'", componentName);
@@ -4430,12 +4355,9 @@ status_t QueryCodecs(
         if (strncmp(componentName, "OMX.", 4)) {
             // Not an OpenMax component but a software codec.
 
-#if HAVE_SOFTWARE_DECODERS
             results->push();
             CodecCapabilities *caps = &results->editItemAt(results->size() - 1);
             caps->mComponentName = componentName;
-#endif
-
             continue;
         }
 
diff --git a/media/libstagefright/ThreadedSource.cpp b/media/libstagefright/ThreadedSource.cpp
deleted file mode 100644 (file)
index 38c6e2d..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2010 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_TAG "ThreadedSource"
-//#define LOG_NDEBUG 0
-#include <utils/Log.h>
-
-#include "include/ThreadedSource.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-static const size_t kMaxQueueSize = 2;
-
-ThreadedSource::ThreadedSource(const sp<MediaSource> &source)
-    : mSource(source),
-      mReflector(new AHandlerReflector<ThreadedSource>(this)),
-      mLooper(new ALooper),
-      mStarted(false) {
-    mLooper->registerHandler(mReflector);
-}
-
-ThreadedSource::~ThreadedSource() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-status_t ThreadedSource::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    status_t err = mSource->start(params);
-
-    if (err != OK) {
-        return err;
-    }
-
-    mFinalResult = OK;
-    mSeekTimeUs = -1;
-    mDecodePending = false;
-
-    Mutex::Autolock autoLock(mLock);
-    postDecodeMore_l();
-
-    CHECK_EQ(mLooper->start(), (status_t)OK);
-
-    mStarted = true;
-
-    return OK;
-}
-
-status_t ThreadedSource::stop() {
-    CHECK(mStarted);
-
-    CHECK_EQ(mLooper->stop(), (status_t)OK);
-
-    Mutex::Autolock autoLock(mLock);
-    clearQueue_l();
-
-    status_t err = mSource->stop();
-
-    mStarted = false;
-
-    return err;
-}
-
-sp<MetaData> ThreadedSource::getFormat() {
-    return mSource->getFormat();
-}
-
-status_t ThreadedSource::read(
-        MediaBuffer **buffer, const ReadOptions *options) {
-    *buffer = NULL;
-
-    Mutex::Autolock autoLock(mLock);
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode seekMode;
-    if (options && options->getSeekTo(&seekTimeUs, &seekMode)) {
-        int32_t seekComplete = 0;
-
-        sp<AMessage> msg = new AMessage(kWhatSeek, mReflector->id());
-        msg->setInt64("timeUs", seekTimeUs);
-        msg->setInt32("mode", seekMode);
-        msg->setPointer("complete", &seekComplete);
-        msg->post();
-
-        while (!seekComplete) {
-            mCondition.wait(mLock);
-        }
-    }
-
-    while (mQueue.empty() && mFinalResult == OK) {
-        mCondition.wait(mLock);
-    }
-
-    if (!mQueue.empty()) {
-        *buffer = *mQueue.begin();
-        mQueue.erase(mQueue.begin());
-
-        if (mFinalResult == OK) {
-            postDecodeMore_l();
-        }
-
-        return OK;
-    }
-
-    return mFinalResult;
-}
-
-void ThreadedSource::onMessageReceived(const sp<AMessage> &msg) {
-    switch (msg->what()) {
-        case kWhatSeek:
-        {
-            CHECK(msg->findInt64("timeUs", &mSeekTimeUs));
-            CHECK_GE(mSeekTimeUs, 0ll);
-
-            int32_t x;
-            CHECK(msg->findInt32("mode", &x));
-            mSeekMode = (ReadOptions::SeekMode)x;
-
-            int32_t *seekComplete;
-            CHECK(msg->findPointer("complete", (void **)&seekComplete));
-
-            Mutex::Autolock autoLock(mLock);
-            clearQueue_l();
-            mFinalResult = OK;
-
-            *seekComplete = 1;
-            mCondition.signal();
-
-            postDecodeMore_l();
-            break;
-        }
-
-        case kWhatDecodeMore:
-        {
-            {
-                Mutex::Autolock autoLock(mLock);
-                mDecodePending = false;
-
-                if (mQueue.size() == kMaxQueueSize) {
-                    break;
-                }
-            }
-
-            MediaBuffer *buffer;
-            ReadOptions options;
-            if (mSeekTimeUs >= 0) {
-                options.setSeekTo(mSeekTimeUs, mSeekMode);
-                mSeekTimeUs = -1ll;
-            }
-            status_t err = mSource->read(&buffer, &options);
-
-            Mutex::Autolock autoLock(mLock);
-
-            if (err != OK) {
-                mFinalResult = err;
-            } else {
-                mQueue.push_back(buffer);
-
-                if (mQueue.size() < kMaxQueueSize) {
-                    postDecodeMore_l();
-                }
-            }
-
-            mCondition.signal();
-            break;
-        }
-
-        default:
-            TRESPASS();
-            break;
-    }
-}
-
-void ThreadedSource::postDecodeMore_l() {
-    if (mDecodePending) {
-        return;
-    }
-
-    mDecodePending = true;
-    (new AMessage(kWhatDecodeMore, mReflector->id()))->post();
-}
-
-void ThreadedSource::clearQueue_l() {
-    while (!mQueue.empty()) {
-        MediaBuffer *buffer = *mQueue.begin();
-        mQueue.erase(mQueue.begin());
-
-        buffer->release();
-        buffer = NULL;
-    }
-}
-
-}  // namespace android
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
deleted file mode 100644 (file)
index d2e3eaa..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "AACDecoder.h"
-#define LOG_TAG "AACDecoder"
-
-#include "../../include/ESDS.h"
-
-#include "pvmp4audiodecoder_api.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-AACDecoder::AACDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferGroup(NULL),
-      mConfig(new tPVMP4AudioDecoderExternal),
-      mDecoderBuf(NULL),
-      mAnchorTimeUs(0),
-      mNumSamplesOutput(0),
-      mInputBuffer(NULL) {
-
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    int32_t sampleRate;
-    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
-
-    mMeta = new MetaData;
-    mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-
-    // We'll always output stereo, regardless of how many channels are
-    // present in the input due to decoder limitations.
-    mMeta->setInt32(kKeyChannelCount, 2);
-    mMeta->setInt32(kKeySampleRate, sampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        mMeta->setInt64(kKeyDuration, durationUs);
-    }
-    mMeta->setCString(kKeyDecoderComponent, "AACDecoder");
-
-    mInitCheck = initCheck();
-}
-
-status_t AACDecoder::initCheck() {
-    memset(mConfig, 0, sizeof(tPVMP4AudioDecoderExternal));
-    mConfig->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED;
-    mConfig->aacPlusEnabled = 1;
-
-    // The software decoder doesn't properly support mono output on
-    // AACplus files. Always output stereo.
-    mConfig->desiredChannels = 2;
-
-    UInt32 memRequirements = PVMP4AudioDecoderGetMemRequirements();
-    mDecoderBuf = malloc(memRequirements);
-
-    status_t err = PVMP4AudioDecoderInitLibrary(mConfig, mDecoderBuf);
-    if (err != MP4AUDEC_SUCCESS) {
-        LOGE("Failed to initialize MP4 audio decoder");
-        return UNKNOWN_ERROR;
-    }
-
-    uint32_t type;
-    const void *data;
-    size_t size;
-    sp<MetaData> meta = mSource->getFormat();
-    if (meta->findData(kKeyESDS, &type, &data, &size)) {
-        ESDS esds((const char *)data, size);
-        CHECK_EQ(esds.InitCheck(), (status_t)OK);
-
-        const void *codec_specific_data;
-        size_t codec_specific_data_size;
-        esds.getCodecSpecificInfo(
-                &codec_specific_data, &codec_specific_data_size);
-
-        mConfig->pInputBuffer = (UChar *)codec_specific_data;
-        mConfig->inputBufferCurrentLength = codec_specific_data_size;
-        mConfig->inputBufferMaxLength = 0;
-
-        if (PVMP4AudioDecoderConfig(mConfig, mDecoderBuf)
-                != MP4AUDEC_SUCCESS) {
-            return ERROR_UNSUPPORTED;
-        }
-    }
-    return OK;
-}
-
-AACDecoder::~AACDecoder() {
-    if (mStarted) {
-        stop();
-    }
-
-    delete mConfig;
-    mConfig = NULL;
-}
-
-status_t AACDecoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(new MediaBuffer(4096 * 2));
-
-    mSource->start();
-
-    mAnchorTimeUs = 0;
-    mNumSamplesOutput = 0;
-    mStarted = true;
-    mNumDecodedBuffers = 0;
-    mUpsamplingFactor = 2;
-
-    return OK;
-}
-
-status_t AACDecoder::stop() {
-    CHECK(mStarted);
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    free(mDecoderBuf);
-    mDecoderBuf = NULL;
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> AACDecoder::getFormat() {
-    return mMeta;
-}
-
-status_t AACDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        CHECK(seekTimeUs >= 0);
-
-        mNumSamplesOutput = 0;
-
-        if (mInputBuffer) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-
-        // Make sure that the next buffer output does not still
-        // depend on fragments from the last one decoded.
-        PVMP4AudioDecoderResetBuffer(mDecoderBuf);
-    } else {
-        seekTimeUs = -1;
-    }
-
-    if (mInputBuffer == NULL) {
-        err = mSource->read(&mInputBuffer, options);
-
-        if (err != OK) {
-            return err;
-        }
-
-        int64_t timeUs;
-        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
-            mAnchorTimeUs = timeUs;
-            mNumSamplesOutput = 0;
-        } else {
-            // We must have a new timestamp after seeking.
-            CHECK(seekTimeUs < 0);
-        }
-    }
-
-    MediaBuffer *buffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&buffer), (status_t)OK);
-
-    mConfig->pInputBuffer =
-        (UChar *)mInputBuffer->data() + mInputBuffer->range_offset();
-
-    mConfig->inputBufferCurrentLength = mInputBuffer->range_length();
-    mConfig->inputBufferMaxLength = 0;
-    mConfig->inputBufferUsedLength = 0;
-    mConfig->remainderBits = 0;
-
-    mConfig->pOutputBuffer = static_cast<Int16 *>(buffer->data());
-    mConfig->pOutputBuffer_plus = &mConfig->pOutputBuffer[2048];
-    mConfig->repositionFlag = false;
-
-    Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
-
-    /*
-     * AAC+/eAAC+ streams can be signalled in two ways: either explicitly
-     * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual
-     * rate system and the sampling rate in the final output is actually
-     * doubled compared with the core AAC decoder sampling rate.
-     *
-     * Explicit signalling is done by explicitly defining SBR audio object
-     * type in the bitstream. Implicit signalling is done by embedding
-     * SBR content in AAC extension payload specific to SBR, and hence
-     * requires an AAC decoder to perform pre-checks on actual audio frames.
-     *
-     * Thus, we could not say for sure whether a stream is
-     * AAC+/eAAC+ until the first data frame is decoded.
-     */
-    if (++mNumDecodedBuffers <= 2) {
-        LOGV("audio/extended audio object type: %d + %d",
-            mConfig->audioObjectType, mConfig->extendedAudioObjectType);
-        LOGV("aac+ upsampling factor: %d desired channels: %d",
-            mConfig->aacPlusUpsamplingFactor, mConfig->desiredChannels);
-
-        CHECK(mNumDecodedBuffers > 0);
-
-        if (decoderErr != MP4AUDEC_SUCCESS) {
-            // If decoding fails this early, the fields in mConfig may
-            // not be valid and we cannot recover.
-
-            LOGE("Unable to decode aac content, decoder returned error %d",
-                 decoderErr);
-
-            buffer->release();
-            buffer = NULL;
-
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-
-            return ERROR_UNSUPPORTED;
-        }
-
-        if (mNumDecodedBuffers == 1) {
-            mUpsamplingFactor = mConfig->aacPlusUpsamplingFactor;
-            // Check on the sampling rate to see whether it is changed.
-            int32_t sampleRate;
-            CHECK(mMeta->findInt32(kKeySampleRate, &sampleRate));
-            if (mConfig->samplingRate != sampleRate) {
-                mMeta->setInt32(kKeySampleRate, mConfig->samplingRate);
-                LOGW("Sample rate was %d Hz, but now is %d Hz",
-                        sampleRate, mConfig->samplingRate);
-                buffer->release();
-                mInputBuffer->release();
-                mInputBuffer = NULL;
-                return INFO_FORMAT_CHANGED;
-            }
-        } else {  // mNumDecodedBuffers == 2
-            if (mConfig->extendedAudioObjectType == MP4AUDIO_AAC_LC ||
-                mConfig->extendedAudioObjectType == MP4AUDIO_LTP) {
-                if (mUpsamplingFactor == 2) {
-                    // The stream turns out to be not aacPlus mode anyway
-                    LOGW("Disable AAC+/eAAC+ since extended audio object type is %d",
-                        mConfig->extendedAudioObjectType);
-                    mConfig->aacPlusEnabled = 0;
-                }
-            } else {
-                if (mUpsamplingFactor == 1) {
-                    // aacPlus mode does not buy us anything, but to cause
-                    // 1. CPU load to increase, and
-                    // 2. a half speed of decoding
-                    LOGW("Disable AAC+/eAAC+ since upsampling factor is 1");
-                    mConfig->aacPlusEnabled = 0;
-                }
-            }
-        }
-    }
-
-    size_t numOutBytes =
-        mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels;
-    if (mUpsamplingFactor == 2) {
-        if (mConfig->desiredChannels == 1) {
-            memcpy(&mConfig->pOutputBuffer[1024], &mConfig->pOutputBuffer[2048], numOutBytes * 2);
-        }
-        numOutBytes *= 2;
-    }
-
-    if (decoderErr != MP4AUDEC_SUCCESS) {
-        LOGW("AAC decoder returned error %d, substituting silence", decoderErr);
-
-        memset(buffer->data(), 0, numOutBytes);
-
-        // Discard input buffer.
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-
-        // fall through
-    }
-
-    buffer->set_range(0, numOutBytes);
-
-    if (mInputBuffer != NULL) {
-        mInputBuffer->set_range(
-                mInputBuffer->range_offset() + mConfig->inputBufferUsedLength,
-                mInputBuffer->range_length() - mConfig->inputBufferUsedLength);
-
-        if (mInputBuffer->range_length() == 0) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-    }
-
-    buffer->meta_data()->setInt64(
-            kKeyTime,
-            mAnchorTimeUs
-                + (mNumSamplesOutput * 1000000) / mConfig->samplingRate);
-
-    mNumSamplesOutput += mConfig->frameLength * mUpsamplingFactor;
-
-    *out = buffer;
-
-    return OK;
-}
-
-}  // namespace android
index 359a2ec..20c7bc0 100644 (file)
@@ -143,7 +143,6 @@ LOCAL_SRC_FILES := \
        unpack_idx.cpp \
        window_tables_fxp.cpp \
        pvmp4setaudioconfig.cpp \
-        AACDecoder.cpp \
 
 LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DOSCL_IMPORT_REF= -DOSCL_EXPORT_REF= -DOSCL_UNUSED_ARG=
 
diff --git a/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp b/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp
deleted file mode 100644 (file)
index a11d46b..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2009 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 "AMRNBDecoder"
-#include <utils/Log.h>
-
-#include "AMRNBDecoder.h"
-
-#include "gsmamr_dec.h"
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-static const int32_t kNumSamplesPerFrame = 160;
-static const int32_t kSampleRate = 8000;
-
-AMRNBDecoder::AMRNBDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferGroup(NULL),
-      mState(NULL),
-      mAnchorTimeUs(0),
-      mNumSamplesOutput(0),
-      mInputBuffer(NULL) {
-}
-
-AMRNBDecoder::~AMRNBDecoder() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-status_t AMRNBDecoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(
-            new MediaBuffer(kNumSamplesPerFrame * sizeof(int16_t)));
-
-    CHECK_EQ(GSMInitDecode(&mState, (Word8 *)"AMRNBDecoder"), 0);
-
-    mSource->start();
-
-    mAnchorTimeUs = 0;
-    mNumSamplesOutput = 0;
-    mStarted = true;
-
-    return OK;
-}
-
-status_t AMRNBDecoder::stop() {
-    CHECK(mStarted);
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    GSMDecodeFrameExit(&mState);
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> AMRNBDecoder::getFormat() {
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    int32_t numChannels;
-    int32_t sampleRate;
-
-    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
-    CHECK_EQ(numChannels, 1);
-
-    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
-    CHECK_EQ(sampleRate, kSampleRate);
-
-    sp<MetaData> meta = new MetaData;
-    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-    meta->setInt32(kKeyChannelCount, numChannels);
-    meta->setInt32(kKeySampleRate, sampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        meta->setInt64(kKeyDuration, durationUs);
-    }
-
-    meta->setCString(kKeyDecoderComponent, "AMRNBDecoder");
-
-    return meta;
-}
-
-status_t AMRNBDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        CHECK(seekTimeUs >= 0);
-
-        mNumSamplesOutput = 0;
-
-        if (mInputBuffer) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-    } else {
-        seekTimeUs = -1;
-    }
-
-    if (mInputBuffer == NULL) {
-        err = mSource->read(&mInputBuffer, options);
-
-        if (err != OK) {
-            return err;
-        }
-
-        int64_t timeUs;
-        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
-            mAnchorTimeUs = timeUs;
-            mNumSamplesOutput = 0;
-        } else {
-            // We must have a new timestamp after seeking.
-            CHECK(seekTimeUs < 0);
-        }
-    }
-
-    MediaBuffer *buffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&buffer), OK);
-
-    const uint8_t *inputPtr =
-        (const uint8_t *)mInputBuffer->data() + mInputBuffer->range_offset();
-
-    int32_t numBytesRead =
-        AMRDecode(mState,
-          (Frame_Type_3GPP)((inputPtr[0] >> 3) & 0x0f),
-          (UWord8 *)&inputPtr[1],
-          static_cast<int16_t *>(buffer->data()),
-          MIME_IETF);
-
-    if (numBytesRead == -1 ) {
-        LOGE("PV AMR decoder AMRDecode() call failed");
-        buffer->release();
-        buffer = NULL;
-        return ERROR_MALFORMED;
-    }
-    ++numBytesRead;  // Include the frame type header byte.
-
-    buffer->set_range(0, kNumSamplesPerFrame * sizeof(int16_t));
-
-    if (static_cast<size_t>(numBytesRead) > mInputBuffer->range_length()) {
-        // This is bad, should never have happened, but did. Abort now.
-
-        buffer->release();
-        buffer = NULL;
-
-        return ERROR_MALFORMED;
-    }
-
-    mInputBuffer->set_range(
-            mInputBuffer->range_offset() + numBytesRead,
-            mInputBuffer->range_length() - numBytesRead);
-
-    if (mInputBuffer->range_length() == 0) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    buffer->meta_data()->setInt64(
-            kKeyTime,
-            mAnchorTimeUs
-                + (mNumSamplesOutput * 1000000) / kSampleRate);
-
-    mNumSamplesOutput += kNumSamplesPerFrame;
-
-    *out = buffer;
-
-    return OK;
-}
-
-}  // namespace android
index 5862abc..23a22ef 100644 (file)
@@ -2,7 +2,6 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        AMRNBDecoder.cpp \
        src/a_refl.cpp \
        src/agc.cpp \
        src/amrdecode.cpp \
diff --git a/media/libstagefright/codecs/amrwb/AMRWBDecoder.cpp b/media/libstagefright/codecs/amrwb/AMRWBDecoder.cpp
deleted file mode 100644 (file)
index 5b111ef..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#include "AMRWBDecoder.h"
-
-#include "pvamrwbdecoder.h"
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-static const int32_t kNumSamplesPerFrame = 320;
-static const int32_t kSampleRate = 16000;
-
-AMRWBDecoder::AMRWBDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferGroup(NULL),
-      mState(NULL),
-      mDecoderBuf(NULL),
-      mDecoderCookie(NULL),
-      mAnchorTimeUs(0),
-      mNumSamplesOutput(0),
-      mInputBuffer(NULL) {
-}
-
-AMRWBDecoder::~AMRWBDecoder() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-status_t AMRWBDecoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(
-            new MediaBuffer(kNumSamplesPerFrame * sizeof(int16_t)));
-
-    int32_t memReq = pvDecoder_AmrWbMemRequirements();
-    mDecoderBuf = malloc(memReq);
-
-    pvDecoder_AmrWb_Init(&mState, mDecoderBuf, &mDecoderCookie);
-
-    mSource->start();
-
-    mAnchorTimeUs = 0;
-    mNumSamplesOutput = 0;
-    mStarted = true;
-
-    return OK;
-}
-
-status_t AMRWBDecoder::stop() {
-    CHECK(mStarted);
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    free(mDecoderBuf);
-    mDecoderBuf = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> AMRWBDecoder::getFormat() {
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    int32_t numChannels;
-    int32_t sampleRate;
-
-    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
-    CHECK_EQ(numChannels, 1);
-
-    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
-    CHECK_EQ(sampleRate, kSampleRate);
-
-    sp<MetaData> meta = new MetaData;
-    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-    meta->setInt32(kKeyChannelCount, numChannels);
-    meta->setInt32(kKeySampleRate, sampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        meta->setInt64(kKeyDuration, durationUs);
-    }
-
-    meta->setCString(kKeyDecoderComponent, "AMRWBDecoder");
-
-    return meta;
-}
-
-static size_t getFrameSize(unsigned FT) {
-    static const size_t kFrameSizeWB[9] = {
-        132, 177, 253, 285, 317, 365, 397, 461, 477
-    };
-
-    size_t frameSize = kFrameSizeWB[FT];
-
-    // Round up bits to bytes and add 1 for the header byte.
-    frameSize = (frameSize + 7) / 8 + 1;
-
-    return frameSize;
-}
-
-status_t AMRWBDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode seekMode;
-    if (options && options->getSeekTo(&seekTimeUs, &seekMode)) {
-        CHECK(seekTimeUs >= 0);
-
-        mNumSamplesOutput = 0;
-
-        if (mInputBuffer) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-    } else {
-        seekTimeUs = -1;
-    }
-
-    if (mInputBuffer == NULL) {
-        err = mSource->read(&mInputBuffer, options);
-
-        if (err != OK) {
-            return err;
-        }
-
-        int64_t timeUs;
-        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
-            mAnchorTimeUs = timeUs;
-            mNumSamplesOutput = 0;
-        } else {
-            // We must have a new timestamp after seeking.
-            CHECK(seekTimeUs < 0);
-        }
-    }
-
-    MediaBuffer *buffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&buffer), OK);
-
-    const uint8_t *inputPtr =
-        (const uint8_t *)mInputBuffer->data() + mInputBuffer->range_offset();
-
-    int16 mode = ((inputPtr[0] >> 3) & 0x0f);
-    size_t frameSize = getFrameSize(mode);
-    CHECK(mInputBuffer->range_length() >= frameSize);
-
-    int16 frameType;
-    RX_State_wb rx_state;
-    mime_unsorting(
-            const_cast<uint8_t *>(&inputPtr[1]),
-            mInputSampleBuffer,
-            &frameType, &mode, 1, &rx_state);
-
-    int16_t *outPtr = (int16_t *)buffer->data();
-
-    int16_t numSamplesOutput;
-    pvDecoder_AmrWb(
-            mode, mInputSampleBuffer,
-            outPtr,
-            &numSamplesOutput,
-            mDecoderBuf, frameType, mDecoderCookie);
-
-    CHECK_EQ(numSamplesOutput, kNumSamplesPerFrame);
-
-    for (int i = 0; i < kNumSamplesPerFrame; ++i) {
-        /* Delete the 2 LSBs (14-bit output) */
-        outPtr[i] &= 0xfffC;
-    }
-
-    buffer->set_range(0, numSamplesOutput * sizeof(int16_t));
-
-    mInputBuffer->set_range(
-            mInputBuffer->range_offset() + frameSize,
-            mInputBuffer->range_length() - frameSize);
-
-    if (mInputBuffer->range_length() == 0) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    buffer->meta_data()->setInt64(
-            kKeyTime,
-            mAnchorTimeUs
-                + (mNumSamplesOutput * 1000000) / kSampleRate);
-
-    mNumSamplesOutput += kNumSamplesPerFrame;
-
-    *out = buffer;
-
-    return OK;
-}
-
-}  // namespace android
index ab591d7..c9e1c25 100644 (file)
@@ -2,7 +2,6 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        AMRWBDecoder.cpp \
        src/agc2_amr_wb.cpp \
        src/band_pass_6k_7k.cpp \
        src/dec_acelp_2p_in_64.cpp \
diff --git a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
deleted file mode 100644 (file)
index 490129f..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * Copyright (C) 2009 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 "AVCDecoder"
-#include <utils/Log.h>
-
-#include "AVCDecoder.h"
-
-#include "avcdec_api.h"
-#include "avcdec_int.h"
-
-#include <OMX_Component.h>
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-#include <media/stagefright/foundation/hexdump.h>
-
-namespace android {
-
-static const char kStartCode[4] = { 0x00, 0x00, 0x00, 0x01 };
-
-static int32_t Malloc(void *userData, int32_t size, int32_t attrs) {
-    return reinterpret_cast<int32_t>(malloc(size));
-}
-
-static void Free(void *userData, int32_t ptr) {
-    free(reinterpret_cast<void *>(ptr));
-}
-
-AVCDecoder::AVCDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mHandle(new tagAVCHandle),
-      mInputBuffer(NULL),
-      mAnchorTimeUs(0),
-      mNumSamplesOutput(0),
-      mPendingSeekTimeUs(-1),
-      mPendingSeekMode(MediaSource::ReadOptions::SEEK_CLOSEST_SYNC),
-      mTargetTimeUs(-1),
-      mSPSSeen(false),
-      mPPSSeen(false) {
-    memset(mHandle, 0, sizeof(tagAVCHandle));
-    mHandle->AVCObject = NULL;
-    mHandle->userData = this;
-    mHandle->CBAVC_DPBAlloc = ActivateSPSWrapper;
-    mHandle->CBAVC_FrameBind = BindFrameWrapper;
-    mHandle->CBAVC_FrameUnbind = UnbindFrame;
-    mHandle->CBAVC_Malloc = Malloc;
-    mHandle->CBAVC_Free = Free;
-
-    mFormat = new MetaData;
-    mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
-    int32_t width, height;
-    CHECK(mSource->getFormat()->findInt32(kKeyWidth, &width));
-    CHECK(mSource->getFormat()->findInt32(kKeyHeight, &height));
-    mFormat->setInt32(kKeyWidth, width);
-    mFormat->setInt32(kKeyHeight, height);
-    mFormat->setRect(kKeyCropRect, 0, 0, width - 1, height - 1);
-    mFormat->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
-    mFormat->setCString(kKeyDecoderComponent, "AVCDecoder");
-
-    int64_t durationUs;
-    if (mSource->getFormat()->findInt64(kKeyDuration, &durationUs)) {
-        mFormat->setInt64(kKeyDuration, durationUs);
-    }
-}
-
-AVCDecoder::~AVCDecoder() {
-    if (mStarted) {
-        stop();
-    }
-
-    PVAVCCleanUpDecoder(mHandle);
-
-    delete mHandle;
-    mHandle = NULL;
-}
-
-status_t AVCDecoder::start(MetaData *) {
-    CHECK(!mStarted);
-
-    uint32_t type;
-    const void *data;
-    size_t size;
-    sp<MetaData> meta = mSource->getFormat();
-    if (meta->findData(kKeyAVCC, &type, &data, &size)) {
-        // Parse the AVCDecoderConfigurationRecord
-
-        const uint8_t *ptr = (const uint8_t *)data;
-
-        CHECK(size >= 7);
-        CHECK_EQ(ptr[0], 1);  // configurationVersion == 1
-        uint8_t profile = ptr[1];
-        uint8_t level = ptr[3];
-
-        // There is decodable content out there that fails the following
-        // assertion, let's be lenient for now...
-        // CHECK((ptr[4] >> 2) == 0x3f);  // reserved
-
-        size_t lengthSize = 1 + (ptr[4] & 3);
-
-        // commented out check below as H264_QVGA_500_NO_AUDIO.3gp
-        // violates it...
-        // CHECK((ptr[5] >> 5) == 7);  // reserved
-
-        size_t numSeqParameterSets = ptr[5] & 31;
-
-        ptr += 6;
-        size -= 6;
-
-        for (size_t i = 0; i < numSeqParameterSets; ++i) {
-            CHECK(size >= 2);
-            size_t length = U16_AT(ptr);
-
-            ptr += 2;
-            size -= 2;
-
-            CHECK(size >= length);
-
-            addCodecSpecificData(ptr, length);
-
-            ptr += length;
-            size -= length;
-        }
-
-        CHECK(size >= 1);
-        size_t numPictureParameterSets = *ptr;
-        ++ptr;
-        --size;
-
-        for (size_t i = 0; i < numPictureParameterSets; ++i) {
-            CHECK(size >= 2);
-            size_t length = U16_AT(ptr);
-
-            ptr += 2;
-            size -= 2;
-
-            CHECK(size >= length);
-
-            addCodecSpecificData(ptr, length);
-
-            ptr += length;
-            size -= length;
-        }
-    }
-
-    mSource->start();
-
-    mAnchorTimeUs = 0;
-    mNumSamplesOutput = 0;
-    mPendingSeekTimeUs = -1;
-    mPendingSeekMode = ReadOptions::SEEK_CLOSEST_SYNC;
-    mTargetTimeUs = -1;
-    mSPSSeen = false;
-    mPPSSeen = false;
-    mStarted = true;
-
-    return OK;
-}
-
-void AVCDecoder::addCodecSpecificData(const uint8_t *data, size_t size) {
-    MediaBuffer *buffer = new MediaBuffer(size + 4);
-    memcpy(buffer->data(), kStartCode, 4);
-    memcpy((uint8_t *)buffer->data() + 4, data, size);
-    buffer->set_range(0, size + 4);
-
-    mCodecSpecificData.push(buffer);
-}
-
-status_t AVCDecoder::stop() {
-    CHECK(mStarted);
-
-    for (size_t i = 0; i < mCodecSpecificData.size(); ++i) {
-        (*mCodecSpecificData.editItemAt(i)).release();
-    }
-    mCodecSpecificData.clear();
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    mSource->stop();
-
-    releaseFrames();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> AVCDecoder::getFormat() {
-    return mFormat;
-}
-
-static void findNALFragment(
-        const MediaBuffer *buffer, const uint8_t **fragPtr, size_t *fragSize) {
-    const uint8_t *data =
-        (const uint8_t *)buffer->data() + buffer->range_offset();
-
-    size_t size = buffer->range_length();
-
-    CHECK(size >= 4);
-    CHECK(!memcmp(kStartCode, data, 4));
-
-    size_t offset = 4;
-    while (offset + 3 < size && memcmp(kStartCode, &data[offset], 4)) {
-        ++offset;
-    }
-
-    *fragPtr = &data[4];
-    if (offset + 3 >= size) {
-        *fragSize = size - 4;
-    } else {
-        *fragSize = offset - 4;
-    }
-}
-
-MediaBuffer *AVCDecoder::drainOutputBuffer() {
-    int32_t index;
-    int32_t Release;
-    AVCFrameIO Output;
-    Output.YCbCr[0] = Output.YCbCr[1] = Output.YCbCr[2] = NULL;
-    AVCDec_Status status = PVAVCDecGetOutput(mHandle, &index, &Release, &Output);
-
-    if (status != AVCDEC_SUCCESS) {
-        LOGV("PVAVCDecGetOutput returned error %d", status);
-        return NULL;
-    }
-
-    CHECK(index >= 0);
-    CHECK(index < (int32_t)mFrames.size());
-
-    MediaBuffer *mbuf = mFrames.editItemAt(index);
-
-    bool skipFrame = false;
-
-    if (mTargetTimeUs >= 0) {
-        int64_t timeUs;
-        CHECK(mbuf->meta_data()->findInt64(kKeyTime, &timeUs));
-        CHECK(timeUs <= mTargetTimeUs);
-
-        if (timeUs < mTargetTimeUs) {
-            // We're still waiting for the frame with the matching
-            // timestamp and we won't return the current one.
-            skipFrame = true;
-
-            LOGV("skipping frame at %lld us", timeUs);
-        } else {
-            LOGV("found target frame at %lld us", timeUs);
-
-            mTargetTimeUs = -1;
-        }
-    }
-
-    if (!skipFrame) {
-        mbuf->set_range(0, mbuf->size());
-        mbuf->add_ref();
-
-        return mbuf;
-    }
-
-    return new MediaBuffer(0);
-}
-
-status_t AVCDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        LOGV("seek requested to %lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6);
-
-        CHECK(seekTimeUs >= 0);
-        mPendingSeekTimeUs = seekTimeUs;
-        mPendingSeekMode = mode;
-
-        if (mInputBuffer) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-
-        PVAVCDecReset(mHandle);
-    }
-
-    if (mInputBuffer == NULL) {
-        LOGV("fetching new input buffer.");
-
-        bool seeking = false;
-
-        if (!mCodecSpecificData.isEmpty()) {
-            mInputBuffer = mCodecSpecificData.editItemAt(0);
-            mCodecSpecificData.removeAt(0);
-        } else {
-            for (;;) {
-                if (mPendingSeekTimeUs >= 0) {
-                    LOGV("reading data from timestamp %lld (%.2f secs)",
-                         mPendingSeekTimeUs, mPendingSeekTimeUs / 1E6);
-                }
-
-                ReadOptions seekOptions;
-                if (mPendingSeekTimeUs >= 0) {
-                    seeking = true;
-
-                    seekOptions.setSeekTo(mPendingSeekTimeUs, mPendingSeekMode);
-                    mPendingSeekTimeUs = -1;
-                }
-                status_t err = mSource->read(&mInputBuffer, &seekOptions);
-                seekOptions.clearSeekTo();
-
-                if (err != OK) {
-                    *out = drainOutputBuffer();
-                    return (*out == NULL)  ? err : (status_t)OK;
-                }
-
-                if (mInputBuffer->range_length() > 0) {
-                    break;
-                }
-
-                mInputBuffer->release();
-                mInputBuffer = NULL;
-            }
-        }
-
-        if (seeking) {
-            int64_t targetTimeUs;
-            if (mInputBuffer->meta_data()->findInt64(kKeyTargetTime, &targetTimeUs)
-                    && targetTimeUs >= 0) {
-                mTargetTimeUs = targetTimeUs;
-            } else {
-                mTargetTimeUs = -1;
-            }
-        }
-    }
-
-    const uint8_t *fragPtr;
-    size_t fragSize;
-    findNALFragment(mInputBuffer, &fragPtr, &fragSize);
-
-    bool releaseFragment = true;
-    status_t err = UNKNOWN_ERROR;
-
-    int nalType;
-    int nalRefIdc;
-    AVCDec_Status res =
-        PVAVCDecGetNALType(
-                const_cast<uint8_t *>(fragPtr), fragSize,
-                &nalType, &nalRefIdc);
-
-    if (res != AVCDEC_SUCCESS) {
-        LOGV("cannot determine nal type");
-    } else if (nalType == AVC_NALTYPE_SPS || nalType == AVC_NALTYPE_PPS
-                || (mSPSSeen && mPPSSeen)) {
-        switch (nalType) {
-            case AVC_NALTYPE_SPS:
-            {
-                mSPSSeen = true;
-
-                res = PVAVCDecSeqParamSet(
-                        mHandle, const_cast<uint8_t *>(fragPtr),
-                        fragSize);
-
-                if (res != AVCDEC_SUCCESS) {
-                    LOGV("PVAVCDecSeqParamSet returned error %d", res);
-                    break;
-                }
-
-                AVCDecObject *pDecVid = (AVCDecObject *)mHandle->AVCObject;
-
-                int32_t width =
-                    (pDecVid->seqParams[0]->pic_width_in_mbs_minus1 + 1) * 16;
-
-                int32_t height =
-                    (pDecVid->seqParams[0]->pic_height_in_map_units_minus1 + 1) * 16;
-
-                int32_t crop_left, crop_right, crop_top, crop_bottom;
-                if (pDecVid->seqParams[0]->frame_cropping_flag)
-                {
-                    crop_left = 2 * pDecVid->seqParams[0]->frame_crop_left_offset;
-                    crop_right =
-                        width - (2 * pDecVid->seqParams[0]->frame_crop_right_offset + 1);
-
-                    if (pDecVid->seqParams[0]->frame_mbs_only_flag)
-                    {
-                        crop_top = 2 * pDecVid->seqParams[0]->frame_crop_top_offset;
-                        crop_bottom =
-                            height -
-                            (2 * pDecVid->seqParams[0]->frame_crop_bottom_offset + 1);
-                    }
-                    else
-                    {
-                        crop_top = 4 * pDecVid->seqParams[0]->frame_crop_top_offset;
-                        crop_bottom =
-                            height -
-                            (4 * pDecVid->seqParams[0]->frame_crop_bottom_offset + 1);
-                    }
-                } else {
-                    crop_bottom = height - 1;
-                    crop_right = width - 1;
-                    crop_top = crop_left = 0;
-                }
-
-                int32_t prevCropLeft, prevCropTop;
-                int32_t prevCropRight, prevCropBottom;
-                if (!mFormat->findRect(
-                            kKeyCropRect,
-                            &prevCropLeft, &prevCropTop,
-                            &prevCropRight, &prevCropBottom)) {
-                    prevCropLeft = prevCropTop = 0;
-                    prevCropRight = width - 1;
-                    prevCropBottom = height - 1;
-                }
-
-                int32_t oldWidth, oldHeight;
-                CHECK(mFormat->findInt32(kKeyWidth, &oldWidth));
-                CHECK(mFormat->findInt32(kKeyHeight, &oldHeight));
-
-                if (oldWidth != width || oldHeight != height
-                        || prevCropLeft != crop_left
-                        || prevCropTop != crop_top
-                        || prevCropRight != crop_right
-                        || prevCropBottom != crop_bottom) {
-                    mFormat->setRect(
-                            kKeyCropRect,
-                            crop_left, crop_top, crop_right, crop_bottom);
-
-                    mFormat->setInt32(kKeyWidth, width);
-                    mFormat->setInt32(kKeyHeight, height);
-
-                    err = INFO_FORMAT_CHANGED;
-                } else {
-                    *out = new MediaBuffer(0);
-                    err = OK;
-                }
-                break;
-            }
-
-            case AVC_NALTYPE_PPS:
-            {
-                mPPSSeen = true;
-
-                res = PVAVCDecPicParamSet(
-                        mHandle, const_cast<uint8_t *>(fragPtr),
-                        fragSize);
-
-                if (res != AVCDEC_SUCCESS) {
-                    LOGV("PVAVCDecPicParamSet returned error %d", res);
-                    break;
-                }
-
-                *out = new MediaBuffer(0);
-
-                err = OK;
-                break;
-            }
-
-            case AVC_NALTYPE_SLICE:
-            case AVC_NALTYPE_IDR:
-            {
-                res = PVAVCDecodeSlice(
-                        mHandle, const_cast<uint8_t *>(fragPtr),
-                        fragSize);
-
-                if (res == AVCDEC_PICTURE_OUTPUT_READY) {
-                    MediaBuffer *mbuf = drainOutputBuffer();
-                    if (mbuf == NULL) {
-                        break;
-                    }
-
-                    *out = mbuf;
-
-                    // Do _not_ release input buffer yet.
-
-                    releaseFragment = false;
-                    err = OK;
-                    break;
-                }
-
-                if (res == AVCDEC_PICTURE_READY || res == AVCDEC_SUCCESS) {
-                    *out = new MediaBuffer(0);
-
-                    err = OK;
-                } else {
-                    LOGV("PVAVCDecodeSlice returned error %d", res);
-                }
-                break;
-            }
-
-            case AVC_NALTYPE_SEI:
-            {
-                res = PVAVCDecSEI(
-                        mHandle, const_cast<uint8_t *>(fragPtr),
-                        fragSize);
-
-                if (res != AVCDEC_SUCCESS) {
-                    break;
-                }
-
-                *out = new MediaBuffer(0);
-
-                err = OK;
-                break;
-            }
-
-            case AVC_NALTYPE_AUD:
-            case AVC_NALTYPE_FILL:
-            case AVC_NALTYPE_EOSEQ:
-            {
-                *out = new MediaBuffer(0);
-
-                err = OK;
-                break;
-            }
-
-            default:
-            {
-                LOGE("Should not be here, unknown nalType %d", nalType);
-
-                err = ERROR_MALFORMED;
-                break;
-            }
-        }
-    } else {
-        // We haven't seen SPS or PPS yet.
-
-        *out = new MediaBuffer(0);
-        err = OK;
-    }
-
-    if (releaseFragment) {
-        size_t offset = mInputBuffer->range_offset();
-        if (fragSize + 4 == mInputBuffer->range_length()) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        } else {
-            mInputBuffer->set_range(
-                    offset + fragSize + 4,
-                    mInputBuffer->range_length() - fragSize - 4);
-        }
-    }
-
-    return err;
-}
-
-// static
-int32_t AVCDecoder::ActivateSPSWrapper(
-        void *userData, unsigned int sizeInMbs, unsigned int numBuffers) {
-    return static_cast<AVCDecoder *>(userData)->activateSPS(sizeInMbs, numBuffers);
-}
-
-// static
-int32_t AVCDecoder::BindFrameWrapper(
-        void *userData, int32_t index, uint8_t **yuv) {
-    return static_cast<AVCDecoder *>(userData)->bindFrame(index, yuv);
-}
-
-// static
-void AVCDecoder::UnbindFrame(void *userData, int32_t index) {
-}
-
-int32_t AVCDecoder::activateSPS(
-        unsigned int sizeInMbs, unsigned int numBuffers) {
-    CHECK(mFrames.isEmpty());
-
-    size_t frameSize = (sizeInMbs << 7) * 3;
-    for (unsigned int i = 0; i < numBuffers; ++i) {
-        MediaBuffer *buffer = new MediaBuffer(frameSize);
-        buffer->setObserver(this);
-
-        mFrames.push(buffer);
-    }
-
-    return 1;
-}
-
-int32_t AVCDecoder::bindFrame(int32_t index, uint8_t **yuv) {
-    CHECK(index >= 0);
-    CHECK(index < (int32_t)mFrames.size());
-
-    CHECK(mInputBuffer != NULL);
-    int64_t timeUs;
-    CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
-    mFrames[index]->meta_data()->setInt64(kKeyTime, timeUs);
-
-    *yuv = (uint8_t *)mFrames[index]->data();
-
-    return 1;
-}
-
-void AVCDecoder::releaseFrames() {
-    for (size_t i = 0; i < mFrames.size(); ++i) {
-        MediaBuffer *buffer = mFrames.editItemAt(i);
-
-        buffer->setObserver(NULL);
-        buffer->release();
-    }
-    mFrames.clear();
-}
-
-void AVCDecoder::signalBufferReturned(MediaBuffer *buffer) {
-}
-
-}  // namespace android
index 4d4533b..2949a04 100644 (file)
@@ -2,7 +2,6 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        AVCDecoder.cpp \
         src/avcdec_api.cpp \
         src/avc_bitstream.cpp \
         src/header.cpp \
index 6e98559..6692533 100644 (file)
@@ -2,20 +2,6 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-    G711Decoder.cpp
-
-LOCAL_C_INCLUDES := \
-        frameworks/base/media/libstagefright/include \
-
-LOCAL_MODULE := libstagefright_g711dec
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
         SoftG711.cpp
 
 LOCAL_C_INCLUDES := \
diff --git a/media/libstagefright/codecs/g711/dec/G711Decoder.cpp b/media/libstagefright/codecs/g711/dec/G711Decoder.cpp
deleted file mode 100644 (file)
index 4414e4e..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2010 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 "G711Decoder"
-#include <utils/Log.h>
-
-#include "G711Decoder.h"
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-
-static const size_t kMaxNumSamplesPerFrame = 16384;
-
-namespace android {
-
-G711Decoder::G711Decoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferGroup(NULL) {
-}
-
-G711Decoder::~G711Decoder() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-status_t G711Decoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    const char *mime;
-    CHECK(mSource->getFormat()->findCString(kKeyMIMEType, &mime));
-
-    mIsMLaw = false;
-    if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_G711_MLAW)) {
-        mIsMLaw = true;
-    } else if (strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_G711_ALAW)) {
-        return ERROR_UNSUPPORTED;
-    }
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(
-            new MediaBuffer(kMaxNumSamplesPerFrame * sizeof(int16_t)));
-
-    mSource->start();
-
-    mStarted = true;
-
-    return OK;
-}
-
-status_t G711Decoder::stop() {
-    CHECK(mStarted);
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> G711Decoder::getFormat() {
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    int32_t numChannels;
-    int32_t sampleRate;
-
-    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
-    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
-
-    sp<MetaData> meta = new MetaData;
-    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-    meta->setInt32(kKeyChannelCount, numChannels);
-    meta->setInt32(kKeySampleRate, sampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        meta->setInt64(kKeyDuration, durationUs);
-    }
-
-    meta->setCString(kKeyDecoderComponent, "G711Decoder");
-
-    return meta;
-}
-
-status_t G711Decoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        CHECK(seekTimeUs >= 0);
-    } else {
-        seekTimeUs = -1;
-    }
-
-    MediaBuffer *inBuffer;
-    err = mSource->read(&inBuffer, options);
-
-    if (err != OK) {
-        return err;
-    }
-
-    if (inBuffer->range_length() > kMaxNumSamplesPerFrame) {
-        LOGE("input buffer too large (%d).", inBuffer->range_length());
-
-        inBuffer->release();
-        inBuffer = NULL;
-
-        return ERROR_UNSUPPORTED;
-    }
-
-    int64_t timeUs;
-    CHECK(inBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
-
-    const uint8_t *inputPtr =
-        (const uint8_t *)inBuffer->data() + inBuffer->range_offset();
-
-    MediaBuffer *outBuffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&outBuffer), OK);
-
-    if (mIsMLaw) {
-        DecodeMLaw(
-                static_cast<int16_t *>(outBuffer->data()),
-                inputPtr, inBuffer->range_length());
-    } else {
-        DecodeALaw(
-                static_cast<int16_t *>(outBuffer->data()),
-                inputPtr, inBuffer->range_length());
-    }
-
-    // Each 8-bit byte is converted into a 16-bit sample.
-    outBuffer->set_range(0, inBuffer->range_length() * 2);
-
-    outBuffer->meta_data()->setInt64(kKeyTime, timeUs);
-
-    inBuffer->release();
-    inBuffer = NULL;
-
-    *out = outBuffer;
-
-    return OK;
-}
-
-// static
-void G711Decoder::DecodeALaw(
-        int16_t *out, const uint8_t *in, size_t inSize) {
-    while (inSize-- > 0) {
-        int32_t x = *in++;
-
-        int32_t ix = x ^ 0x55;
-        ix &= 0x7f;
-
-        int32_t iexp = ix >> 4;
-        int32_t mant = ix & 0x0f;
-
-        if (iexp > 0) {
-            mant += 16;
-        }
-
-        mant = (mant << 4) + 8;
-
-        if (iexp > 1) {
-            mant = mant << (iexp - 1);
-        }
-
-        *out++ = (x > 127) ? mant : -mant;
-    }
-}
-
-// static
-void G711Decoder::DecodeMLaw(
-        int16_t *out, const uint8_t *in, size_t inSize) {
-    while (inSize-- > 0) {
-        int32_t x = *in++;
-
-        int32_t mantissa = ~x;
-        int32_t exponent = (mantissa >> 4) & 7;
-        int32_t segment = exponent + 1;
-        mantissa &= 0x0f;
-
-        int32_t step = 4 << segment;
-
-        int32_t abs = (0x80l << exponent) + step * mantissa + step / 2 - 4 * 33;
-
-        *out++ = (x < 0x80) ? -abs : abs;
-    }
-}
-
-}  // namespace android
index f1bec08..2ffa5f2 100644 (file)
@@ -2,7 +2,6 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-       M4vH263Decoder.cpp \
        src/adaptive_smooth_no_mmx.cpp \
        src/bitstream.cpp \
        src/block_idct.cpp \
diff --git a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp
deleted file mode 100644 (file)
index 2bdb3ef..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2009 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 "M4vH263Decoder"
-#include <utils/Log.h>
-#include <stdlib.h> // for free
-#include "ESDS.h"
-#include "M4vH263Decoder.h"
-
-#include "mp4dec_api.h"
-
-#include <OMX_Component.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-
-namespace android {
-
-M4vH263Decoder::M4vH263Decoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mHandle(new tagvideoDecControls),
-      mInputBuffer(NULL),
-      mNumSamplesOutput(0),
-      mTargetTimeUs(-1) {
-
-    LOGV("M4vH263Decoder");
-    memset(mHandle, 0, sizeof(tagvideoDecControls));
-    mFormat = new MetaData;
-    mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
-
-    // CHECK(mSource->getFormat()->findInt32(kKeyWidth, &mWidth));
-    // CHECK(mSource->getFormat()->findInt32(kKeyHeight, &mHeight));
-
-    // We'll ignore the dimension advertised by the source, the decoder
-    // appears to require us to always start with the default dimensions
-    // of 352 x 288 to operate correctly and later react to changes in
-    // the dimensions as needed.
-    mWidth = 352;
-    mHeight = 288;
-
-    mFormat->setInt32(kKeyWidth, mWidth);
-    mFormat->setInt32(kKeyHeight, mHeight);
-    mFormat->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
-    mFormat->setCString(kKeyDecoderComponent, "M4vH263Decoder");
-}
-
-M4vH263Decoder::~M4vH263Decoder() {
-    if (mStarted) {
-        stop();
-    }
-
-    delete mHandle;
-    mHandle = NULL;
-}
-
-void M4vH263Decoder::allocateFrames(int32_t width, int32_t height) {
-    size_t frameSize =
-        (((width + 15) & - 16) * ((height + 15) & - 16) * 3) / 2;
-
-    for (uint32_t i = 0; i < 2; ++i) {
-        mFrames[i] = new MediaBuffer(frameSize);
-        mFrames[i]->setObserver(this);
-    }
-
-    PVSetReferenceYUV(
-            mHandle,
-            (uint8_t *)mFrames[1]->data());
-}
-
-status_t M4vH263Decoder::start(MetaData *) {
-    CHECK(!mStarted);
-
-    const char *mime = NULL;
-    sp<MetaData> meta = mSource->getFormat();
-    CHECK(meta->findCString(kKeyMIMEType, &mime));
-
-    MP4DecodingMode mode;
-    if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_MPEG4, mime)) {
-        mode = MPEG4_MODE;
-    } else {
-        CHECK(!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime));
-        mode = H263_MODE;
-    }
-
-    uint32_t type;
-    const void *data = NULL;
-    size_t size = 0;
-    uint8_t *vol_data[1] = {0};
-    int32_t vol_size = 0;
-    if (meta->findData(kKeyESDS, &type, &data, &size)) {
-        ESDS esds((const uint8_t *)data, size);
-        CHECK_EQ(esds.InitCheck(), (status_t)OK);
-
-        const void *codec_specific_data;
-        size_t codec_specific_data_size;
-        esds.getCodecSpecificInfo(
-                &codec_specific_data, &codec_specific_data_size);
-
-        vol_data[0] = (uint8_t *) malloc(codec_specific_data_size);
-        memcpy(vol_data[0], codec_specific_data, codec_specific_data_size);
-        vol_size = codec_specific_data_size;
-    } else {
-        vol_data[0] = NULL;
-        vol_size = 0;
-
-    }
-
-    Bool success = PVInitVideoDecoder(
-            mHandle, vol_data, &vol_size, 1, mWidth, mHeight, mode);
-    if (vol_data[0]) free(vol_data[0]);
-
-    if (success != PV_TRUE) {
-        LOGW("PVInitVideoDecoder failed. Unsupported content?");
-        return ERROR_UNSUPPORTED;
-    }
-
-    MP4DecodingMode actualMode = PVGetDecBitstreamMode(mHandle);
-    if (mode != actualMode) {
-        PVCleanUpVideoDecoder(mHandle);
-        return UNKNOWN_ERROR;
-    }
-
-    PVSetPostProcType((VideoDecControls *) mHandle, 0);
-
-    int32_t width, height;
-    PVGetVideoDimensions(mHandle, &width, &height);
-    if (mode == H263_MODE && (width == 0 || height == 0)) {
-        width = 352;
-        height = 288;
-    }
-    allocateFrames(width, height);
-
-    mSource->start();
-
-    mNumSamplesOutput = 0;
-    mTargetTimeUs = -1;
-    mStarted = true;
-
-    return OK;
-}
-
-status_t M4vH263Decoder::stop() {
-    CHECK(mStarted);
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    mSource->stop();
-
-    releaseFrames();
-
-    mStarted = false;
-    return (PVCleanUpVideoDecoder(mHandle) == PV_TRUE)? OK: UNKNOWN_ERROR;
-}
-
-sp<MetaData> M4vH263Decoder::getFormat() {
-    return mFormat;
-}
-
-status_t M4vH263Decoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    *out = NULL;
-
-    bool seeking = false;
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        seeking = true;
-        CHECK_EQ((int)PVResetVideoDecoder(mHandle), PV_TRUE);
-    }
-
-    MediaBuffer *inputBuffer = NULL;
-    status_t err = mSource->read(&inputBuffer, options);
-    if (err != OK) {
-        return err;
-    }
-
-    if (seeking) {
-        int64_t targetTimeUs;
-        if (inputBuffer->meta_data()->findInt64(kKeyTargetTime, &targetTimeUs)
-                && targetTimeUs >= 0) {
-            mTargetTimeUs = targetTimeUs;
-        } else {
-            mTargetTimeUs = -1;
-        }
-    }
-
-    uint8_t *bitstream =
-        (uint8_t *) inputBuffer->data() + inputBuffer->range_offset();
-
-    uint32_t timestamp = 0xFFFFFFFF;
-    int32_t bufferSize = inputBuffer->range_length();
-    uint32_t useExtTimestamp = 0;
-    if (PVDecodeVideoFrame(
-                mHandle, &bitstream, &timestamp, &bufferSize,
-                &useExtTimestamp,
-                (uint8_t *)mFrames[mNumSamplesOutput & 0x01]->data())
-            != PV_TRUE) {
-        LOGE("failed to decode video frame.");
-
-        inputBuffer->release();
-        inputBuffer = NULL;
-
-        return UNKNOWN_ERROR;
-    }
-
-    int32_t disp_width, disp_height;
-    PVGetVideoDimensions(mHandle, &disp_width, &disp_height);
-
-    int32_t buf_width, buf_height;
-    PVGetBufferDimensions(mHandle, &buf_width, &buf_height);
-
-    if (buf_width != mWidth || buf_height != mHeight) {
-        ++mNumSamplesOutput;  // The client will never get to see this frame.
-
-        inputBuffer->release();
-        inputBuffer = NULL;
-
-        mWidth = buf_width;
-        mHeight = buf_height;
-        mFormat->setInt32(kKeyWidth, mWidth);
-        mFormat->setInt32(kKeyHeight, mHeight);
-
-        CHECK_LE(disp_width, buf_width);
-        CHECK_LE(disp_height, buf_height);
-
-        mFormat->setRect(kKeyCropRect, 0, 0, disp_width - 1, disp_height - 1);
-
-        return INFO_FORMAT_CHANGED;
-    }
-
-    int64_t timeUs;
-    CHECK(inputBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
-
-    inputBuffer->release();
-    inputBuffer = NULL;
-
-    bool skipFrame = false;
-
-    if (mTargetTimeUs >= 0) {
-        CHECK(timeUs <= mTargetTimeUs);
-
-        if (timeUs < mTargetTimeUs) {
-            // We're still waiting for the frame with the matching
-            // timestamp and we won't return the current one.
-            skipFrame = true;
-
-            LOGV("skipping frame at %lld us", timeUs);
-        } else {
-            LOGV("found target frame at %lld us", timeUs);
-
-            mTargetTimeUs = -1;
-        }
-    }
-
-    if (skipFrame) {
-        *out = new MediaBuffer(0);
-    } else {
-        *out = mFrames[mNumSamplesOutput & 0x01];
-        (*out)->add_ref();
-        (*out)->meta_data()->setInt64(kKeyTime, timeUs);
-    }
-
-    ++mNumSamplesOutput;
-
-    return OK;
-}
-
-void M4vH263Decoder::releaseFrames() {
-    for (size_t i = 0; i < sizeof(mFrames) / sizeof(mFrames[0]); ++i) {
-        MediaBuffer *buffer = mFrames[i];
-
-        buffer->setObserver(NULL);
-        buffer->release();
-
-        mFrames[i] = NULL;
-    }
-}
-
-void M4vH263Decoder::signalBufferReturned(MediaBuffer *buffer) {
-    LOGV("signalBufferReturned");
-}
-
-
-}  // namespace android
index 229988e..a08c9f0 100644 (file)
@@ -2,7 +2,6 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        MP3Decoder.cpp \
        src/pvmp3_normalize.cpp \
        src/pvmp3_alias_reduction.cpp \
        src/pvmp3_crc.cpp \
diff --git a/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp b/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp
deleted file mode 100644 (file)
index 0ba42ff..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2009 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 "MP3Decoder"
-
-#include "MP3Decoder.h"
-
-#include "include/pvmp3decoder_api.h"
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-
-namespace android {
-
-MP3Decoder::MP3Decoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mNumChannels(0),
-      mStarted(false),
-      mBufferGroup(NULL),
-      mConfig(new tPVMP3DecoderExternal),
-      mDecoderBuf(NULL),
-      mAnchorTimeUs(0),
-      mNumFramesOutput(0),
-      mInputBuffer(NULL) {
-    init();
-}
-
-void MP3Decoder::init() {
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    int32_t sampleRate;
-    CHECK(srcFormat->findInt32(kKeyChannelCount, &mNumChannels));
-    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
-
-    mMeta = new MetaData;
-    mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-    mMeta->setInt32(kKeyChannelCount, mNumChannels);
-    mMeta->setInt32(kKeySampleRate, sampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        mMeta->setInt64(kKeyDuration, durationUs);
-    }
-
-    mMeta->setCString(kKeyDecoderComponent, "MP3Decoder");
-}
-
-MP3Decoder::~MP3Decoder() {
-    if (mStarted) {
-        stop();
-    }
-
-    delete mConfig;
-    mConfig = NULL;
-}
-
-status_t MP3Decoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(new MediaBuffer(4608 * 2));
-
-    mConfig->equalizerType = flat;
-    mConfig->crcEnabled = false;
-
-    uint32_t memRequirements = pvmp3_decoderMemRequirements();
-    mDecoderBuf = malloc(memRequirements);
-
-    pvmp3_InitDecoder(mConfig, mDecoderBuf);
-
-    mSource->start();
-
-    mAnchorTimeUs = 0;
-    mNumFramesOutput = 0;
-    mStarted = true;
-
-    return OK;
-}
-
-status_t MP3Decoder::stop() {
-    CHECK(mStarted);
-
-    if (mInputBuffer) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    free(mDecoderBuf);
-    mDecoderBuf = NULL;
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> MP3Decoder::getFormat() {
-    return mMeta;
-}
-
-status_t MP3Decoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        CHECK(seekTimeUs >= 0);
-
-        mNumFramesOutput = 0;
-
-        if (mInputBuffer) {
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-        }
-
-        // Make sure that the next buffer output does not still
-        // depend on fragments from the last one decoded.
-        pvmp3_InitDecoder(mConfig, mDecoderBuf);
-    } else {
-        seekTimeUs = -1;
-    }
-
-    if (mInputBuffer == NULL) {
-        err = mSource->read(&mInputBuffer, options);
-
-        if (err != OK) {
-            return err;
-        }
-
-        int64_t timeUs;
-        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
-            mAnchorTimeUs = timeUs;
-            mNumFramesOutput = 0;
-        } else {
-            // We must have a new timestamp after seeking.
-            CHECK(seekTimeUs < 0);
-        }
-    }
-
-    MediaBuffer *buffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&buffer), OK);
-
-    mConfig->pInputBuffer =
-        (uint8_t *)mInputBuffer->data() + mInputBuffer->range_offset();
-
-    mConfig->inputBufferCurrentLength = mInputBuffer->range_length();
-    mConfig->inputBufferMaxLength = 0;
-    mConfig->inputBufferUsedLength = 0;
-
-    mConfig->outputFrameSize = buffer->size() / sizeof(int16_t);
-    mConfig->pOutputBuffer = static_cast<int16_t *>(buffer->data());
-
-    ERROR_CODE decoderErr;
-    if ((decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf))
-            != NO_DECODING_ERROR) {
-        LOGV("mp3 decoder returned error %d", decoderErr);
-
-        if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR ||
-                mConfig->outputFrameSize == 0) {
-
-            if (mConfig->outputFrameSize == 0) {
-                LOGE("Output frame size is 0");
-            }
-            buffer->release();
-            buffer = NULL;
-
-            mInputBuffer->release();
-            mInputBuffer = NULL;
-
-            return UNKNOWN_ERROR;
-        }
-
-        // This is recoverable, just ignore the current frame and
-        // play silence instead.
-        memset(buffer->data(), 0, mConfig->outputFrameSize * sizeof(int16_t));
-        mConfig->inputBufferUsedLength = mInputBuffer->range_length();
-    }
-
-    buffer->set_range(
-            0, mConfig->outputFrameSize * sizeof(int16_t));
-
-    mInputBuffer->set_range(
-            mInputBuffer->range_offset() + mConfig->inputBufferUsedLength,
-            mInputBuffer->range_length() - mConfig->inputBufferUsedLength);
-
-    if (mInputBuffer->range_length() == 0) {
-        mInputBuffer->release();
-        mInputBuffer = NULL;
-    }
-
-    buffer->meta_data()->setInt64(
-            kKeyTime,
-            mAnchorTimeUs
-                + (mNumFramesOutput * 1000000) / mConfig->samplingRate);
-
-    mNumFramesOutput += mConfig->outputFrameSize / mNumChannels;
-
-    *out = buffer;
-
-    return OK;
-}
-
-}  // namespace android
index 832b885..32bbd6b 100644 (file)
@@ -2,24 +2,6 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        VPXDecoder.cpp  \
-
-LOCAL_MODULE := libstagefright_vpxdec
-
-LOCAL_C_INCLUDES := \
-        $(TOP)/frameworks/base/media/libstagefright/include \
-        frameworks/base/include/media/stagefright/openmax \
-        $(TOP)/external/libvpx \
-        $(TOP)/external/libvpx/vpx_codec \
-        $(TOP)/external/libvpx/vpx_ports
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
         SoftVPX.cpp
 
 LOCAL_C_INCLUDES := \
@@ -30,7 +12,6 @@ LOCAL_C_INCLUDES := \
         frameworks/base/include/media/stagefright/openmax \
 
 LOCAL_STATIC_LIBRARIES := \
-        libstagefright_vpxdec \
         libvpx
 
 LOCAL_SHARED_LIBRARIES := \
diff --git a/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp b/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp
deleted file mode 100644 (file)
index 489e5ad..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2010 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 "VPXDecoder"
-#include <utils/Log.h>
-
-#include "VPXDecoder.h"
-
-#include <OMX_Component.h>
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-
-#include "vpx/vpx_decoder.h"
-#include "vpx/vpx_codec.h"
-#include "vpx/vp8dx.h"
-
-namespace android {
-
-VPXDecoder::VPXDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferSize(0),
-      mCtx(NULL),
-      mBufferGroup(NULL),
-      mTargetTimeUs(-1) {
-    sp<MetaData> inputFormat = source->getFormat();
-    const char *mime;
-    CHECK(inputFormat->findCString(kKeyMIMEType, &mime));
-    CHECK(!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_VPX));
-
-    CHECK(inputFormat->findInt32(kKeyWidth, &mWidth));
-    CHECK(inputFormat->findInt32(kKeyHeight, &mHeight));
-
-    mBufferSize = (mWidth * mHeight * 3) / 2;
-
-    mFormat = new MetaData;
-    mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW);
-    mFormat->setInt32(kKeyWidth, mWidth);
-    mFormat->setInt32(kKeyHeight, mHeight);
-    mFormat->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
-    mFormat->setCString(kKeyDecoderComponent, "VPXDecoder");
-
-    int64_t durationUs;
-    if (inputFormat->findInt64(kKeyDuration, &durationUs)) {
-        mFormat->setInt64(kKeyDuration, durationUs);
-    }
-}
-
-VPXDecoder::~VPXDecoder() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-status_t VPXDecoder::start(MetaData *) {
-    if (mStarted) {
-        return UNKNOWN_ERROR;
-    }
-
-    status_t err = mSource->start();
-
-    if (err != OK) {
-        return err;
-    }
-
-    mCtx = new vpx_codec_ctx_t;
-    vpx_codec_err_t vpx_err;
-    if ((vpx_err = vpx_codec_dec_init(
-                (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, NULL, 0))) {
-        LOGE("on2 decoder failed to initialize. (%d)", vpx_err);
-
-        mSource->stop();
-
-        return UNKNOWN_ERROR;
-    }
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
-    mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
-
-    mTargetTimeUs = -1;
-
-    mStarted = true;
-
-    return OK;
-}
-
-status_t VPXDecoder::stop() {
-    if (!mStarted) {
-        return UNKNOWN_ERROR;
-    }
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    vpx_codec_destroy((vpx_codec_ctx_t *)mCtx);
-    delete (vpx_codec_ctx_t *)mCtx;
-    mCtx = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> VPXDecoder::getFormat() {
-    return mFormat;
-}
-
-status_t VPXDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    *out = NULL;
-
-    bool seeking = false;
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode seekMode;
-    if (options && options->getSeekTo(&seekTimeUs, &seekMode)) {
-        seeking = true;
-    }
-
-    MediaBuffer *input;
-    status_t err = mSource->read(&input, options);
-
-    if (err != OK) {
-        return err;
-    }
-
-    LOGV("read %d bytes from source\n", input->range_length());
-
-    if (seeking) {
-        int64_t targetTimeUs;
-        if (input->meta_data()->findInt64(kKeyTargetTime, &targetTimeUs)
-                && targetTimeUs >= 0) {
-            mTargetTimeUs = targetTimeUs;
-        } else {
-            mTargetTimeUs = -1;
-        }
-    }
-
-    if (vpx_codec_decode(
-                (vpx_codec_ctx_t *)mCtx,
-                (uint8_t *)input->data() + input->range_offset(),
-                input->range_length(),
-                NULL,
-                0)) {
-        LOGE("on2 decoder failed to decode frame.");
-        input->release();
-        input = NULL;
-
-        return UNKNOWN_ERROR;
-    }
-
-    LOGV("successfully decoded 1 or more frames.");
-
-    int64_t timeUs;
-    CHECK(input->meta_data()->findInt64(kKeyTime, &timeUs));
-
-    input->release();
-    input = NULL;
-
-    bool skipFrame = false;
-
-    if (mTargetTimeUs >= 0) {
-        CHECK(timeUs <= mTargetTimeUs);
-
-        if (timeUs < mTargetTimeUs) {
-            // We're still waiting for the frame with the matching
-            // timestamp and we won't return the current one.
-            skipFrame = true;
-
-            LOGV("skipping frame at %lld us", timeUs);
-        } else {
-            LOGV("found target frame at %lld us", timeUs);
-
-            mTargetTimeUs = -1;
-        }
-    }
-
-    if (skipFrame) {
-        *out = new MediaBuffer(0);
-        return OK;
-    }
-
-    vpx_codec_iter_t iter = NULL;
-    vpx_image_t *img = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter);
-
-    if (img == NULL) {
-        // The VPX format supports "internal-only" frames that are
-        // referenced by future content but never actually displayed, so
-        // this is a perfectly valid scenario.
-
-        *out = new MediaBuffer(0);
-        return OK;
-    }
-
-    CHECK_EQ(img->fmt, IMG_FMT_I420);
-
-    int32_t width = img->d_w;
-    int32_t height = img->d_h;
-
-    if (width != mWidth || height != mHeight) {
-        LOGI("Image dimensions changed, width = %d, height = %d",
-             width, height);
-
-        mWidth = width;
-        mHeight = height;
-        mFormat->setInt32(kKeyWidth, width);
-        mFormat->setInt32(kKeyHeight, height);
-
-        mBufferSize = (mWidth * mHeight * 3) / 2;
-        delete mBufferGroup;
-        mBufferGroup = new MediaBufferGroup;
-        mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
-        mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
-
-        return INFO_FORMAT_CHANGED;
-    }
-
-    MediaBuffer *output;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&output), OK);
-
-    const uint8_t *srcLine = (const uint8_t *)img->planes[PLANE_Y];
-    uint8_t *dst = (uint8_t *)output->data();
-    for (size_t i = 0; i < img->d_h; ++i) {
-        memcpy(dst, srcLine, img->d_w);
-
-        srcLine += img->stride[PLANE_Y];
-        dst += img->d_w;
-    }
-
-    srcLine = (const uint8_t *)img->planes[PLANE_U];
-    for (size_t i = 0; i < img->d_h / 2; ++i) {
-        memcpy(dst, srcLine, img->d_w / 2);
-
-        srcLine += img->stride[PLANE_U];
-        dst += img->d_w / 2;
-    }
-
-    srcLine = (const uint8_t *)img->planes[PLANE_V];
-    for (size_t i = 0; i < img->d_h / 2; ++i) {
-        memcpy(dst, srcLine, img->d_w / 2);
-
-        srcLine += img->stride[PLANE_V];
-        dst += img->d_w / 2;
-    }
-
-    output->set_range(0, (width * height * 3) / 2);
-
-    output->meta_data()->setInt64(kKeyTime, timeUs);
-
-    *out = output;
-
-    return OK;
-}
-
-}  // namespace android
-
index 9251229..f33f3ac 100644 (file)
@@ -2,21 +2,6 @@ LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        VorbisDecoder.cpp \
-
-LOCAL_C_INCLUDES := \
-        frameworks/base/media/libstagefright/include \
-        external/tremolo \
-
-LOCAL_MODULE := libstagefright_vorbisdec
-
-include $(BUILD_STATIC_LIBRARY)
-
-################################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
         SoftVorbis.cpp
 
 LOCAL_C_INCLUDES := \
@@ -24,9 +9,6 @@ LOCAL_C_INCLUDES := \
         frameworks/base/media/libstagefright/include \
         frameworks/base/include/media/stagefright/openmax \
 
-LOCAL_STATIC_LIBRARIES := \
-        libstagefright_vorbisdec
-
 LOCAL_SHARED_LIBRARIES := \
         libvorbisidec libstagefright libstagefright_omx \
         libstagefright_foundation libutils
diff --git a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
deleted file mode 100644 (file)
index e14fb95..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2010 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 "VorbisDecoder"
-#include <utils/Log.h>
-
-#include "VorbisDecoder.h"
-
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-
-extern "C" {
-    #include <Tremolo/codec_internal.h>
-
-    int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb);
-    int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb);
-    int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb);
-}
-
-namespace android {
-
-VorbisDecoder::VorbisDecoder(const sp<MediaSource> &source)
-    : mSource(source),
-      mStarted(false),
-      mBufferGroup(NULL),
-      mAnchorTimeUs(0),
-      mNumFramesOutput(0),
-      mState(NULL),
-      mVi(NULL) {
-    sp<MetaData> srcFormat = mSource->getFormat();
-    CHECK(srcFormat->findInt32(kKeyChannelCount, &mNumChannels));
-    CHECK(srcFormat->findInt32(kKeySampleRate, &mSampleRate));
-}
-
-VorbisDecoder::~VorbisDecoder() {
-    if (mStarted) {
-        stop();
-    }
-}
-
-static void makeBitReader(
-        const void *data, size_t size,
-        ogg_buffer *buf, ogg_reference *ref, oggpack_buffer *bits) {
-    buf->data = (uint8_t *)data;
-    buf->size = size;
-    buf->refcount = 1;
-    buf->ptr.owner = NULL;
-
-    ref->buffer = buf;
-    ref->begin = 0;
-    ref->length = size;
-    ref->next = NULL;
-
-    oggpack_readinit(bits, ref);
-}
-
-status_t VorbisDecoder::start(MetaData *params) {
-    CHECK(!mStarted);
-
-    mBufferGroup = new MediaBufferGroup;
-    mBufferGroup->add_buffer(
-            new MediaBuffer(kMaxNumSamplesPerBuffer * sizeof(int16_t)));
-
-    mSource->start();
-
-    sp<MetaData> meta = mSource->getFormat();
-
-    mVi = new vorbis_info;
-    vorbis_info_init(mVi);
-
-    ///////////////////////////////////////////////////////////////////////////
-
-    uint32_t type;
-    const void *data;
-    size_t size;
-    CHECK(meta->findData(kKeyVorbisInfo, &type, &data, &size));
-
-    ogg_buffer buf;
-    ogg_reference ref;
-    oggpack_buffer bits;
-    makeBitReader((const uint8_t *)data + 7, size - 7, &buf, &ref, &bits);
-    CHECK_EQ(0, _vorbis_unpack_info(mVi, &bits));
-
-    ///////////////////////////////////////////////////////////////////////////
-
-    CHECK(meta->findData(kKeyVorbisBooks, &type, &data, &size));
-
-    makeBitReader((const uint8_t *)data + 7, size - 7, &buf, &ref, &bits);
-    CHECK_EQ(0, _vorbis_unpack_books(mVi, &bits));
-
-    ///////////////////////////////////////////////////////////////////////////
-
-    mState = new vorbis_dsp_state;
-    CHECK_EQ(0, vorbis_dsp_init(mState, mVi));
-
-    mAnchorTimeUs = 0;
-    mNumFramesOutput = 0;
-
-    // If the source never limits the number of valid frames contained
-    // in the input data, we'll assume that all of the decoded frames are
-    // valid.
-    mNumFramesLeftOnPage = -1;
-
-    mStarted = true;
-
-    return OK;
-}
-
-status_t VorbisDecoder::stop() {
-    CHECK(mStarted);
-
-    vorbis_dsp_clear(mState);
-    delete mState;
-    mState = NULL;
-
-    vorbis_info_clear(mVi);
-    delete mVi;
-    mVi = NULL;
-
-    delete mBufferGroup;
-    mBufferGroup = NULL;
-
-    mSource->stop();
-
-    mStarted = false;
-
-    return OK;
-}
-
-sp<MetaData> VorbisDecoder::getFormat() {
-    sp<MetaData> srcFormat = mSource->getFormat();
-
-    sp<MetaData> meta = new MetaData;
-    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
-    meta->setInt32(kKeyChannelCount, mNumChannels);
-    meta->setInt32(kKeySampleRate, mSampleRate);
-
-    int64_t durationUs;
-    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
-        meta->setInt64(kKeyDuration, durationUs);
-    }
-
-    meta->setCString(kKeyDecoderComponent, "VorbisDecoder");
-
-    return meta;
-}
-
-int VorbisDecoder::decodePacket(MediaBuffer *packet, MediaBuffer *out) {
-    ogg_buffer buf;
-    buf.data = (uint8_t *)packet->data() + packet->range_offset();
-    buf.size = packet->range_length();
-    buf.refcount = 1;
-    buf.ptr.owner = NULL;
-
-    ogg_reference ref;
-    ref.buffer = &buf;
-    ref.begin = 0;
-    ref.length = packet->range_length();
-    ref.next = NULL;
-
-    ogg_packet pack;
-    pack.packet = &ref;
-    pack.bytes = packet->range_length();
-    pack.b_o_s = 0;
-    pack.e_o_s = 0;
-    pack.granulepos = 0;
-    pack.packetno = 0;
-
-    int numFrames = 0;
-
-    int err = vorbis_dsp_synthesis(mState, &pack, 1);
-    if (err != 0) {
-        LOGW("vorbis_dsp_synthesis returned %d", err);
-    } else {
-        numFrames = vorbis_dsp_pcmout(
-                mState, (int16_t *)out->data(), kMaxNumSamplesPerBuffer);
-
-        if (numFrames < 0) {
-            LOGE("vorbis_dsp_pcmout returned %d", numFrames);
-            numFrames = 0;
-        }
-    }
-
-    if (mNumFramesLeftOnPage >= 0) {
-        if (numFrames > mNumFramesLeftOnPage) {
-            LOGV("discarding %d frames at end of page",
-                 numFrames - mNumFramesLeftOnPage);
-            numFrames = mNumFramesLeftOnPage;
-        }
-        mNumFramesLeftOnPage -= numFrames;
-    }
-
-    out->set_range(0, numFrames * sizeof(int16_t) * mNumChannels);
-
-    return numFrames;
-}
-
-status_t VorbisDecoder::read(
-        MediaBuffer **out, const ReadOptions *options) {
-    status_t err;
-
-    *out = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        CHECK(seekTimeUs >= 0);
-
-        mNumFramesOutput = 0;
-        vorbis_dsp_restart(mState);
-    } else {
-        seekTimeUs = -1;
-    }
-
-    MediaBuffer *inputBuffer;
-    err = mSource->read(&inputBuffer, options);
-
-    if (err != OK) {
-        return ERROR_END_OF_STREAM;
-    }
-
-    int64_t timeUs;
-    if (inputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
-        mAnchorTimeUs = timeUs;
-        mNumFramesOutput = 0;
-    } else {
-        // We must have a new timestamp after seeking.
-        CHECK(seekTimeUs < 0);
-    }
-
-    int32_t numPageSamples;
-    if (inputBuffer->meta_data()->findInt32(
-                kKeyValidSamples, &numPageSamples)) {
-        CHECK(numPageSamples >= 0);
-        mNumFramesLeftOnPage = numPageSamples;
-    }
-
-    MediaBuffer *outputBuffer;
-    CHECK_EQ(mBufferGroup->acquire_buffer(&outputBuffer), OK);
-
-    int numFrames = decodePacket(inputBuffer, outputBuffer);
-
-    inputBuffer->release();
-    inputBuffer = NULL;
-
-    outputBuffer->meta_data()->setInt64(
-            kKeyTime,
-            mAnchorTimeUs
-                + (mNumFramesOutput * 1000000ll) / mSampleRate);
-
-    mNumFramesOutput += numFrames;
-
-    *out = outputBuffer;
-
-    return OK;
-}
-
-}  // namespace android
diff --git a/media/libstagefright/include/ThreadedSource.h b/media/libstagefright/include/ThreadedSource.h
deleted file mode 100644 (file)
index c67295c..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2010 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 THREADED_SOURCE_H_
-
-#define THREADED_SOURCE_H_
-
-#include <media/stagefright/foundation/ABase.h>
-#include <media/stagefright/foundation/AHandlerReflector.h>
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/MediaSource.h>
-#include <utils/threads.h>
-
-namespace android {
-
-struct ThreadedSource : public MediaSource {
-    ThreadedSource(const sp<MediaSource> &source);
-
-    virtual status_t start(MetaData *params);
-    virtual status_t stop();
-
-    virtual sp<MetaData> getFormat();
-
-    virtual status_t read(
-            MediaBuffer **buffer, const ReadOptions *options);
-
-    virtual void onMessageReceived(const sp<AMessage> &msg);
-
-protected:
-    virtual ~ThreadedSource();
-
-private:
-    enum {
-        kWhatDecodeMore = 'deco',
-        kWhatSeek       = 'seek',
-    };
-
-    sp<MediaSource> mSource;
-    sp<AHandlerReflector<ThreadedSource> > mReflector;
-    sp<ALooper> mLooper;
-
-    Mutex mLock;
-    Condition mCondition;
-    List<MediaBuffer *> mQueue;
-    status_t mFinalResult;
-    bool mDecodePending;
-    bool mStarted;
-
-    int64_t mSeekTimeUs;
-    ReadOptions::SeekMode mSeekMode;
-
-    void postDecodeMore_l();
-    void clearQueue_l();
-
-    DISALLOW_EVIL_CONSTRUCTORS(ThreadedSource);
-};
-
-}  // namespace android
-
-#endif  // THREADED_SOURCE_H_