android 4.0 support sf mkv parser on GB.

來源:互聯網
上載者:User
http://nv-tegra.nvidia.com/gitweb/?p=android/platform/frameworks/base.git;a=commitdiff;h=d818c244204bee4890e1a76bb3581b9c10113c8b stagefrightmkv: enable stagefright mkv  
author Siva Ramaraju <sramaraju@nvidia.com>  
  Tue, 10 May 2011 05:06:30 +0000 (10:06 +0530)
committer Varun Colbert <vcolbert@nvidia.com>  
  Sat, 14 May 2011 02:16:41 +0000 (19:16 -0700)
- support sf mkv parser on GB.
- changes to stabilize mkv playback.
- fix crash issues during playback.
- add divx/mpeg4 and mp3/ac3 support.
- Bug 816058
- Bug 812529
Change-Id: Ib39a744fb054b579455e9d57bd87774e1e9ca681

12 files changed:
include/media/stagefright/MediaDefs.h   patch | blob | history
include/media/stagefright/MetaData.h   patch | blob | history
media/libstagefright/Android.mk   patch | blob | history
media/libstagefright/ESDS.cpp   patch | blob | history
media/libstagefright/MediaDefs.cpp   patch | blob | history
media/libstagefright/MediaExtractor.cpp   patch | blob | history
media/libstagefright/OMXCodec.cpp [changed mode: 0755->0644] patch | blob | history
media/libstagefright/SuperExtractor.cpp   patch | blob | history
media/libstagefright/codecs/avc/dec/AVCDecoder.cpp   patch | blob | history
media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp   patch | blob | history
media/libstagefright/matroska/MatroskaExtractor.cpp   patch | blob | history
media/libstagefright/matroska/mkvparser.cpp   patch | blob | history

diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.hindex eeb9190..883b09a 100644 (file)--- a/include/media/stagefright/MediaDefs.h+++ b/include/media/stagefright/MediaDefs.h@@ -39,6 +39,7 @@ extern const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW; extern const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW; extern const char *MEDIA_MIMETYPE_AUDIO_RAW; extern const char *MEDIA_MIMETYPE_AUDIO_WMA;+extern const char *MEDIA_MIMETYPE_AUDIO_AC3;  extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4; extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.hindex 9301276..4bb2520 100644 (file)--- a/include/media/stagefright/MetaData.h+++ b/include/media/stagefright/MetaData.h@@ -41,6 +41,7 @@ enum {     kKeyBitRate           = 'brte',  // int32_t (bps)     kKeyESDS              = 'esds',  // raw data     kKeyAVCC              = 'avcc',  // raw data+    kKeyD263              = 'd263',  // raw data     kKeyVorbisInfo        = 'vinf',  // raw data     kKeyVorbisBooks       = 'vboo',  // raw data     kKeyWantsNALFragments = 'NALf',diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mkindex 5b65682..5cd1b60 100644 (file)--- a/media/libstagefright/Android.mk+++ b/media/libstagefright/Android.mk@@ -3,7 +3,6 @@ include $(CLEAR_VARS)  include frameworks/base/media/libstagefright/codecs/common/Config.mk -NV_MKV_ENABLED := 1  LOCAL_SRC_FILES:=                         \         AMRExtractor.cpp                  \@@ -113,8 +112,6 @@ endif  LOCAL_CFLAGS += -Wno-multichar -LOCAL_CFLAGS += -DNV_MKV_ENABLED=$(NV_MKV_ENABLED)- LOCAL_MODULE:= libstagefright  include $(BUILD_SHARED_LIBRARY)diff --git a/media/libstagefright/ESDS.cpp b/media/libstagefright/ESDS.cppindex b7c8e0c..1240d7b 100644 (file)--- a/media/libstagefright/ESDS.cpp+++ b/media/libstagefright/ESDS.cpp@@ -17,6 +17,10 @@ #include "include/ESDS.h"  #include <string.h>+#include <utils/Log.h>++//#define LOG_NDEBUG 0+#define LOG_TAG "ESDS"  namespace android { @@ -87,12 +91,11 @@ status_t ESDS::skipDescriptorHeader(     }     while (more); +    *data_offset = offset;     if (*data_size > size) {         return ERROR_MALFORMED;     } -    *data_offset = offset;-     return OK; } @@ -191,7 +194,7 @@ status_t ESDS::parseDecoderConfigDescriptor(size_t offset, size_t size) {     status_t err = skipDescriptorHeader(             offset, size, &tag, &sub_offset, &sub_size); -    if (err != OK) {+    if (err != OK && tag != kTag_DecoderSpecificInfo) {         return err;     } diff --git a/media/libstagefright/MediaDefs.cpp b/media/libstagefright/MediaDefs.cppindex a4cdae7..cde20b2 100644 (file)--- a/media/libstagefright/MediaDefs.cpp+++ b/media/libstagefright/MediaDefs.cpp@@ -37,6 +37,7 @@ const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW = "audio/g711-alaw"; const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW = "audio/g711-mlaw"; const char *MEDIA_MIMETYPE_AUDIO_WMA = "audio/x-ms-wma"; const char *MEDIA_MIMETYPE_AUDIO_RAW = "audio/raw";+const char *MEDIA_MIMETYPE_AUDIO_AC3 = "audio/ac3";  const char *MEDIA_MIMETYPE_CONTAINER_MPEG4 = "video/mpeg4"; const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/wav";diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cppindex 71dbf54..123475f 100644 (file)--- a/media/libstagefright/MediaExtractor.cpp+++ b/media/libstagefright/MediaExtractor.cpp@@ -80,12 +80,6 @@ sp<MediaExtractor> MediaExtractor::Create(     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) {         return new OggExtractor(source);     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) {-        #if (NV_MKV_ENABLED)-        {-            LOGV("NV_MKV_ENABLED - SuperExtractor Invoked");-            return new SuperExtractor (source);-        }-        #endif         LOGV("SF Matroska Extractor Invoked");         return new MatroskaExtractor(source);     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cppold mode 100755 (executable)
new mode 100644 (file)
index ca098c2..91c50ad--- a/media/libstagefright/OMXCodec.cpp+++ b/media/libstagefright/OMXCodec.cpp@@ -587,22 +587,27 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {          if (meta->findData(kKeyESDS, &type, &data, &size)) {             ESDS esds((const char *)data, size);-            CHECK_EQ(esds.InitCheck(), OK);--            const void *codec_specific_data;-            size_t codec_specific_data_size;-            esds.getCodecSpecificInfo(+            // relax and bypass codec specific info if init check fails+            // CHECK_EQ(esds.InitCheck(), OK);+            if (esds.InitCheck() == OK)+            {+                const void *codec_specific_data;+                size_t codec_specific_data_size;+                esds.getCodecSpecificInfo(                     &codec_specific_data, &codec_specific_data_size);--            addCodecSpecificData(+                addCodecSpecificData(                     codec_specific_data, codec_specific_data_size);+            }         } else if (meta->findData(kKeyAVCC, &type, &data, &size)) {             // Parse the AVCDecoderConfigurationRecord              const uint8_t *ptr = (const uint8_t *)data;-+            if (ptr == NULL || size < 7) {+                LOGV("Skipcodecdata- kKeyAVCC ERRROR: ptr= %x - size = %d", ptr, size);+                goto skipcodecdata;+            }             CHECK(size >= 7);-            CHECK_EQ(ptr[0], 1);  // configurationVersion == 1+            CHECK_EQ((unsigned)ptr[0], 1u);  // configurationVersion == 1             uint8_t profile = ptr[1];             uint8_t level = ptr[3]; @@ -672,6 +677,7 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {             }         }     }+ skipcodecdata:      int32_t bitRate = 0;     if (mIsEncoder) {diff --git a/media/libstagefright/SuperExtractor.cpp b/media/libstagefright/SuperExtractor.cppindex 2ed268e..c8a4567 100644 (file)--- a/media/libstagefright/SuperExtractor.cpp+++ b/media/libstagefright/SuperExtractor.cpp@@ -1814,80 +1814,6 @@ cleanup:  } -static bool ValidateMkv (const sp<DataSource> &source,-    uint8_t *header, uint32_t readsize)-{-    uint32_t cnt = 4; // 4 bytes ebml already read-    uint64_t hlen = 0;-    int32_t len_mask = 0x80;-    int32_t size = 1;-    int32_t n = 1;-    uint32_t rdsz = 0;-    bool status = false;-    bool reinitialise = false;-    uint8_t *data = NULL;-    if(!header)-    {-        goto cleanup;-    }-    data = header;-    static const char probe_data[] = "matroska";-    LOGV ("sniffsuper ++ validate mkv");-    hlen = data[cnt++];-    /*Determine length of hdr */-    while (size <= 8 && !(hlen & len_mask)) {-        size++;-        len_mask >>= 1;-    }-    if (size > 8) {-        LOGV ("sniffsuper mkv error- size > 8");-        goto cleanup;-    }-    hlen &= (len_mask - 1);-    while (n++ < size) {-        hlen = (hlen << 8) | data[cnt++];-    }-    LOGV ("sniff super: validate mkv- headerlen = %x", hlen);-    /* check if first read contain the whole header */-    if (readsize < (4 + size + hlen)) {-        // read more data as requried-        rdsz = 4 + size + (uint32_t)hlen;-        LOGV ("sniffsuper: mkv read more data = %d", rdsz);-        data = (uint8_t *) new uint8_t [rdsz];-        if(!data) {-            LOGV ("sniffsuper mkv error:: new alloc data fail");-            goto cleanup;-        }-        reinitialise = true;-        // Goto the beginning of the file-        size_t readcount = source->readAt(0, data, rdsz);-        if (readcount < (size_t)rdsz) {-            LOGV ("sniffsuper mkv error:: n < (ssize_t)rdsz");-            goto cleanup;-        }-    }-    /* Parse through the initial header to check if it contains the-    * document type 'matroska'.-    */-    for (n = 4+size; n <= (int)(4+size+hlen-(sizeof(probe_data)-1)); n++)-    {-        LOGV ("sniffsuper mkv memcmp n = %d", n);-        if (!memcmp(&data[n], probe_data, sizeof(probe_data)-1)) {-            LOGV ("sniffsuper break for loop - matroska identified");-            status = true;-            goto cleanup;-        }-    }-cleanup:-    if(data && reinitialise)-    {-        LOGV ("sniffsuper: delete data");-        delete [] data;-    }-    LOGV ("sniffsuper -- validate mkv: status = %x", status);-    return status;-}- bool SniffSuper (         const sp<DataSource> &source, String8 *mimeType, float *confidence,         sp<AMessage> *meta)@@ -1917,17 +1843,6 @@ bool SniffSuper (         LOGV ("asf is identified /////");         return true;     }-    else if (!memcmp(header, NVFS_MKV_EBML, 4))-    {-        LOGV ("sniff super: ebml is identified, sniff mkv now");-        if (ValidateMkv (source, header, readsize))-        {-            *mimeType = MEDIA_MIMETYPE_CONTAINER_MATROSKA;-            *confidence = 1.0;-            LOGV ("sniffSuper: mkv identified");-            return true;-        }-    }     return false; } diff --git a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp b/media/libstagefright/codecs/avc/dec/AVCDecoder.cppindex 868c514..080fca4 100644 (file)--- a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp+++ b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp@@ -104,6 +104,10 @@ status_t AVCDecoder::start(MetaData *) {         // Parse the AVCDecoderConfigurationRecord          const uint8_t *ptr = (const uint8_t *)data;+        if (ptr == NULL || size < 7) {+            LOGV("AVCDecoder BAD_VALUE: ptr = %x - size = %d", ptr, size);+            return BAD_VALUE;+        }          CHECK(size >= 7);         CHECK_EQ(ptr[0], 1);  // configurationVersion == 1diff --git a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cppindex dcf129e..2902b29 100644 (file)--- a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp+++ b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp@@ -106,16 +106,19 @@ status_t M4vH263Decoder::start(MetaData *) {     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(+        // relax and skip codec specfic info if initcheck fails+        // CHECK_EQ(esds.InitCheck(), (status_t)OK);+        if (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;+            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;@@ -132,7 +135,10 @@ status_t M4vH263Decoder::start(MetaData *) {     }      MP4DecodingMode actualMode = PVGetDecBitstreamMode(mHandle);-    CHECK_EQ((int)mode, (int)actualMode);+    if (mode != actualMode) {+        PVCleanUpVideoDecoder(mHandle);+        return UNKNOWN_ERROR;+    }      PVSetPostProcType((VideoDecControls *) mHandle, 0); diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cppindex 1661130..79c833f 100644 (file)--- a/media/libstagefright/matroska/MatroskaExtractor.cpp+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp@@ -125,6 +125,9 @@ private:     enum Type {         AVC,         AAC,+        MP3,+        AC3,+        MPEG4,         OTHER     }; @@ -167,12 +170,22 @@ MatroskaSource::MatroskaSource(         CHECK(meta->findData(                     kKeyAVCC, &dummy, (const void **)&avcc, &avccSize)); -        CHECK_GE(avccSize, 5u);--        mNALSizeLen = 1 + (avcc[4] & 3);+        LOGV("avccSize = %d", avccSize);+        mNALSizeLen = 1;+        if (avcc && avccSize >= 5){+            // relax this since failing for some content+            // CHECK_GE(avccSize, 5u);+            mNALSizeLen = 1 + (avcc[4] & 3);+        }         LOGV("mNALSizeLen = %d", mNALSizeLen);     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {         mType = AAC;+    }  else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AC3)) {+        mType = AC3;+    }  else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {+        mType = MP3;+    }  else if (!strcasecmp (mime, MEDIA_MIMETYPE_VIDEO_MPEG4)) {+        mType = MPEG4;     } } @@ -221,7 +234,6 @@ void BlockIterator::advance() {             if (eos()) {                 break;             }-             mBlockEntry = mCluster->GetFirst();         } @@ -481,10 +493,10 @@ status_t MatroskaSource::readBlock() { status_t MatroskaSource::read(         MediaBuffer **out, const ReadOptions *options) {     *out = NULL;-     int64_t seekTimeUs;     Rea

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.