Changeset 964:5b7763190f86 in mediastreamer2
- Timestamp:
- May 12, 2010 6:37:38 PM (3 years ago)
- Branch:
- default
- Location:
- src
- Files:
-
- 3 edited
-
drawdib-display.c (modified) (12 diffs)
-
nowebcam.c (modified) (1 diff)
-
videostream.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/drawdib-display.c
r963 r964 27 27 #include "ffmpeg-priv.h" 28 28 29 #define SCALE_FACTOR 0.1 f29 #define SCALE_FACTOR 0.16f 30 30 #define SELVIEW_POS_INACTIVE -100.0 31 31 #include <Vfw.h> … … 35 35 size_t rgblen; 36 36 MSVideoSize dsize; 37 MSVideoSize ssize; 37 38 struct ms_SwsContext *sws; 38 39 }Yuv2RgbCtx; … … 43 44 ctx->dsize.width=0; 44 45 ctx->dsize.height=0; 46 ctx->ssize.width=0; 47 ctx->ssize.height=0; 45 48 ctx->sws=NULL; 46 49 } … … 56 59 ctx->sws=NULL; 57 60 } 61 ctx->dsize.width=0; 62 ctx->dsize.height=0; 63 ctx->ssize.width=0; 64 ctx->ssize.height=0; 58 65 } 59 66 … … 64 71 SWS_FAST_BILINEAR, NULL, NULL, NULL); 65 72 ctx->dsize=dst; 73 ctx->ssize=src; 66 74 ctx->rgblen=dst.width*dst.height*3; 67 ctx->rgb=ms_malloc0(ctx->rgblen );75 ctx->rgb=ms_malloc0(ctx->rgblen+dst.width); 68 76 } 69 77 70 78 71 79 static void yuv2rgb_process(Yuv2RgbCtx *ctx, MSPicture *src, MSVideoSize dstsize){ 72 if (!ms_video_size_equal(dstsize,ctx->dsize)){ 73 MSVideoSize srcsize; 74 srcsize.width=src->w; 75 srcsize.height=src->h; 80 MSVideoSize srcsize; 81 82 srcsize.width=src->w; 83 srcsize.height=src->h; 84 if (!ms_video_size_equal(dstsize,ctx->dsize) || !ms_video_size_equal(srcsize,ctx->ssize)){ 76 85 yuv2rgb_prepare(ctx,srcsize,dstsize); 77 86 } … … 81 90 82 91 p=ctx->rgb+(dstsize.width*3*(dstsize.height-1)); 83 84 92 if (ms_sws_scale(ctx->sws,src->planes,src->strides, 0, 85 93 src->h, &p, &rgb_stride)<0){ … … 133 141 134 142 if (wd!=NULL){ 143 ms_message("Need repaint"); 144 wd->need_repaint=TRUE; 135 145 //wd->window_size.width=w; 136 146 //wd->window_size.height=h; … … 240 250 static void center_with_ratio(MSVideoSize wsize, MSVideoSize vsize, MSRect *rect){ 241 251 int w,h; 242 w=wsize.width & ~0x 1;252 w=wsize.width & ~0x3; 243 253 h=((w*vsize.height)/vsize.width) & ~0x1; 244 254 if (h>wsize.height){ 245 255 /*the height doesn't fit, so compute the width*/ 246 256 h=wsize.height & ~0x1; 247 w=((h*vsize.width)/vsize.height) & ~0x 1;257 w=((h*vsize.width)/vsize.height) & ~0x3; 248 258 } 249 259 rect->x=(wsize.width-w)/2; … … 260 270 psize.height=wsize.height*SCALE_FACTOR; 261 271 center_with_ratio(psize,orig_psize,localrect); 262 localrect->x=wsize.width-localrect->w ;263 localrect->y=wsize.height-localrect->h ;264 272 localrect->x=wsize.width-localrect->w-2; 273 localrect->y=wsize.height-localrect->h-2; 274 /* 265 275 ms_message("Compute layout result for\nwindow size=%ix%i\nvideo orig size=%ix%i\nlocal size=%ix%i\nlocal orig size=%ix%i\n" 266 276 "mainrect=%i,%i,%i,%i\tlocalrect=%i,%i,%i,%i", … … 268 278 mainrect->x,mainrect->y,mainrect->w,mainrect->h, 269 279 localrect->x,localrect->y,localrect->w,localrect->h); 280 */ 281 } 282 283 static void draw_local_view_frame(HDC hdc, MSVideoSize wsize, MSRect localrect){ 284 HGDIOBJ old_object = SelectObject(hdc, GetStockObject(WHITE_BRUSH)); 285 Rectangle(hdc, localrect.x-2, localrect.y-2, localrect.x+localrect.w+2, localrect.y+localrect.h+2); 286 SelectObject(hdc,old_object); 270 287 } 271 288 … … 345 362 lsize.width=localrect.w; 346 363 lsize.height=localrect.h; 347 364 348 365 if (local_im!=NULL) 349 366 yuv2rgb_process(&obj->locview,&localpic,lsize); 367 350 368 if (main_im!=NULL) 351 369 yuv2rgb_process(&obj->mainview,&mainpic,vsize); … … 356 374 return; 357 375 } 358 if (main_im){ 359 yuv2rgb_draw(&obj->mainview,obj->ddh,hdc,mainrect.x,mainrect.y); 360 } 361 if (local_im){ 362 yuv2rgb_draw(&obj->locview,obj->ddh,hdc,localrect.x,localrect.y); 363 } 376 364 377 if (obj->need_repaint){ 365 378 draw_background(hdc,wsize,mainrect); 366 379 obj->need_repaint=FALSE; 367 380 } 381 382 if (main_im!=NULL){ 383 yuv2rgb_draw(&obj->mainview,obj->ddh,hdc,mainrect.x,mainrect.y); 384 } 385 386 if (local_im!=NULL || main_im!=NULL){ 387 draw_local_view_frame(hdc,wsize,localrect); 388 yuv2rgb_draw(&obj->locview,obj->ddh,hdc,localrect.x,localrect.y); 389 } 390 368 391 ReleaseDC(NULL,hdc); 369 392 if (main_im!=NULL) -
src/nowebcam.c
r959 r964 1649 1649 uint8_t *jpgbuf; 1650 1650 int err; 1651 #ifndef WIN32 1651 1652 int fd=open(jpgpath,O_RDONLY); 1653 #else 1654 int fd=open(jpgpath,O_RDONLY|O_BINARY); 1655 #endif 1652 1656 if (fd!=-1){ 1653 1657 fstat(fd,&statbuf); -
src/videostream.c
r962 r964 185 185 stream->corner=val ? 0 : -1; 186 186 if (out){ 187 ms_filter_call_method(out,MS_VIDEO_ OUT_SET_CORNER,&stream->corner);187 ms_filter_call_method(out,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_CORNER,&stream->corner); 188 188 } 189 189 } … … 295 295 tmp=1; 296 296 ms_filter_call_method(stream->output,MS_FILTER_SET_VIDEO_SIZE,&disp_size); 297 ms_filter_call_method(stream->output,MS_VIDEO_ OUT_AUTO_FIT,&tmp);297 ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_ENABLE_AUTOFIT,&tmp); 298 298 ms_filter_call_method(stream->output,MS_FILTER_SET_PIX_FMT,&format); 299 ms_filter_call_method(stream->output,MS_VIDEO_ OUT_SET_CORNER,&stream->corner);299 ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_CORNER,&stream->corner); 300 300 301 301 if (pt->recv_fmtp!=NULL) … … 358 358 unsigned long id; 359 359 if (stream->output){ 360 if (ms_filter_call_method(stream->output,MS_VIDEO_ OUT_GET_NATIVE_WINDOW_ID,&id)==0)360 if (ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID,&id)==0) 361 361 return id; 362 362 } … … 555 555 return -1; 556 556 } 557 #ifndef WIN32 557 558 stream->output=ms_filter_new(MS_VIDEO_OUT_ID); 558 559 #else 560 stream->output=ms_filter_new(MS_DRAWDIB_DISPLAY_ID); 561 #endif 559 562 /*force the decoder to output YUV420P */ 560 563 format=MS_YUV420P;
Note: See TracChangeset
for help on using the changeset viewer.
