Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

XBMC - Hardware Accelerated Decoding - What works and what doesn't (update 1-5-13)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    XBMC - Hardware Accelerated Decoding - What works and what doesn't (update 1-5-13)

    Hi Folks!

    In this thread i hope to collect all the information you need to run XBMC with NATIVE hardware (HW) accelerated decoding on any RK3066 device. (So no external players like MX player)

    Here is a summary of the information i've collected over the past few weeks:

    First HERE is a great thread by dark_angel where you can read all about XBMC, what it can do, what nice plugins there are and how to install them. Also there is information how to use XBMC in combination with an external player (MX player) for hardware acceleration. But if you ended up here i guess you know what XBMC is and you know you want it!

    BASIC INFO

    Hardware accelerated decoding means the video is decoded by the GPU (graphics processing unit) instead of the CPU. (i know that's hardware too right??? The standard version of XBMC for android doesn't support HW accel decoding but uses software decoders ) This is often more efficient/faster so you can play higher resolution videos.

    to decode video. This means it's very slow and you wont even get close to playing HD video.

    But the developers of XBMC do have "test builds" available with HW accel decoding.
    You can find those HERE
    The ones with HWACCEL or STAGEFRIGHT in the filename are the ones with HW accel decoding.
    So THIS one is the latest.
    But with THIS one you can check CPU load, cache size (for non-local files) and the amount of dropped frames by pressing the letter O while playing a video. (not working with the latest version)

    The HW accel version of XBMC for android is still in a very early stage of development. So expect some bugs, but also expect it to get better and hopefully faster!

    WHAT WORKS AND WHAT DOESN'T

    LIBSTAGEFRIGHT
    Rockchip released a patch to fix or at least improve the HW accel decoding. This patch is called libstagefright. I haven't done tesst without this patch, but lets just assume results will be worse.
    As far as i know pretty much all available custom ROMs (the later versions) have the libstagefright patch. If your custom ROM doesn't have it or you want to use the stock ROM there are ways to "install" it. Just search the forum how to do that.

    UPDATE
    There is an updated version of libstagefright available. I've tested this on my MK808 using Leolas his CWM flashable zip file and while the flash worked fine, all of a sudden XBMC would display artifacts and crash when i tested a 1920x1080 video. 1920x1024 played fine. So not sure if 1920x1080 caused those problems because that resolution isn't devidable by 16 or if there is another reason. I have to say i didn't do a lot of testing, but so far i didn't notice any improvement from the new/updated libstagefright.so.

    XBMC FOR ANDROID WITH HW ACCEL DECODING
    Without tweaks XBMC will only use the HW accel decoder on videos where the resolution is dividable by 16. For instance 1280x720 (720/16=45). But for a very common movie resolution like 1280x532 (532/16=33,25) the HW accel decoder wont be used and while it is a lower resolution video as the 1280x720 one it will play much much worse. This also means that, without tweaks, the HW accel decoder will also not be used for full 1080p/1920x1080 (1080/16=67,5) videos. So here is the tweak to fix it...

    ADVANCEDSETTINGS.XML
    Lewy20041 pointed out that you can tweak XBMC by using the advancedsettings.xml file. By adding the following code to that file you will force XBMC to always use the HW accel decoder even if the video is not dividable by 16. It will also force it to use the HW accel decoder for different codecs. The advancedsettings.xml file must be placed in /sdcard/android/data/org.xbmc.xbmc/files/.xbmc/userdata

    Code:
    <advancedsettings>
      <video>
        <stagefright>
          <!--  -1 is default, 0 is never used this codec, 1 is always use this codec, bypassing blacklist -->
          <useavccodec>1</useavccodec>
          <usevc1codec>1</usevc1codec>
          <usevpxcodec>1</usevpxcodec>
          <usemp4codec>1</usemp4codec>
          <usempeg2codec>1</usempeg2codec>
          <useswrenderer>false</useswrenderer>
        </stagefright>
      </video>
    </advancedsettings>
    You can get a pre-made advancedsettings.xml file HERE (Right mouse click and "save target as")
    Or a zipped version HERE

    AUDIO 2.0/5.1
    As it seems right now these RK3066 devices will only output stereo/2.0 audio. While HDMI can handle much higher and with the right speaker system with digital receiver any AC3 or DTS audio stream could just be send directly to that digital receiver (passthrough) it doesn't seem to be working. HERE you can find a thread about a MINIX firmware apparently supporting 5.1 audio, but i think it only works with AC3 and not in combination with XBMC. But i guess they are working on it. Lets hope they dont forget about the RK3066 now that the RK3188 devices are here.

    LIVE STREAMS PATCH
    Again big thanks to Lewy20041 for providing a patch for live video streams.
    Lewy20041:
    unpack thease files http://d-h.st/lQB into /system/etc/
    set permisions "rwx --- ---" to install-recovery.sh
    this way it load fix at startup.
    Finless:
    Additionally if your using one of my ROMs it has init.d script support.
    Just rename the script to 00script
    copy it into the init.d folder.
    reboot
    720p vs 1080p
    There are 720p kernels and 1080p kernels available.
    These devices by default have a 720p kernel, meaning the "internal system" will run at 720p resolution no matter what. Even if you set the output to 1080p under settings it will just take that 720p resolution and upscale it to 1080p.
    So when you watch a 1080p movie on a 720p kernel (and the output set to 1080p under settings), that video image will first be downscaled to 720p (loosing detail in the process) and then upscaled again to 1080p (just increasing pixels, not adding detail) before it's send to the TV/Monitor. So even if you are able to play a 1080p movie on a 720p kernel, all detail over 1280x720 resolution will be lost. That doesn't mean it still cant look very good and you'll have the benefit of a fast running android and other apps. Also i think you will be able to play 1920x800 resolution videos (a very common movie resolution) without having to overclock the device (even though you wont get the full detail).

    With a 1080p kernel you will have real 1920x1080 output to your TV/Monitor. Meaning when you watch a 1080p movie you will also see that 1080p detail. However with a stock/non-overclocked kernel you wont be able to watch even the lowest common 1080p movie resolution which is 1920x800 without a lot of dropped frames. So you will have to overclock...

    So with 720p kernel you can play (most) 1080p movies, but you wont see the detail so there is no real reason to watch a 1080p movie. And with a 1080p kernel you will be able to see the extra detail of a 1080p movie but you wont be able to play them!!! I think that's what they call a "catch 22"
    Unless... you overclock...

    PERFORMANCE UG007II with Finless 1.7a with stock and 2dark4u (UG802) OC kernel.
    These are some rough indications of what you will be able to play with what kernel. (720p/1080p/stock/overclocked)

    720p kernel, stock speed (GPU at 266mhz)
    720p60hz Videos with a resolution up to 1920x992 can be played.
    720p50hz Videos with a resolution up to 1920x1008 can be played.

    720p kernel, overclocked (GPU at 466mhz)
    Videos with a resolution up to 1920x1080 can be played without breaking a sweat.

    1080p kernel, stock speed (GPU at 266mhz)
    Video with a resolution up to 1920x688 (not a standard movie resolution) can be played. 1920x800 unfortunately has way too much dropped frames.

    1080p kernel, overclocked (GPU at 466mhz)
    Video with a resolution up to 1920x1080 can be played

    NOTES
    - When i use 1080p50hz it seems i always have quite a bit less dropped frames compared to 1080p60hz. Maybe because the GPU only has to do 50 updates/sec instead of 60 or maybe it has to do with something else, but i assume the same applies to 720p 60hz/50hz, so i suggest you use 50hz if that's possible.
    If this really makes that big a difference, maybe kernel makers are able to build a 24hz option in there since quite a few TV's support that and MAYBE that means there is no need for overclocking. (For the 720p kernels at least)

    - With the overclock 1080p kernel (GPU at 466mhz) i can play 1920x1080 videos perfectly even when i lock the CPU to 816mhz. Of course this is because the GPU does most of the work. But this also means you dont need a kernel that overclocks the CPU, just the GPU. Even if i use "interactive" or "ondemand" governor with a max of 1.6ghz i will get random dropped frames. I have no idea what the real difference is between these scaling governors, but "hotplug" seems to work best for me. Since 816mhz seems to be enough and apparently these governors dont always scale fast enough (considering the dropped frames) i'm not using hotplug governor with a min freq of 816mhz and a max or 1.6ghz. But like i said the stock 1.2Ghz is more than enough.

    - For people having problems with streaming movies over a SMB/Windows network maybe there is a workaround. I just tested playing files from my local server using the SMB/Windows network and XBMC doesn't seem to buffer anything or at least very little. This wont be a problem most of the time but during very high motion scenes or scenes with a lot of movie grain the bitrate can be much higher than the movie average and your WIFI connection might not be able to keep up with that.
    I also have a remote server and i stream my movies from that server using an FTP server. That way XBMC will use a buffer of at least 25MB. That way bitrate bursts are covered by the buffer.
    I know a lot of NAS devices have FTP servers build in and on normal computers/servers you can always use the free filezilla (windows).

    - Overclocked kernels: As far as i know right now there are overclocked kernels available for the MK808 (non-B) and the UG802 and i think that UG802 kernel should be compatible with Minix Neo G4 and the Rikomagic MK802 III. That doesn't mean all other sticks wont be able to use overclocked kernels, that just means if you do use one of those kernels you will loose WIFI (and BT) and will have to use an USB WIFI dongle or USB to ethernet adapter. However the MK808 kernels dont work on my UG007. So maybe for some devices neither kernel works, but i think for most at least one will (please correct me if i'm wrong). With the MK808 kernels the GPU is clocked at 433mhz or 400mhz. I'm not sure if that will be enough for 1920x1080. 1920x800 shouldn't be a problem.

    - I have this simple wattage meter and figured i share some results.
    Stock/non-overclocked 1080p kernel, max load (Epic Citadel) it consumes 5w, but since the power supply itself gets a little warm lets just assume my UG007II uses about 4w.
    2dark4u OC 1080p kernel CPU 1.6Ghz GPU466mhz, max load (Epic Citadel) 7w, again my UG007II probably 6w. But while watching a 1920x1080p movie in XBMC it's at 4-5w 99% of the time. So that would be 3-4w for the UG007II, the same as the stock kernel under full load.
    So when comparing the full load there is an 50% increase in power usage (4w -> 6w), but when using an overclocked kernel to watch even 1080p movies using XBMC the max power usage is about the same as the full load power usage with the stock kernel. I'm definately not saying use overclocked kernels without a heatsink, but "i think" a rather small heatsink (like on the MK808(B)) should be enough, since even such a small heatsink will AT LEAST quadruple the cooling surface area compared to no heatsink at all.
    BUT! OVERCLOCK AT YOUR OWN RISK! AND NOT WITHOUT A HEATSINK! (even if it's just a small one) That's what she said...
    Last edited by Abducted; 05-07-2013, 08:00. Reason: keep editable....
    - UG007-II with Finless iMito MX1/2 1.7a ROM and UG802 2Dark4U 1080p overclock kernel and USB WIFI dongle.
    - MK808 with Finless MK808 1.7c ROM and 2Dark4U 1.4 MK808 1080p overclock kernel.
    - MK908-II: XBMC full 1080p playback with a 1080p kernel HERE

    #2
    old post for posterity

    Hi folks! I've only gotten my UG007II for a couple of days so i'm not totally up to date about hardware accelerated decoding on these RK3066 + Mali 400 sticks. But XBMC (with HW acceleration) is the main reason i got this stick, so it'll be my main focus till it works flawlessly.

    However over the last few days i've been searching to find an answer whether or not HW acceleration works on our sticks. So far i haven't been able to find a clear answer. So i hope we can collect all information related to XBMC native hardware accelerated decoding in this thread.

    First HERE is a great thread by dark_angel where you can read all about XBMC, what it can do, what nice plugins there are and how to install them. Also there is information how to use XBMC in combination with an external player (MX player) for hardware acceleration. But if you ended up here i guess you know what XBMC is and you know you want it!

    After i flashed my stick to a ROM with the libstagefright patch and installed a HW accelerated build of XBMC and tested a few (720p) movies. Unfortunately i didnt notice any difference compared to just software decoding. But when i tested a few (720p) TV-series all of a sudden it worked perfectly while the TV-series were full 720p (1280x720) and the movies i tested were of a lower resolution like 1280x692 or even 1280x532 which is a quite common resolution for 720p movies. Then when i tested a 1080p movie it didn't run great but better compared to the 720p movies! (+/- 10FPS for the 720p movies and +/-15FPS for the 1080p movies) Then i happend to test a 720p movie with 1280x544 resolution which again played fine. And then i figured it out...

    (Now i assume the following information is written down somewhere and most likely multiple times on the XBMC forum itself and probably somewhere on this forum too. But since i haven't been able to find it so far, i figured this is a good place to write it down for people like myself. )

    As it turns out the XBMC HW accelerated decoder is rather picky about its video files. It can only use the HW accelerated decoder on files with a resolution which is dividable by 16.

    For instance the standard 1280x720 resolution (720/16=45) and this is also why the 1280x544 resolution works (544/16=34).
    However the often seen 1280x532 doesn't work (532/16=33,25) and neither does 1280x692 (692/16=43,25)
    I think the reason the 1080p movie played better compared to the 1280x532 720p movie was because that 1080p movie used a resolution that was dividable by 16. (1920x800 800/16=50)
    So for the (1280x532) 720p movie it used software decoding and only reached +/-10fps but for the (1920x800) 1080p movie it used HW accel decoding and reached +/-15fps.

    With some hardware decoders (like with some standalone videoplayers) there are limitations to how the video was encoded. I think it could only have a max of 3 B-frames in a row and could only use 2 reference frames. So far (only testing for a day now) i haven't noticed any restrictions like that. I've tested 720p up to 8 reference frames and 6 B-frames and those worked fine as long as the resolution was dividable by 16.

    SUMMARY

    XBMC with hardware accelerated decoding works under the following conditions:
    - You need the libstagefright patch. If i'm correct Bob already included this patch in all his latest ROMs, so im sure there is a ROM with this patch available for your device.
    - A hardware accelerated build of XBMC. You can download it HERE
    - Video files with H264/AVC/x264 encoded video with a resolution which is dividable by 16. For instance 1280x720 (720/16=45) or 1280x544 (544/16=34).
    A common movie resolution that DOES NOT WORK is 1280x532 (532/16=33,25)
    - This will work for local files, but also files played over LAN or streamed over the internet from, for instance an FTP server (which is what i use XBMC for).

    Since the hardware accelerated version of XBMC for android is still in a very early stage of development i can only assume this "dividable by 16" limitation will sooner or later get fixed.
    As for the max resolution it can play, i think that might be something the ROM and kernel developers might be able to fix.

    I hope this all wasn't general knowledge for everybody.

    What's next

    - First i'm going to encode video clips with increasing resolution and see what my stick can play without frame drops.
    I'll start with 1280x704, 1280x712 and 1280x720 files to show you 704 and 720 will play fine and 712 wont because it's not dividable by 16.

    - I think it's not the CPU holding the stick back from playing 1080p files, but the GPU. I have to look into this further. But i think that's good news because if im correct we can still overclock the GPU without placing a heatsink, but to increase the CPU speed (over it's stock 1.2Ghz) does require a heatsink.
    I'm just not sure what speed my GPU is running now and how far it can be 'overclocked'.
    So when i reach a resolution where i get dropped frames i'm going to lower the CPU speed and see if that has any effect on dropped frames. If not (or minimal) i guess it's the GPU holding me back, not the CPU.
    I found this in a thread about a kernel for the MK808.
    Increased MALI-400 GPU upper limits from default of 133 mhz to 266 mhz to 133mhz to 400 mhz.
    So if i'm running at 266mhz max right now i guess i still have some headroom. Now all i need is a kernel that unlocks/overclocks it.

    - I'll upload the video files so people with other devices/ROMs can also run tests. Hopefully people with overclocked CPU and/or GPU can also run the tests.

    LINK TO TEST VIDEOS
    I used a trailer from Meet The Robinsons as source so no copyright problems.
    I use the UG007II (same as UG007 or iMito MX1/2) with Finless iMito MX1/2 1.7a 1080p ROM. I have the CPU locked at 1.2Ghz.
    I'm playing the files from the external SD-card till almost the end of the clip and then make a screenshot.
    Before opening XBMC i hide the notification bar so XBMC will start fullscreen (1920x1080 in my case) SCREENSHOT
    If you press the letter O while playing back a file in XBMC you will get on screen information about the audio and video but also CPU usage (per core), framerate and the amount of dropped frames.
    Some info about the file: 3561 frames @ 23,97fps (2m28s). AC3 5.1 audio. Matroska (mkv) container.

    Anything under 10 dropped frames i consider a pass. For some reason there are often a few dropped frames at the start of the video and 10 dropped frames out of 3561 frames is perfectly watchable.

    -1280x704 PASS HW accel working. 0 dropped frames. CPU load about 30-50% per core.
    901120 Pixels. SCREENSHOT

    -1280x712 FAIL HW accel NOT working. 1635 dropped frames. CPU load often at least one core at 100%.
    911360 Pixels. SCREENSHOT

    -1280x720 PASS HW accel working. 0 dropped frames. CPU load about 30-55% per core.
    921600 Pixels. SCREENSHOT

    -1536x800 PASS HW accel working. 7 dropped frames. CPU load about 30-55% per core.
    1228800 Pixels. SCREENSHOT

    -1920x640 PASS HW accel working. 0 dropped frames. CPU load about 30-55% per core
    1228800 Pixels. SCREENSHOT

    -1152x1072 PASS HW accel working. 0 dropped frames. CPU load about 30-55% per core.
    1234944 Pixels. SCREENSHOT

    -1536x864 FAIL HW accel working. 292 dropped frames. CPU load about 30-55% per core.
    1327104 Pixels. SCREENSHOT


    FYI 1920x1072 = 2058240 pixels. So we still have a long way to go.
    However the often used video resolution 1920x800 = 1536000 pixels.

    I'll add more files and results when i've encoded and tested them.
    "Pzebacz im, bo nie wiedzą, co czynią"
    "Прости им, они не ведают, что творят"
    "Perdona loro perché non sanno quello che fanno"
    "Vergib ihnen, denn sie wissen nicht, was sie tun"
    "Vergeef hen want ze weten niet wat ze doen"
    "Pardonne-leur car ils ne savent pas ce qu'ils font"
    "Perdónalos porque no saben que lo que hacen"
    "Oprosti im, jer ne znaju što čine"
    "Forgive them as they know not what they do"





    Comment


      #3
      Thanks! But i pretty much re-wrote the whole thing.
      - UG007-II with Finless iMito MX1/2 1.7a ROM and UG802 2Dark4U 1080p overclock kernel and USB WIFI dongle.
      - MK808 with Finless MK808 1.7c ROM and 2Dark4U 1.4 MK808 1080p overclock kernel.
      - MK908-II: XBMC full 1080p playback with a 1080p kernel HERE

      Comment


        #4
        I found a linux version with Mali400 HW accelerated drivers and XBMC pre installed,
        They say that XBMC in this linux distribution is HW Acelerated , you can find it here:


        Post No. 109

        ALso there is another distribution (Ubuntu 12.10) with Mali400 HW accelerated drivers
        but without XBMC (But i think without XBMC ) here:



        It didn't work for me for some reason , but you can try it and see if XBMC in this distribution
        Can handle 1920x1080 without overclocking.

        Comment

        Working...
        X