freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于android平臺(tái)的音頻編解碼技術(shù)研究與應(yīng)用-資料下載頁(yè)

2025-01-18 14:08本頁(yè)面
  

【正文】 (unsigned short) (s) 8) | ((unsigned short) (s) 8))lame_t lame。int read_samples(FILE *input_file, short *input) { int nb_read。 nb_read = fread(input, 1, sizeof(short), input_file) / sizeof(short)。 int i = 0。 while (i nb_read) { input[i] = be_short(input[i])。 i++。 } return nb_read。}void Java__samsung_sample_lame4android_LameActivity_initEncoder(JNIEnv *env, jobject jobj, jint in_num_channels, jint in_samplerate, jint in_brate, jint in_mode, jint in_quality) { lame = lame_init()。 LOGD(Init parameters:)。 lame_set_num_channels(lame, in_num_channels)。 LOGD(Number of channels: %d, in_num_channels)。 lame_set_in_samplerate(lame, in_samplerate)。 LOGD(Sample rate: %d, in_samplerate)。 lame_set_brate(lame, in_brate)。 LOGD(Bitrate: %d, in_brate)。 lame_set_mode(lame, in_mode)。 LOGD(Mode: %d, in_mode)。 lame_set_quality(lame, in_quality)。 LOGD(Quality: %d, in_quality)。 int res = lame_init_params(lame)。 LOGD(Init returned: %d, res)。}void Java__samsung_sample_lame4android_LameActivity_destroyEncoder( JNIEnv *env, jobject jobj) { int res = lame_close(lame)。 LOGD(Deinit returned: %d, res)。}void Java__samsung_sample_lame4android_LameActivity_encodeFile(JNIEnv *env, jobject jobj, jstring in_source_path, jstring in_target_path) { const char *source_path, *target_path。 source_path = (*env)GetStringUTFChars(env, in_source_path, NULL)。 target_path = (*env)GetStringUTFChars(env, in_target_path, NULL)。 FILE *input_file, *output_file。 input_file = fopen(source_path, rb)。 output_file = fopen(target_path, wb)。 short input[BUFFER_SIZE]。 char output[BUFFER_SIZE]。 int nb_read = 0。 int nb_write = 0。 int nb_total = 0。 LOGD(Encoding started)。 while (nb_read = read_samples(input_file, input)) { nb_write = lame_encode_buffer(lame, input, input, nb_read, output, BUFFER_SIZE)。 fwrite(output, nb_write, 1, output_file)。 nb_total += nb_write。 } LOGD(Encoded %d bytes, nb_total)。 nb_write = lame_encode_flush(lame, output, BUFFER_SIZE)。 fwrite(output, nb_write, 1, output_file)。 LOGD(Flushed %d bytes, nb_write)。 fclose(input_file)。 fclose(output_file)。}6 Android平臺(tái)音頻播放及解碼模塊 Android 音頻播放由于音頻設(shè)備千差萬(wàn)別,Android不可能為每種設(shè)備都提供支持。Android定義了一個(gè)框架,這個(gè)框架來(lái)適配底層的音頻設(shè)備。該適配層的定義位于hardware/libhardware_legacy/include/hardware_legacy/,AudioStreamIn,AudioHardwareInterface等類,并實(shí)現(xiàn)createAudioHardware函數(shù)。 Android創(chuàng)建音頻播放設(shè)備的代碼,源代碼位于:frameworks/base/libs/audioflinger/。主要代碼分析: AudioHardwareInterface*AudioHardwareInterface::create(){AudioHardwareInterface*hw=0。char value[PROPERTY_VALUE_MAX]。ifdef GENERIC_AUDIOhw=new AudioHardwareGeneric()。elseif(property_get(,value,0)){LOGD(Running in emulationusinggeneric audio driver)。hw=new AudioHardwareGeneric()。}else{LOGV(Creating Vendor Specific AudioHardware)。hw=createAudioHardware()。}endifif(hwinitCheck()!=NO_ERROR){LOGW(Using stubbed audio will be produced.)。delete hw。hw=new AudioHardwareStub()。}ifdef WITH_A2DPhw=new A2dpAudioInterface(hw)。endififdef ENABLE_AUDIO_DUMPwhichhw=new AudioDumpInterface(hw)。//replaceinterfaceendifreturn hw。}從代碼中我們可以看出如果定義了GENERIC_AUDIO的宏,則會(huì)創(chuàng)建AudioHardwareGeneric,如果是模擬器的話,AudioHardwareGeneric會(huì)不能初始化,進(jìn)而創(chuàng)建 AudioHardwareStub。這兩個(gè)類都是Audio設(shè)備的適配層,是Android默認(rèn)提供的模擬器都是用 AudioHardwareStub,不會(huì)有聲音輸出設(shè)備都是用AudioHardwareGeneric,因?yàn)槟J(rèn)GENERIC_AUDIO是設(shè)置的 一般我們只關(guān)心AudioHardwareGeneric實(shí)現(xiàn)。首先說(shuō)明一下這個(gè)音頻適配層是 Android自帶的,可以保證你的音頻設(shè)備正常運(yùn)行,但是不能發(fā)揮設(shè)備的最佳性能。通過(guò)后面的描述你將會(huì)了解AudioHardwareGeneric 的定義位于:frameworks/base/libs/audioflinger/。通過(guò)查看源碼發(fā)現(xiàn)這個(gè)適配層需要實(shí)現(xiàn)設(shè)備/dev/eac,如果不是 ,然后再輸出給 音頻設(shè)備。,大部分Mp3都是以這個(gè)采樣率壓縮的,所以選擇這個(gè)采樣率做為默認(rèn)采樣率還是有一定的合理性的。AudioHardwareGeneric是軟件實(shí)現(xiàn)Resample過(guò)程是,效率會(huì)比較低。很多音頻設(shè)備支持不同采樣率的數(shù)據(jù),可以理解成硬件實(shí) 現(xiàn)Resample過(guò)程。通過(guò)上面的描述我們可以知道這個(gè)通用音頻適配層只是讓當(dāng)前設(shè)備可以用而已,不能發(fā)揮設(shè)備的性能優(yōu)勢(shì),如果你的設(shè)備對(duì)音頻質(zhì)量有更 高的要求,必須要自己實(shí)現(xiàn)音頻適配層。谷歌只能保證你的音頻可以播放,但是不能保證效率(設(shè)備差異性)。 MP3解碼器MP3(Moving Picture Experts Group Audio Layer III)是目前最流行的音頻編碼格式,通過(guò)丟棄脈沖編碼調(diào)制(PCM)音頻數(shù)據(jù)中對(duì)人類聽(tīng)覺(jué)不重要的數(shù)據(jù)和采用較好的壓縮算法,可以獲得1:10甚至1:12的壓縮率。MP3在1991年被標(biāo)準(zhǔn)化。MP3采樣率在16~48kHZ之間,編碼速率在8kb/s~。隨著信號(hào)處理技術(shù)的不斷發(fā)展,MP3的一些缺點(diǎn)(如壓縮率低,僅有兩個(gè)聲道,音質(zhì)不理想等)逐漸暴露出來(lái)。但MP3作為人們最熟悉的音頻編碼格式還會(huì)在日常生活中繼續(xù)流行。MP3的解碼需要進(jìn)行同步及檢錯(cuò)、哈弗曼編碼、逆量化、立體聲解碼、反鋸齒、IMDCT和子帶合成等運(yùn)算,其中IMDCT過(guò)程中的運(yùn)算量占到了整個(gè)解碼運(yùn)算總量的19%。具體過(guò)程如圖62所示:圖62 MP3解碼流程圖MP3的解碼過(guò)程代碼核心代碼:Int Mp3Decoder::Mp3DecodeAudio(OMX_S16* aOutBuff, OMX_U32* aOutputLength, OMX_U8** aInputBuf, OMX_U32* aInBufSize, OMX_S32* aFrameCount, OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam, OMX_AUDIO_PARAM_MP3TYPE* aAudioMp3Param, OMX_BOOL aMarkerFlag, OMX_BOOL* aResizeFlag){ int32 Status = MP3DEC_SUCCESS。 *aResizeFlag = OMX_FALSE。 if (iInitFlag == 0) { //Initialization is required again when the client inbetween rewinds the input bitstream //Added to pass khronous conformance tests if (*aFrameCount != 0) { e_equalization EqualizType = iMP3DecExtequalizerType。 iMP3DecExtinputBufferCurrentLength = 0。 iInputUsedLength = 0。 iAudioMp3DecoderStartL(iMP3DecExt, false, false, false, EqualizType)。 } iInitFlag = 1。 } iMP3DecExtpInputBuffer = *aInputBuf + iInputUsedLength。 iMP3DecExtpOutputBuffer = amp。aOutBuff[0]。 iMP3DecExtinputBufferCurrentLength = *aInBufSize。 iMP3DecExtinputBufferUsedLength = 0。 if (OMX_FALSE == aMarkerFlag) { //If the input buffer has finished off, do not check the frame boundaries just return from here //This will detect the EOS for without marker test case. if (0 == iMP3DecExtinputBufferCurrentLength) { iInputUsedLength = 0。 return MP3DEC_INCOMPLETE_FRAME。 } //If the marker flag is not set, find out the frame boundaries else { Status = iAudioMp3DecoderSeekMp3Synchronization(iMP3DecExt)。 if (1 == Status) {
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1