mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 05:40:27 +00:00
Trivial change of the quad capture module due to changes in the Quad SDK.
Merged the CVS tree with code by Tomas Sedmik
New features:
* switching between windowed and fullscreen mode ("f" key) for both SDL and GL displays
* splashscreen moved to GIMP header file. The splashscreen is compiled in.
Also, the splashscreen is displayed for both SDL and GL displays now.
* code fragments for Shader units moved to respective display module header files.
UltraGrid is not depending on external files anymore!
This commit is contained in:
@@ -295,8 +295,8 @@ vidcap_quad_grab(void *state)
|
||||
time_sec = tv.tv_sec + (double)tv.tv_usec / 1000000;
|
||||
dt = time_sec - lasttime;
|
||||
|
||||
/* Only for HD-SDI, display timestamp and counter */
|
||||
|
||||
/* Only for HD-SDI, display timestamp and counter */
|
||||
/* TODO: This is currently not working. Something has changed in Quad SDK 2.7.1. SDI_IOC_RXGET27COUNT and SDI_IOC_RXGETTIMESTAMP are lost now.
|
||||
if(dt >= 5) {
|
||||
if(ioctl (fd, SDI_IOC_RXGET27COUNT, &frames) < 0) {
|
||||
fprintf (stderr, "%s: ", device);
|
||||
@@ -347,6 +347,7 @@ vidcap_quad_grab(void *state)
|
||||
|
||||
lasttime = time_sec;
|
||||
}
|
||||
*/
|
||||
|
||||
if(s->data != NULL) {
|
||||
vf = (struct video_frame *) malloc(sizeof(struct video_frame));
|
||||
|
||||
@@ -117,7 +117,6 @@ void dxt_draw();
|
||||
void * display_dxt_init(void);
|
||||
void dxt_arb_init(void *arg);
|
||||
void glsl_dxt_init(void *arg);
|
||||
void dxt_loadShader(void *arg, char *filename);
|
||||
void dxt_draw();
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -208,24 +207,6 @@ void * display_dxt_init(void)
|
||||
return (void*)s;
|
||||
}
|
||||
|
||||
void dxt_loadShader(void *arg, char *filename)
|
||||
{
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
struct stat file;
|
||||
s = (struct state_sdl *) calloc(1,sizeof(struct state_sdl));
|
||||
|
||||
stat(filename,&file);
|
||||
s->FProgram=calloc(file.st_size+1,sizeof(char));
|
||||
FILE *fh;
|
||||
fh=fopen(filename, "r");
|
||||
if(!fh){
|
||||
perror(filename);
|
||||
exit(113);
|
||||
}
|
||||
fread(s->FProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
}
|
||||
|
||||
void dxt_arb_init(void *arg)
|
||||
{
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
@@ -428,52 +409,14 @@ static void * display_thread_dxt(void *arg)
|
||||
if(glewIsSupported("GL_VERSION_2_0")){
|
||||
fprintf(stderr, "OpenGL 2.0 is supported...\n");
|
||||
}
|
||||
/* Load shader */
|
||||
//TODO: Need a less breaky way to do this...
|
||||
struct stat file;
|
||||
char *filename=strdup("../src/video_display/dxt.frag");
|
||||
if (stat(filename,&file) != 0) {
|
||||
filename=strdup("/usr/share/uv-0.3.1/dxt.frag");
|
||||
if (stat(filename,&file) != 0) {
|
||||
filename=strdup("/usr/local/share/uv-0.3.1/dxt.frag");
|
||||
if (stat(filename,&file) != 0) {
|
||||
fprintf(stderr, "dxt.frag not found. Giving up!\n");
|
||||
exit(113);
|
||||
}
|
||||
}
|
||||
}
|
||||
s->FProgram=calloc(file.st_size+1,sizeof(char));
|
||||
|
||||
FILE *fh;
|
||||
fh=fopen(filename, "r");
|
||||
if(!fh){
|
||||
perror(filename);
|
||||
exit(113);
|
||||
}
|
||||
fread(s->FProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
|
||||
char *filename2=strdup("../src/video_display/dxt.vert");
|
||||
if (stat(filename2,&file) != 0) {
|
||||
filename2=strdup("/usr/share/uv-0.3.1/dxt.vert");
|
||||
if (stat(filename2,&file) != 0) {
|
||||
filename2=strdup("/usr/local/share/uv-0.3.1/dxt.vert");
|
||||
if (stat(filename2,&file) != 0) {
|
||||
fprintf(stderr, "dxt.vert not found. Giving up!\n");
|
||||
exit(113);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
s->VProgram=calloc(file.st_size+1,sizeof(char));
|
||||
|
||||
fh=fopen(filename2, "r");
|
||||
if(!fh){
|
||||
perror(filename2);
|
||||
exit(113);
|
||||
}
|
||||
fread(s->VProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
|
||||
/* load shader
|
||||
* modified: xsedmik, 13-02-2010
|
||||
*/
|
||||
s->FProgram = frag;
|
||||
s->VProgram = vert;
|
||||
|
||||
|
||||
/* Check to see if OpenGL 2.0 is supported, if not use ARB (if supported) */
|
||||
glewInit();
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
uniform sampler2D yuvtex;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = texture2D(yuvtex, gl_TexCoord[0].st);
|
||||
|
||||
float Y = col[0];
|
||||
float U = col[1]-0.5;
|
||||
float V = col[2]-0.5;
|
||||
Y=1.1643*(Y-0.0625);
|
||||
|
||||
float G = Y-0.39173*U-0.81290*V;
|
||||
float B = Y+2.017*U;
|
||||
float R = Y+1.5958*V;
|
||||
|
||||
gl_FragColor=vec4(R,G,B,1.0);
|
||||
}
|
||||
|
||||
@@ -56,3 +56,25 @@ int display_dxt_putf(void *state, char *frame);
|
||||
display_colour_t display_dxt_colour(void *state);
|
||||
|
||||
int display_dxt_handle_events(void *arg);
|
||||
|
||||
static char * frag = "\
|
||||
uniform sampler2D yuvtex;\
|
||||
\
|
||||
void main(void) {\
|
||||
vec4 col = texture2D(yuvtex, gl_TexCoord[0].st);\
|
||||
\
|
||||
float Y = col[0];\
|
||||
float U = col[1]-0.5;\
|
||||
float V = col[2]-0.5;\
|
||||
Y=1.1643*(Y-0.0625);\
|
||||
\
|
||||
float G = Y-0.39173*U-0.81290*V;\
|
||||
float B = Y+2.017*U;\
|
||||
float R = Y+1.5958*V;\
|
||||
\
|
||||
gl_FragColor=vec4(R,G,B,1.0);}";
|
||||
|
||||
static char * vert = "\
|
||||
void main() {\
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;\
|
||||
gl_Position = ftransform();}";
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
@@ -73,50 +73,270 @@
|
||||
#include "video_display.h"
|
||||
#include "video_display/gl_sdl.h"
|
||||
|
||||
// splash screen (xsedmik)
|
||||
#include "video_display/splashscreen.h"
|
||||
|
||||
#define HD_WIDTH 1920
|
||||
#define HD_HEIGHT 1080
|
||||
#define MAGIC_GL DISPLAY_GL_ID
|
||||
#define MAGIC_GL DISPLAY_GL_ID
|
||||
|
||||
|
||||
struct state_sdl {
|
||||
Display *display;
|
||||
unsigned int x_res_x;
|
||||
unsigned int x_res_y;
|
||||
unsigned int x_width;
|
||||
unsigned int x_height;
|
||||
|
||||
int vw_depth;
|
||||
SDL_Overlay *vw_image;
|
||||
GLubyte *buffers[2];
|
||||
GLubyte *outbuffer;
|
||||
GLubyte *y, *u, *v; //Guess what this might be...
|
||||
char* VSHandle,FSHandle,PHandle;
|
||||
GLubyte *outbuffer;
|
||||
GLubyte *y, *u, *v; //Guess what this might be...
|
||||
char* VSHandle,FSHandle,PHandle;
|
||||
int image_display, image_network;
|
||||
GLuint texture[4];
|
||||
GLuint texture[4];
|
||||
|
||||
/* Thread related information follows... */
|
||||
pthread_t thread_id;
|
||||
sem_t semaphore;
|
||||
pthread_t thread_id;
|
||||
sem_t semaphore;
|
||||
|
||||
/* For debugging... */
|
||||
uint32_t magic;
|
||||
uint32_t magic;
|
||||
|
||||
SDL_Surface *sdl_screen;
|
||||
SDL_Rect rect;
|
||||
SDL_Surface *sdl_screen;
|
||||
SDL_Rect rect;
|
||||
|
||||
char *VProgram,*FProgram;
|
||||
char *VProgram,*FProgram;
|
||||
|
||||
unsigned fs:1;
|
||||
};
|
||||
|
||||
/* Prototyping */
|
||||
inline int gl_video_flags(void * arg);
|
||||
void gl_draw();
|
||||
inline void gl_load_splashscreen(void *arg);
|
||||
inline int gl_toggle_fullscreen(void *arg);
|
||||
void gl_show_help(void);
|
||||
|
||||
static void * display_thread_gl(void *arg);
|
||||
void gl_deinterlace(GLubyte *buffer);//unsigned
|
||||
void extrapolate(GLubyte *input, GLubyte *output);
|
||||
inline void getY(GLubyte *input,GLubyte *y, GLubyte *u,GLubyte *v);
|
||||
void gl_resize_window(int width, int height);
|
||||
void gl_bind_texture(void *args);
|
||||
void gl_draw();
|
||||
void loadShader(void *arg, char *filename);
|
||||
void glsl_gl_init(void *arg);
|
||||
void glsl_arb_init(void *arg);
|
||||
inline void gl_copyline64(GLubyte *dst, GLubyte *src, int len);
|
||||
inline void gl_copyline128(GLubyte *d, GLubyte *s, int len);//unsigned
|
||||
void * display_gl_init(void);
|
||||
void * display_gl_init(char *fmt);
|
||||
|
||||
|
||||
/**
|
||||
* Prepares the flags for SDL_SetVideoMode
|
||||
*
|
||||
* @since 21-03-2010, xsedmik
|
||||
* @param arg
|
||||
* @return integral
|
||||
*/
|
||||
int gl_video_flags(void * arg) {
|
||||
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
const SDL_VideoInfo * videoInfo;
|
||||
int videoFlags;
|
||||
|
||||
// Fetch the video info
|
||||
videoInfo = SDL_GetVideoInfo();
|
||||
|
||||
if (!videoInfo) {
|
||||
fprintf(stderr, "Video query failed: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// the flags to pass to SDL_SetVideoMode
|
||||
videoFlags = SDL_OPENGL; // Enable OpenGL in SDL
|
||||
videoFlags |= SDL_GL_DOUBLEBUFFER; // Enable double buffering
|
||||
videoFlags |= SDL_HWPALETTE; // Store the palette in hardware
|
||||
if (s->fs) {
|
||||
videoFlags |= SDL_FULLSCREEN; // Fullscreen
|
||||
}
|
||||
|
||||
// This checks to see if surfaces can be stored in memory
|
||||
if ( videoInfo->hw_available ) {
|
||||
videoFlags |= SDL_HWSURFACE;
|
||||
}
|
||||
else {
|
||||
videoFlags |= SDL_SWSURFACE;
|
||||
}
|
||||
|
||||
// This checks if hardware blits can be done
|
||||
if ( videoInfo->blit_hw ) {
|
||||
videoFlags |= SDL_HWACCEL;
|
||||
}
|
||||
|
||||
return videoFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show help
|
||||
* @since 23-03-2010, xsedmik
|
||||
*/
|
||||
void gl_show_help(void) {
|
||||
printf("GL(SDL) options:\n");
|
||||
printf("\t[fs] | help\n");
|
||||
printf("\tfs - fullscreen\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Load splashscreen
|
||||
* Function loads graphic data from header file "splashscreen.h", where are
|
||||
* stored splashscreen data in RGB format. Thereafter are data written into
|
||||
* the temporary SDL_Surface. At the end of the function are displayed on
|
||||
* the screen.
|
||||
*
|
||||
* @since 29-03-2010, xsedmik
|
||||
* @param s Structure contains the current settings
|
||||
*/
|
||||
void gl_load_splashscreen(void *arg) {
|
||||
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
unsigned int x_coord;
|
||||
unsigned int y_coord;
|
||||
char pixel[3];
|
||||
GLuint texture; // This is a handle to our texture object
|
||||
SDL_Surface *image;
|
||||
|
||||
image = SDL_CreateRGBSurface(SDL_HWSURFACE ,splash_width, splash_height, 24,
|
||||
s->sdl_screen->format->Rmask, s->sdl_screen->format->Gmask,
|
||||
s->sdl_screen->format->Bmask, s->sdl_screen->format->Amask);
|
||||
|
||||
for (y_coord = 0; y_coord < splash_height; y_coord++) {
|
||||
for (x_coord = 0; x_coord < splash_width; x_coord++) {
|
||||
|
||||
HEADER_PIXEL(splash_data,pixel);
|
||||
|
||||
// 24-bpp
|
||||
Uint8 *bufp;
|
||||
bufp = (Uint8 *)image->pixels + y_coord*image->pitch +
|
||||
x_coord*image->format->BytesPerPixel;
|
||||
*(bufp+image->format->Rshift/8) = pixel[0];
|
||||
*(bufp+image->format->Gshift/8) = pixel[1];
|
||||
*(bufp+image->format->Bshift/8) = pixel[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (image != NULL) {
|
||||
// Display the SDL_surface as a OpenGL texture
|
||||
|
||||
// Have OpenGL generate a texture object handle for us
|
||||
glGenTextures(1, &texture);
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
// Set the texture's stretching properties
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// Edit the texture object's image data using the information SDL_Surface gives us
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
|
||||
SDL_FreeSurface(image);
|
||||
|
||||
gl_draw();
|
||||
glDeleteTextures( 1, &texture );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function toggles between fullscreen and window display mode
|
||||
*
|
||||
* @since 29-03-2010, xsedmik
|
||||
* @param arg Structure contains the current settings
|
||||
* @return zero value everytime
|
||||
*/
|
||||
int gl_toggle_fullscreen(void *arg) {
|
||||
|
||||
struct state_sdl * s = (struct state_sdl *) arg;
|
||||
|
||||
if(s->fs) {
|
||||
s->fs = 0;
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", HD_WIDTH, HD_HEIGHT);
|
||||
s->sdl_screen = SDL_SetVideoMode(HD_WIDTH, HD_HEIGHT, 32, gl_video_flags(s));
|
||||
s->fs = 0;
|
||||
|
||||
// Set the begining of the video rectangle and resize
|
||||
s->rect.y = 0;
|
||||
s->rect.x = 0;
|
||||
gl_resize_window(HD_WIDTH, HD_HEIGHT);
|
||||
}
|
||||
else {
|
||||
s->fs = 1;
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", s->x_width, s->x_height);
|
||||
s->sdl_screen = SDL_SetVideoMode(s->x_width, s->x_height, 32, gl_video_flags(s));
|
||||
s->fs = 1;
|
||||
|
||||
// Set the begining of the video rectangle and resize
|
||||
if ((int)s->x_height > HD_HEIGHT) {
|
||||
s->rect.y = (s->x_height - HD_HEIGHT) / 2;
|
||||
}
|
||||
else {
|
||||
s->rect.y = 0;
|
||||
}
|
||||
if ((int)s->x_width > HD_WIDTH) {
|
||||
s->rect.x = (s->x_width - HD_WIDTH) / 2;
|
||||
}
|
||||
else {
|
||||
s->rect.x = 0;
|
||||
}
|
||||
gl_resize_window(s->x_width, s->x_height);
|
||||
}
|
||||
if(s->sdl_screen == NULL){
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", s->x_width, s->x_height);
|
||||
free(s);
|
||||
exit(128);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles outer events like a keyboard press
|
||||
* Responds to key:<br/>
|
||||
* <table>
|
||||
* <td><tr>q</tr><tr>terminates program</tr></td>
|
||||
* <td><tr>f</tr><tr>toggles between fullscreen and windowed display mode</tr></td>
|
||||
* </table>
|
||||
*
|
||||
* @since 08-04-2010, xsedmik
|
||||
* @param state Structure (state_sdl) contains the current settings
|
||||
* @return zero value everytime
|
||||
*/
|
||||
int display_gl_handle_events(void *state) {
|
||||
|
||||
SDL_Event sdl_event;
|
||||
|
||||
while (SDL_PollEvent(&sdl_event)) {
|
||||
switch (sdl_event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "q")) {
|
||||
kill(0, SIGINT);
|
||||
}
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "f")) {
|
||||
gl_toggle_fullscreen(state);
|
||||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
kill(0, SIGINT);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void gl_check_error()
|
||||
{
|
||||
@@ -154,82 +374,96 @@ void gl_check_error()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void * display_gl_init(void)
|
||||
{
|
||||
struct state_sdl *s;
|
||||
void * display_gl_init(char *fmt) {
|
||||
|
||||
int ret;
|
||||
int itemp;
|
||||
unsigned int utemp;
|
||||
Window wtemp;
|
||||
struct state_sdl *s;
|
||||
int ret;
|
||||
int itemp;
|
||||
unsigned int utemp;
|
||||
Window wtemp;
|
||||
|
||||
s = (struct state_sdl *) calloc(1,sizeof(struct state_sdl));
|
||||
s->magic = MAGIC_GL;
|
||||
|
||||
if (!(s->display = XOpenDisplay(NULL))) {
|
||||
printf("Unable to open display GL: XOpenDisplay.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get XWindows resolution */
|
||||
ret = XGetGeometry(s->display, DefaultRootWindow(s->display), &wtemp, &itemp, &itemp, &(s->x_res_x), &(s->x_res_y), &utemp, &utemp);
|
||||
|
||||
s->rect.w = HD_WIDTH;
|
||||
s->rect.h = HD_HEIGHT;
|
||||
if ((s->x_res_x - HD_WIDTH) > 0) {
|
||||
s->rect.x = (s->x_res_x - HD_WIDTH) / 2;
|
||||
} else {
|
||||
s->rect.x = 0;
|
||||
}
|
||||
if ((s->x_res_y - HD_HEIGHT) > 0) {
|
||||
s->rect.y = (s->x_res_y - HD_HEIGHT) / 2;
|
||||
} else {
|
||||
s->rect.y = 0;
|
||||
}
|
||||
|
||||
s->buffers[0]=malloc(HD_WIDTH*HD_HEIGHT*3);
|
||||
s->buffers[1]=malloc(HD_WIDTH*HD_HEIGHT*3);
|
||||
s->outbuffer=malloc(HD_WIDTH*HD_HEIGHT*4);
|
||||
s->image_network=0;
|
||||
s->image_display=1;
|
||||
s->y=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
s->u=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
s->v=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
|
||||
asm("emms\n");
|
||||
|
||||
platform_sem_init(&s->semaphore, 0, 0);
|
||||
if (pthread_create(&(s->thread_id), NULL, display_thread_gl, (void *) s) != 0) {
|
||||
perror("Unable to create display thread\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*)s;
|
||||
}
|
||||
|
||||
void loadShader(void *arg, char *filename)
|
||||
{
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
struct stat file;
|
||||
|
||||
s = (struct state_sdl *) calloc(1,sizeof(struct state_sdl));
|
||||
s->magic = MAGIC_GL;
|
||||
|
||||
stat(filename,&file);
|
||||
s->FProgram=calloc(file.st_size+1,sizeof(char));
|
||||
FILE *fh;
|
||||
fh=fopen(filename, "r");
|
||||
if(!fh){
|
||||
perror(filename);
|
||||
exit(113);
|
||||
// parse parameters
|
||||
if (fmt != NULL) {
|
||||
if (strcmp(fmt, "help") == 0) {
|
||||
gl_show_help();
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *tmp = strdup(fmt);
|
||||
char *tok;
|
||||
|
||||
tok = strtok(tmp, ":");
|
||||
if ((tok != NULL) && (tok[0] == 'f') && (tok[1] == 's')) {
|
||||
s->fs=1;
|
||||
}
|
||||
else {
|
||||
s->fs=0;
|
||||
}
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
fread(s->FProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
|
||||
if (s->fs) {
|
||||
fprintf(stdout,"GL(SDL) setup: %dx%d, fullscreen: on\n", HD_WIDTH, HD_HEIGHT);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"GL(SDL) setup: %dx%d, fullscreen: off\n", HD_WIDTH, HD_HEIGHT);
|
||||
}
|
||||
|
||||
if (!(s->display = XOpenDisplay(NULL))) {
|
||||
printf("Unable to open display GL: XOpenDisplay.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get XWindows resolution
|
||||
ret = XGetGeometry(s->display, DefaultRootWindow(s->display), &wtemp, &itemp, &itemp, &(s->x_width), &(s->x_height), &utemp, &utemp);
|
||||
|
||||
// set video rectangle's position and size
|
||||
s->rect.w = HD_WIDTH;
|
||||
s->rect.h = HD_HEIGHT;
|
||||
if ((int)s->x_width > HD_WIDTH) {
|
||||
s->rect.x = (s->x_width - HD_WIDTH) / 2;
|
||||
}
|
||||
else {
|
||||
s->rect.w = s->x_width;
|
||||
}
|
||||
if (((int)s->x_height > HD_HEIGHT) && (s->fs)) {
|
||||
s->rect.y = (s->x_height - HD_HEIGHT) / 2;
|
||||
}
|
||||
else if ((int)s->x_height < HD_HEIGHT){
|
||||
s->rect.h = s->x_height;
|
||||
}
|
||||
|
||||
fprintf(stdout,"Setting SDL rect %dx%d, %d,%d.\n", s->rect.w, s->rect.h, s->rect.x, s->rect.y);
|
||||
|
||||
s->buffers[0]=malloc(HD_WIDTH*HD_HEIGHT*3);
|
||||
s->buffers[1]=malloc(HD_WIDTH*HD_HEIGHT*3);
|
||||
s->outbuffer=malloc(HD_WIDTH*HD_HEIGHT*4);
|
||||
s->image_network=0;
|
||||
s->image_display=1;
|
||||
s->y=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
s->u=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
s->v=malloc(HD_WIDTH*HD_HEIGHT);
|
||||
|
||||
asm("emms\n");
|
||||
|
||||
platform_sem_init(&s->semaphore, 0, 0);
|
||||
if (pthread_create(&(s->thread_id), NULL, display_thread_gl, (void *) s) != 0) {
|
||||
perror("Unable to create display thread\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void*)s;
|
||||
}
|
||||
|
||||
void glsl_arb_init(void *arg)
|
||||
{
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
char *log;
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
char *log;
|
||||
|
||||
/* Set up program objects. */
|
||||
s->PHandle=glCreateProgramObjectARB();
|
||||
@@ -270,10 +504,10 @@ void glsl_arb_init(void *arg)
|
||||
glUseProgramObjectARB(s->PHandle);
|
||||
}
|
||||
|
||||
void glsl_gl_init(void *arg)
|
||||
{
|
||||
void glsl_gl_init(void *arg) {
|
||||
|
||||
//TODO: Add log
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
|
||||
s->PHandle=glCreateProgram();
|
||||
s->FSHandle=glCreateShader(GL_FRAGMENT_SHADER);
|
||||
@@ -317,7 +551,6 @@ static void * display_thread_gl(void *arg)
|
||||
struct state_sdl *s = (struct state_sdl *) arg;
|
||||
int j, i;
|
||||
|
||||
const SDL_VideoInfo *videoInfo;
|
||||
int videoFlags;
|
||||
/* FPS */
|
||||
static GLint T0 = 0;
|
||||
@@ -335,40 +568,24 @@ static void * display_thread_gl(void *arg)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Fetch the video info */
|
||||
videoInfo = SDL_GetVideoInfo( );
|
||||
|
||||
if ( !videoInfo ) {
|
||||
fprintf( stderr, "Video query failed: %s\n",SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* the flags to pass to SDL_SetVideoMode */
|
||||
videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */
|
||||
videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
|
||||
videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */
|
||||
videoFlags |= SDL_FULLSCREEN; /* Fullscreen */
|
||||
|
||||
/* This checks to see if surfaces can be stored in memory */
|
||||
if ( videoInfo->hw_available )
|
||||
videoFlags |= SDL_HWSURFACE;
|
||||
else
|
||||
videoFlags |= SDL_SWSURFACE;
|
||||
|
||||
/* This checks if hardware blits can be done */
|
||||
if ( videoInfo->blit_hw )
|
||||
videoFlags |= SDL_HWACCEL;
|
||||
videoFlags = gl_video_flags(s);
|
||||
|
||||
/* Sets up OpenGL double buffering */
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); //TODO: Is this necessary?
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1 ); //TODO: Is this necessary?
|
||||
#ifdef HAVE_SDL_1210
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
||||
#endif /* HAVE_SDL_1210 */
|
||||
|
||||
/* get a SDL surface */
|
||||
s->sdl_screen = SDL_SetVideoMode(s->x_res_x, s->x_res_y, 32, videoFlags);
|
||||
if (s->fs) {
|
||||
s->sdl_screen = SDL_SetVideoMode(s->x_width, s->x_height, 32, videoFlags);
|
||||
}
|
||||
else {
|
||||
s->sdl_screen = SDL_SetVideoMode(HD_WIDTH, HD_HEIGHT, 32, videoFlags);
|
||||
}
|
||||
if(!s->sdl_screen){
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", s->x_res_x, s->x_res_y);
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", s->x_width, s->x_height);
|
||||
exit(128);
|
||||
}
|
||||
|
||||
@@ -379,80 +596,19 @@ static void * display_thread_gl(void *arg)
|
||||
/* OpenGL Setup */
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glClearColor( 1.0f, 1.0f, 1.0f, 0.1f );
|
||||
gl_resize_window(s->x_res_x, s->x_res_y);
|
||||
if (s->fs) {
|
||||
gl_resize_window(s->x_width, s->x_height);
|
||||
}
|
||||
else {
|
||||
gl_resize_window(HD_WIDTH, HD_HEIGHT);
|
||||
}
|
||||
glGenTextures(4, s->texture); //TODO: Is this necessary?
|
||||
|
||||
/* Display splash screen */
|
||||
SDL_Surface *temp;
|
||||
GLuint texture; // This is a handle to our texture object
|
||||
temp = SDL_LoadBMP("/usr/share/uv-0.3.1/uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
temp = SDL_LoadBMP("/usr/local/share/uv-0.3.1/uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
temp = SDL_LoadBMP("uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
printf("Unable to load splash bitmap: uv_startup.bmp.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
//load shader (xsedmik, 13-02-2010)
|
||||
s->FProgram = glsl;
|
||||
|
||||
if (temp != NULL) {
|
||||
/* Display the SDL_surface as a OpenGL texture */
|
||||
|
||||
// Have OpenGL generate a texture object handle for us
|
||||
glGenTextures(1, &texture);
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
// Set the texture's stretching properties
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// Edit the texture object's image data using the information SDL_Surface gives us
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, temp->w, temp->h, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, temp->pixels);
|
||||
|
||||
gl_draw();
|
||||
|
||||
glDeleteTextures( 1, &texture );
|
||||
}
|
||||
|
||||
/* Load shader */
|
||||
//TODO: Need a less breaky way to do this...
|
||||
struct stat file;
|
||||
char *filename=strdup("../src/video_display/gl_sdl.glsl");
|
||||
if ((stat(filename,&file)) == -1) {
|
||||
filename=strdup("/usr/share/uv-0.3.1/gl_sdl.glsl");
|
||||
if ((stat(filename,&file)) == -1) {
|
||||
filename=strdup("/usr/local/share/uv-0.3.1/gl_sdl.glsl");
|
||||
if ((stat(filename,&file)) == -1) {
|
||||
fprintf(stderr, "gl_sdl.glsl not found. Giving up!\n");
|
||||
exit(113);
|
||||
}
|
||||
}
|
||||
}
|
||||
s->FProgram=calloc(file.st_size+1,sizeof(char));
|
||||
FILE *fh;
|
||||
fh=fopen(filename, "r");
|
||||
if(!fh){
|
||||
perror(filename);
|
||||
exit(113);
|
||||
}
|
||||
fread(s->FProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
#if 0
|
||||
char filename2[]="../src/video_display/gl.vert";
|
||||
stat(filename2,&file);
|
||||
s->VProgram=calloc(file.st_size+1,sizeof(char));
|
||||
fh=fopen(filename2, "r");
|
||||
if(!fh){
|
||||
perror(filename2);
|
||||
exit(113);
|
||||
}
|
||||
fread(s->VProgram,sizeof(char),file.st_size,fh);
|
||||
fclose(fh);
|
||||
#endif
|
||||
//load splash screen (xsedmik, 08-03-2010)
|
||||
gl_load_splashscreen(s);
|
||||
|
||||
/* Check to see if OpenGL 2.0 is supported, if not use ARB (if supported) */
|
||||
glewInit();
|
||||
@@ -517,7 +673,7 @@ static void * display_thread_gl(void *arg)
|
||||
// gl_deinterlace(s->outbuffer);
|
||||
getY(s->outbuffer,s->y,s->u,s->v);
|
||||
gl_bind_texture(s);
|
||||
gl_draw(s);
|
||||
gl_draw();
|
||||
|
||||
/* FPS Data, this is pretty ghetto though.... */
|
||||
Frames++;
|
||||
@@ -854,26 +1010,3 @@ display_colour_t display_gl_colour(void *state)
|
||||
return DC_YUV;
|
||||
}
|
||||
|
||||
int display_gl_handle_events(void *state)
|
||||
{
|
||||
SDL_Event sdl_event;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
while (SDL_PollEvent(&sdl_event)) {
|
||||
switch (sdl_event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "q")) {
|
||||
kill(0, SIGINT);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
uniform sampler2D Ytex;
|
||||
uniform sampler2D Utex,Vtex;
|
||||
void main(void) {
|
||||
float nx,ny,r,g,b,y,u,v;
|
||||
vec4 txl,ux,vx;
|
||||
nx=gl_TexCoord[0].x;
|
||||
ny=gl_TexCoord[0].y;
|
||||
y=texture2D(Ytex,vec2(nx,ny)).r;
|
||||
u=texture2D(Utex,vec2(nx,ny)).r;
|
||||
v=texture2D(Vtex,vec2(nx,ny)).r;
|
||||
|
||||
y=1.1643*(y-0.0625);
|
||||
u=u-0.5;
|
||||
v=v-0.5;
|
||||
|
||||
r=y+1.5958*v;
|
||||
g=y-0.39173*u-0.81290*v;
|
||||
b=y+2.017*u;
|
||||
|
||||
gl_FragColor=vec4(r,g,b,1.0);
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* 3. All rertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by CESNET z.s.p.o.
|
||||
@@ -49,10 +49,33 @@
|
||||
#define DISPLAY_GL_ID 0xba370a2a
|
||||
|
||||
display_type_t *display_gl_probe(void);
|
||||
void *display_gl_init(void);
|
||||
void *display_gl_init(char *fmt);
|
||||
void display_gl_done(void *state);
|
||||
char *display_gl_getf(void *state);
|
||||
int display_gl_putf(void *state, char *frame);
|
||||
display_colour_t display_gl_colour(void *state);
|
||||
|
||||
int display_gl_handle_events(void *arg);
|
||||
|
||||
|
||||
// source code for a shader unit (xsedmik)
|
||||
static char * glsl = "\
|
||||
uniform sampler2D Ytex;\
|
||||
uniform sampler2D Utex,Vtex;\
|
||||
\
|
||||
void main(void) {\
|
||||
float nx,ny,r,g,b,y,u,v;\
|
||||
vec4 txl,ux,vx;\
|
||||
nx=gl_TexCoord[0].x;\
|
||||
ny=gl_TexCoord[0].y;\
|
||||
y=texture2D(Ytex,vec2(nx,ny)).r;\
|
||||
u=texture2D(Utex,vec2(nx,ny)).r;\
|
||||
v=texture2D(Vtex,vec2(nx,ny)).r;\
|
||||
y=1.1643*(y-0.0625);\
|
||||
u=u-0.5;\
|
||||
v=v-0.5;\
|
||||
r=y+1.5958*v;\
|
||||
g=y-0.39173*u-0.81290*v;\
|
||||
b=y+2.017*u;\
|
||||
gl_FragColor=vec4(r,g,b,1.0);\
|
||||
}";
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Revision: 1.19 $
|
||||
* $Date: 2010/02/05 15:14:14 $
|
||||
*
|
||||
* $Revision: 1.20 $
|
||||
* $Date: 2010/07/15 12:25:59 $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -85,6 +85,9 @@ void NSApplicationLoad();
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_syswm.h>
|
||||
|
||||
/* splashscreen (xsedmik) */
|
||||
#include "video_display/splashscreen.h"
|
||||
|
||||
#define MAGIC_SDL DISPLAY_SDL_ID
|
||||
#define FOURCC_UYVY 0x59565955
|
||||
|
||||
@@ -111,11 +114,12 @@ struct state_sdl {
|
||||
int frames;
|
||||
|
||||
SDL_Surface *sdl_screen;
|
||||
SDL_Rect src_rect;
|
||||
SDL_Rect dst_rect;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int width;
|
||||
int height;
|
||||
unsigned int x_width;
|
||||
unsigned int x_height;
|
||||
double bpp;
|
||||
int src_linesize;
|
||||
int dst_linesize;
|
||||
@@ -129,6 +133,8 @@ struct state_sdl {
|
||||
unsigned fs:1;
|
||||
};
|
||||
|
||||
inline int toggleFullscreen(struct state_sdl *s);
|
||||
inline void loadSplashscreen(struct state_sdl *s);
|
||||
inline void copyline64(unsigned char *dst, unsigned char *src, int len);
|
||||
inline void copyline128(unsigned char *dst, unsigned char *src, int len);
|
||||
inline void copylinev210(unsigned char *dst, unsigned char *src, int len);
|
||||
@@ -136,31 +142,186 @@ inline void copyliner10k(struct state_sdl *s, unsigned char *dst, unsigned char
|
||||
void copylineRGBA(struct state_sdl *s, unsigned char *dst, unsigned char *src, int len);
|
||||
void deinterlace(struct state_sdl *s, unsigned char *buffer);
|
||||
void show_help(void);
|
||||
|
||||
extern int should_exit;
|
||||
|
||||
int
|
||||
display_sdl_handle_events(void *arg)
|
||||
{
|
||||
SDL_Event sdl_event;
|
||||
struct state_sdl *s = arg;
|
||||
while (SDL_PollEvent(&sdl_event)) {
|
||||
switch (sdl_event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "q")) {
|
||||
should_exit = 1;
|
||||
platform_sem_post(&s->semaphore);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
/**
|
||||
* Load splashscreen
|
||||
* Function loads graphic data from header file "splashscreen.h", where are
|
||||
* stored splashscreen data in RGB format. Thereafter are data written into
|
||||
* the temporary SDL_Surface. At the end of the function are displayed on
|
||||
* the screen.
|
||||
*
|
||||
* @since 18-02-2010, xsedmik
|
||||
* @param s Structure contains the current settings
|
||||
*/
|
||||
void loadSplashscreen(struct state_sdl *s) {
|
||||
|
||||
unsigned int x_coord;
|
||||
unsigned int y_coord;
|
||||
char pixel[3];
|
||||
SDL_Surface* image;
|
||||
SDL_Rect splash_src;
|
||||
SDL_Rect splash_dest;
|
||||
|
||||
// create a temporary SDL_Surface with the settings of displaying surface
|
||||
image = SDL_DisplayFormat(s->sdl_screen);
|
||||
SDL_LockSurface(image);
|
||||
|
||||
// load splash data
|
||||
for (y_coord = 0; y_coord < splash_height; y_coord++) {
|
||||
for (x_coord = 0; x_coord < splash_width; x_coord++) {
|
||||
|
||||
HEADER_PIXEL(splash_data,pixel);
|
||||
Uint32 color = SDL_MapRGB(image->format, pixel[0], pixel[1], pixel[2]);
|
||||
|
||||
switch(image->format->BytesPerPixel) {
|
||||
case 1: // Assuming 8-bpp
|
||||
{
|
||||
Uint8 *bufp;
|
||||
bufp = (Uint8 *)image->pixels + y_coord*image->pitch + x_coord;
|
||||
*bufp = color;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // Probably 15-bpp or 16-bpp
|
||||
{
|
||||
Uint16 *bufp;
|
||||
bufp = (Uint16 *)image->pixels + y_coord*image->pitch/2 + x_coord;
|
||||
*bufp = color;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // Slow 24-bpp mode, usually not used
|
||||
{
|
||||
Uint8 *bufp;
|
||||
bufp = (Uint8 *)image->pixels + y_coord*image->pitch +
|
||||
x_coord*image->format->BytesPerPixel;
|
||||
*(bufp+image->format->Rshift/8) = pixel[0];
|
||||
*(bufp+image->format->Gshift/8) = pixel[1];
|
||||
*(bufp+image->format->Bshift/8) = pixel[2];
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: // Probably 32-bpp
|
||||
{
|
||||
Uint32 *bufp;
|
||||
bufp = (Uint32 *)image->pixels + y_coord*image->pitch/4 + x_coord;
|
||||
*bufp = color;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(image);
|
||||
|
||||
// place loaded splash on the right position (center of screen)
|
||||
splash_src.x = 0;
|
||||
splash_src.y = 0;
|
||||
splash_src.w = splash_width;
|
||||
splash_src.h = splash_height;
|
||||
|
||||
if (s->fs) {
|
||||
splash_dest.x = (int)((s->x_width - splash_src.w) / 2);
|
||||
splash_dest.y = (int)((s->x_height - splash_src.h) / 2);
|
||||
|
||||
}
|
||||
else {
|
||||
splash_dest.x = (int)((s->width - splash_src.w) / 2);
|
||||
splash_dest.y = (int)((s->height - splash_src.h) / 2);
|
||||
|
||||
}
|
||||
splash_dest.w = splash_width;
|
||||
splash_dest.h = splash_height;
|
||||
|
||||
SDL_BlitSurface(image, &splash_src, s->sdl_screen, &splash_dest);
|
||||
SDL_Flip(s->sdl_screen);
|
||||
SDL_FreeSurface(image);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function toggles between fullscreen and window display mode
|
||||
*
|
||||
* @since 23-03-2010, xsedmik
|
||||
* @param s Structure contains the current settings
|
||||
* @return zero value everytime
|
||||
*/
|
||||
int toggleFullscreen(struct state_sdl *s) {
|
||||
|
||||
if(s->fs) {
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", s->width, s->height);
|
||||
s->sdl_screen = SDL_SetVideoMode(s->width, s->height, 0, SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
|
||||
// Set the begining of the video rectangle
|
||||
s->dst_rect.y = 0;
|
||||
s->dst_rect.x = 0;
|
||||
|
||||
s->fs = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", s->x_width, s->x_height);
|
||||
s->sdl_screen = SDL_SetVideoMode(s->x_width, s->x_height, 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
|
||||
return 0;
|
||||
// Set the begining of the video rectangle
|
||||
if ((int)s->x_height > s->height) {
|
||||
s->dst_rect.y = (s->x_height - s->height) / 2;
|
||||
}
|
||||
if ((int)s->x_width > s->width) {
|
||||
s->dst_rect.x = (s->x_width - s->width) / 2;
|
||||
}
|
||||
|
||||
s->fs = 1;
|
||||
}
|
||||
if(s->sdl_screen == NULL){
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", s->x_width, s->x_height);
|
||||
free(s);
|
||||
exit(128);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles outer events like a keyboard press
|
||||
* Responds to key:<br/>
|
||||
* <table>
|
||||
* <td><tr>q</tr><tr>terminates program</tr></td>
|
||||
* <td><tr>f</tr><tr>toggles between fullscreen and windowed display mode</tr></td>
|
||||
* </table>
|
||||
*
|
||||
* @since 08-04-2010, xsedmik
|
||||
* @param arg Structure (state_sdl) contains the current settings
|
||||
* @return zero value everytime
|
||||
*/
|
||||
int display_sdl_handle_events(void * arg) {
|
||||
|
||||
struct state_sdl * s = (struct state_sdl *) arg;
|
||||
|
||||
SDL_Event sdl_event;
|
||||
|
||||
while (SDL_PollEvent(&sdl_event)) {
|
||||
switch (sdl_event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "q")) {
|
||||
should_exit = 1;
|
||||
platform_sem_post(&s->semaphore);
|
||||
}
|
||||
if (!strcmp(SDL_GetKeyName(sdl_event.key.keysym.sym), "f")) {
|
||||
toggleFullscreen(s);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
should_exit = 1;
|
||||
platform_sem_post(&s->semaphore);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +340,7 @@ deinterlace(struct state_sdl *s, unsigned char *buffer)
|
||||
bline3 = buffer + 3*pitch;
|
||||
for(i=0; i < s->dst_linesize; i+=16) {
|
||||
/* preload first two lines */
|
||||
asm volatile(
|
||||
asm volatile(
|
||||
"movdqa (%0), %%xmm0\n"
|
||||
"movdqa (%1), %%xmm1\n"
|
||||
:
|
||||
@@ -439,7 +600,7 @@ display_thread_sdl(void *arg)
|
||||
int height=0;
|
||||
|
||||
if(s->use_file && s->filename) {
|
||||
FILE *in;
|
||||
FILE *in;
|
||||
buff = (unsigned char*)malloc(s->src_linesize*s->height);
|
||||
in = fopen(s->filename, "r");
|
||||
if(!in || fread(buff, s->src_linesize*s->height, 1, in) == 0) {
|
||||
@@ -464,6 +625,7 @@ display_thread_sdl(void *arg)
|
||||
}
|
||||
|
||||
while (!should_exit) {
|
||||
|
||||
display_sdl_handle_events(s);
|
||||
|
||||
if(!(s->use_file && buff)) {
|
||||
@@ -562,7 +724,6 @@ display_thread_sdl(void *arg)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(s->deinterlace) {
|
||||
if(s->rgb) {
|
||||
@@ -612,24 +773,16 @@ show_help(void)
|
||||
show_codec_help();
|
||||
}
|
||||
|
||||
void *
|
||||
display_sdl_init(char *fmt)
|
||||
{
|
||||
|
||||
void * display_sdl_init(char *fmt) {
|
||||
|
||||
struct state_sdl *s;
|
||||
int ret;
|
||||
|
||||
SDL_Surface *image;
|
||||
SDL_Surface *temp;
|
||||
SDL_Rect splash_src;
|
||||
SDL_Rect splash_dest;
|
||||
|
||||
int itemp;
|
||||
unsigned int utemp;
|
||||
Window wtemp;
|
||||
|
||||
unsigned int x_res_x;
|
||||
unsigned int x_res_y;
|
||||
|
||||
const struct codec_info_t *c_info=NULL;
|
||||
|
||||
unsigned int i;
|
||||
@@ -737,19 +890,17 @@ display_sdl_init(char *fmt)
|
||||
|
||||
/* Get XWindows resolution */
|
||||
ret = XGetGeometry(s->display, DefaultRootWindow(s->display), &wtemp, &itemp,
|
||||
&itemp, &x_res_x, &x_res_y, &utemp, &utemp);
|
||||
&itemp, &s->x_width, &s->x_height, &utemp, &utemp);
|
||||
|
||||
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", x_res_x, x_res_y);
|
||||
if(s->fs)
|
||||
s->sdl_screen = SDL_SetVideoMode(x_res_x, x_res_y, 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
else {
|
||||
x_res_x = s->width;
|
||||
x_res_y = s->height;
|
||||
s->sdl_screen = SDL_SetVideoMode(x_res_x, x_res_y, 0, SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
if(s->fs) {
|
||||
s->sdl_screen = SDL_SetVideoMode(s->x_width, s->x_height, 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", s->x_width, s->x_height);
|
||||
} else {
|
||||
s->sdl_screen = SDL_SetVideoMode(s->width, s->height, 0, SDL_HWSURFACE | SDL_DOUBLEBUF);
|
||||
fprintf(stdout,"Setting video mode %dx%d.\n", s->width, s->height);
|
||||
}
|
||||
if(s->sdl_screen == NULL){
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", x_res_x, x_res_y);
|
||||
fprintf(stderr,"Error setting video mode %dx%d!\n", s->x_width, s->x_height);
|
||||
free(s);
|
||||
exit(128);
|
||||
}
|
||||
@@ -793,19 +944,17 @@ display_sdl_init(char *fmt)
|
||||
s->dst_rect.w = s->width;
|
||||
s->dst_rect.h = s->height;
|
||||
|
||||
if ((int)x_res_x > s->width) {
|
||||
s->dst_rect.x = (x_res_x - s->width) / 2;
|
||||
} else if((int)x_res_x < s->width){
|
||||
s->dst_rect.w = x_res_x;
|
||||
}
|
||||
if ((int)x_res_y > s->height) {
|
||||
s->dst_rect.y = (x_res_y - s->height) / 2;
|
||||
} else if((int)x_res_y < s->height) {
|
||||
s->dst_rect.h = x_res_y;
|
||||
}
|
||||
|
||||
s->src_rect.w = s->width;
|
||||
s->src_rect.h = s->height;
|
||||
if (((int)s->x_width > s->width) && (s->fs)) {
|
||||
s->dst_rect.x = (s->x_width - s->width) / 2;
|
||||
} else if((int)s->x_width < s->width){
|
||||
s->dst_rect.w = s->x_width;
|
||||
}
|
||||
if (((int)s->x_height > s->height) && (s->fs)) {
|
||||
s->dst_rect.y = (s->x_height - s->height) / 2;
|
||||
} else if((int)s->x_height < s->height) {
|
||||
s->dst_rect.h = s->x_height;
|
||||
}
|
||||
|
||||
fprintf(stdout,"Setting SDL rect %dx%d - %d,%d.\n", s->dst_rect.w, s->dst_rect.h, s->dst_rect.x,
|
||||
s->dst_rect.y);
|
||||
@@ -813,34 +962,8 @@ display_sdl_init(char *fmt)
|
||||
s->image_network = 0;
|
||||
s->image_display = 1;
|
||||
|
||||
temp = SDL_LoadBMP("/usr/share/uv-0.3.1/uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
temp = SDL_LoadBMP("/usr/local/share/uv-0.3.1/uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
temp = SDL_LoadBMP("uv_startup.bmp");
|
||||
if (temp == NULL) {
|
||||
printf("Unable to load splash bitmap: uv_startup.bmp.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (temp != NULL) {
|
||||
image = SDL_DisplayFormat(temp);
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
splash_src.x = 0;
|
||||
splash_src.y = 0;
|
||||
splash_src.w = image->w;
|
||||
splash_src.h = image->h;
|
||||
|
||||
splash_dest.x = (int)((x_res_x - splash_src.w) / 2);
|
||||
splash_dest.y = (int)((x_res_y - splash_src.h) / 2) + 60;
|
||||
splash_dest.w = image->w;
|
||||
splash_dest.h = image->h;
|
||||
|
||||
SDL_BlitSurface(image, &splash_src, s->sdl_screen, &splash_dest);
|
||||
SDL_Flip(s->sdl_screen);
|
||||
}
|
||||
// load splashscreen (xsedmik)
|
||||
loadSplashscreen(s);
|
||||
|
||||
if (pthread_create(&(s->thread_id), NULL, display_thread_sdl, (void *) s) != 0) {
|
||||
perror("Unable to create display thread\n");
|
||||
|
||||
4150
ultragrid/src/video_display/splashscreen.h
Normal file
4150
ultragrid/src/video_display/splashscreen.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user