我正在嘗試使用openmax編解碼器編寫android視頻會議應用程序。 當我利用OpenMAX IL進行avc解碼時, 發現發送空緩衝區命令到填充緩衝區 做過回調的時間很長。 我的情況是處理沒有B-切片的4-cif h.264基本流。 我的omx呼叫序列是:如何縮短openmax avc解碼器的延遲?
- 分配avc解碼角色的openmax節點;
- 將節點的狀態轉換爲空閒狀態;
- 配置端口定義;
- 爲輸入和輸出端口分配緩衝區;
- 將節點的狀態轉爲執行;
- 爲空緩衝區啓動一個線程,爲填充緩衝區啓動另一個線程;
日誌輸出表明存在8幀的等待時間, 來自空緩衝區#9命令發送到消息FILL_BUFFER_DONE#1到達。 我已經測試了三星note2和HTC-ONE-X和其他一些手機, 都有一個很大的解碼延遲。
對於視頻會議應用程序的接受程度來說,這個延遲很大。 任何人都可以幫助我縮短這種延遲?
日誌輸出雲:
I/java:TestKdavc(19867): video test started
I/java:TestKdavc(19867): set video source: /sdcard/DCIM/vidrev.dat
I/testkdavc/testkdavc.cpp(19867): [[email protected]] frame dimesion: 704 x 576
I/OMXClient(19867): Using client-side OMX mux.
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1
D/avc/omxctrl.cpp(19867): [[email protected]] tid = 1074982704
D/avc/omxctrl.cpp(19867): [[email protected]] m_node = 4136a16c
D/avc/omxctrl.cpp(19867): [getVideoPor[email protected]] nPorts = 2, iport = 0, oport = 1
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1, port = 0, info.nBufferCountActual = 5, info.nBufferSize = 50688, info.nBufferCountMin = 5
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1, port = 1, info.nBufferCountActual = 2, info.nBufferSize = 608256, info.nBufferCountMin = 2
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1, portIndex = 0, def.nBufferCountActual = 5, def.nBufferSize = 608256, def.nBufferCountMin = 5, buffersize = 608256
D/avc/omxctrl.cpp(19867): [[email protected]] before useBuffer
D/avc/omxctrl.cpp(19867): [[email protected]] before useBuffer
D/avc/omxctrl.cpp(19867): [[email protected]] before useBuffer
D/avc/omxctrl.cpp(19867): [[email protected]] before useBuffer
D/avc/omxctrl.cpp(19867): [[email protected]] before useBuffer
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1, portIndex = 1, def.nBufferCountActual = 2, def.nBufferSize = 608256, def.nBufferCountMin = 2, buffersize = 608256
D/avc/omxctrl.cpp(19867): [[email protected]] before allocateBufferWithBackup
D/avc/omxctrl.cpp(19867): [[email protected]] before allocateBufferWithBackup
D/avc/omxctrl.cpp(19867): [[email protected]] mComType: 1, OMX_CommandStateSet, state: 2
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EVENT
D/avc/omxctrl.cpp(19867): [[email protected]] mComType: 1, OMX_CommandStateSet, state: 3
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EVENT
D/avc/omxctrl.cpp(19867): [[email protected]] mComType = 1, m_vecOutputBuffers.size() = 2, err = 0
I/testkdavc/testkdavc.cpp(19867): [[email protected]] found AVC/H264 decoder: OMX.SEC.AVC.Decoder, color format: OMX_COLOR_FormatYUV420Planar
I/testkdavc/testkdavc.cpp(19867): [[email protected]] start feed
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #1
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #2
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #3
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #4
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #5
I/avc/omxctrl.cpp(19867): [[email protected]] fill buffer #1
I/avc/omxctrl.cpp(19867): [[email protected]] fill buffer #2
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #1
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #6
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #2
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #7
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #3
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #8
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #4
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #9
I/avc/omxctrl.cpp(19867): [[email protected]] message type: FILL_BUFFER_DONE #1
I/testkdavc/testkdavc.cpp(19867): [[email protected]] get frame #1 of 704 x 576
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #5
I/avc/omxctrl.cpp(19867): [[email protected]] fill buffer #3
I/avc/omxctrl.cpp(19867): [[email protected]] empty buffer #10
I/avc/omxctrl.cpp(19867): [[email protected]] message type: FILL_BUFFER_DONE #2
I/testkdavc/testkdavc.cpp(19867): [[email protected]] get frame #2 of 704 x 576
I/avc/omxctrl.cpp(19867): [[email protected]] message type: EMPTY_BUFFER_DONE #6
I/testkdavc/testkdavc.cpp(19867): [[email protected]] retry put data
I/avc/omxctrl.cpp(19867): [[email protected]] message type: FILL_BUFFER_DONE #3
I/testkdavc/testkdavc.cpp(19867): [[email protected]] get frame #3 of 704 x 576
在PushData線程中添加一些睡眠模擬實際情況後,例如在發送每個空緩衝區命令之後睡眠40毫秒後,SamSung Note2上的延遲縮短到小於4幀。但我想要的是找到一種方法來控制IOMX,而不會在幀的基礎上延遲。 – Zighouse