Changeset 897:6d16408a1ff2 in mediastreamer2
- Timestamp:
- Feb 26, 2010 1:24:01 PM (3 years ago)
- Branch:
- default
- Parents:
- 895:29e9357e6fb3 (diff), 896:92f3fa1b08d7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
-
src/videoout.c (modified) (14 diffs)
-
src/videoout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/videoout.c
r895 r897 40 40 return d->desc->pollevent(d,ev); 41 41 else return FALSE; 42 } 43 44 static int gcd(int m, int n) 45 { 46 if(n == 0) 47 return m; 48 else 49 return gcd(n, m % n); 50 } 51 52 static void reduce(int *num, int *denom) 53 { 54 int divisor = gcd(*num, *denom); 55 *num /= divisor; 56 *denom /= divisor; 42 57 } 43 58 … … 55 70 56 71 float sv_scalefactor; 72 MSVideoSize screen_size; 57 73 } SdlDisplay; 58 74 … … 109 125 static int sdl_create_window(SdlDisplay *wd, int w, int h){ 110 126 static bool_t once=TRUE; 127 uint32_t flags = SDL_ANYFORMAT | SDL_DOUBLEBUF | SDL_RESIZABLE; 128 const SDL_VideoInfo *info; 129 info =SDL_GetVideoInfo(); 130 if (info->wm_available) { 131 ms_message("Using window manager"); 132 } 133 if (info->hw_available) { 134 ms_message("hw surface available (%dk memory)", info->video_mem); 135 flags |= SDL_HWSURFACE; 136 } 137 else 138 flags |= SDL_SWSURFACE; 111 139 112 wd->sdl_screen = SDL_SetVideoMode(w,h, 0,SDL_HWSURFACE|SDL_RESIZABLE); 140 if (info->blit_hw) { 141 ms_message("hw surface available (%dk memory)", info->video_mem); 142 flags |= SDL_ASYNCBLIT; 143 } 144 if (info->blit_hw_CC) 145 ms_message("Colorkey blits between hw surfaces: accelerated"); 146 if (info->blit_hw_A) 147 ms_message("Alpha blits between hw surfaces: accelerated"); 148 if (info->blit_sw) 149 ms_message("Copy blits from sw to hw surfaces: accelerated"); 150 if (info->blit_hw_CC) 151 ms_message("Colorkey blits between sw to hw surfaces: accelerated"); 152 if (info->blit_hw_A) 153 ms_message("Alpha blits between sw to hw surfaces: accelerated"); 154 155 wd->sdl_screen = SDL_SetVideoMode(wd->screen_size.width,wd->screen_size.height, 0,flags); 113 156 if (wd->sdl_screen == NULL ) { 114 157 ms_warning("no hardware for video mode: %s\n", 115 SDL_GetError()); 116 } 117 if (wd->sdl_screen == NULL ) 118 wd->sdl_screen = SDL_SetVideoMode(w,h, 0,SDL_SWSURFACE|SDL_RESIZABLE); 119 if (wd->sdl_screen == NULL ) { 120 ms_warning("Couldn't set video mode: %s\n", 121 SDL_GetError()); 122 return -1; 158 SDL_GetError()); 123 159 } 124 160 if (wd->sdl_screen->flags & SDL_HWSURFACE) ms_message("SDL surface created in hardware"); … … 127 163 once=FALSE; 128 164 } 129 ms_message("Using yuv overlay.");130 165 wd->lay=SDL_CreateYUVOverlay(w , h ,SDL_YV12_OVERLAY,wd->sdl_screen); 131 166 if (wd->lay==NULL){ … … 147 182 int i; 148 183 if (wd==NULL){ 184 char driver[128]; 149 185 /* Initialize the SDL library */ 150 186 wd=(SdlDisplay*)ms_new0(SdlDisplay,1); … … 157 193 } 158 194 wd->sdl_initialized=TRUE; 195 if (SDL_VideoDriverName(driver, sizeof(driver))){ 196 ms_message("Video driver: %s", driver); 197 } 159 198 ms_mutex_init(&wd->sdl_mutex,NULL); 160 199 ms_mutex_lock(&wd->sdl_mutex); 200 wd->screen_size.width = fbuf->w; 201 wd->screen_size.height = fbuf->h; 202 161 203 }else { 162 204 ms_mutex_lock(&wd->sdl_mutex); … … 170 212 } 171 213 wd->filter = f; 172 214 173 215 i=sdl_create_window(wd, fbuf->w, fbuf->h); 174 216 if (i==0){ … … 209 251 SdlDisplay *wd = (SdlDisplay*)obj->data; 210 252 SDL_Rect rect; 253 int ratiow; 254 int ratioh; 255 int w; 256 int h; 257 211 258 rect.x=0; 212 259 rect.y=0; 213 260 ms_mutex_lock(&wd->sdl_mutex); 214 rect.w=wd->lay->w; 215 rect.h=wd->lay->h; 261 262 ratiow=wd->lay->w; 263 ratioh=wd->lay->h; 264 reduce(&ratiow, &ratioh); 265 w = wd->screen_size.width/ratiow*ratiow; 266 h = wd->screen_size.height/ratioh*ratioh; 267 268 if (h*ratiow>w*ratioh) 269 { 270 w = w; 271 h = w*ratioh/ratiow; 272 } 273 else 274 { 275 h = h; 276 w = h*ratiow/ratioh; 277 } 278 279 if (h*wd->lay->w!=w*wd->lay->h) 280 ms_error("wrong ratio"); 281 282 rect.x = (wd->screen_size.width-w)/2; 283 rect.y = (wd->screen_size.height-h)/2; 284 rect.w = w; 285 rect.h = h; 216 286 SDL_DisplayYUVOverlay(wd->lay,&rect); 217 287 ms_mutex_unlock(&wd->sdl_mutex); … … 231 301 ev->w=event.resize.w; 232 302 ev->h=event.resize.h; 303 wd->screen_size.width = event.resize.w; 304 wd->screen_size.height = event.resize.h; 233 305 return TRUE; 234 306 break; … … 516 588 ms_error("Error in 420->rgb ms_sws_scale()."); 517 589 } 518 }519 520 static int gcd(int m, int n)521 {522 if(n == 0)523 return m;524 else525 return gcd(n, m % n);526 }527 528 static void reduce(int *num, int *denom)529 {530 int divisor = gcd(*num, *denom);531 *num /= divisor;532 *denom /= divisor;533 590 } 534 591 … … 924 981 } 925 982 983 static void re_vsize(VideoOut *s, MSVideoSize *sz){ 984 ms_message("Windows size set to %ix%i",sz->width,sz->height); 985 } 986 987 926 988 static void set_vsize(VideoOut *s, MSVideoSize *sz){ 927 989 s->fbuf.w=sz->width & ~0x1; … … 1007 1069 1008 1070 static int video_out_handle_resizing(MSFilter *f, void *data){ 1071 /* to be removed */ 1072 } 1073 1074 static int _video_out_handle_resizing(MSFilter *f, void *data){ 1009 1075 VideoOut *s=(VideoOut*)f->data; 1010 1076 MSDisplay *disp=s->display; … … 1018 1084 ms_filter_lock(f); 1019 1085 if (s->ready){ 1020 set_vsize(s,&sz);1086 re_vsize(s,&sz); 1021 1087 s->ready=FALSE; 1022 1088 } … … 1038 1104 int update=0; 1039 1105 int update_selfview=0; 1040 1106 int i; 1107 1108 for(i=0;i<100;++i){ 1109 _video_out_handle_resizing(f, NULL); 1110 } 1041 1111 ms_filter_lock(f); 1042 1112 if (!obj->ready) video_out_prepare(f); -
src/videoout.c
r896 r897 1226 1226 corner.planes[3]=0; 1227 1227 ms_display_lock(obj->display); 1228 yuv_buf_copy(obj->local_pic.planes,obj->local_pic.strides,1228 ms_yuv_buf_copy(obj->local_pic.planes,obj->local_pic.strides, 1229 1229 corner.planes,corner.strides,roi); 1230 1230 ms_display_unlock(obj->display);
Note: See TracChangeset
for help on using the changeset viewer.
