Changeset 965:6aad7bf5ca29 in mediastreamer2


Ignore:
Timestamp:
May 12, 2010 8:08:14 PM (3 years ago)
Author:
unknown <smorlat@…>
Branch:
default
Message:

add mirroring feature

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/mediastreamer2/msinterfaces.h

    r963 r965  
    2727/** whether the video window should be resized to the stream's resolution*/ 
    2828#define MS_VIDEO_DISPLAY_ENABLE_AUTOFIT \ 
    29         MS_FILTER_METHOD(MSFilterVideoDisplayInterface,0,bool_t) 
     29        MS_FILTER_METHOD(MSFilterVideoDisplayInterface,0,int) 
    3030 
    3131/**position of the local view */ 
  • include/mediastreamer2/msvideo.h

    r903 r965  
    150150                uint8_t *dst_planes[], const int dst_strides[3], MSVideoSize roi); 
    151151void ms_yuv_buf_mirror(YuvBuf *buf); 
     152void rgb24_mirror(uint8_t *buf, int w, int h, int linesize); 
    152153void rgb24_revert(uint8_t *buf, int w, int h, int linesize); 
    153154void rgb24_copy_revert(uint8_t *dstbuf, int dstlsz, 
  • src/drawdib-display.c

    r964 r965  
    7777 
    7878 
    79 static void yuv2rgb_process(Yuv2RgbCtx *ctx, MSPicture *src, MSVideoSize dstsize){ 
     79static void yuv2rgb_process(Yuv2RgbCtx *ctx, MSPicture *src, MSVideoSize dstsize, bool_t mirroring){ 
    8080        MSVideoSize srcsize; 
    8181         
     
    9494                        ms_error("Error in 420->rgb ms_sws_scale()."); 
    9595                } 
     96                if (mirroring) rgb24_mirror(ctx->rgb,dstsize.width,dstsize.height,dstsize.width*3); 
    9697        } 
    9798} 
     
    108109                bi.biCompression=BI_RGB; 
    109110                bi.biSizeImage=ctx->rgblen; 
    110                 DrawDibDraw(ddh,hdc,dstx,dsty,ctx->dsize.width,ctx->dsize.height,&bi,ctx->rgb, 
     111                DrawDibDraw(ddh,hdc,dstx,dsty,-1,-1,&bi,ctx->rgb, 
    111112                        0,0,ctx->dsize.width,ctx->dsize.height,0); 
    112113        } 
     
    121122        Yuv2RgbCtx locview; 
    122123        bool_t need_repaint; 
     124        bool_t autofit; 
     125        bool_t mirroring; 
    123126}DDDisplay; 
    124127 
     
    209212        yuv2rgb_init(&obj->locview); 
    210213        obj->need_repaint=FALSE; 
     214        obj->autofit=TRUE; 
     215        obj->mirroring=FALSE; 
    211216        f->data=obj; 
    212217} 
     
    353358        if (f->inputs[0]!=NULL && (main_im=ms_queue_peek_last(f->inputs[0]))!=NULL) { 
    354359                if (yuv_buf_init_from_mblk(&mainpic,main_im)==0){ 
     360                        if (obj->autofit && (obj->vsize.width!=mainpic.w || obj->vsize.height!=mainpic.h) 
     361                                && (mainpic.w>wsize.width || mainpic.h>wsize.height)){ 
     362                                RECT cur; 
     363                                ms_message("Detected video resolution changed, resizing window"); 
     364                                GetWindowRect(obj->window,&cur); 
     365                                wsize.width=mainpic.w; 
     366                                wsize.height=mainpic.h; 
     367                                MoveWindow(obj->window,cur.left, cur.top, wsize.width, wsize.height,TRUE); 
     368                        } 
    355369                        obj->vsize.width=mainpic.w; 
    356370                        obj->vsize.height=mainpic.h; 
     
    364378         
    365379        if (local_im!=NULL) 
    366                 yuv2rgb_process(&obj->locview,&localpic,lsize); 
    367          
     380                yuv2rgb_process(&obj->locview,&localpic,lsize,!mblk_get_precious_flag(local_im)); 
     381 
    368382        if (main_im!=NULL) 
    369                 yuv2rgb_process(&obj->mainview,&mainpic,vsize); 
     383                yuv2rgb_process(&obj->mainview,&mainpic,vsize,obj->mirroring && !mblk_get_precious_flag(main_im)); 
    370384 
    371385        hdc=GetDC(obj->window); 
     
    385399         
    386400        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); 
     401                if (obj->locview.rgb!=NULL){ 
     402                        draw_local_view_frame(hdc,wsize,localrect); 
     403                        yuv2rgb_draw(&obj->locview,obj->ddh,hdc,localrect.x,localrect.y); 
     404                } 
    389405        } 
    390406 
     
    402418} 
    403419 
     420static int enable_autofit(MSFilter *f, void *data){ 
     421        DDDisplay *obj=(DDDisplay*)f->data; 
     422        obj->autofit=*(int*)data; 
     423        return 0; 
     424} 
     425 
     426static int enable_mirroring(MSFilter *f, void *data){ 
     427        DDDisplay *obj=(DDDisplay*)f->data; 
     428        obj->mirroring=*(int*)data; 
     429        return 0; 
     430} 
     431 
    404432static MSFilterMethod methods[]={ 
    405433        {       MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID, get_native_window_id }, 
     434        {       MS_VIDEO_DISPLAY_ENABLE_AUTOFIT         ,       enable_autofit  }, 
     435        {       MS_VIDEO_DISPLAY_ENABLE_MIRRORING       ,       enable_mirroring}, 
    406436        {       0       ,NULL} 
    407437}; 
  • src/msvideo.c

    r964 r965  
    198198} 
    199199 
     200void rgb24_mirror(uint8_t *buf, int w, int h, int linesize){ 
     201        int i,j; 
     202        int r,g,b; 
     203        int end=w*3; 
     204        for(i=0;i<h;++i){ 
     205                for(j=0;j<end/2;j+=3){ 
     206                        r=buf[j]; 
     207                        g=buf[j+1]; 
     208                        b=buf[j+2]; 
     209                        buf[j]=buf[end-j-3]; 
     210                        buf[j+1]=buf[end-j-2]; 
     211                        buf[j+2]=buf[end-j-1]; 
     212                        buf[end-j-3]=r; 
     213                        buf[end-j-2]=g; 
     214                        buf[end-j-1]=b; 
     215                } 
     216                buf+=linesize; 
     217        } 
     218} 
     219 
    200220void rgb24_revert(uint8_t *buf, int w, int h, int linesize){ 
    201221        uint8_t *p,*pe; 
Note: See TracChangeset for help on using the changeset viewer.