v4l2bufferpool: Use default VideoInfo for frame operation

When doing frame operation, we need to use the default VideoInfo
and let the frame API read the video meta in order to get the stride
and offset right. Currently we where using the specialized VideoInfo
which reflects what the HW is setup to.
This commit is contained in:
Nicolas Dufresne 2014-05-12 18:03:18 -04:00
parent 2e5daf15e7
commit de7e5e481d
2 changed files with 9 additions and 5 deletions

View file

@ -95,7 +95,7 @@ static GstFlowReturn
gst_v4l2_buffer_pool_copy_buffer (GstV4l2BufferPool * pool, GstBuffer * dest,
GstBuffer * src)
{
const GstVideoFormatInfo *finfo = pool->obj->info.finfo;
const GstVideoFormatInfo *finfo = pool->caps_info.finfo;
GST_LOG_OBJECT (pool, "copying buffer");
@ -106,10 +106,10 @@ gst_v4l2_buffer_pool_copy_buffer (GstV4l2BufferPool * pool, GstBuffer * dest,
GST_DEBUG_OBJECT (pool, "copy video frame");
/* we have raw video, use videoframe copy to get strides right */
if (!gst_video_frame_map (&src_frame, &pool->obj->info, src, GST_MAP_READ))
if (!gst_video_frame_map (&src_frame, &pool->caps_info, src, GST_MAP_READ))
goto invalid_buffer;
if (!gst_video_frame_map (&dest_frame, &pool->obj->info, dest,
if (!gst_video_frame_map (&dest_frame, &pool->caps_info, dest,
GST_MAP_WRITE)) {
gst_video_frame_unmap (&src_frame);
goto invalid_buffer;
@ -185,7 +185,7 @@ gst_v4l2_buffer_pool_import_userptr (GstV4l2BufferPool * pool,
GstFlowReturn ret = GST_FLOW_OK;
GstV4l2MemoryGroup *group = NULL;
GstMapFlags flags;
const GstVideoFormatInfo *finfo = pool->obj->info.finfo;
const GstVideoFormatInfo *finfo = pool->caps_info.finfo;
struct UserPtrData *data = NULL;
GST_LOG_OBJECT (pool, "importing userptr");
@ -205,7 +205,7 @@ gst_v4l2_buffer_pool_import_userptr (GstV4l2BufferPool * pool,
finfo->format != GST_VIDEO_FORMAT_ENCODED)) {
data->is_frame = TRUE;
if (!gst_video_frame_map (&data->frame, &pool->obj->info, src, flags))
if (!gst_video_frame_map (&data->frame, &pool->caps_info, src, flags))
goto invalid_buffer;
if (!gst_v4l2_allocator_import_userptr (pool->vallocator, group,
@ -502,6 +502,9 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
gst_buffer_pool_config_set_params (config, caps, size, min_buffers,
max_buffers);
/* keep a GstVideoInfo with defaults for the when we need to copy */
gst_video_info_from_caps (&pool->caps_info, caps);
done:
ret = GST_BUFFER_POOL_CLASS (parent_class)->set_config (bpool, config);

View file

@ -56,6 +56,7 @@ struct _GstV4l2BufferPool
GstAllocationParams params;
GstBufferPool *other_pool;
guint size;
GstVideoInfo caps_info; /* Default video information */
gboolean add_videometa; /* set if video meta should be added */