Android uses ndk instead of yuv420 overlay to ensure smooth video display. Instead, it uses a platform to port a safer rgb565 display. Tested on Android 2.3.
However, the MTK andriod platform (a301) encountered a glteximage2d gl_error 0x501 error (the source image is 176*144 ). After repeated tests, this MTK andriod version supports OpenGL ES, but it has a strange limit on the resolution of the source image. When the source dimension width and height must be a multiple of 64 and the width and height are usually two times the relationship. For example, 512*256,256*128 is acceptable. You can only scale the image to 256*128 first, and then use OpenGL ES to screen.
In addition, opensl es can still be used on MTK android.
~~~ Finally, paste the sample code of OpenGL ES for your reference.
Void opengl_resize (jint screen_width, jint screen_height)
{
Gldeletetextures (1, & s_texture );
Gluint * Start = s_disable_caps;
While (* start)
Gldisable (* Start ++ );
Glable (gl_texture_2d );
Glgentextures (1, & s_texture );
Glbindtexture (gl_texture_2d, s_texture );
Gltexparameterf (gl_texture_2d,
Gl_texture_min_filter, gl_linear );
Gltexparameterf (gl_texture_2d,
Gl_texture_mag_filter, gl_linear );
Glshademodel (gl_flat );
Check_gl_error ("glshademodel ");
Glcolor4x (0x10000, 0x10000, 0x10000, 0x10000 );
Check_gl_error ("glcolor4x ");
Int rect [4] = {0, texture_height, texture_width,-texture_height };
Gltexparameteriv (gl_texture_2d, gl_texture_crop_rect_oes, rect );
Check_gl_error ("gltexparameteriv ");
Videowidth = width;
Videoheight = height;
}
Static void render_video_opengl (unsigned char * rgb_buffer)
{
Glclear (gl_color_buffer_bit );
Glteximage2d (gl_texture_2d,/* Target */
0,/* level */
Gl_rgb,
/* Internal format */
Texture_width,/* width */
Texture_height,/* height */
0,/* border */
Gl_rgb,
/* Format */
Gl_unsigned_short_5_6_5,/* type */
Rgb_buffer );
/* Pixels */
Check_gl_error ("glteximage2d ");
Gldrawtexioes (0, 0, 0, videowidth, videoheight );
Check_gl_error ("gldrawtexioes ");
}