Changeset 964:5b7763190f86 in mediastreamer2


Ignore:
Timestamp:
May 12, 2010 6:37:38 PM (3 years ago)
Author:
unknown <smorlat@…>
Branch:
default
Message:

new display is now working

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/drawdib-display.c

    r963 r964  
    2727#include "ffmpeg-priv.h" 
    2828 
    29 #define SCALE_FACTOR 0.1f 
     29#define SCALE_FACTOR 0.16f 
    3030#define SELVIEW_POS_INACTIVE -100.0 
    3131#include <Vfw.h> 
     
    3535        size_t rgblen; 
    3636        MSVideoSize dsize; 
     37        MSVideoSize ssize; 
    3738        struct ms_SwsContext *sws; 
    3839}Yuv2RgbCtx; 
     
    4344        ctx->dsize.width=0; 
    4445        ctx->dsize.height=0; 
     46        ctx->ssize.width=0; 
     47        ctx->ssize.height=0; 
    4548        ctx->sws=NULL; 
    4649} 
     
    5659                ctx->sws=NULL; 
    5760        } 
     61        ctx->dsize.width=0; 
     62        ctx->dsize.height=0; 
     63        ctx->ssize.width=0; 
     64        ctx->ssize.height=0; 
    5865} 
    5966 
     
    6471                        SWS_FAST_BILINEAR, NULL, NULL, NULL); 
    6572        ctx->dsize=dst; 
     73        ctx->ssize=src; 
    6674        ctx->rgblen=dst.width*dst.height*3; 
    67         ctx->rgb=ms_malloc0(ctx->rgblen); 
     75        ctx->rgb=ms_malloc0(ctx->rgblen+dst.width); 
    6876} 
    6977 
    7078 
    7179static 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)){       
    7685                yuv2rgb_prepare(ctx,srcsize,dstsize); 
    7786        } 
     
    8190 
    8291                p=ctx->rgb+(dstsize.width*3*(dstsize.height-1)); 
    83                  
    8492                if (ms_sws_scale(ctx->sws,src->planes,src->strides, 0, 
    8593                                        src->h, &p, &rgb_stride)<0){ 
     
    133141                                 
    134142                                if (wd!=NULL){ 
     143                                        ms_message("Need repaint"); 
     144                                        wd->need_repaint=TRUE; 
    135145                                        //wd->window_size.width=w; 
    136146                                        //wd->window_size.height=h; 
     
    240250static void center_with_ratio(MSVideoSize wsize, MSVideoSize vsize, MSRect *rect){ 
    241251        int w,h; 
    242         w=wsize.width & ~0x1; 
     252        w=wsize.width & ~0x3; 
    243253        h=((w*vsize.height)/vsize.width) & ~0x1; 
    244254        if (h>wsize.height){ 
    245255                /*the height doesn't fit, so compute the width*/ 
    246256                h=wsize.height & ~0x1; 
    247                 w=((h*vsize.width)/vsize.height) & ~0x1; 
     257                w=((h*vsize.width)/vsize.height) & ~0x3; 
    248258        } 
    249259        rect->x=(wsize.width-w)/2; 
     
    260270        psize.height=wsize.height*SCALE_FACTOR; 
    261271        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/* 
    265275        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" 
    266276                "mainrect=%i,%i,%i,%i\tlocalrect=%i,%i,%i,%i", 
     
    268278                mainrect->x,mainrect->y,mainrect->w,mainrect->h, 
    269279                localrect->x,localrect->y,localrect->w,localrect->h); 
     280*/ 
     281} 
     282 
     283static 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); 
    270287} 
    271288 
     
    345362        lsize.width=localrect.w; 
    346363        lsize.height=localrect.h; 
    347  
     364         
    348365        if (local_im!=NULL) 
    349366                yuv2rgb_process(&obj->locview,&localpic,lsize); 
     367         
    350368        if (main_im!=NULL) 
    351369                yuv2rgb_process(&obj->mainview,&mainpic,vsize); 
     
    356374                return; 
    357375        } 
    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 
    364377        if (obj->need_repaint){ 
    365378                draw_background(hdc,wsize,mainrect); 
    366379                obj->need_repaint=FALSE; 
    367380        } 
     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 
    368391        ReleaseDC(NULL,hdc); 
    369392        if (main_im!=NULL) 
  • src/nowebcam.c

    r959 r964  
    16491649        uint8_t *jpgbuf; 
    16501650        int err; 
     1651#ifndef WIN32 
    16511652        int fd=open(jpgpath,O_RDONLY); 
     1653#else 
     1654        int fd=open(jpgpath,O_RDONLY|O_BINARY); 
     1655#endif 
    16521656        if (fd!=-1){ 
    16531657                fstat(fd,&statbuf); 
  • src/videostream.c

    r962 r964  
    185185        stream->corner=val ? 0 : -1; 
    186186        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); 
    188188        } 
    189189} 
     
    295295        tmp=1; 
    296296        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); 
    298298        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); 
    300300 
    301301        if (pt->recv_fmtp!=NULL) 
     
    358358        unsigned long id; 
    359359        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) 
    361361                        return id; 
    362362        } 
     
    555555                return -1; 
    556556        } 
     557#ifndef WIN32 
    557558        stream->output=ms_filter_new(MS_VIDEO_OUT_ID); 
    558  
     559#else 
     560        stream->output=ms_filter_new(MS_DRAWDIB_DISPLAY_ID); 
     561#endif 
    559562        /*force the decoder to output YUV420P */ 
    560563        format=MS_YUV420P; 
Note: See TracChangeset for help on using the changeset viewer.