Commit e3163a31 authored by smorlat's avatar smorlat
Browse files

- on windows, start capture using driver's default pixel format.

It appears some drivers don't like trying multiple formats.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@44 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 7724a1bf
......@@ -79,7 +79,8 @@ typedef enum{
MS_RGB24,
MS_MJPEG,
MS_UYVY,
MS_YUY2 /* -> same as MS_YUYV */
MS_YUY2, /* -> same as MS_YUYV */
MS_PIX_FMT_UNKNOWN
}MSPixFmt;
typedef struct _MSPicture{
......@@ -96,6 +97,7 @@ extern "C"{
int ms_pix_fmt_to_ffmpeg(MSPixFmt fmt);
MSPixFmt ffmpeg_pix_fmt_to_ms(int fmt);
MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc);
void ms_ffmpeg_check_init(void);
int yuv_buf_init_from_mblk(MSPicture *buf, mblk_t *m);
void yuv_buf_init_from_mblk_with_size(MSPicture *buf, mblk_t *m, int w, int h);
......
......@@ -105,3 +105,31 @@ void yuv_buf_copy(uint8_t *src_planes[], const int src_strides[],
plane_copy(src_planes[2],src_strides[2],dst_planes[2],dst_strides[2],roi);
}
#ifndef MAKEFOURCC
#define MAKEFOURCC(a,b,c,d) ((d)<<24 | (c)<<16 | (b)<<8 | (a))
#endif
MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc){
MSPixFmt ret;
switch (fourcc){
case MAKEFOURCC('I','4','2','0'):
ret=MS_YUV420P;
break;
case MAKEFOURCC('Y','U','Y','2'):
ret=MS_YUY2;
break;
case MAKEFOURCC('Y','U','Y','V'):
ret=MS_YUYV;
break;
case MAKEFOURCC('U','Y','V','Y'):
ret=MS_UYVY;
break;
case 0: /*BI_RGB on windows*/
ret=MS_RGB24;
break;
default:
ret=MS_PIX_FMT_UNKNOWN;
}
return ret;
}
......@@ -115,6 +115,7 @@ static int v4w_open_videodevice(V4wState *s)
BITMAPINFO videoformat;
char compname[5];
int i;
MSPixFmt driver_last;
char dev[80];
char ver[80];
compname[4]='\0';
......@@ -183,9 +184,14 @@ static int v4w_open_videodevice(V4wState *s)
memcpy(compname,&videoformat.bmiHeader.biCompression,4);
ms_message("v4w: camera's current format is %s", compname);
driver_last=ms_fourcc_to_pix_fmt(videoformat.bmiHeader.biCompression);
if (s->startwith_yuv_bug==TRUE && try_format(s,&videoformat,MS_RGB24)){
s->pix_fmt=MS_RGB24;
ms_message("Using RGB24");
}else if (driver_last!=MS_PIX_FMT_UNKNOWN && try_format(s,&videoformat,driver_last)){
ms_message("Using driver last setting");
s->pix_fmt=driver_last;
}else if (try_format(s,&videoformat,MS_YUV420P)){
s->pix_fmt=MS_YUV420P;
ms_message("Using YUV420P");
......
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