By joringyang
on Wed, 06/20/2012 - 17:12
I'm trying to convert from a video using FFmpeg to an OpenGL ES texture in ImageTargets.cpp with jni, but what I get is a mess.
[CODE]
avpicture_free(&picture);
sws_freeContext(img_convert_ctx);
avpicture_alloc(&picture, PIX_FMT_RGBA, pCodecCtx->width, pCodecCtx->height);
img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height,
pCodecCtx->pix_fmt,
target_width, target_height, PIX_FMT_RGBA, SWS_FAST_BILINEAR,
NULL, NULL, NULL);
sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, picture.data, picture.linesize);
videoTextures[0]->mWidth = 256;
videoTextures[0]->mHeight = 256;
videoTextures[0]->mData = picture.data[0];
glClearColor(0.0f, 0.0f, 0.0f, QCAR::requiresAlpha() ? 0.0f : 1.0f);
glGenTextures(1, &s_texture);
videoTextures[0]->mTextureID = 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);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, videoTextures[0]->mWidth, videoTextures[0]->mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *) videoTextures[0]->mData);
[/CODE]
These FFmpeg code works, I can use this FFmpeg code to get a java bitmap.