ffmpegcolorspace: Speed up _remove_format_info

Instead of copying full caps, use the fact that the provided caps only have
one structure and only copy around structures.
This commit is contained in:
Edward Hervey 2010-06-14 13:26:02 +02:00
parent 19f5fda87d
commit 3f1f8f66ed

View file

@ -58,40 +58,26 @@ static GstPadTemplate *sinktempl, *srctempl;
static GstCaps * static GstCaps *
gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps) gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
{ {
int i; GstStructure *yuvst, *rgbst, *grayst;
GstStructure *structure;
GstCaps *rgbcaps;
GstCaps *graycaps;
/* We know there's only one structure since we're given simple caps */
caps = gst_caps_copy (caps); caps = gst_caps_copy (caps);
for (i = 0; i < gst_caps_get_size (caps); i++) { yuvst = gst_caps_get_structure (caps, 0);
structure = gst_caps_get_structure (caps, i);
gst_structure_set_name (structure, "video/x-raw-yuv"); gst_structure_set_name (yuvst, "video/x-raw-yuv");
gst_structure_remove_fields (structure, "format", "endianness", "depth", gst_structure_remove_fields (yuvst, "format", "endianness", "depth",
"bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask", "bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
"palette_data", NULL); "palette_data", NULL);
}
gst_caps_do_simplify (caps); rgbst = gst_structure_copy (yuvst);
rgbcaps = gst_caps_copy (caps); gst_structure_set_name (rgbst, "video/x-raw-rgb");
for (i = 0; i < gst_caps_get_size (rgbcaps); i++) { grayst = gst_structure_copy (rgbst);
structure = gst_caps_get_structure (rgbcaps, i); gst_structure_set_name (grayst, "video/x-raw-gray");
gst_structure_set_name (structure, "video/x-raw-rgb"); gst_caps_append_structure (caps, rgbst);
} gst_caps_append_structure (caps, grayst);
graycaps = gst_caps_copy (caps);
for (i = 0; i < gst_caps_get_size (graycaps); i++) {
structure = gst_caps_get_structure (graycaps, i);
gst_structure_set_name (structure, "video/x-raw-gray");
}
gst_caps_append (caps, graycaps);
gst_caps_append (caps, rgbcaps);
return caps; return caps;
} }