android - What are lib_k3_generic_audio_extractor.so, lib_k3_mov_extractor.so, and so on? -
i'm experimenting android mediacodec, code got here: https://code.google.com/p/android-source-browsing.platform--cts
when tried run code "android-source-browsing.platform--cts/tests/tests/media/src/android/media/cts/decodertest.java", got these errors:
d/android.media.cts.decodertest(6615): decode(): master = 2131034134 d/android.media.cts.decodertest(6615): decode(): masterfd = {assetfiledescriptor: {parcelfiledescriptor: filedescriptor[50]} start=1781867 len=529200} d/android.media.cts.decodertest(6615): decode(): masterlength = 529200 d/android.media.cts.decodertest(6615): decode(): = android.content.res.assetfiledescriptor$autocloseinputstream@417592a0 d/android.media.cts.decodertest(6615): decode(): bis = java.io.bufferedinputstream@41759368 i/extractorloader(6615): register extractor [lib_k3_avi_extractor.so] e/extractorloader(6615): open [lib_k3_mov_extractor.so] failed! e/extractorloader(6615): open [lib_k3_flv_extractor.so] failed! i/extractorloader(6615): register extractor [lib_k3_m2ts_extractor.so] e/extractorloader(6615): open [lib_k3_asf_extractor.so] failed! e/extractorloader(6615): open [lib_k3_generic_audio_extractor.so] failed! d/android.media.cts.decodertest(6615): decode(): testassetfd = {assetfiledescriptor: {parcelfiledescriptor: filedescriptor[50]} start=1591735 len=49318} d/android.media.cts.decodertest(6615): decode(): testfd = filedescriptor[50] d/android.media.cts.decodertest(6615): decode(): trackcount = 1 d/android.media.cts.decodertest(6615): decode(): filelength = 49318 d/android.media.cts.decodertest(6615): decode(): format = {durationus=3056326, encoder-padding=1908, channel-count=2, encoder-delay=576, mime=audio/mpeg, sample-rate=44100} d/android.media.cts.decodertest(6615): decode(): mime = audio/mpeg
apparently libraries lib_k3_avi_extractor.so, lib_k3_mov_extractor.so, etc, not in device. here questions: these libraries? for? why not in device? googled these libraries, strangely search came absolutely nothing.
the java code generated errors listed below, minor changes add log information:
private void decode(int testinput, int master, float maxerror) throws ioexception { // read master file memory assetfiledescriptor masterfd = mresources.openrawresourcefd(master); long masterlength = masterfd.getlength(); //in bytes? short[] masterbuffer = new short[(int)(masterlength/2)]; inputstream = masterfd.createinputstream(); bufferedinputstream bis = new bufferedinputstream(is); log.d(tag, "decode(): master = " + master); log.d(tag, "decode(): masterfd = " + masterfd); log.d(tag, "decode(): masterlength = " + masterlength); log.d(tag, "decode(): = " + is); log.d(tag, "decode(): bis = " + bis); (int = 0; < masterbuffer.length; i++) { int lo = bis.read(); int hi = bis.read(); if (hi >= 128) { hi -= 256; } int sample = hi * 256 + lo; masterbuffer[i] = (short) sample; } bis.close(); mediaextractor extractor; mediacodec codec; bytebuffer[] codecinputbuffers; bytebuffer[] codecoutputbuffers; assetfiledescriptor testassetfd = mresources.openrawresourcefd(testinput); filedescriptor testfd = testassetfd.getfiledescriptor(); extractor = new mediaextractor(); extractor.setdatasource(testfd, testassetfd.getstartoffset(), testassetfd.getlength()); //assertequals("wrong number of tracks", 1, extractor.gettrackcount()); mediaformat format = extractor.gettrackformat(0); string mime = format.getstring(mediaformat.key_mime); //asserttrue("not audio file", mime.startswith("audio/")); log.d(tag, "decode(): testassetfd = " + testassetfd); log.d(tag, "decode(): testfd = " + testfd); log.d(tag, "decode(): trackcount = " + extractor.gettrackcount()); log.d(tag, "decode(): filelength = " + testassetfd.getlength()); log.d(tag, "decode(): format = " + format); log.d(tag, "decode(): mime = " + mime); codec = mediacodec.createdecoderbytype(mime); codec.configure(format, null /* surface */, null /* crypto */, 0 /* flags */); codec.start(); codecinputbuffers = codec.getinputbuffers(); codecoutputbuffers = codec.getoutputbuffers(); extractor.selecttrack(0); // start decoding int numbytesdecoded = 0; int maxdelta = 0; long totalerrorsquared = 0; final long ktimeoutus = 5000; mediacodec.bufferinfo info = new mediacodec.bufferinfo(); boolean sawinputeos = false; boolean sawoutputeos = false; while (!sawoutputeos) { if (!sawinputeos) { // transfer control of input buffer codec java code int inputbufindex = codec.dequeueinputbuffer(ktimeoutus); if (inputbufindex >= 0) { bytebuffer dstbuf = codecinputbuffers[inputbufindex]; // fill input buffer data int samplesize = extractor.readsampledata(dstbuf, 0 /* offset */); long presentationtimeus = 0; if (samplesize < 0) { log.d(tag, "saw input eos."); sawinputeos = true; samplesize = 0; } else { presentationtimeus = extractor.getsampletime(); } // let codec control input buffer again codec.queueinputbuffer( inputbufindex, 0 /* offset */, samplesize, presentationtimeus, sawinputeos ? mediacodec.buffer_flag_end_of_stream : 0); if (!sawinputeos) { extractor.advance(); } } } int res = codec.dequeueoutputbuffer(info, ktimeoutus); if (res >= 0) { int outputbufindex = res; bytebuffer buf = codecoutputbuffers[outputbufindex]; // check waveform matches within specified max error (int = 0; < info.size; += 2) { short sample = buf.getshort(i); int idx = (numbytesdecoded + i) / 2; //asserttrue("decoder returned data", idx < masterbuffer.length); short mastersample = masterbuffer[idx]; int d = sample - mastersample; totalerrorsquared += d * d; } numbytesdecoded += info.size; codec.releaseoutputbuffer(outputbufindex, false /* render */); if ((info.flags & mediacodec.buffer_flag_end_of_stream) != 0) { log.d(tag, "saw output eos."); sawoutputeos = true; } } else if (res == mediacodec.info_output_buffers_changed) { codecoutputbuffers = codec.getoutputbuffers(); log.d(tag, "output buffers have changed."); } else if (res == mediacodec.info_output_format_changed) { mediaformat oformat = codec.getoutputformat(); log.d(tag, "output format has changed " + oformat); } } codec.stop(); codec.release(); testassetfd.close(); masterfd.close(); //assertequals("wrong data size", masterlength, numbytesdecoded); long avgerrorsquared = (totalerrorsquared / (numbytesdecoded / 2)); double rmse = math.sqrt(avgerrorsquared); //asserttrue("decoding error big: " + rmse, rmse <= maxerror); }
Comments
Post a Comment