0

I recently ported a video decoder(written in C) to android platform. its output was in YUV format. So i had to convert it to RGB8888 to display it using the ANativeWindow API from the native code. Although the porting was successful, the output that i'm able to render is some 8.5fps for an input of 416x240, that too after using an optimization level of -O2(LOCAL_C_FLAG).

  • Is there a way to render the video faster without going to c and assembly level of optimization?
  • Even though the decoding is slower, is there a way to to make it look as if the video is running faster?

Any helpful suggestions will be appreciated.

Zax
  • 2,870
  • 7
  • 52
  • 76
  • One thing that would most likely speed up rendering is to use OpenGL ES and do the YUV->RGB conversion in a fragment shader. – Michael Feb 26 '13 at 10:52

1 Answers1

1

You can use GLSurfaceView/Renderer pair to do the renderering.

  1. In your own GLSurfaceView.Renderer implementation, override OnDrawFrame with a native method.

  2. In you native implementation, use OpenGL ES.20 frag shader to do color space conversion (and scaling as well).

You don't have to worry about the details of views/bitmaps/UI-synchronization this way. And OpenGL ES is really fast.

Joey
  • 133
  • 1
  • 7
  • Thanks for the reply. +1 for your efforts. But do you think yuv->RGB is slowing the no of frames per second?? Also if you have any example about how to use Open GL ES.20 in the native code please do post it. Coz i have never worked with it. So with an example i can try out things. Please post some example so that i can proceed. Thanks in advance. – Zax Feb 27 '13 at 04:22
  • 1
    OpenGL based yuv->RGB should take less than 10ms to finish for a typical 720x480 image, so it won't be a bottleneck. AS for 8.5fps you get, you need to profile the CPU loading for each of follow stages: decoding, color-space-conversion, bitmap copying ... to find out which one is the weakest link. You can refer to [this topic](http://stackoverflow.com/questions/12130790/yuv-to-rgb-convertion-by-fragment-shader) for more information about OpenGL-based YUV-RGB conversion. But you do need to have some basic OpenGL knowledge, though. – Joey Feb 27 '13 at 05:47
  • Hi, as u said i profiled it using android-ndk-profiler and found that the conversion for each frame hardly takes 6.66ms. So i think this technique is pretty faster.. – Zax Feb 27 '13 at 06:23