Currently I am developing a video player using FFMPEG. I'm trying to convert YUV420P to RGB by Shader to reduce performance hit and I could see it works fine. The problem is caused when I try to change image size.
Case 1. YUV to RGB is perfect. but the image is not exactly fit to Texture Bounds. For example, if i play 640x360 video, right (640-512) part is cropped and bottom (512-360) is filled with green colored rectangle.
FRAME_X=512; //This is texture size
FRAME_Y=512;
avpicture_fill((AVPicture *) f, [currentVideoBuffer.data mutableBytes],
enc->pix_fmt,
FRAME_X, FRAME_Y);
av_picture_copy((AVPicture *) f, (AVPicture *) avFrame,
enc->pix_fmt,
enc->width, enc->height);
....
int yuvWidth= FRAME_X ;
int yuvHeight= FRAME_Y;
glBindTexture ( GL_TEXTURE_2D, textureIdY );
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
yuvWidth, yuvHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, y_channel);
glBindTexture ( GL_TEXTURE_2D, textureIdU );
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
yuvWidth/2, yuvHeight/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, u_channel);
glBindTexture ( GL_TEXTURE_2D, textureIdV );
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
yuvWidth/2, yuvHeight/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, v_channel);
Case 2. If i set actual image size to texture size, then image is exactly fit to texture but the color of image is a little bit strange. It has too much green color.
Does anybody give me some clues for this?? Thanks in advance.