Seems that NDK r4 adds stable api to access bitmap from native code.
So method 3) is now officially supported :)

On Apr 14, 5:50 pm, Lauri Ehrenpreis <lauri...@gmail.com> wrote:
> I need torendervideoon 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 torenderframes.
>
> 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
> * torendera 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 thevideoframe 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 torendervideo? 
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to