make ffcolorspace work

Original commit message from CVS:
make ffcolorspace work
This commit is contained in:
Benjamin Otte 2003-11-25 04:48:31 +00:00
parent 2d2624fe49
commit 982d1612b2

View file

@ -524,9 +524,9 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
bpp = depth = 32; bpp = depth = 32;
endianness = G_BIG_ENDIAN; endianness = G_BIG_ENDIAN;
#if (G_BYTE_ORDER == G_BIG_ENDIAN) #if (G_BYTE_ORDER == G_BIG_ENDIAN)
r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00; r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000;
#else #else
r_mask = 0x000000ff; g_mask = 0x0000ff00; b_mask = 0x00ff0000; r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
#endif #endif
break; break;
case PIX_FMT_YUV410P: case PIX_FMT_YUV410P:
@ -835,73 +835,66 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
context->frame_rate_base = DEFAULT_FRAME_RATE_BASE; context->frame_rate_base = DEFAULT_FRAME_RATE_BASE;
} }
if (gst_caps_has_property_typed (caps, "format", if (strcmp (gst_caps_get_mime (caps), "video/x-raw-yuv") == 0) {
if (gst_caps_has_property_typed (caps, "format",
GST_PROPS_FOURCC_TYPE)) { GST_PROPS_FOURCC_TYPE)) {
guint32 fourcc; guint32 fourcc;
gst_caps_get_fourcc_int (caps, "format", &fourcc); gst_caps_get_fourcc_int (caps, "format", &fourcc);
switch (fourcc) { switch (fourcc) {
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y','U','Y','2'):
context->pix_fmt = PIX_FMT_YUV422; context->pix_fmt = PIX_FMT_YUV422;
break; break;
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I','4','2','0'):
context->pix_fmt = PIX_FMT_YUV420P; context->pix_fmt = PIX_FMT_YUV420P;
break; break;
case GST_MAKE_FOURCC ('Y','4','1','B'): case GST_MAKE_FOURCC ('Y','4','1','B'):
context->pix_fmt = PIX_FMT_YUV411P; context->pix_fmt = PIX_FMT_YUV411P;
break; break;
case GST_MAKE_FOURCC ('Y','U','V','9'): case GST_MAKE_FOURCC ('Y','U','V','9'):
context->pix_fmt = PIX_FMT_YUV410P; context->pix_fmt = PIX_FMT_YUV410P;
break; break;
#if 0 #if 0
case FIXME: case FIXME:
context->pix_fmt = PIX_FMT_YUV444P; context->pix_fmt = PIX_FMT_YUV444P;
break; break;
#endif #endif
case GST_MAKE_FOURCC ('R','G','B',' '): }
if (gst_caps_has_property_typed (caps, "depth", }
GST_PROPS_INT_TYPE) && } else if (strcmp (gst_caps_get_mime (caps), "video/x-raw-rgb") == 0) {
gst_caps_has_property_typed (caps, "endianness", if (gst_caps_has_property_typed (caps, "bpp", GST_PROPS_INT_TYPE) &&
GST_PROPS_INT_TYPE)) { gst_caps_has_property_typed (caps, "red_mask", GST_PROPS_INT_TYPE)) {
gint depth = 0, endianness = 0; gint bpp = 0, red_mask = 0;
gst_caps_get_int (caps, "depth", &depth); gst_caps_get_int (caps, "bpp", &bpp);
gst_caps_get_int (caps, "endianness", &endianness); gst_caps_get_int (caps, "red_mask", &red_mask);
switch (depth) { switch (bpp) {
case 32: case 32:
if (endianness == G_BYTE_ORDER) context->pix_fmt = PIX_FMT_RGBA32;
context->pix_fmt = PIX_FMT_RGBA32; break;
break; case 24:
case 24: switch (red_mask) {
switch (endianness) { case 0x0000FF:
case G_LITTLE_ENDIAN: context->pix_fmt = PIX_FMT_BGR24;
context->pix_fmt = PIX_FMT_BGR24;
break;
case G_BIG_ENDIAN:
context->pix_fmt = PIX_FMT_RGB24;
break;
default:
/* nothing */
break;
}
break;
case 16:
if (endianness == G_BYTE_ORDER)
context->pix_fmt = PIX_FMT_RGB565;
break;
case 15:
if (endianness == G_BYTE_ORDER)
context->pix_fmt = PIX_FMT_RGB555;
break; break;
case 0xFF0000:
context->pix_fmt = PIX_FMT_RGB24;
break;
default: default:
/* nothing */ /* nothing */
break; break;
} }
} break;
break; case 16:
default: context->pix_fmt = PIX_FMT_RGB565;
/* nothing */ break;
break; case 15:
context->pix_fmt = PIX_FMT_RGB555;
break;
default:
/* nothing */
break;
}
} }
} }
} }