v4l2: Add NV12_64Z32 support

https://bugzilla.gnome.org/show_bug.cgi?id=722127
This commit is contained in:
Nicolas Dufresne 2013-12-10 14:29:55 -05:00
parent c6d0f122c9
commit 4cffae36e3
2 changed files with 35 additions and 5 deletions

View file

@ -56,7 +56,6 @@
#define V4L2_FIELD_INTERLACED_BT 9
#endif
GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
#define GST_CAT_DEFAULT v4l2_debug
@ -317,7 +316,21 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
obj->bytesperline[i]);
offset[i] = offs;
stride[i] = obj->bytesperline[i];
if (GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) {
guint x_tiles, y_tiles, ws, hs, tile_height;
ws = GST_VIDEO_FORMAT_INFO_TILE_WS (finfo);
hs = GST_VIDEO_FORMAT_INFO_TILE_HS (finfo);
tile_height = 1 << hs;
x_tiles = obj->bytesperline[i] >> ws;
y_tiles = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, i,
GST_ROUND_UP_N (height, tile_height) >> hs);
stride[i] = GST_VIDEO_TILE_MAKE_STRIDE (x_tiles, y_tiles);
} else {
stride[i] = obj->bytesperline[i];
}
/* when using multiplanar mode and if there is more then one v4l
* plane for each gst plane
@ -329,10 +342,10 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
* the gst buffer point of view. */
offs += meta->vplanes[i].length;
else
offs +=
stride[i] * GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, i,
height);
offs += obj->bytesperline[i] *
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, i, height);
}
gst_buffer_add_video_meta_full (newbuf, GST_VIDEO_FRAME_FLAG_NONE,
GST_VIDEO_INFO_FORMAT (info), width, height, n_gst_planes,
offset, stride);
@ -430,6 +443,11 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
* 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]);

View file

@ -58,6 +58,9 @@
#ifndef V4L2_PIX_FMT_NV12M
#define V4L2_PIX_FMT_NV12M GST_MAKE_FOURCC ('N', 'M', '1', '2')
#endif
#ifndef V4L2_PIX_FMT_NV12MT
#define V4L2_PIX_FMT_NV12MT GST_MAKE_FOURCC ('T', 'M', '1', '2')
#endif
#ifndef V4L2_PIX_FMT_NV21M
#define V4L2_PIX_FMT_NV21M GST_MAKE_FOURCC ('N', 'M', '2', '1')
#endif
@ -1007,6 +1010,7 @@ static const GstV4L2FormatDesc gst_v4l2_formats[] = {
/* two planes -- one Y, one Cr + Cb interleaved */
{V4L2_PIX_FMT_NV12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12MT, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21M, TRUE, GST_V4L2_RAW},
@ -1167,6 +1171,7 @@ gst_v4l2_object_format_get_rank (const struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
case V4L2_PIX_FMT_NV12M: /* Same as NV12 */
case V4L2_PIX_FMT_NV12MT: /* NV12 64x32 tile */
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
case V4L2_PIX_FMT_NV21M: /* Same as NV21 */
case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
@ -1402,6 +1407,9 @@ gst_v4l2_object_v4l2fourcc_to_video_format (guint32 fourcc)
case V4L2_PIX_FMT_NV12M:
format = GST_VIDEO_FORMAT_NV12;
break;
case V4L2_PIX_FMT_NV12MT:
format = GST_VIDEO_FORMAT_NV12_64Z32;
break;
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV21M:
format = GST_VIDEO_FORMAT_NV21;
@ -1511,6 +1519,7 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
case V4L2_PIX_FMT_NV12M:
case V4L2_PIX_FMT_NV12MT:
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
case V4L2_PIX_FMT_NV21M:
case V4L2_PIX_FMT_YVU410:
@ -1723,6 +1732,9 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
gst_v4l2_object_choose_fourcc (v4l2object, V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_NV12M, &fourcc, &fourcc_alt);
break;
case GST_VIDEO_FORMAT_NV12_64Z32:
fourcc = V4L2_PIX_FMT_NV12MT;
break;
case GST_VIDEO_FORMAT_NV21:
gst_v4l2_object_choose_fourcc (v4l2object, V4L2_PIX_FMT_NV21,
V4L2_PIX_FMT_NV21M, &fourcc, &fourcc_alt);