v4l2: Correctly check if video meta is needed

Correctly check if video meta is needed. In buffer pool, trust need_video_meta
flag in order to decide if configuration should succeed.
This commit is contained in:
Nicolas Dufresne 2014-03-18 15:49:49 -04:00
parent f70bb08411
commit 403909d873
2 changed files with 13 additions and 26 deletions

View file

@ -426,27 +426,8 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
if (!pool->add_videometa &&
GST_VIDEO_INFO_FORMAT (&obj->info) != GST_VIDEO_FORMAT_ENCODED) {
gint stride = 0;
gint i = 0;
for (i = 0; i < obj->n_v4l2_planes; i++) {
/* we don't have video metadata, and we are dealing with raw video,
* see if the strides are compatible */
stride = GST_VIDEO_INFO_PLANE_STRIDE (&obj->info, i);
if (GST_VIDEO_FORMAT_INFO_IS_TILED (obj->info.finfo)) {
stride = GST_VIDEO_TILE_X_TILES (stride) <<
GST_VIDEO_FORMAT_INFO_TILE_WS ((obj->info.finfo));
}
GST_DEBUG_OBJECT (pool, "no videometadata, checking strides %d and %u",
stride, obj->bytesperline[i]);
if (stride != obj->bytesperline[i])
goto missing_video_api;
}
}
if (!pool->add_videometa && obj->need_video_meta)
goto missing_video_api;
/* parse the config and keep around */
if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers,
@ -479,9 +460,7 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
/* ERRORS */
missing_video_api:
{
GST_ERROR_OBJECT (pool, "missing GstMetaVideo API in config, "
"default stride: %d, wanted stride %u",
GST_VIDEO_INFO_PLANE_STRIDE (&obj->info, 0), obj->bytesperline[0]);
GST_ERROR_OBJECT (pool, "missing GstMetaVideo API in config");
return FALSE;
}
wrong_config:

View file

@ -2257,8 +2257,16 @@ gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
((align->padding_bottom + align->padding_right) != 0));
/* ... or also video meta if stride is non "standard" */
if (GST_VIDEO_INFO_PLANE_STRIDE (info, 0) != v4l2object->bytesperline[0])
v4l2object->need_video_meta = TRUE;
for (i = 0; i < v4l2object->n_v4l2_planes; i++) {
gint stride = GST_VIDEO_INFO_PLANE_STRIDE (info, i);
if (GST_VIDEO_FORMAT_INFO_IS_TILED (info->finfo))
stride = GST_VIDEO_TILE_X_TILES (stride) <<
GST_VIDEO_FORMAT_INFO_TILE_WS (info->finfo);
if (stride != v4l2object->bytesperline[i])
v4l2object->need_video_meta = TRUE;
}
/* ... or also video meta if we use multiple, non-contiguous, planes */
if (v4l2object->n_v4l2_planes > 1)