video: update video caps

This commit is contained in:
Wim Taymans 2011-06-15 16:16:02 +02:00
parent c1a4650394
commit 42fa1010cb
2 changed files with 98 additions and 677 deletions

View file

@ -23,8 +23,63 @@
# include "config.h" # include "config.h"
#endif #endif
#include <string.h>
#include "video.h" #include "video.h"
typedef struct
{
const gchar *fmt;
GstVideoFormat format;
guint32 fourcc;
} VideoFormat;
static VideoFormat formats[] = {
{"UNKNOWN", GST_VIDEO_FORMAT_UNKNOWN, 0x00000000},
{"I420", GST_VIDEO_FORMAT_I420, GST_MAKE_FOURCC ('I', '4', '2', '0')},
{"YV12", GST_VIDEO_FORMAT_YV12, GST_MAKE_FOURCC ('Y', 'V', '1', '2')},
{"YUY2", GST_VIDEO_FORMAT_YUY2, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')},
{"UYVY", GST_VIDEO_FORMAT_UYVY, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')},
{"AYUV", GST_VIDEO_FORMAT_AYUV, GST_MAKE_FOURCC ('A', 'Y', 'U', 'V')},
{"RGBx", GST_VIDEO_FORMAT_RGBx, 0x00000000},
{"BGRx", GST_VIDEO_FORMAT_BGRx, 0x00000000},
{"xRGB", GST_VIDEO_FORMAT_xRGB, 0x00000000},
{"xBGR", GST_VIDEO_FORMAT_xBGR, 0x00000000},
{"RGBA", GST_VIDEO_FORMAT_RGBA, 0x00000000},
{"BGRA", GST_VIDEO_FORMAT_BGRA, 0x00000000},
{"ARGB", GST_VIDEO_FORMAT_ARGB, 0x00000000},
{"ABGR", GST_VIDEO_FORMAT_ABGR, 0x00000000},
{"RGB", GST_VIDEO_FORMAT_RGB, 0x00000000},
{"BGR", GST_VIDEO_FORMAT_BGR, 0x00000000},
{"Y41B", GST_VIDEO_FORMAT_Y41B, GST_MAKE_FOURCC ('Y', '4', '1', 'B')},
{"Y42B", GST_VIDEO_FORMAT_Y42B, GST_MAKE_FOURCC ('Y', '4', '2', 'B')},
{"YVYU", GST_VIDEO_FORMAT_YVYU, GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U')},
{"Y444", GST_VIDEO_FORMAT_Y444, GST_MAKE_FOURCC ('Y', '4', '4', '4')},
{"v210", GST_VIDEO_FORMAT_v210, GST_MAKE_FOURCC ('v', '2', '1', '0')},
{"v216", GST_VIDEO_FORMAT_v216, GST_MAKE_FOURCC ('v', '2', '1', '6')},
{"NV12", GST_VIDEO_FORMAT_NV12, GST_MAKE_FOURCC ('N', 'V', '1', '2')},
{"NV21", GST_VIDEO_FORMAT_NV21, GST_MAKE_FOURCC ('N', 'V', '2', '1')},
{"GRAY8", GST_VIDEO_FORMAT_GRAY8, 0x00000000},
{"GRAY16_BE", GST_VIDEO_FORMAT_GRAY16_BE, 0x00000000},
{"GRAY16_LE", GST_VIDEO_FORMAT_GRAY16_LE, 0x00000000},
{"v308", GST_VIDEO_FORMAT_v308, GST_MAKE_FOURCC ('v', '3', '0', '8')},
{"Y800", GST_VIDEO_FORMAT_Y800, GST_MAKE_FOURCC ('Y', '8', '0', '0')},
{"Y16", GST_VIDEO_FORMAT_Y16, GST_MAKE_FOURCC ('Y', '1', '6', ' ')},
{"RGB16", GST_VIDEO_FORMAT_RGB16, 0x00000000},
{"BGR16", GST_VIDEO_FORMAT_BGR16, 0x00000000},
{"RGB15", GST_VIDEO_FORMAT_RGB15, 0x00000000},
{"BGR15", GST_VIDEO_FORMAT_BGR15, 0x00000000},
{"UYVP", GST_VIDEO_FORMAT_UYVP, GST_MAKE_FOURCC ('U', 'Y', 'V', 'P')},
{"A420", GST_VIDEO_FORMAT_A420, GST_MAKE_FOURCC ('A', '4', '2', '0')},
{"RGB8_PALLETTED", GST_VIDEO_FORMAT_RGB8_PALETTED, 0x00000000},
{"YUV9", GST_VIDEO_FORMAT_YUV9, GST_MAKE_FOURCC ('Y', 'U', 'V', '9')},
{"YVU9", GST_VIDEO_FORMAT_YVU9, GST_MAKE_FOURCC ('Y', 'V', 'U', '9')},
{"IYU1", GST_VIDEO_FORMAT_IYU1, GST_MAKE_FOURCC ('I', 'Y', 'U', '1')},
{"ARGB64", GST_VIDEO_FORMAT_ARGB64, 0x00000000},
{"AYUV64", GST_VIDEO_FORMAT_AYUV64, GST_MAKE_FOURCC ('A', 'Y', '6', '4')},
{"r210", GST_VIDEO_FORMAT_r210, 0x00000000}
};
/** /**
* SECTION:gstvideo * SECTION:gstvideo
* @short_description: Support library for video operations * @short_description: Support library for video operations
@ -37,16 +92,6 @@
* </refsect2> * </refsect2>
*/ */
static GstVideoFormat gst_video_format_from_rgb32_masks (int red_mask,
int green_mask, int blue_mask);
static GstVideoFormat gst_video_format_from_rgba32_masks (int red_mask,
int green_mask, int blue_mask, int alpha_mask);
static GstVideoFormat gst_video_format_from_rgb24_masks (int red_mask,
int green_mask, int blue_mask);
static GstVideoFormat gst_video_format_from_rgb16_masks (int red_mask,
int green_mask, int blue_mask);
/** /**
* gst_video_frame_rate: * gst_video_frame_rate:
* @pad: pointer to a #GstPad * @pad: pointer to a #GstPad
@ -360,98 +405,17 @@ gst_video_format_parse_caps (const GstCaps * caps, GstVideoFormat * format,
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if (format) { if (format) {
if (gst_structure_has_name (structure, "video/x-raw-yuv")) { if (gst_structure_has_name (structure, "video/x-raw")) {
guint32 fourcc; const gchar *fmt;
ok &= gst_structure_get_fourcc (structure, "format", &fourcc); fmt = gst_structure_get_string (structure, "format");
if (fmt == NULL)
ok = FALSE;
*format = gst_video_format_from_fourcc (fourcc); *format = gst_video_format_from_string (fmt);
if (*format == GST_VIDEO_FORMAT_UNKNOWN) { if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
ok = FALSE; ok = FALSE;
} }
} else if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
int depth;
int bpp;
int endianness = 0;
int red_mask = 0;
int green_mask = 0;
int blue_mask = 0;
int alpha_mask = 0;
gboolean have_alpha;
ok &= gst_structure_get_int (structure, "depth", &depth);
ok &= gst_structure_get_int (structure, "bpp", &bpp);
if (bpp != 8) {
ok &= gst_structure_get_int (structure, "endianness", &endianness);
ok &= gst_structure_get_int (structure, "red_mask", &red_mask);
ok &= gst_structure_get_int (structure, "green_mask", &green_mask);
ok &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
}
have_alpha = gst_structure_get_int (structure, "alpha_mask", &alpha_mask);
if (depth == 30 && bpp == 32 && endianness == G_BIG_ENDIAN) {
*format = GST_VIDEO_FORMAT_r210;
} else if (depth == 24 && bpp == 32 && endianness == G_BIG_ENDIAN) {
*format = gst_video_format_from_rgb32_masks (red_mask, green_mask,
blue_mask);
if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
ok = FALSE;
}
} else if (depth == 32 && bpp == 32 && endianness == G_BIG_ENDIAN &&
have_alpha) {
*format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
blue_mask, alpha_mask);
if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
ok = FALSE;
}
} else if (depth == 24 && bpp == 24 && endianness == G_BIG_ENDIAN) {
*format = gst_video_format_from_rgb24_masks (red_mask, green_mask,
blue_mask);
if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
ok = FALSE;
}
} else if ((depth == 15 || depth == 16) && bpp == 16 &&
endianness == G_BYTE_ORDER) {
*format = gst_video_format_from_rgb16_masks (red_mask, green_mask,
blue_mask);
if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
ok = FALSE;
}
} else if (depth == 8 && bpp == 8) {
*format = GST_VIDEO_FORMAT_RGB8_PALETTED;
} else if (depth == 64 && bpp == 64) {
*format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
blue_mask, alpha_mask);
if (*format == GST_VIDEO_FORMAT_ARGB) {
*format = GST_VIDEO_FORMAT_ARGB64;
} else {
*format = GST_VIDEO_FORMAT_UNKNOWN;
ok = FALSE;
}
} else {
ok = FALSE;
}
} else if (gst_structure_has_name (structure, "video/x-raw-gray")) {
int depth;
int bpp;
int endianness;
ok &= gst_structure_get_int (structure, "depth", &depth);
ok &= gst_structure_get_int (structure, "bpp", &bpp);
if (bpp > 8)
ok &= gst_structure_get_int (structure, "endianness", &endianness);
if (depth == 8 && bpp == 8) {
*format = GST_VIDEO_FORMAT_GRAY8;
} else if (depth == 16 && bpp == 16 && endianness == G_BIG_ENDIAN) {
*format = GST_VIDEO_FORMAT_GRAY16_BE;
} else if (depth == 16 && bpp == 16 && endianness == G_LITTLE_ENDIAN) {
*format = GST_VIDEO_FORMAT_GRAY16_LE;
} else {
ok = FALSE;
}
} else { } else {
ok = FALSE; ok = FALSE;
} }
@ -572,178 +536,8 @@ gst_video_format_new_caps_raw (GstVideoFormat format)
{ {
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL); g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, NULL);
if (gst_video_format_is_yuv (format)) { return gst_caps_new_simple ("video/x-raw",
return gst_caps_new_simple ("video/x-raw-yuv", "format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
"format", GST_TYPE_FOURCC, gst_video_format_to_fourcc (format), NULL);
}
if (gst_video_format_is_rgb (format)) {
GstCaps *caps;
int red_mask = 0;
int blue_mask = 0;
int green_mask = 0;
int alpha_mask;
int depth;
int bpp;
gboolean have_alpha;
unsigned int mask = 0;
switch (format) {
case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_xRGB:
case GST_VIDEO_FORMAT_xBGR:
bpp = 32;
depth = 24;
have_alpha = FALSE;
break;
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_ABGR:
bpp = 32;
depth = 32;
have_alpha = TRUE;
break;
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
bpp = 24;
depth = 24;
have_alpha = FALSE;
break;
case GST_VIDEO_FORMAT_RGB16:
case GST_VIDEO_FORMAT_BGR16:
bpp = 16;
depth = 16;
have_alpha = FALSE;
break;
case GST_VIDEO_FORMAT_RGB15:
case GST_VIDEO_FORMAT_BGR15:
bpp = 16;
depth = 15;
have_alpha = FALSE;
break;
case GST_VIDEO_FORMAT_RGB8_PALETTED:
bpp = 8;
depth = 8;
have_alpha = FALSE;
break;
case GST_VIDEO_FORMAT_ARGB64:
bpp = 64;
depth = 64;
have_alpha = TRUE;
break;
case GST_VIDEO_FORMAT_r210:
bpp = 32;
depth = 30;
have_alpha = FALSE;
break;
default:
return NULL;
}
if (bpp == 32 && depth == 30) {
red_mask = 0x3ff00000;
green_mask = 0x000ffc00;
blue_mask = 0x000003ff;
have_alpha = FALSE;
} else if (bpp == 32 || bpp == 24 || bpp == 64) {
if (bpp == 32) {
mask = 0xff000000;
} else {
mask = 0xff0000;
}
red_mask =
mask >> (8 * gst_video_format_get_component_offset (format, 0, 0, 0));
green_mask =
mask >> (8 * gst_video_format_get_component_offset (format, 1, 0, 0));
blue_mask =
mask >> (8 * gst_video_format_get_component_offset (format, 2, 0, 0));
} else if (bpp == 16) {
switch (format) {
case GST_VIDEO_FORMAT_RGB16:
red_mask = GST_VIDEO_COMP1_MASK_16_INT;
green_mask = GST_VIDEO_COMP2_MASK_16_INT;
blue_mask = GST_VIDEO_COMP3_MASK_16_INT;
break;
case GST_VIDEO_FORMAT_BGR16:
red_mask = GST_VIDEO_COMP3_MASK_16_INT;
green_mask = GST_VIDEO_COMP2_MASK_16_INT;
blue_mask = GST_VIDEO_COMP1_MASK_16_INT;
break;
break;
case GST_VIDEO_FORMAT_RGB15:
red_mask = GST_VIDEO_COMP1_MASK_15_INT;
green_mask = GST_VIDEO_COMP2_MASK_15_INT;
blue_mask = GST_VIDEO_COMP3_MASK_15_INT;
break;
case GST_VIDEO_FORMAT_BGR15:
red_mask = GST_VIDEO_COMP3_MASK_15_INT;
green_mask = GST_VIDEO_COMP2_MASK_15_INT;
blue_mask = GST_VIDEO_COMP1_MASK_15_INT;
break;
default:
g_assert_not_reached ();
}
} else if (bpp != 8) {
g_assert_not_reached ();
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
"bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
if (bpp != 8) {
gst_caps_set_simple (caps,
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"red_mask", G_TYPE_INT, red_mask,
"green_mask", G_TYPE_INT, green_mask,
"blue_mask", G_TYPE_INT, blue_mask, NULL);
}
if (have_alpha) {
alpha_mask =
mask >> (8 * gst_video_format_get_component_offset (format, 3, 0, 0));
gst_caps_set_simple (caps, "alpha_mask", G_TYPE_INT, alpha_mask, NULL);
}
return caps;
}
if (gst_video_format_is_gray (format)) {
GstCaps *caps;
int bpp;
int depth;
int endianness;
switch (format) {
case GST_VIDEO_FORMAT_GRAY8:
bpp = depth = 8;
endianness = G_BIG_ENDIAN;
break;
case GST_VIDEO_FORMAT_GRAY16_BE:
bpp = depth = 16;
endianness = G_BIG_ENDIAN;
break;
case GST_VIDEO_FORMAT_GRAY16_LE:
bpp = depth = 16;
endianness = G_LITTLE_ENDIAN;
break;
default:
return NULL;
break;
}
if (bpp <= 8) {
caps = gst_caps_new_simple ("video/x-raw-gray",
"bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
} else {
caps = gst_caps_new_simple ("video/x-raw-gray",
"bpp", G_TYPE_INT, bpp,
"depth", G_TYPE_INT, depth,
"endianness", G_TYPE_INT, endianness, NULL);
}
return caps;
}
return NULL;
} }
/** /**
@ -903,6 +697,19 @@ gst_video_format_from_fourcc (guint32 fourcc)
} }
} }
GstVideoFormat
gst_video_format_from_string (const gchar * format)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
if (strcmp (formats[i].fmt, format) == 0)
return formats[i].format;
}
return GST_VIDEO_FORMAT_UNKNOWN;
}
/** /**
* gst_video_format_to_fourcc: * gst_video_format_to_fourcc:
* @format: a #GstVideoFormat video format * @format: a #GstVideoFormat video format
@ -920,154 +727,21 @@ gst_video_format_to_fourcc (GstVideoFormat format)
{ {
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0); g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
switch (format) { if (format >= G_N_ELEMENTS (formats))
case GST_VIDEO_FORMAT_I420:
return GST_MAKE_FOURCC ('I', '4', '2', '0');
case GST_VIDEO_FORMAT_YV12:
return GST_MAKE_FOURCC ('Y', 'V', '1', '2');
case GST_VIDEO_FORMAT_YUY2:
return GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
case GST_VIDEO_FORMAT_YVYU:
return GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
case GST_VIDEO_FORMAT_UYVY:
return GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
case GST_VIDEO_FORMAT_AYUV:
return GST_MAKE_FOURCC ('A', 'Y', 'U', 'V');
case GST_VIDEO_FORMAT_Y41B:
return GST_MAKE_FOURCC ('Y', '4', '1', 'B');
case GST_VIDEO_FORMAT_Y42B:
return GST_MAKE_FOURCC ('Y', '4', '2', 'B');
case GST_VIDEO_FORMAT_Y444:
return GST_MAKE_FOURCC ('Y', '4', '4', '4');
case GST_VIDEO_FORMAT_v210:
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');
case GST_VIDEO_FORMAT_v308:
return GST_MAKE_FOURCC ('v', '3', '0', '8');
case GST_VIDEO_FORMAT_Y800:
return GST_MAKE_FOURCC ('Y', '8', '0', '0');
case GST_VIDEO_FORMAT_Y16:
return GST_MAKE_FOURCC ('Y', '1', '6', ' ');
case GST_VIDEO_FORMAT_UYVP:
return GST_MAKE_FOURCC ('U', 'Y', 'V', 'P');
case GST_VIDEO_FORMAT_A420:
return GST_MAKE_FOURCC ('A', '4', '2', '0');
case GST_VIDEO_FORMAT_YUV9:
return GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
case GST_VIDEO_FORMAT_YVU9:
return GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
case GST_VIDEO_FORMAT_IYU1:
return GST_MAKE_FOURCC ('I', 'Y', 'U', '1');
case GST_VIDEO_FORMAT_AYUV64:
return GST_MAKE_FOURCC ('A', 'Y', '6', '4');
default:
return 0; return 0;
}
return formats[format].fourcc;
} }
/* const gchar *
* gst_video_format_from_rgb32_masks: gst_video_format_to_string (GstVideoFormat format)
* @red_mask: red bit mask
* @green_mask: green bit mask
* @blue_mask: blue bit mask
*
* Converts red, green, blue bit masks into the corresponding
* #GstVideoFormat.
*
* Since: 0.10.16
*
* Returns: the #GstVideoFormat corresponding to the bit masks
*/
static GstVideoFormat
gst_video_format_from_rgb32_masks (int red_mask, int green_mask, int blue_mask)
{ {
if (red_mask == 0xff000000 && green_mask == 0x00ff0000 && g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN, 0);
blue_mask == 0x0000ff00) {
return GST_VIDEO_FORMAT_RGBx;
}
if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
blue_mask == 0xff000000) {
return GST_VIDEO_FORMAT_BGRx;
}
if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
blue_mask == 0x000000ff) {
return GST_VIDEO_FORMAT_xRGB;
}
if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
blue_mask == 0x00ff0000) {
return GST_VIDEO_FORMAT_xBGR;
}
if (format >= G_N_ELEMENTS (formats))
return GST_VIDEO_FORMAT_UNKNOWN; return GST_VIDEO_FORMAT_UNKNOWN;
}
static GstVideoFormat return formats[format].fmt;
gst_video_format_from_rgba32_masks (int red_mask, int green_mask,
int blue_mask, int alpha_mask)
{
if (red_mask == 0xff000000 && green_mask == 0x00ff0000 &&
blue_mask == 0x0000ff00 && alpha_mask == 0x000000ff) {
return GST_VIDEO_FORMAT_RGBA;
}
if (red_mask == 0x0000ff00 && green_mask == 0x00ff0000 &&
blue_mask == 0xff000000 && alpha_mask == 0x000000ff) {
return GST_VIDEO_FORMAT_BGRA;
}
if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
return GST_VIDEO_FORMAT_ARGB;
}
if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
return GST_VIDEO_FORMAT_ABGR;
}
return GST_VIDEO_FORMAT_UNKNOWN;
}
static GstVideoFormat
gst_video_format_from_rgb24_masks (int red_mask, int green_mask, int blue_mask)
{
if (red_mask == 0xff0000 && green_mask == 0x00ff00 && blue_mask == 0x0000ff) {
return GST_VIDEO_FORMAT_RGB;
}
if (red_mask == 0x0000ff && green_mask == 0x00ff00 && blue_mask == 0xff0000) {
return GST_VIDEO_FORMAT_BGR;
}
return GST_VIDEO_FORMAT_UNKNOWN;
}
static GstVideoFormat
gst_video_format_from_rgb16_masks (int red_mask, int green_mask, int blue_mask)
{
if (red_mask == GST_VIDEO_COMP1_MASK_16_INT
&& green_mask == GST_VIDEO_COMP2_MASK_16_INT
&& blue_mask == GST_VIDEO_COMP3_MASK_16_INT) {
return GST_VIDEO_FORMAT_RGB16;
}
if (red_mask == GST_VIDEO_COMP3_MASK_16_INT
&& green_mask == GST_VIDEO_COMP2_MASK_16_INT
&& blue_mask == GST_VIDEO_COMP1_MASK_16_INT) {
return GST_VIDEO_FORMAT_BGR16;
}
if (red_mask == GST_VIDEO_COMP1_MASK_15_INT
&& green_mask == GST_VIDEO_COMP2_MASK_15_INT
&& blue_mask == GST_VIDEO_COMP3_MASK_15_INT) {
return GST_VIDEO_FORMAT_RGB15;
}
if (red_mask == GST_VIDEO_COMP3_MASK_15_INT
&& green_mask == GST_VIDEO_COMP2_MASK_15_INT
&& blue_mask == GST_VIDEO_COMP1_MASK_15_INT) {
return GST_VIDEO_FORMAT_BGR15;
}
return GST_VIDEO_FORMAT_UNKNOWN;
} }
/** /**

View file

@ -121,274 +121,19 @@ typedef enum {
GST_VIDEO_FORMAT_r210 GST_VIDEO_FORMAT_r210
} GstVideoFormat; } GstVideoFormat;
#define GST_VIDEO_BYTE1_MASK_32 "0xFF000000"
#define GST_VIDEO_BYTE2_MASK_32 "0x00FF0000"
#define GST_VIDEO_BYTE3_MASK_32 "0x0000FF00"
#define GST_VIDEO_BYTE4_MASK_32 "0x000000FF"
#define GST_VIDEO_BYTE1_MASK_24 "0x00FF0000"
#define GST_VIDEO_BYTE2_MASK_24 "0x0000FF00"
#define GST_VIDEO_BYTE3_MASK_24 "0x000000FF"
#define GST_VIDEO_BYTE1_MASK_32_INT 0xFF000000
#define GST_VIDEO_BYTE2_MASK_32_INT 0x00FF0000
#define GST_VIDEO_BYTE3_MASK_32_INT 0x0000FF00
#define GST_VIDEO_BYTE4_MASK_32_INT 0x000000FF
#define GST_VIDEO_BYTE1_MASK_24_INT 0x00FF0000
#define GST_VIDEO_BYTE2_MASK_24_INT 0x0000FF00
#define GST_VIDEO_BYTE3_MASK_24_INT 0x000000FF
#define GST_VIDEO_COMP1_MASK_16 "0xf800"
#define GST_VIDEO_COMP2_MASK_16 "0x07e0"
#define GST_VIDEO_COMP3_MASK_16 "0x001f"
#define GST_VIDEO_COMP1_MASK_15 "0x7c00"
#define GST_VIDEO_COMP2_MASK_15 "0x03e0"
#define GST_VIDEO_COMP3_MASK_15 "0x001f"
#define GST_VIDEO_COMP1_MASK_16_INT 0xf800
#define GST_VIDEO_COMP2_MASK_16_INT 0x07e0
#define GST_VIDEO_COMP3_MASK_16_INT 0x001f
#define GST_VIDEO_COMP1_MASK_15_INT 0x7c00
#define GST_VIDEO_COMP2_MASK_15_INT 0x03e0
#define GST_VIDEO_COMP3_MASK_15_INT 0x001f
#ifndef GST_DISABLE_DEPRECATED
#define GST_VIDEO_RED_MASK_16 GST_VIDEO_COMP1_MASK_16
#define GST_VIDEO_GREEN_MASK_16 GST_VIDEO_COMP2_MASK_16
#define GST_VIDEO_BLUE_MASK_16 GST_VIDEO_COMP3_MASK_16
#define GST_VIDEO_RED_MASK_15 GST_VIDEO_COMP1_MASK_15
#define GST_VIDEO_GREEN_MASK_15 GST_VIDEO_COMP2_MASK_15
#define GST_VIDEO_BLUE_MASK_15 GST_VIDEO_COMP3_MASK_15
#define GST_VIDEO_RED_MASK_16_INT GST_VIDEO_COMP1_MASK_16_INT
#define GST_VIDEO_GREEN_MASK_16_INT GST_VIDEO_COMP2_MASK_16_INT
#define GST_VIDEO_BLUE_MASK_16_INT GST_VIDEO_COMP3_MASK_16_INT
#define GST_VIDEO_RED_MASK_15_INT GST_VIDEO_COMP1_MASK_15_INT
#define GST_VIDEO_GREEN_MASK_15_INT GST_VIDEO_COMP2_MASK_15_INT
#define GST_VIDEO_BLUE_MASK_15_INT GST_VIDEO_COMP3_MASK_15_INT
#endif
#define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]" #define GST_VIDEO_SIZE_RANGE "(int) [ 1, max ]"
#define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]" #define GST_VIDEO_FPS_RANGE "(fraction) [ 0, max ]"
/* consider the next 2 protected */
#define __GST_VIDEO_CAPS_MAKE_32A(R, G, B, A) \
"video/x-raw-rgb, " \
"bpp = (int) 32, " \
"depth = (int) 32, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " GST_VIDEO_BYTE ## R ## _MASK_32 ", " \
"green_mask = (int) " GST_VIDEO_BYTE ## G ## _MASK_32 ", " \
"blue_mask = (int) " GST_VIDEO_BYTE ## B ## _MASK_32 ", " \
"alpha_mask = (int) " GST_VIDEO_BYTE ## A ## _MASK_32 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
#define __GST_VIDEO_CAPS_MAKE_32(R, G, B) \
"video/x-raw-rgb, " \
"bpp = (int) 32, " \
"depth = (int) 24, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " GST_VIDEO_BYTE ## R ## _MASK_32 ", " \
"green_mask = (int) " GST_VIDEO_BYTE ## G ## _MASK_32 ", " \
"blue_mask = (int) " GST_VIDEO_BYTE ## B ## _MASK_32 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
#define __GST_VIDEO_CAPS_MAKE_24(R, G, B) \
"video/x-raw-rgb, " \
"bpp = (int) 24, " \
"depth = (int) 24, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " GST_VIDEO_BYTE ## R ## _MASK_24 ", " \
"green_mask = (int) " GST_VIDEO_BYTE ## G ## _MASK_24 ", " \
"blue_mask = (int) " GST_VIDEO_BYTE ## B ## _MASK_24 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
#define __GST_VIDEO_CAPS_MAKE_16(R, G, B) \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"depth = (int) 16, " \
"endianness = (int) BYTE_ORDER, " \
"red_mask = (int) " GST_VIDEO_COMP ## R ## _MASK_16 ", " \
"green_mask = (int) " GST_VIDEO_COMP ## G ## _MASK_16 ", " \
"blue_mask = (int) " GST_VIDEO_COMP ## B ## _MASK_16 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
#define __GST_VIDEO_CAPS_MAKE_15(R, G, B) \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"depth = (int) 15, " \
"endianness = (int) BYTE_ORDER, " \
"red_mask = (int) " GST_VIDEO_COMP ## R ## _MASK_15 ", " \
"green_mask = (int) " GST_VIDEO_COMP ## G ## _MASK_15 ", " \
"blue_mask = (int) " GST_VIDEO_COMP ## B ## _MASK_15 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
#define __GST_VIDEO_CAPS_MAKE_64A(R, G, B, A) \
"video/x-raw-rgb, " \
"bpp = (int) 64, " \
"depth = (int) 64, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " GST_VIDEO_BYTE ## R ## _MASK_32 ", " \
"green_mask = (int) " GST_VIDEO_BYTE ## G ## _MASK_32 ", " \
"blue_mask = (int) " GST_VIDEO_BYTE ## B ## _MASK_32 ", " \
"alpha_mask = (int) " GST_VIDEO_BYTE ## A ## _MASK_32 ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
/* 24 bit */
#define GST_VIDEO_CAPS_RGB \
__GST_VIDEO_CAPS_MAKE_24 (1, 2, 3)
#define GST_VIDEO_CAPS_BGR \
__GST_VIDEO_CAPS_MAKE_24 (3, 2, 1)
/* 32 bit */
#define GST_VIDEO_CAPS_RGBx \
__GST_VIDEO_CAPS_MAKE_32 (1, 2, 3)
#define GST_VIDEO_CAPS_xRGB \
__GST_VIDEO_CAPS_MAKE_32 (2, 3, 4)
#define GST_VIDEO_CAPS_BGRx \
__GST_VIDEO_CAPS_MAKE_32 (3, 2, 1)
#define GST_VIDEO_CAPS_xBGR \
__GST_VIDEO_CAPS_MAKE_32 (4, 3, 2)
/* 32 bit alpha */
#define GST_VIDEO_CAPS_RGBA \
__GST_VIDEO_CAPS_MAKE_32A (1, 2, 3, 4)
#define GST_VIDEO_CAPS_ARGB \
__GST_VIDEO_CAPS_MAKE_32A (2, 3, 4, 1)
#define GST_VIDEO_CAPS_BGRA \
__GST_VIDEO_CAPS_MAKE_32A (3, 2, 1, 4)
#define GST_VIDEO_CAPS_ABGR \
__GST_VIDEO_CAPS_MAKE_32A (4, 3, 2, 1)
/* note: the macro name uses the order on BE systems */
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
#else
#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
#endif
/* 15/16 bit */
#define GST_VIDEO_CAPS_RGB_16 \
__GST_VIDEO_CAPS_MAKE_16 (1, 2, 3)
#define GST_VIDEO_CAPS_BGR_16 \
__GST_VIDEO_CAPS_MAKE_16 (3, 2, 1)
#define GST_VIDEO_CAPS_RGB_15 \
__GST_VIDEO_CAPS_MAKE_15 (1, 2, 3)
#define GST_VIDEO_CAPS_BGR_15 \
__GST_VIDEO_CAPS_MAKE_15 (3, 2, 1)
/* 30 bit */
#define GST_VIDEO_CAPS_r210 \
"video/x-raw-rgb, " \
"bpp = (int) 32, " \
"depth = (int) 30, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) 0x3ff00000, " \
"green_mask = (int) 0x000ffc00, " \
"blue_mask = (int) 0x000003ff, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
/* 64 bit alpha */
#define GST_VIDEO_CAPS_ARGB_64 \
__GST_VIDEO_CAPS_MAKE_64A (2, 3, 4, 1)
/** /**
* GST_VIDEO_CAPS_RGB8_PALETTED: * GST_VIDEO_CAPS_MAKE:
* @format: string format that describes the pixel layout, as string
* (e.g. "I420", "RGB", "YV12", "YUY2", "AYUV", etc.)
* *
* Generic caps string for 8-bit paletted RGB video, for use in pad templates. * Generic caps string for video, for use in pad templates.
*
* Since: 0.10.32
*/ */
#define GST_VIDEO_CAPS_RGB8_PALETTED \ #define GST_VIDEO_CAPS_MAKE(format) \
"video/x-raw-rgb, bpp = (int)8, depth = (int)8, " \ "video/x-raw, " \
"width = "GST_VIDEO_SIZE_RANGE" , " \ "format = (string) " format ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = "GST_VIDEO_FPS_RANGE
/**
* GST_VIDEO_CAPS_YUV:
* @fourcc: YUV fourcc format that describes the pixel layout, as string
* (e.g. "I420", "YV12", "YUY2", "AYUV", etc.)
*
* Generic caps string for YUV video, for use in pad templates.
*/
#define GST_VIDEO_CAPS_YUV(fourcc) \
"video/x-raw-yuv, " \
"format = (fourcc) " fourcc ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
/**
* GST_VIDEO_CAPS_GRAY8:
*
* Generic caps string for 8-bit grayscale video, for use in pad templates.
*
* Since: 0.10.29
*/
#define GST_VIDEO_CAPS_GRAY8 \
"video/x-raw-gray, " \
"bpp = (int) 8, " \
"depth = (int) 8, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE
/**
* GST_VIDEO_CAPS_GRAY16:
* @endianness: endianness as string, ie. either "1234", "4321", "BIG_ENDIAN"
* or "LITTLE_ENDIAN"
*
* Generic caps string for 16-bit grayscale video, for use in pad templates.
*
* Since: 0.10.29
*/
#define GST_VIDEO_CAPS_GRAY16(endianness) \
"video/x-raw-gray, " \
"bpp = (int) 16, " \
"depth = (int) 16, " \
"endianness = (int) " endianness ", " \
"width = " GST_VIDEO_SIZE_RANGE ", " \ "width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE "framerate = " GST_VIDEO_FPS_RANGE
@ -494,8 +239,10 @@ GstCaps * gst_video_format_new_template_caps (GstVideoFormat format);
/* format properties */ /* format properties */
GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc) G_GNUC_CONST; GstVideoFormat gst_video_format_from_fourcc (guint32 fourcc) G_GNUC_CONST;
GstVideoFormat gst_video_format_from_string (const gchar *format) G_GNUC_CONST;
guint32 gst_video_format_to_fourcc (GstVideoFormat format) G_GNUC_CONST; guint32 gst_video_format_to_fourcc (GstVideoFormat format) G_GNUC_CONST;
const gchar * gst_video_format_to_string (GstVideoFormat format) G_GNUC_CONST;
gboolean gst_video_format_is_rgb (GstVideoFormat format) G_GNUC_CONST; gboolean gst_video_format_is_rgb (GstVideoFormat format) G_GNUC_CONST;