-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add buffering to video renderers #2777
Conversation
This need testing on vaap, rbpi and omx. I'm not sure what android uses in playback, but it won't hurt to test it there too. |
maybe we should drop the OMXPlayer commit: 3e9c2b9785fba9336192b203e26285c53273b5c9 from this pr, only keep the required change to configure. It will correct out of sync subs but regression in performance. The current code in OMXPlayer is not correct because it just skips driving the gui but this requires more work to get this fixed without sacrifice current performance. |
ubuntu packages for testing: https://launchpad.net/~wsnipex/+archive/xbmc-pr-tests |
There is a performance issue with the queue (should not be worse than old code) causing it to not queue items unless decode is quite a lot faster than display. This is due to our large scale locks in rendermanager. FlipPage get's blocked on a shared lock during render. The queue and the present info need to be on a separate lock from the shared lock. |
I'm starting to feel quite happy with this pull now. But again, i need testing on OMX. I think dxva/vaapi/vdpau/vda are fine. |
@elupus I needed this change for successful compilation on RPi: FernetMenta@1876d2a |
Looking ok to me on the PI. Waiting for feedback from popcornmix. |
I'll try to test this tonight with some borderline performance clips and see if things are better or worse. |
Note. Rbpi is limited to tw buffers at the moment. Change that 0 in |
@elupus |
Little out of sync internal subs [1/17] in this video sample on Rpi. On FernetMenta version this patch subs sync is perfect. |
Nope not glx buffering, I'm not sure how the Rbpi renders frames. Is it Regarding subs, it aught to be identical to before the pull? But I think I |
Video is separate from GL on Pi (an external overlay). |
Currently OMXplayer just skips driving the gl layer when getting late. This causes out-of-sync subs but a gain in performance. Buffering alone in the gl layer won't cure the loss in performance when keeping video and gl in sync. The gl layer still gets cleared and flipped on every cycle. It has to be treated like a dirty region in order to get both, synced subs and performance. |
I just pushed a shot in the dark at an RBPI improvement. It will avoid blocking rbpi thread, and queue up overlays. |
I checked out master and wound the clock frequency down until my test clip just played without buffering. My test clip did not contain subtitles. 284f9c3 was less successful. That clearly seemed to hurt performance (it buffered every time on about 10 runs). OMXMediaTime() is the time of the currently displayed video frame which can be several seconds behind the pts values of packets arriving at OMXPlayerVideo.cpp. You need the pts of the subtitle being rendered to match OMXMediaTime(). |
I think I'm seeing a regression. If I play a file through json. Then play it again (or a different one) without quitting back to UI, I get no video. I hear the audio, the home menu is still present (no visualisation). I can select "fullscreen" from menu, but I just get a blank screen. Once in this state I can't play any video (even if video is quit first). Restarting xbmc allows video to work again. This required 3 plays to get into this bad state: |
if(m_presentstep == PRESENT_IDLE) | ||
{ | ||
if(GetNextRender() >= 0) | ||
m_presentstep = PRESENT_READY; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I've not any issues with video playlists but some dvd's don't play correctly. The menu seems to render correctly, but for some movies the last frame of the menu gets stuck on screen. The audio for the movie will play behind it and xbmc becomes unresponsive. It won't respond to the remote or to events sent from xbmc-send to localhost. The same problematic videos play in Frodo and in Gotham without the patch applied. (They were the same ones I used when testing the dvd_reader patch.) I just noticed the new commit, 00ad3e6. My build is from before this commit. I will test with it as soon as a I can to see if it fixes the problem. |
Yea that should fix that issue. Dvds reconfigure all the time. |
It can still hang due to negative timeouts in WaitForBuffer, it did so during my last tests. |
That is a bit strange. That should just cause a huge timeout value. Why |
It happened on stop and video player thread was waiting with that huge timeout in m_presentevent.wait iirc main thread was waiting for player to exit which was waiting for video player. |
I've got an iso that fails consistently and that commit didn't fix it. The same thing happens. Nothing looks anomalous from the log. I'll be away for the weekend but can help debug after I'm back. |
I'm rebasing and merging within in the hour. @kraqh3d i would think your issue is the negative timestamp problem. |
This is how many references to pictures that can be retained when calling Decode the next time around
We don't even need to hold lock here potentially
This allow renderer to queue up frames for display after decode. Original Implementation By: Rainer Hochecker <fernetmenta@online.de>
Allo dropping a frame that is about to be rendered, if it is late and there already exist a replacement frame that should be presented now.
RenderManager can now take care of this in a much more intellegent fashion
This looks rather messy. But is solves an important performance issue where decode thread would be blocked waiting flip by render thread while it was rendering current frame. Without this faster than display rate decode is not possible
Add buffering to video renderers
this causes major regression on dvd with menu playback. Tested several dvds, after I go through the dvd menu, select "play", the image freezes and all I hear is sound, but no video starts. The only thing I can do is kill xbmc. Excerpt debug Log:
|
update - this is the same problem @kraqh3d described. Last frame of the menu stays stuck instead of playing the video. |
yup. seeing it too. just can't figure out what the heck is going on. my xcode keeps crashing. |
hang should be resolved at df90ddd |
it is resolved indeed - thanks! |
When stop playing movie on Rpi, picture freeze and only hard reset helps. |
omxplayer still suffers from negative timeout. I will prepare a pr. |
@popcornmix could do do this with #2798? dvdplayer clamps timeout for WaitForBuffers to positive values. |
@FernetMenta |
@popcornmix those cleanups are already in. |
This patch fixed frezze picture on Rpi #2798, but cause out of sync subs (subs display some 1.5s too fast) |
Rbpis output logic need to be looked over. |
This replaces: #2309
It implements a render queue in the renderers allowing main thread to continue rendering more frames while we are decoding. This should reduce the likelihood of stuttering due to high cpu load.
The default queue size is 3. Thus 1 additional frames. This is likely a candidate for advanced settings since it will allocate full pictures frames in memory during playback. This could be increased on systems that have enough memory.
The queue will always select the last decoded frame that has a present time that has passed. This mean it will potentially drop frames at output stage. This has the added benefit of us finally being able to play 50fps video's on 30hz displays and 60fps video's on 50hz displays without causing total audio desync.