Android 4.0 support sf mkv parser on GB.

Source: Internet
Author: 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 (+ 0530)
Committer Varun Colbert <vcolbert@nvidia.com>  
  Sat, 14 May 2011 02:16:41 + 0000 (-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 * handle; extern const char * media_mimetype_audio_raw; extern const char * Media _ Mimetype_audio_wma; + extern const char * numeric; 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 {kk Eybitrate = '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 + =-labels = $ (callback)-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: round (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 .. cde20b2100644 (File) --- A/Media/libstagefright/mediadefs. CPP ++ B/Media/libstagefright/mediadefs. CPP @-37,6 + 37,7 @ const char * audio = "audio/g711-alaw"; const char * media_mimetype_audio_g711_mlaw = "audio/g711-mlaw"; const char * Audio = "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/stlibagefright/mediaextractor. cpp B/Media/libstagefright/mediaextractor. cppindex 71dbf54 .. 123475f 100644 (File) --- /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 (const char *) data, size);-check_eq (ESDs. initcheck (), OK); -- const void * codec_specific_data;-size_t codec_specific_data_size;-ESDs. get Codecspecificinfo (+ // 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, & response); -- addcodecspecificdata (+ addcodecspecificdata (codec_specific_data, codec_specific_data_size); ++} else I F (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/libst Agefright/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 * confid Ence, 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. CPP Index 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 = 1 diff -- 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 @-+ @ Status_t m4vh263decoder: Start (metadata *) {int32_t vol_size = 0; If (meta-> finddata (kkeyesds, & type, & Data, & size )) {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, & bytes);-vol_data [0] = (uint8_t *) malloc (bytes);-memcpy (vol_data [0], codec_specific_data, bytes ); -vol_size = codec_specific_data_size; + vol_data [0] = (uint8_t *) malloc (Co Authorization); + 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 restart: Start (metadata *) {} mp4decodingmode actualmode = pvgetdecbitstreammode (mhandle);-check_eq (INT) mode, (INT) actualmode); + If (mode! = Actualmode) {+ handle (mhandle); + return unknown_error; +} pvsetpostproctype (videodeccontrols *) mhandle, 0); diff -- git a/Media/libstagefright/matroska/notify. cpp B/Media/libstagefright/matroska/matroskaextractor. cppindex 1661130 .. 79c833f 100644 (File) --- A/Media/libstagefright/matroska/matroskaextractor. CPP ++ B/Media/libstagefright/matroska/matroskaextractor. CPP @-12 5, 6 + @ 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.