Android Hardware Acceleration/Decoder Development Inquiru
#1
Question 
Hello, I'd like to start this thread by stating that I'm no coder, but I do have a have a basic overview understanding of how sofware is developed to work with specific hardware.

So, with that now cleared up, I'll get to my question...

So, I've noticed that XBMC for Android doesn't really have hardware acceleration and/or decoding for most, if not all ARM based devices. I get horrible playback lag on both of my devices watching anything above 480p. However, I've been using MX Player Pro, which supports hardware decoding, (it also exists in the free version.) And in my experience, it works amazingly well on both my HTC One X+ (Tegra 3 and underclocked to 1.5GHz with only two of the four cores active at any given time.), and my Nexus 7 2013 edition. As I play any 720p/1080p video with no sign of stutter or lag on the Nexus 7, and very little lag on the HTC One X+ (Only format I get stutter with is 1GB+ .wmv files, but it only appears when fast-forwarding/rewinding 10+ minutes at a time. And again, only two cores active.)

But, short of it is, the MX Player dev has forged a fantastic hardware decoding engine for ARM devices. And I'm curious to know if it's possible to convert his/her decoding engine to function with XBMC for Android, (with permission, of course.) If it is, then from my perspective, it seems like that would be the far quicker and easier route for the XBMC devs to travel.

I'd very much appreciate some more info from someone who is more experienced than I. Also, I apologize for the overuse and/or underuse of certain punctuation. I'm a high school student that has yet to master the art of grammatically correct punctuation.

Thanks so much in advance!
Reply
#2
MX Player is private source code. They won't share it. Case closed, move along, there's nothing to see here.

XBMC for Android DOES have hardware decode. I say decode because people tend to confuse GLES rendering (hardware acceleration) with hardware decode.

There are three basic types under Android;

1) AMLCodec: AMLogic based devices. AMLogic does not support the standard decoding methods under Android.
2) MediaCodec: The public Android API for hardware decoding of video content.
3) LibStageFright: The private Android API for hardware decoding of video content.

Nvidia based devices (T3, T4) work well with MediaCodec. I should know, I have several of them and they were used to develop MediaCodec. MediaCodec is the defacto google blessed way to do video decode. If some device has problems then we do want to know about it as fixing said problems is high on the priority list.

LibStageFright also tends to work as it is using internal/private APIs. But in using internal/private APIs, sooner or later it will break. So far, it has been quite robust as new Android versions come out.

AMLCodec is not default enabled. There are technical reasons for this that will become resolved at some time in the future.

Personally, I'm not interested in 'hooking' video playback to some external player. Sort of defeats the purpose of xbmc devs working on improving our internal players/codecs. So requests to me for 'external player' help goes to /dev/null Smile
Reply
#3
Hey Davilla et. al..

I have looked and looked and looked for an answer to this, but I've been unable to find it. Hoping this is an appropriate thread to resurrect. I'm noticing that on both my Ouya and Fire TV I'm able to play hardware accelerated 1080p h264-encoded videos no problem. However, when I try playing normal 480p Xvid or Divx AVI files, it's hit or miss and I get some choppiness/stuttering in the video. I've searched high and low for answers to this and the best thing I can find is a recommendation to disable the hardware acceleration since the GPU isn't as good at decoding divx/xvid. When I disable the hardware acceleration, the xvid/divx files play perfectly fine (i'm assuming since both of thse devices are more than capable of software-decoding the videos). Obviously, once doing this, i'm unable to watch anything 720p/1080p without re-enabling it.

So, here is the question. Is there any way to set Kodi to use hardware acceleration on a per-format basis? Possibly editing the AdvancedSettings.xml file? I haven't been able to find anything like this. If this is NOT currently possible, where could I go for a feature request area to submit this? I'm sure others would like to see this as the prevalence of android STBs increases.

Thanks for all your hard work on this software. I've been using it since 2007 on the original XBox (and seen your name more than a couple timee on these fora Smile ), and have since used it on almost every one of my devices (windows-based laptops and desktops, linux-based laptops, apple tv, ouya, fireTV, android phones/tablets, etc)
Reply
#4
In Kodi there is only this http://kodi.wiki/view/Advancedsettings.xml#video see towards bottom of that Video section is info on <stagefright> & <mediacodec> settings, this allows enabling/disabling to be done on a per codec basis. However if you switch to the SMPC fork by koying (note this is still based on Gotham for now) this can be more finely tuned between SD & HD as well as codec.
Reply
#5
Hey jjd-uk, thanks for sharing this. I looked into this a bit, and I see that there are 5 options for codec: avc, vc1, vpx, mp4, and mpeg2. Upon my first searching, I seemed to determine that since Ouya can only hardware-decode h264 video, that's the only one I'd want to force to hardware and the rest i'd leave to software. Obviously I don't see an h264 option there, so I ddi some more searching and seemed to find that h264 was AVC (Thanks Wikipedia: http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC). So I figured, hey, I guess I need AVC and mp4 set to hardware decode, and the rest set to software. Now, I'm aware that there is a difference between coded and container also, so that's adds another issue.

Regardless, I figured, before I start to mess with the advancedsettings.xml file, let me try to see what I'm getting on a smooth 1080p file mkv vs a choppy 480p file avi. Here's what I'm seeing when pressing "o" for overlay while the video is playing....

For the choppy 480p:
Video: mpeg4 (Advanced Simple Profile) (XVID / 0x444495658)

For the smooth 1080p:
Video: h264 (high)

Sooooo .... i'm sorta confused. I do'nt see that the smoth h264 mkv is actually AVC OR MP4. I assumed that the mkv 1080p h264 would show it as AVC, but alas it doesn't. And I don't see anywhere in advancedsettings.xml a way to only force hardware acceleration to h264 and keep everything else as software.

Any thoughts here? Sorry for sounding noobish with this, but it just seems that what's showing in advancedsettings doesn't match what's showing in the overlays to my layman eyes.

Thanks for the help!!
Reply
#6
H264 = AVC = MPEG4 Part 10 - they are the same thing.

Beware of confusing mp4 the wrapper with mpeg4 simple profile, advanced simple profile etc. video the codec.

You can have H264/avc, MPEG4 video, MPEG2 video, MPEG1 video as codecs, and they can all be carried in MPEG2 transport stream, MP4, MKV, AVI etc. wrappers. The extension of the file often tells you the wrapper NOT the codec being carried within the wrapper.
Reply
#7
Ahhhh ok, this makes some more sense to me now. I knew that the wrapper (what I called 'container" above) and the codec were different things, but I don't think I fully understood it. The real confusing part for me was that MPEG4 Part 10 is NOT the same as mp4. It seems weird that a codec and a container/wrapper would be named the same / so similarly! I thought mp4 stood for MPEG4. But I may be wrong.

Bottom line, if I'm trying to force hardware accelleration/decoding for just h264's on my android STBS (Ouya and Amazon Fire TV), please tell me if the below Advance Settings make sense?

<stagefright>
<!-- -1 is default, 0 is never used this codec, 1 is always use this codec, bypassing blacklist -->
<useavccodec>1</useavccodec>
<usevc1codec>0</usevc1codec>
<usevpxcodec>0</usevpxcodec>
<usemp4codec>0</usemp4codec>
<usempeg2codec>0</usempeg2codec>
</stagefright>
<mediacodec>
<!-- -1 is default, 0 is never used this codec, 1 is always use this codec, bypassing blacklist -->
<useavccodec>1</useavccodec>
<usevc1codec>0</usevc1codec>
<usevpxcodec>0</usevpxcodec>
<usemp4codec>0</usemp4codec>
<usempeg2codec>0</usempeg2codec>
</mediacodec>


I already tried uploading the AdvancedSettings.xml with the useMp4codec and usempeg2codec set to 0 and everything else set to -1 (default), but for some reason, my xvids were still playing back choppy. With that XML uploaded, i still needed to change the Decoding Method to "Software" from the GUI in order to get the XVID's to play back smoothly. Is it true that if I have Kodi set to hardware decode, then it will be using EITHER libstagefright OR mediacodec, and there is no other option? If so, what happens when "Hardware accelerated" is selected for decoding method, but neither libstagefright or mediacodec are checked?

I'll try having everything set to 0 except useavccoded set to 1. Will report back shortly.
Reply
#8
Ok .... just applied the above to my AdvanceSettings, and I don't think it took. Sad Still seeing choppy ... Going to take a look at my logs to see if it says anything about the hardware decoding being disabled for everything but AVC.

I noticed that there is a <useswrenderer>false</useswrenderer> option also. I left those out, as it seemed to be a global setting for each of the 2 types of hardware decodings, not a specific per-codec option. Should I do anything with that one?

Any other thoughts or pointers for me?

Thanks guys!
************************EDIT**********************
so I tried doing 2 comparisons of log files. Both have the advancedsettings applied as above. In one, I turned off the radio buttons for libstagefright and mediacodec (but still left the decoding method set to hardware). That one played fine. In the other, I left the two radio buttons checked (that one stuttered). Here's what I see though (among, obviously, lots of other stuff):

The bad one showed this when (i think) the video file opened:
15:18:36 T:1877148184 DEBUG: FactoryCodec - Video: mediacodec - Opening
15:18:36 T:1877148184 DEBUG: CDVDVideoCodecAndroidMediaCodec::Open m_codecname(OMX.Nvidia.mp4.decode), colorFormat(19)
15:18:36 T:1735811336 DEBUG: int CVideoDatabase::RunQuery(const CStdString&) took 318 ms for 430 items query: select * from movieview WHERE ((movieview.playCount IS NULL OR movieview.playCount = 0))
15:18:36 T:1877148184 DEBUG: CDVDVideoCodecAndroidMediaCodec:: width(624), height(352), stride(0), slice-height(0), color-format(0)
15:18:36 T:1877148184 DEBUG: CDVDVideoCodecAndroidMediaCodec:: crop-left(0), crop-top(0), crop-right(0), crop-bottom(0)
15:18:36 T:1877148184 DEBUG: CDVDVideoCodecAndroidMediaCodec:: Direct Surface Rendering
15:18:36 T:1877148184 INFO: CDVDVideoCodecAndroidMediaCodec:: Open Android MediaCodec OMX.Nvidia.mp4.decode
15:18:36 T:1877148184 DEBUG: FactoryCodec - Video: amc-mpeg4 - Opened
15:18:36 T:1877148184 NOTICE: Creating video thread


The good one showed this:
15:23:13 T:1874307120 DEBUG: FactoryCodec - Video: - Opening
15:23:13 T:1874307120 NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: MPEG-4 part 2
15:23:13 T:1874307120 DEBUG: CDVDVideoCodecFFmpeg::Open() Keeping default threading 3
15:23:13 T:1874307120 DEBUG: FactoryCodec - Video: ff-mpeg4 - Opened
15:23:13 T:1874307120 NOTICE: Creating video thread
15:23:13 T:1816233320 NOTICE: Thread DVDPlayerVideo start, auto delete: false
15:23:13 T:1874307120 NOTICE: Opening stream: 1 source: 256
15:23:13 T:1816233320 NOTICE: running thread: video_thread
15:23:13 T:1874307120 NOTICE: Finding audio codec for: 86017
15:23:13 T:1874307120 DEBUG: FactoryCodec - Audio: passthrough - Opening
15:23:13 T:1874307120 DEBUG: FactoryCodec - Audio: passthrough - Failed
15:23:13 T:1874307120 DEBUG: FactoryCodec - Audio: FFmpeg - Opening
15:23:13 T:1874307120 DEBUG: FactoryCodec - Audio: FFmpeg - Opened

It's almost as though my settings from the advancedsetting.xml are not working at all.

Oh, and I didn't mention this earlier, so I'll mention it now, I'm using Kodi official release from 12/23/2014, not any nightlies or anything....

So, seems like even though I have advancedsettings set to disable hardware (mediacodec and stagefright, though it seems mediacodec is what's loading the stuttery version), the hardware accelerators are still being used.



Help please Smile
Reply
#9
So, I thought that I had possibly figured out my situation when I realized that I forgot/neglected to wrap the stagefright and mediacodec tags in a video tag. Whoops. I just added the video tags wrapped around, and unfortunately I still am not able to force the non-AVC (SD or otherwise) files to software decode, and therefore they are still being hardware-decoded and are still displaying choppy.

I did NOT include the <useswrenderer> tag, as I couldn't find any information anywhere explaining what that is for, and how it works with regard to the other sections of the tag, nor what the default value is if it is left out. Can anyone explain what that tag does?

Anyone have any idea how I can fix this, and get Kodi to only hardware-decode AVC files? I can provide logs if need be, or anything else. Just really want to get this working!!!!

Thanks in advance Smile
Reply
#10
(2015-01-08, 04:35)drumst1x Wrote: So, I thought that I had possibly figured out my situation when I realized that I forgot/neglected to wrap the stagefright and mediacodec tags in a video tag. Whoops. I just added the video tags wrapped around, and unfortunately I still am not able to force the non-AVC (SD or otherwise) files to software decode, and therefore they are still being hardware-decoded and are still displaying choppy.

I did NOT include the <useswrenderer> tag, as I couldn't find any information anywhere explaining what that is for, and how it works with regard to the other sections of the tag, nor what the default value is if it is left out. Can anyone explain what that tag does?

Anyone have any idea how I can fix this, and get Kodi to only hardware-decode AVC files? I can provide logs if need be, or anything else. Just really want to get this working!!!!

Thanks in advance Smile

Did you ever figure this out? I'm in the same boat, just wanting to disable HW acceleration for MPEG4, but these settings don't seem to make any difference.

Edit - NM, I forgot to wrap it in <video> tags. Seems to be working fine now. No longer dropping frames in DivX/Xvid, but still using HW acceleration for h.264.

Code:
<video>
    <stagefright>
        <usemp4codec>0</usemp4codec>
    </stagefright>
</video>
Reply

Logout Mark Read Team Forum Stats Members Help
Android Hardware Acceleration/Decoder Development Inquiru0