Loading media/libstagefright/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ LOCAL_SHARED_LIBRARIES := \ ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true) LOCAL_STATIC_LIBRARIES := \ libstagefright_aacdec libstagefright_aacdec \ libstagefright_mp3dec endif Loading media/libstagefright/OMXCodec.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #if BUILD_WITH_FULL_STAGEFRIGHT #include "include/AACDecoder.h" #include "include/MP3Decoder.h" #endif #include "include/ESDS.h" Loading Loading @@ -291,6 +292,8 @@ sp<MediaSource> OMXCodec::Create( #if BUILD_WITH_FULL_STAGEFRIGHT if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) { return new AACDecoder(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { return new MP3Decoder(source); } #endif Loading media/libstagefright/codecs/mp3dec/Android.mk 0 → 100644 +59 −0 Original line number Diff line number Diff line 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 \ src/pvmp3_decode_header.cpp \ src/pvmp3_decode_huff_cw.cpp \ src/pvmp3_getbits.cpp \ src/pvmp3_dequantize_sample.cpp \ src/pvmp3_framedecoder.cpp \ src/pvmp3_get_main_data_size.cpp \ src/pvmp3_get_side_info.cpp \ src/pvmp3_get_scale_factors.cpp \ src/pvmp3_mpeg2_get_scale_data.cpp \ src/pvmp3_mpeg2_get_scale_factors.cpp \ src/pvmp3_mpeg2_stereo_proc.cpp \ src/pvmp3_huffman_decoding.cpp \ src/pvmp3_huffman_parsing.cpp \ src/pvmp3_tables.cpp \ src/pvmp3_imdct_synth.cpp \ src/pvmp3_mdct_6.cpp \ src/pvmp3_dct_6.cpp \ src/pvmp3_poly_phase_synthesis.cpp \ src/pvmp3_equalizer.cpp \ src/pvmp3_seek_synch.cpp \ src/pvmp3_stereo_proc.cpp \ src/pvmp3_reorder.cpp \ src/pvmp3_polyphase_filter_window.cpp \ src/pvmp3_mdct_18.cpp \ src/pvmp3_dct_9.cpp \ src/pvmp3_dct_16.cpp ifeq ($(TARGET_ARCH),arm) LOCAL_SRC_FILES += \ src/asm/pvmp3_polyphase_filter_window_gcc.s \ src/asm/pvmp3_mdct_18_gcc.s \ src/asm/pvmp3_dct_9_gcc.s \ src/asm/pvmp3_dct_16_gcc.s endif LOCAL_C_INCLUDES := \ frameworks/base/media/libstagefright/include \ $(LOCAL_PATH)/src \ $(LOCAL_PATH)/include LOCAL_CFLAGS := \ -DOSCL_UNUSED_ARG= LOCAL_SHARED_LIBRARIES := \ libstagefright \ libutils LOCAL_MODULE := libstagefright_mp3dec include $(BUILD_STATIC_LIBRARY) media/libstagefright/codecs/mp3dec/MP3Decoder.cpp 0 → 100644 +165 −0 Original line number Diff line number Diff line #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), mStarted(false), mBufferGroup(NULL), mConfig(new tPVMP3DecoderExternal), mDecoderBuf(NULL), mAnchorTimeUs(0), mNumSamplesOutput(0), mInputBuffer(NULL) { } 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 = true; uint32_t memRequirements = pvmp3_decoderMemRequirements(); mDecoderBuf = malloc(memRequirements); pvmp3_InitDecoder(mConfig, mDecoderBuf); mSource->start(); mAnchorTimeUs = 0; mNumSamplesOutput = 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() { 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); return meta; } status_t MP3Decoder::read( MediaBuffer **out, const ReadOptions *options) { status_t err; *out = NULL; int64_t seekTimeUs; if (options && options->getSeekTo(&seekTimeUs)) { 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; } } 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()); CHECK_EQ(pvmp3_framedecoder(mConfig, mDecoderBuf), NO_DECODING_ERROR); 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 + (mNumSamplesOutput * 1000000) / mConfig->samplingRate); mNumSamplesOutput += mConfig->outputFrameSize / sizeof(int16_t); *out = buffer; return OK; } } // namespace android media/libstagefright/codecs/mp3dec/include/mp3_decoder_selection.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. * See the License for the specific language governing permissions * and limitations under the License. * ------------------------------------------------------------------- */ /*! \file mp3_decoder_selection.h * \brief select mp3 decoder * */ #ifndef MP3_DECODER_SELECTION_H #define MP3_DECODER_SELECTION_H #define NEW_PV_MP3_DECODER 1 // 1 == PV mp3 decoder #endif Loading
media/libstagefright/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ LOCAL_SHARED_LIBRARIES := \ ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true) LOCAL_STATIC_LIBRARIES := \ libstagefright_aacdec libstagefright_aacdec \ libstagefright_mp3dec endif Loading
media/libstagefright/OMXCodec.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #if BUILD_WITH_FULL_STAGEFRIGHT #include "include/AACDecoder.h" #include "include/MP3Decoder.h" #endif #include "include/ESDS.h" Loading Loading @@ -291,6 +292,8 @@ sp<MediaSource> OMXCodec::Create( #if BUILD_WITH_FULL_STAGEFRIGHT if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) { return new AACDecoder(source); } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { return new MP3Decoder(source); } #endif Loading
media/libstagefright/codecs/mp3dec/Android.mk 0 → 100644 +59 −0 Original line number Diff line number Diff line 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 \ src/pvmp3_decode_header.cpp \ src/pvmp3_decode_huff_cw.cpp \ src/pvmp3_getbits.cpp \ src/pvmp3_dequantize_sample.cpp \ src/pvmp3_framedecoder.cpp \ src/pvmp3_get_main_data_size.cpp \ src/pvmp3_get_side_info.cpp \ src/pvmp3_get_scale_factors.cpp \ src/pvmp3_mpeg2_get_scale_data.cpp \ src/pvmp3_mpeg2_get_scale_factors.cpp \ src/pvmp3_mpeg2_stereo_proc.cpp \ src/pvmp3_huffman_decoding.cpp \ src/pvmp3_huffman_parsing.cpp \ src/pvmp3_tables.cpp \ src/pvmp3_imdct_synth.cpp \ src/pvmp3_mdct_6.cpp \ src/pvmp3_dct_6.cpp \ src/pvmp3_poly_phase_synthesis.cpp \ src/pvmp3_equalizer.cpp \ src/pvmp3_seek_synch.cpp \ src/pvmp3_stereo_proc.cpp \ src/pvmp3_reorder.cpp \ src/pvmp3_polyphase_filter_window.cpp \ src/pvmp3_mdct_18.cpp \ src/pvmp3_dct_9.cpp \ src/pvmp3_dct_16.cpp ifeq ($(TARGET_ARCH),arm) LOCAL_SRC_FILES += \ src/asm/pvmp3_polyphase_filter_window_gcc.s \ src/asm/pvmp3_mdct_18_gcc.s \ src/asm/pvmp3_dct_9_gcc.s \ src/asm/pvmp3_dct_16_gcc.s endif LOCAL_C_INCLUDES := \ frameworks/base/media/libstagefright/include \ $(LOCAL_PATH)/src \ $(LOCAL_PATH)/include LOCAL_CFLAGS := \ -DOSCL_UNUSED_ARG= LOCAL_SHARED_LIBRARIES := \ libstagefright \ libutils LOCAL_MODULE := libstagefright_mp3dec include $(BUILD_STATIC_LIBRARY)
media/libstagefright/codecs/mp3dec/MP3Decoder.cpp 0 → 100644 +165 −0 Original line number Diff line number Diff line #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), mStarted(false), mBufferGroup(NULL), mConfig(new tPVMP3DecoderExternal), mDecoderBuf(NULL), mAnchorTimeUs(0), mNumSamplesOutput(0), mInputBuffer(NULL) { } 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 = true; uint32_t memRequirements = pvmp3_decoderMemRequirements(); mDecoderBuf = malloc(memRequirements); pvmp3_InitDecoder(mConfig, mDecoderBuf); mSource->start(); mAnchorTimeUs = 0; mNumSamplesOutput = 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() { 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); return meta; } status_t MP3Decoder::read( MediaBuffer **out, const ReadOptions *options) { status_t err; *out = NULL; int64_t seekTimeUs; if (options && options->getSeekTo(&seekTimeUs)) { 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; } } 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()); CHECK_EQ(pvmp3_framedecoder(mConfig, mDecoderBuf), NO_DECODING_ERROR); 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 + (mNumSamplesOutput * 1000000) / mConfig->samplingRate); mNumSamplesOutput += mConfig->outputFrameSize / sizeof(int16_t); *out = buffer; return OK; } } // namespace android
media/libstagefright/codecs/mp3dec/include/mp3_decoder_selection.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. * See the License for the specific language governing permissions * and limitations under the License. * ------------------------------------------------------------------- */ /*! \file mp3_decoder_selection.h * \brief select mp3 decoder * */ #ifndef MP3_DECODER_SELECTION_H #define MP3_DECODER_SELECTION_H #define NEW_PV_MP3_DECODER 1 // 1 == PV mp3 decoder #endif