[gst-cvs] gst-plugins-base: ffmpegcolorspace: Speed up _remove_format_info
Edward Hervey
bilboed at kemper.freedesktop.org
Mon Jun 14 05:14:27 PDT 2010
Module: gst-plugins-base
Branch: master
Commit: 3f1f8f66ed204a85eb19f767a278ead18cdb6a72
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=3f1f8f66ed204a85eb19f767a278ead18cdb6a72
Author: Edward Hervey <bilboed at bilboed.com>
Date: Mon Jun 14 13:26:02 2010 +0200
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.
---
gst/ffmpegcolorspace/gstffmpegcolorspace.c | 40 +++++++++-------------------
1 files changed, 13 insertions(+), 27 deletions(-)
diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c
index f278758..58d044d 100644
--- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c
+++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c
@@ -58,40 +58,26 @@ static GstPadTemplate *sinktempl, *srctempl;
static GstCaps *
gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
{
- int i;
- GstStructure *structure;
- GstCaps *rgbcaps;
- GstCaps *graycaps;
+ GstStructure *yuvst, *rgbst, *grayst;
+ /* We know there's only one structure since we're given simple caps */
caps = gst_caps_copy (caps);
- for (i = 0; i < gst_caps_get_size (caps); i++) {
- structure = gst_caps_get_structure (caps, i);
-
- gst_structure_set_name (structure, "video/x-raw-yuv");
- gst_structure_remove_fields (structure, "format", "endianness", "depth",
- "bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
- "palette_data", NULL);
- }
+ yuvst = gst_caps_get_structure (caps, 0);
- gst_caps_do_simplify (caps);
- rgbcaps = gst_caps_copy (caps);
+ gst_structure_set_name (yuvst, "video/x-raw-yuv");
+ gst_structure_remove_fields (yuvst, "format", "endianness", "depth",
+ "bpp", "red_mask", "green_mask", "blue_mask", "alpha_mask",
+ "palette_data", NULL);
- for (i = 0; i < gst_caps_get_size (rgbcaps); i++) {
- structure = gst_caps_get_structure (rgbcaps, i);
+ rgbst = gst_structure_copy (yuvst);
+ gst_structure_set_name (rgbst, "video/x-raw-rgb");
- gst_structure_set_name (structure, "video/x-raw-rgb");
- }
- 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");
- }
+ grayst = gst_structure_copy (rgbst);
+ gst_structure_set_name (grayst, "video/x-raw-gray");
- gst_caps_append (caps, graycaps);
- gst_caps_append (caps, rgbcaps);
+ gst_caps_append_structure (caps, rgbst);
+ gst_caps_append_structure (caps, grayst);
return caps;
}
More information about the Gstreamer-commits
mailing list