The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Broken SDE-environment and problems in 2.0.x with YCbCr-data
figgis


Joined: 11 Feb 2014
Posts: 3
Location: Sweden
Hi,

My SDE-environment is broken!

I have written a YCbCr-viewer that has worked great in the past
https://github.com/figgis/yuv-viewer

Now my computer at work got upgraded to Debian Wheezy and after that everything I do
with SDL is broken. Having said that, ffplay works without any issues!

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.3 (wheezy)
Release: 7.3
Codename: wheezy

The link below shows the first frame of the foreman-clip when displayed using my
viewer above.
http://imgur.com/53YBxpL,u0Jj5K5#0

Then I tried using SDL2, and the result is different but also wrong
http://imgur.com/53YBxpL,u0Jj5K5#1

The SDL 1.x version works great at my colleagues workstations though (and on
ubuntu @ home) (haven't tried the 2.0 version on them yet)

This is what I'm doing in 2.0 (minimum example, I have verified the output
of every single and not one returns anything unexpected):

#include "SDL.h"
#include <stdio.h>

int main(int argc, char* argv[]) {
FILE* fd;
Uint8* raw;
Uint32 W = 352;
Uint32 H = 288;

SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *texture = NULL;

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow( "YCbCr", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, W, H, SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, W, H);

fd = fopen("foreman_cif.yuv", "rb");
raw = malloc(sizeof(Uint8) * 152064);
fread(raw, sizeof(Uint8), 152064, fd);

SDL_UpdateTexture(texture, NULL, raw, W * SDL_BYTESPERPIXEL(SDL_PIXELFORMAT_YV12));
// If I insted of the above use the below it works! Function is however only valid for YV12 or IYUV
// according to docs SDL_UpdateTexture() should work for all YCbCr-formats as long as they're
// contiguous in memory. The pitch parameter though, I don't get due to the subsampling of the chroma-planes...
// SDL_UpdateYUVTexture(texture, NULL, &raw[0], 352, &raw[352*288], 176, &raw[352*288+352*288/4], 176);

SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

SDL_Delay(3000);
free(raw);
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_DestroyTexture(texture);

// Clean up
SDL_Quit();
return EXIT_SUCCESS;
}

I compile it with:
gcc -o yv yv.c -std=c99 $(sdl2-config --cflags --libs)

Back to the 1.x version:

Right now I'm comparing the output of strace between working and the broken, but sofar
I haven't seen anything.

Any ideas on where to start looking?

If I do ldd on the binary and compare the libraries between my broken and a functional one,
I get:

$ diff broken working
1a2,3
> libaa.so.1
> libartsc.so.0
4a7
> libaudiofile.so.0
11a15
> libesd.so.0
13a18,19
> libgdbm.so.3
> libgpm.so.2
15d20
< libjson.so.0
16a22
> libncurses.so.5
21c27
< libpulsecommon-2.0.so
---
> libpulsecommon-0.9.21.so
30,31d35
< libtinfo.so.5
< libts-0.0.so.0
32a37
> libvga.so.1
37c42
< libX11-xcb.so.1
---
> libx86.so.1

I have tested this on both 2.0.0 and 2.0.1

Any ideas? 1.x is utterly broken (tried removing re-installing several times) and I can't get 2.0.x to work...