fallback to libyuv supported formats when preferred format negotiation fails

This commit is contained in:
niels
2015-01-10 23:56:01 +01:00
parent 3699ac2b5b
commit ce6b17e252

View File

@@ -90,6 +90,7 @@ typedef struct {
} bufs; } bufs;
#define N_FRAMES 2 #define N_FRAMES 2
#define LOOP_LIMIT 64
typedef struct typedef struct
{ {
@@ -131,8 +132,9 @@ typedef struct
int processed_buffer; int processed_buffer;
int grey; int grey;
int threaded; int threaded;
uint32_t supported_pixel_formats[64]; uint32_t supported_pixel_formats[LOOP_LIMIT];
int is_vloopback; int is_vloopback;
int n_pixel_formats;
} v4l2info; } v4l2info;
static struct { static struct {
@@ -295,8 +297,10 @@ int v4l2_pixelformat2ffmpeg( int pf )
veejay_msg(0, "v4l2: Unhandled pixel format: %d", pf ); veejay_msg(0, "v4l2: Unhandled pixel format: %d", pf );
break; break;
} }
return PIX_FMT_BGR24; return PIX_FMT_BGR24;
} }
static int v4l2_ffmpeg2v4l2( int pf) static int v4l2_ffmpeg2v4l2( int pf)
{ {
switch(pf) { switch(pf) {
@@ -323,7 +327,6 @@ static int v4l2_ffmpeg2v4l2( int pf)
case PIX_FMT_YUV444P: case PIX_FMT_YUV444P:
return V4L2_PIX_FMT_YUV32; return V4L2_PIX_FMT_YUV32;
default: default:
#ifdef STRICT_CHECKING #ifdef STRICT_CHECKING
assert( pf >= 0 ); assert( pf >= 0 );
@@ -437,9 +440,7 @@ static void v4l2_enum_frame_sizes( v4l2info *v )
//@clear mem //@clear mem
memset( &fmtdesc, 0, sizeof( fmtdesc )); memset( &fmtdesc, 0, sizeof( fmtdesc ));
int loop_limit = 64; int loop_limit = LOOP_LIMIT;
int pf_cnt = 0;
for( fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; for( fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmtdesc.type < V4L2_BUF_TYPE_VIDEO_OVERLAY; fmtdesc.type < V4L2_BUF_TYPE_VIDEO_OVERLAY;
@@ -454,8 +455,8 @@ static void v4l2_enum_frame_sizes( v4l2info *v )
(fmtdesc.pixelformat >> 16) & 0xff, (fmtdesc.pixelformat >> 16) & 0xff,
(fmtdesc.pixelformat >> 24) & 0xff ); (fmtdesc.pixelformat >> 24) & 0xff );
v->supported_pixel_formats[ pf_cnt ] = fmtdesc.pixelformat; v->supported_pixel_formats[ v->n_pixel_formats ] = fmtdesc.pixelformat;
pf_cnt = (pf_cnt + 1 ) % loop_limit; v->n_pixel_formats = (v->n_pixel_formats + 1 ) % loop_limit;
fmtdesc.index ++; fmtdesc.index ++;
@@ -681,20 +682,17 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int
} }
//@ try anything else //@ try anything else
/*
int k; int k;
for( k = 0; k < 64; k ++ ) { for( k = 0; k < v->n_pixel_formats; k ++ ) {
if( v->supported_pixel_formats[k] == 0 ) if( v->supported_pixel_formats[k] == 0 )
continue; continue;
int pf = v4l2_pixelformat2ffmpeg( v->supported_pixel_formats[k] ); supported = v4l2_pixelformat2ffmpeg( v->supported_pixel_formats[k] );
if( pf >= 0 ) { if( supported >= 0 ) {
*candidate = v->supported_pixel_formats[k]; veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports %x", supported );
return 1; return 1;
} }
} }
*/
veejay_msg(VEEJAY_MSG_ERROR, "v4l2: No supported pixel format found!"); veejay_msg(VEEJAY_MSG_ERROR, "v4l2: No supported pixel format found!");