Fix handling of RGB caps
authorDavid Schleef <ds@schleef.org>
Sun, 27 Jul 2003 05:31:01 +0000 (05:31 +0000)
committerDavid Schleef <ds@schleef.org>
Sun, 27 Jul 2003 05:31:01 +0000 (05:31 +0000)
Original commit message from CVS:
Fix handling of RGB caps

gst/videotestsrc/gstvideotestsrc.c
gst/videotestsrc/videotestsrc.c

index aebdc8f8065ee2409b681df52abd939a9caa8143..812a0b67a50c0d41f8bf36fa921d53259ad0bcd4 100644 (file)
@@ -268,6 +268,7 @@ gst_videotestsrc_change_state (GstElement * element)
       v->pool = gst_pad_get_bufferpool (v->srcpad);
       break;
     case GST_STATE_PLAYING_TO_PAUSED:
+      gst_buffer_pool_unref(v->pool);
       v->pool = NULL;
       break;
     case GST_STATE_READY_TO_NULL:
@@ -419,7 +420,7 @@ gst_videotestsrc_get (GstPad * pad)
   newsize = (videotestsrc->width * videotestsrc->height * videotestsrc->bpp) >> 3;
   g_return_val_if_fail (newsize > 0, NULL);
 
-  GST_DEBUG ("size=%ld %dx%d\n", newsize, videotestsrc->width, videotestsrc->height);
+  GST_DEBUG ("size=%ld %dx%d", newsize, videotestsrc->width, videotestsrc->height);
 
   buf = NULL;
   if (videotestsrc->pool) {
@@ -431,9 +432,7 @@ gst_videotestsrc_get (GstPad * pad)
     }
   }
   if (!buf) {
-    buf = gst_buffer_new ();
-    GST_BUFFER_SIZE (buf) = newsize;
-    GST_BUFFER_DATA (buf) = g_malloc (newsize);
+    buf = gst_buffer_new_and_alloc (newsize);
   }
   g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
 
index c64f86942d52150153d77f95dc3ff1b6c0791fe0..9888341e5904451621cbc8c03c3cebbd892fb60d 100644 (file)
@@ -385,11 +385,11 @@ struct fourcc_list_struct *paintinfo_find_by_caps(GstCaps *caps)
 {
   int i;
   const char *mimetype = gst_caps_get_mime(caps);
-  guint32 format;
 
   if(strcmp(mimetype, "video/x-raw-yuv")==0){
     char *s;
     int fourcc;
+    guint32 format;
 
     gst_caps_get(caps, "format", &format);
     for (i = 0; i < n_fourccs; i++) {
@@ -401,7 +401,28 @@ struct fourcc_list_struct *paintinfo_find_by_caps(GstCaps *caps)
       }
     }
   }else if(strcmp(mimetype, "video/x-raw-rgb")==0){
-    g_warning("video/x-raw-rgb not implemented");
+    int red_mask;
+    int green_mask;
+    int blue_mask;
+    int depth;
+    int bpp;
+
+    gst_caps_get(caps, "red_mask", &red_mask,
+       "green_mask", &green_mask,
+       "blue_mask", &blue_mask,
+       "depth", &depth,
+       "bpp", &bpp);
+    for (i = 0; i < n_fourccs; i++) {
+      if (strcmp(fourcc_list[i].fourcc, "RGB ") == 0 &&
+         fourcc_list[i].red_mask == red_mask &&
+         fourcc_list[i].green_mask == green_mask &&
+         fourcc_list[i].blue_mask == blue_mask &&
+         fourcc_list[i].depth == depth &&
+         fourcc_list[i].bitspp == bpp){
+       return fourcc_list + i;
+
+      }
+    }
     return NULL;
   }else{
     g_warning("unknown format");
@@ -458,53 +479,21 @@ GstCaps *paint_get_caps(struct fourcc_list_struct *format)
   fourcc = GST_MAKE_FOURCC (format->fourcc[0], format->fourcc[1], format->fourcc[2], format->fourcc[3]);
 
   if(format->ext_caps){
-#if GST_VERSION_MINOR > 6
-    caps = GST_CAPS_NEW ("videotestsrc_filter",
-                        "video/x-raw-rgb",
-                        "bpp", GST_PROPS_INT(format->bitspp),
-                        "endianness", GST_PROPS_INT(G_BIG_ENDIAN),
-                        "depth", GST_PROPS_INT(format->depth),
-                        "red_mask", GST_PROPS_INT(format->red_mask),
-                        "green_mask", GST_PROPS_INT(format->green_mask),
-                        "blue_mask", GST_PROPS_INT(format->blue_mask));
-#else
-    guint32 red_mask;
-    guint32 green_mask;
-    guint32 blue_mask;
-    guint32 endianness;
+    int endianness;
 
     if(format->bitspp==16){
-           endianness = G_BYTE_ORDER;
-           red_mask = format->red_mask;
-           green_mask = format->green_mask;
-           blue_mask = format->blue_mask;
-    }else if(format->bitspp==24){
-           endianness = G_BYTE_ORDER;
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-           red_mask = GUINT32_SWAP_LE_BE(format->red_mask)>>8;
-           green_mask = GUINT32_SWAP_LE_BE(format->green_mask)>>8;
-           blue_mask = GUINT32_SWAP_LE_BE(format->blue_mask)>>8;
-#else
-           red_mask = format->red_mask;
-           green_mask = format->green_mask;
-           blue_mask = format->blue_mask;
-#endif
+      endianness = G_BYTE_ORDER;
     }else{
-           endianness = G_BYTE_ORDER;
-           red_mask = GUINT32_FROM_BE(format->red_mask);
-           green_mask = GUINT32_FROM_BE(format->green_mask);
-           blue_mask = GUINT32_FROM_BE(format->blue_mask);
+      endianness = G_BIG_ENDIAN;
     }
-
     caps = GST_CAPS_NEW ("videotestsrc_filter",
                         "video/x-raw-rgb",
                         "bpp", GST_PROPS_INT(format->bitspp),
                         "endianness", GST_PROPS_INT(endianness),
                         "depth", GST_PROPS_INT(format->depth),
-                        "red_mask", GST_PROPS_INT(red_mask),
-                        "green_mask", GST_PROPS_INT(green_mask),
-                        "blue_mask", GST_PROPS_INT(blue_mask));
-#endif
+                        "red_mask", GST_PROPS_INT(format->red_mask),
+                        "green_mask", GST_PROPS_INT(format->green_mask),
+                        "blue_mask", GST_PROPS_INT(format->blue_mask));
   }else{
     caps = GST_CAPS_NEW ("videotestsrc_filter",
                         "video/x-raw-yuv",