Commit 1cf651f8 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

Add NV12 and NV21 formats

parent 92928134
......@@ -586,6 +586,10 @@ gst_video_format_from_fourcc (guint32 fourcc)
return GST_VIDEO_FORMAT_v210;
case GST_MAKE_FOURCC ('v', '2', '1', '6'):
return GST_VIDEO_FORMAT_v216;
case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
return GST_VIDEO_FORMAT_NV12;
case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
return GST_VIDEO_FORMAT_NV21;
default:
return GST_VIDEO_FORMAT_UNKNOWN;
}
......@@ -631,6 +635,10 @@ gst_video_format_to_fourcc (GstVideoFormat format)
return GST_MAKE_FOURCC ('v', '2', '1', '0');
case GST_VIDEO_FORMAT_v216:
return GST_MAKE_FOURCC ('v', '2', '1', '6');
case GST_VIDEO_FORMAT_NV12:
return GST_MAKE_FOURCC ('N', 'V', '1', '2');
case GST_VIDEO_FORMAT_NV21:
return GST_MAKE_FOURCC ('N', 'V', '2', '1');
default:
return 0;
}
......@@ -734,6 +742,8 @@ gst_video_format_is_rgb (GstVideoFormat format)
case GST_VIDEO_FORMAT_Y444:
case GST_VIDEO_FORMAT_v210:
case GST_VIDEO_FORMAT_v216:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return FALSE;
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx:
......@@ -776,6 +786,8 @@ gst_video_format_is_yuv (GstVideoFormat format)
case GST_VIDEO_FORMAT_Y444:
case GST_VIDEO_FORMAT_v210:
case GST_VIDEO_FORMAT_v216:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return TRUE;
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx:
......@@ -818,6 +830,8 @@ gst_video_format_has_alpha (GstVideoFormat format)
case GST_VIDEO_FORMAT_Y444:
case GST_VIDEO_FORMAT_v210:
case GST_VIDEO_FORMAT_v216:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return FALSE;
case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_RGBA:
......@@ -906,6 +920,9 @@ gst_video_format_get_row_stride (GstVideoFormat format, int component,
return ((width + 47) / 48) * 128;
case GST_VIDEO_FORMAT_v216:
return GST_ROUND_UP_8 (width * 4);
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return GST_ROUND_UP_4 (width);
default:
return 0;
}
......@@ -968,6 +985,13 @@ gst_video_format_get_pixel_stride (GstVideoFormat format, int component)
} else {
return 8;
}
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
if (component == 0) {
return 1;
} else {
return 2;
}
default:
return 0;
}
......@@ -1027,6 +1051,8 @@ gst_video_format_get_component_width (GstVideoFormat format, int component,
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
case GST_VIDEO_FORMAT_Y444:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return width;
default:
return 0;
......@@ -1058,6 +1084,8 @@ gst_video_format_get_component_height (GstVideoFormat format, int component,
switch (format) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
if (component == 0) {
return height;
} else {
......@@ -1261,6 +1289,20 @@ gst_video_format_get_component_offset (GstVideoFormat format, int component,
if (component == 2)
return 6;
return 0;
case GST_VIDEO_FORMAT_NV12:
if (component == 0)
return 0;
if (component == 1)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
if (component == 2)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) + 1;
case GST_VIDEO_FORMAT_NV21:
if (component == 0)
return 0;
if (component == 1)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) + 1;
if (component == 2)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
default:
return 0;
}
......@@ -1323,6 +1365,9 @@ gst_video_format_get_size (GstVideoFormat format, int width, int height)
return ((width + 47) / 48) * 128 * height;
case GST_VIDEO_FORMAT_v216:
return GST_ROUND_UP_8 (width * 4) * height;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) * 3 / 2;
default:
return 0;
}
......
......@@ -51,6 +51,8 @@ G_BEGIN_DECLS
* @GST_VIDEO_FORMAT_Y444: planar 4:4:4 YUV (Since: 0.10.24)
* @GST_VIDEO_FORMAT_v210: packed 4:2:2 10-bit YUV, complex format (Since: 0.10.24)
* @GST_VIDEO_FORMAT_v216: packed 4:2:2 16-bit YUV, Y0-U0-Y1-V1 order (Since: 0.10.24)
* @GST_VIDEO_FORMAT_NV12: planar 4:2:0 YUV with interleaved UV plane (Since: 0.10.25)
* @GST_VIDEO_FORMAT_NV21: planar 4:2:0 YUV with interleaved VU plane (Since: 0.10.25)
*
* Enum value describing the most common video formats.
*/
......@@ -76,7 +78,9 @@ typedef enum {
GST_VIDEO_FORMAT_YVYU,
GST_VIDEO_FORMAT_Y444,
GST_VIDEO_FORMAT_v210,
GST_VIDEO_FORMAT_v216
GST_VIDEO_FORMAT_v216,
GST_VIDEO_FORMAT_NV12,
GST_VIDEO_FORMAT_NV21
} GstVideoFormat;
#define GST_VIDEO_BYTE1_MASK_32 "0xFF000000"
......
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