[SDL 1.3] Greenish video when video size smaller than texture

Hi all

I’m getting greenish video when video size smaller than the texture size.

My display device size is 1366x768. My video size is 1366x582.

What I’m trying to do is to display the video centered with two black borders on top and bottom of the video.

Portions of the code how I’m doing is below.

But when I play different videos which are fitting exactly to 1366x768, I don’t have any issue, video is displayed fine, but when the video height is smaller than display device height, I’m getting greenish video.

Have I made any mistake in my code?

Many thanks in advance.

Best regards
Unga

Code:

SDL_GetDesktopDisplayMode(0, &mode);

win = SDL_CreateWindow(“myPlayer”, 0, 0, mode.w, mode.h, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);

renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);

bitmapTex = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_YV12,
SDL_TEXTUREACCESS_STREAMING,
mode.w,
mode.h);

Display is done as follows:

SDL_Rect rect;
SDL_Rect srcrect;
SDL_Rect dstrect;

rect.x = 0;
rect.y = (int)rint((mode.h - videoHeight) / 2);
rect.w = videoWidth;
rect.h = videoHeight;

srcrect = rect;
dstrect = rect;

SDL_UpdateTexture(bitmapTex, &rect, data[0],
(videoWidth * SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_YV12));

SDL_RenderCopy(renderer, bitmapTex, &srcrect, &dstrect);

SDL_RenderPresent(renderer);================================