I am working to improve the video display efficiency of our video conferencing project in android. Video display is implemented in native opengl code. The opengl code is implemented in native with opengl version 1. The code given below is used for displaying each frames of the video.
int ofi_vc_video_display::render_video_frame(unsigned char *frame_buffer)
{
// Check the frame is available or not. If available display the frame.
if (frame_buffer != NULL){
// Clear the screen buffers.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Bind the frame data to the texture.
glTexSubImage2D(GL_TEXTURE_2D,
0,
0,
0,
frame_width,
frame_height,
GL_RGB,
GL_UNSIGNED_BYTE,
frame_buffer);
// Check for the error status.
while ((gl_error_status=glGetError()) != GL_NO_ERROR) {
error_status = gl_error_status;
}
// Transform and rotate the texture.
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0.0);
glRotatef(180.0, 180.0, 0.0,1.0);
glTranslatef(-0.5, -0.5, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -4);
// Enable drawing texture.
glBindTexture(GL_TEXTURE_2D, mTextureId);
// Draw the frames in texture.
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
// Check for the error status.
while ((gl_error_status=glGetError()) != GL_NO_ERROR) {
error_status = gl_error_status;
}
}
return error_status;
}
All initializations are done before. The code is fine for lower resolutions. But when displaying higher resolutions like 640 X 480, glTexSubImage2D itself is taking around 35 - 40 ms and the whole display time goes above 50 ms per frame. But I need 30 fps.
Can some one help with your suggestions.