* fixed wrong destriptor set (UDP)
* SDL - read display resolution only on first time
This commit is contained in:
Martin Pulec
2011-08-29 09:52:01 +02:00
parent d123947c9f
commit da2b0f49bb
3 changed files with 24 additions and 18 deletions

View File

@@ -816,7 +816,7 @@ void udp_fd_zero(void)
void udp_fd_zero_r(struct udp_fd_r *fd_struct)
{
FD_ZERO(&fd_struct->rfd);
max_fd = 0;
fd_struct->max_fd = 0;
}
/**

View File

@@ -441,6 +441,11 @@ void *vidcap_testcard_init(char *fmt, unsigned int flags)
return NULL;
}
s->frame.width = atoi(tmp);
if(s->frame.width % 2 != 0) {
fprintf(stderr, "Width must be multiple of 2.\n");
free(s);
return NULL;
}
tmp = strtok(NULL, ":");
if (!tmp) {
fprintf(stderr, "Wrong format for testcard '%s'\n", fmt);
@@ -568,13 +573,13 @@ void *vidcap_testcard_init(char *fmt, unsigned int flags)
}
s->data = s->surface->pixels;
if (codec == UYVY || codec == v210 || codec == Vuy2) {
rgb2yuv422((unsigned char *) s->data, s->frame.width,
rgb2yuv422((unsigned char *) s->data, aligned_x,
s->frame.height);
}
if (codec == v210) {
s->data =
(char *)tov210((unsigned char *) s->data, s->frame.width,
(char *)tov210((unsigned char *) s->data, aligned_x,
aligned_x, s->frame.height, bpp);
}

View File

@@ -100,6 +100,7 @@ struct state_sdl {
volatile int buffer_writable;
SDL_cond *buffer_writable_cond;
SDL_mutex *buffer_writable_lock;
int screen_w, screen_h;
};
extern int should_exit;
@@ -411,11 +412,9 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height,
codec_t color_spec, double fps, int aux)
{
struct state_sdl *s = (struct state_sdl *)state;
const SDL_VideoInfo *video_info;
int h_align = 0;
unsigned int x_res_x, x_res_y;
unsigned int screen_x, screen_y;
int i;
@@ -437,12 +436,9 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height,
fprintf(stdout, "Reconfigure to size %dx%d\n", s->frame.width,
s->frame.height);
video_info = SDL_GetVideoInfo();
x_res_x = video_info->current_w;
x_res_y = video_info->current_h;
screen_x = x_res_x;
screen_y = x_res_y;
x_res_x = s->screen_w;
x_res_y = s->screen_h;
fprintf(stdout, "Setting video mode %dx%d.\n", x_res_x, x_res_y);
if (s->fs)
@@ -528,15 +524,15 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height,
}
} else if(!s->rgb && s->fs && (s->frame.width != x_res_x || s->frame.height != x_res_y)) {
double frame_aspect = (double) s->frame.width / s->frame.height;
double screen_aspect = (double) screen_x / screen_y;
double screen_aspect = (double) s->screen_w / s->screen_h;
if(screen_aspect > frame_aspect) {
s->dst_rect.h = screen_y;
s->dst_rect.w = screen_y * frame_aspect;
s->dst_rect.x = ((int) screen_x - s->dst_rect.w) / 2;
s->dst_rect.h = s->screen_h;
s->dst_rect.w = s->screen_h * frame_aspect;
s->dst_rect.x = ((int) s->screen_w - s->dst_rect.w) / 2;
} else {
s->dst_rect.w = screen_x;
s->dst_rect.h = screen_x / frame_aspect;
s->dst_rect.y = ((int) screen_y - s->dst_rect.h) / 2;
s->dst_rect.w = s->screen_w;
s->dst_rect.h = s->screen_w / frame_aspect;
s->dst_rect.y = ((int) s->screen_h - s->dst_rect.h) / 2;
}
}
@@ -598,6 +594,7 @@ void *display_sdl_init(char *fmt)
{
struct state_sdl *s;
int ret;
const SDL_VideoInfo *video_info;
unsigned int i;
@@ -702,6 +699,10 @@ void *display_sdl_init(char *fmt)
return NULL;
}
video_info = SDL_GetVideoInfo();
s->screen_w = video_info->current_w;
s->screen_h = video_info->current_h;
if (fmt != NULL) {
reconfigure_screen(s, s->frame.width, s->frame.height,
s->codec_info->codec, s->frame.fps,