Commit 50644816 authored by Aymeric Moizard's avatar Aymeric Moizard

allow setting different background color

parent f7003dab
......@@ -102,6 +102,8 @@ void ms_display_destroy(MSDisplay *d);
#define MS_VIDEO_OUT_GET_SCALE_FACTOR MS_FILTER_METHOD(MS_VIDEO_OUT_ID,8,float)
#define MS_VIDEO_OUT_SET_SELFVIEW_POS MS_FILTER_METHOD(MS_VIDEO_OUT_ID,9,float[3])
#define MS_VIDEO_OUT_GET_SELFVIEW_POS MS_FILTER_METHOD(MS_VIDEO_OUT_ID,10,float[3])
#define MS_VIDEO_OUT_SET_BACKGROUND_COLOR MS_FILTER_METHOD(MS_VIDEO_OUT_ID,11,int[3])
#define MS_VIDEO_OUT_GET_BACKGROUND_COLOR MS_FILTER_METHOD(MS_VIDEO_OUT_ID,12,int[3])
#ifdef __cplusplus
}
......
......@@ -280,7 +280,6 @@ typedef struct _WinDisplay{
struct SwsContext *sws_selfview;
MSDisplayEvent last_rsz;
uint8_t *rgb;
uint8_t *black;
int last_rect_w;
int last_rect_h;
int rgb_len;
......@@ -376,7 +375,6 @@ static bool_t win_display_init(MSDisplay *obj, MSFilter *f, MSPicture *fbuf, MSP
wd->fb.planes[2]=NULL;
wd->fb.planes[3]=NULL;
if (wd->rgb) ms_free(wd->rgb);
if (wd->black) ms_free(wd->black);
wd->rgb=NULL;
wd->rgb_len=0;
sws_freeContext(wd->sws);
......@@ -391,7 +389,6 @@ static bool_t win_display_init(MSDisplay *obj, MSFilter *f, MSPicture *fbuf, MSP
wd->rgb_len_selfview=0;
sws_freeContext(wd->sws_selfview);
wd->sws_selfview=NULL;
wd->black=NULL;
wd->last_rect_w=0;
wd->last_rect_h=0;
}
......@@ -453,7 +450,6 @@ static bool_t win_display_init(MSDisplay *obj, MSFilter *f, MSPicture *fbuf, MSP
if (wd->fb.planes[0]) ms_free(wd->fb.planes[0]);
if (wd->rgb) ms_free(wd->rgb);
if (wd->black) ms_free(wd->black);
ysize=wd->fb.w*wd->fb.h;
usize=ysize/4;
fbuf->planes[0]=wd->fb.planes[0]=(uint8_t*)ms_malloc0(ysize+2*usize);
......@@ -467,7 +463,6 @@ static bool_t win_display_init(MSDisplay *obj, MSFilter *f, MSPicture *fbuf, MSP
wd->rgb_len=ysize*3;
wd->rgb=(uint8_t*)ms_malloc0(wd->rgb_len);
wd->black = (uint8_t*)ms_malloc0(wd->rgb_len);
wd->last_rect_w=0;
wd->last_rect_h=0;
return TRUE;
......@@ -543,9 +538,11 @@ static void win_display_update(MSDisplay *obj, int new_image, int new_selfview){
int corner;
float sv_scalefactor;
float sv_pos[3];
int color[3];
HDC dd_hdc;
HBITMAP dd_bmp;
HBRUSH brush;
BOOL dont_draw;
if (wd->window==NULL) return;
......@@ -601,11 +598,15 @@ static void win_display_update(MSDisplay *obj, int new_image, int new_selfview){
HGDIOBJ old_object = SelectObject(dd_hdc, dd_bmp);
dont_draw = DrawDibBegin(wd->ddh,dd_hdc, 0, 0, &bi, 0, 0, DDF_BUFFER);
//full screen in black
ret=DrawDibDraw(wd->ddh,dd_hdc,0,0,
rect.right,rect.bottom,
&bi,wd->black,
0,0,bi.biWidth,bi.biHeight,dont_draw?DDF_DONTDRAW:0);
/* full screen in background color */
color[0]=color[1]=color[2]=0;
if (wd->filter)
ms_filter_call_method(wd->filter, MS_VIDEO_OUT_GET_BACKGROUND_COLOR, &color);
brush = CreateSolidBrush(RGB(color[0],color[1],color[2]));
FillRect(dd_hdc, &rect, brush);
DeleteObject(brush);
corner = 0;
sv_scalefactor = SCALE_FACTOR;
......@@ -794,7 +795,6 @@ static void win_display_uninit(MSDisplay *obj){
if (wd->sws_selfview) sws_freeContext(wd->sws_selfview);
if (wd->fb.planes[0]) ms_free(wd->fb.planes[0]);
if (wd->rgb) ms_free(wd->rgb);
if (wd->black) ms_free(wd->black);
if (wd->sws) sws_freeContext(wd->sws);
ms_free(wd);
}
......@@ -876,6 +876,7 @@ typedef struct VideoOut
int corner; /*for selfview*/
float scale_factor; /*for selfview*/
float sv_posx,sv_posy;
int background_color[3];
struct SwsContext *sws1;
struct SwsContext *sws2;
......@@ -935,6 +936,7 @@ static void video_out_init(MSFilter *f){
obj->corner=0;
obj->scale_factor=SCALE_FACTOR;
obj->sv_posx=obj->sv_posy=SELVIEW_POS_INACTIVE;
obj->background_color[0]=obj->background_color[1]=obj->background_color[2]=0;
obj->sws1=NULL;
obj->sws2=NULL;
obj->display=NULL;
......@@ -1270,6 +1272,23 @@ static int video_out_get_selfview_pos(MSFilter *f,void *arg){
((float*)arg)[2]=(float)100.0/s->scale_factor;
return 0;
}
static int video_out_set_background_color(MSFilter *f,void *arg){
VideoOut *s=(VideoOut*)f->data;
s->background_color[0]=((int*)arg)[0];
s->background_color[1]=((int*)arg)[1];
s->background_color[2]=((int*)arg)[2];
return 0;
}
static int video_out_get_background_color(MSFilter *f,void *arg){
VideoOut *s=(VideoOut*)f->data;
((int*)arg)[0]=s->background_color[0];
((int*)arg)[1]=s->background_color[1];
((int*)arg)[2]=s->background_color[2];
return 0;
}
static MSFilterMethod methods[]={
{ MS_FILTER_SET_VIDEO_SIZE , video_out_set_vsize },
{ MS_VIDEO_OUT_SET_DISPLAY , video_out_set_display},
......@@ -1283,6 +1302,9 @@ static MSFilterMethod methods[]={
{ MS_VIDEO_OUT_GET_SCALE_FACTOR , video_out_get_scalefactor},
{ MS_VIDEO_OUT_SET_SELFVIEW_POS , video_out_set_selfview_pos},
{ MS_VIDEO_OUT_GET_SELFVIEW_POS , video_out_get_selfview_pos},
{ MS_VIDEO_OUT_SET_BACKGROUND_COLOR , video_out_set_background_color},
{ MS_VIDEO_OUT_GET_BACKGROUND_COLOR , video_out_get_background_color},
{ 0 ,NULL}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment