Changeset 704:ca4d7f83b4c0 in mediastreamer2
- Timestamp:
- Oct 2, 2009 5:02:24 PM (4 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
linphone/mediastreamer2/src/videoout.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/mediastreamer2/src/videoout.c
r683 r704 255 255 MSDisplayEvent last_rsz; 256 256 uint8_t *rgb; 257 uint8_t *black; 258 int last_rect_w; 259 int last_rect_h; 257 260 int rgb_len; 258 261 struct SwsContext *sws; … … 347 350 wd->fb.planes[3]=NULL; 348 351 if (wd->rgb) ms_free(wd->rgb); 352 if (wd->black) ms_free(wd->black); 349 353 wd->rgb=NULL; 354 wd->black=NULL; 350 355 wd->rgb_len=0; 351 356 sws_freeContext(wd->sws); 352 357 wd->sws=NULL; 358 wd->last_rect_w=0; 359 wd->last_rect_h=0; 353 360 } 354 361 else … … 390 397 if (wd->fb.planes[0]) ms_free(wd->fb.planes[0]); 391 398 if (wd->rgb) ms_free(wd->rgb); 399 if (wd->black) ms_free(wd->black); 392 400 ysize=wd->fb.w*wd->fb.h; 393 401 usize=ysize/4; … … 403 411 wd->rgb_len=ysize*3; 404 412 wd->rgb=(uint8_t*)ms_malloc0(wd->rgb_len); 413 wd->black = (uint8_t*)ms_malloc0(wd->rgb_len); 414 wd->last_rect_w=0; 415 wd->last_rect_h=0; 405 416 return TRUE; 406 417 } … … 430 441 ms_error("Error in 420->rgb sws_scale()."); 431 442 } 443 } 444 445 int gcd(int m, int n) 446 { 447 if(n == 0) 448 return m; 449 else 450 return gcd(n, m % n); 451 } 452 453 void reduce(int *num, int *denom) 454 { 455 int divisor = gcd(*num, *denom); 456 *num /= divisor; 457 *denom /= divisor; 432 458 } 433 459 … … 448 474 bi.biSize=sizeof(bi); 449 475 GetClientRect(wd->window,&rect); 450 /* 451 bi.biWidth=wd->fb.w; 452 bi.biHeight=wd->fb.h; 453 bi.biPlanes=3; 454 bi.biBitCount=12; 455 bi.biCompression=MAKEFOURCC('I','4','2','0'); 456 bi.biSizeImage=(wd->fb.w*wd->fb.h*3)/2; 457 */ 476 458 477 bi.biWidth=wd->fb.w; 459 478 bi.biHeight=wd->fb.h; … … 463 482 bi.biSizeImage=wd->rgb_len; 464 483 465 //if (bi.biHeight>rect.bottom) 466 // bi.biHeight=rect.bottom; 467 //bi.biSizeImage=(bi.biWidth*bi.biHeight)*3; 468 469 ret=DrawDibDraw(wd->ddh,hdc,0,0, 470 //bi.biWidth,bi.biHeight, 471 rect.right,rect.bottom, 484 if (wd->last_rect_w!=rect.right || wd->last_rect_h!=rect.bottom) 485 { 486 ret=DrawDibDraw(wd->ddh,hdc,00,00, 487 rect.right,rect.bottom, 488 &bi,wd->black, 489 0,0,bi.biWidth,bi.biHeight,0); 490 wd->last_rect_w=rect.right; 491 wd->last_rect_h=rect.bottom; 492 } 493 494 int ratiow=wd->fb.w; 495 int ratioh=wd->fb.h; 496 reduce(&ratiow, &ratioh); 497 int w = rect.right/ratiow*ratiow; 498 int h = rect.bottom/ratioh*ratioh; 499 500 if (h*ratiow>w*ratioh) 501 { 502 w = w; 503 h = w*ratioh/ratiow; 504 } 505 else 506 { 507 h = h; 508 w = h*ratiow/ratioh; 509 } 510 511 if (h*wd->fb.w!=w*wd->fb.h) 512 ms_error("wrong ratio"); 513 514 ret=DrawDibDraw(wd->ddh,hdc, 515 rect.right/2-(w/2), 516 rect.bottom/2-(h/2), 517 w, 518 h, 472 519 &bi,wd->rgb, 473 //0,0,rect.right,rect.bottom,0);474 520 0,0,bi.biWidth,bi.biHeight,0); 521 475 522 476 523 if (!ret) ms_error("DrawDibDraw failed."); … … 486 533 if (wd->fb.planes[0]) ms_free(wd->fb.planes[0]); 487 534 if (wd->rgb) ms_free(wd->rgb); 535 if (wd->black) ms_free(wd->black); 488 536 if (wd->sws) sws_freeContext(wd->sws); 489 537 ms_free(wd);
Note: See TracChangeset
for help on using the changeset viewer.
