I need to render video on android. I got sw decoder which decodes stream to YUV or RGB with very reasonable cpu usage, but so far haven't found a nice way how to render frames.
I have tried 3 methods so far: 1) using opengl from native code: * create a texture of type GL_TEXTURE_2D * set coordinates to fill full opengl rendering area * to render a frame update the texture with glTexSubImage2D or glTexImage2D function (more or less the same method that is used in vlc media player) With this method the performance is most terrible.. VGA rendering @5..7FPS uses up 100% of nexus one cpu! 2) rendering with canvas function Canvas.drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)Was hoping to use this via JNI. First i just made a simple perfo test: * colors array was initialized in java code * then I just called mSurfaceHolder.lockCanvas(); canvas.drawBitmap(colors, ... ); mSurfaceHolder.unlockCanvasAndPost(canvas); in sequence Perfo is better than with opengl - v...@30fps uses up 40% of nexus one- s cpu... 3) Rendering with canvas function Canvas.drawBitmap(Bitmap bitmap, float left, float top, Paint paint), while updating bitmap in native code * in java code i do: mSurfaceHolder.lockCanvas(); nativeUpdate(); canvas.drawBitmap(mybitmap, ... ); mSurfaceHolder.unlockCanvasAndPost(canvas); * in native code i get value of a variable myrenderclass.mybitmap.mNativeBitmap via JNI * cast it to SkBitmap * pVideoBuffer * use pVideoBuffer->allocPixels(); && pVideoBuffer->getPixels(); to get native pointer to memory (need to link to native android library libskia.so to get these functions) * copy or decode the video frame to this memory With this method i get only 10% cpu usage when doing v...@30fps... but lets face it - its a hack which may break in future Am I missing something or there really isn't any better way to render video? for example some opengl extension function etc..? Br, Lauri -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

