sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

YUV format support is incomplete

Open sailfish009 opened this issue 8 years ago • 2 comments

Hi,

how do i replace SDL_UpdateYUVTexture() with sdl-gpu functions?

with GPU_UpdateImageBytes(), i can only copy Y planar pixels to GPU_image. so i can see gray image/stream only, no color image.


  while (1) {
    GPU_Clear(screen);
    for (int i = 0; i < 4; ++i) {
      fread(yPlane[i], 1, pixel_w * pixel_h, fp[i]);
      fread(uPlane[i], 1, pixel_w * pixel_h / 4, fp[i]);
      fread(vPlane[i], 1, pixel_w * pixel_h / 4, fp[i]);

      GPU_UpdateImageBytes(texture, &rect[i], yPlane[i], pixel_w);
      GPU_Blit(texture, NULL, screen, pixel_w / 2, pixel_h / 2);
    }

    GPU_Flip(screen);
    SDL_Delay(33);
  }

//SDL2 version 
 while (1) {
    SDL_RenderClear(renderer);
    for (int i = 0; i < 4; ++i) {
      fread(yPlane[i], 1, pixel_w * pixel_h, fp[i]);
      fread(uPlane[i], 1, pixel_w * pixel_h / 4, fp[i]);
      fread(vPlane[i], 1, pixel_w * pixel_h / 4, fp[i]);

      SDL_UpdateYUVTexture(texture, NULL, yPlane[i], pixel_w, uPlane[i],
                           uvPitch, vPlane[i], uvPitch);
      SDL_RenderCopy(renderer, texture, NULL, &(rect[i]));
    }

    SDL_RenderPresent(renderer);
    SDL_Delay(33);
 }

sailfish009 avatar Sep 08 '16 07:09 sailfish009

Unfortunately, SDL_gpu's YUV support is not complete. I started it a long time ago and never did finish it. As it is, I think you'd have to write your own shader to combine planes from 3 individual GPU_Images.

My personal obligations are pressing lately, so I can't commit to finishing YUV support any time soon.

grimfang4 avatar Sep 08 '16 10:09 grimfang4

Thanks for the answer! :)

i will look at libyuv. https://chromium.googlesource.com/libyuv/libyuv/

sailfish009 avatar Sep 08 '16 11:09 sailfish009