From: David Schleef Date: Tue, 30 Jul 2002 07:17:37 +0000 (+0000) Subject: Will now negotiate I420, YV12, and RGB X-Git-Tag: 1.19.3~511^2~15841 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eea061c98b35a1c84b928581714950724d7bf605;p=platform%2Fupstream%2Fgstreamer.git Will now negotiate I420, YV12, and RGB Original commit message from CVS: Will now negotiate I420, YV12, and RGB --- diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 9bc1393..bf588b6 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -57,7 +57,11 @@ GST_PAD_TEMPLATE_FACTORY (src_templ, GST_CAPS_NEW ( "videotestsrc_caps", "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), + "format", GST_PROPS_LIST( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('R','G','B',' ')) + ), "width", GST_PROPS_INT(640), "height", GST_PROPS_INT(480) ) @@ -93,7 +97,9 @@ static GstElementClass *parent_class = NULL; void gst_videotestsrc_setup (GstVideotestsrc *v); static void random_chars(unsigned char *dest, int nbytes); -static void gst_videotestsrc_random_yuv (GstVideotestsrc *v, unsigned char *dest, int w, int h); +void gst_videotestsrc_smpte_I420 (GstVideotestsrc *v, unsigned char *dest, int w, int h); +void gst_videotestsrc_smpte_YV12 (GstVideotestsrc *v, unsigned char *dest, int w, int h); +void gst_videotestsrc_smpte_RGB (GstVideotestsrc *v, unsigned char *dest, int w, int h); GType @@ -161,7 +167,28 @@ gst_videotestsrc_srcconnect (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &videotestsrc->width); gst_caps_get_int (caps, "height", &videotestsrc->height); - gst_videotestsrc_setup(videotestsrc); + GST_DEBUG (0,"format is 0x%08x\n",videotestsrc->format); + + switch(videotestsrc->format){ + case GST_MAKE_FOURCC('R','G','B',' '): + videotestsrc->make_image = gst_videotestsrc_smpte_RGB; + videotestsrc->bpp = 16; + break; + case GST_MAKE_FOURCC('I','4','2','0'): + videotestsrc->make_image = gst_videotestsrc_smpte_I420; + videotestsrc->bpp = 12; + break; + case GST_MAKE_FOURCC('Y','U','Y','V'): + //videotestsrc->make_image = gst_videotestsrc_smpte_YUYV; + return GST_PAD_CONNECT_REFUSED; + break; + case GST_MAKE_FOURCC('Y','V','1','2'): + videotestsrc->make_image = gst_videotestsrc_smpte_YV12; + videotestsrc->bpp = 12; + break; + default: + return GST_PAD_CONNECT_REFUSED; + } GST_DEBUG (0,"size %d x %d",videotestsrc->width, videotestsrc->height); @@ -184,6 +211,14 @@ gst_videotestsrc_init (GstVideotestsrc *videotestsrc) gst_pad_set_get_function(videotestsrc->srcpad,gst_videotestsrc_get); gst_pad_set_connect_function(videotestsrc->srcpad,gst_videotestsrc_srcconnect); +#if 0 + "bpp", GST_PROPS_INT(16), + "depth", GST_PROPS_INT(16), + "endianness", GST_PROPS_INT(1234), + "red_mask", GST_PROPS_INT(63488), + "green_mask", GST_PROPS_INT(2016), + "blue_mask", GST_PROPS_INT(31), +#endif videotestsrc->width = 640; videotestsrc->height = 480; @@ -206,14 +241,18 @@ gst_videotestsrc_get (GstPad *pad) videotestsrc = GST_VIDEOTESTSRC (gst_pad_get_parent (pad)); +#if 0 + /* XXX this is wrong for anything but I420 */ newsize = videotestsrc->width*videotestsrc->height + videotestsrc->width*videotestsrc->height/2; +#endif + /* XXX this is wrong for anything but RGB16 */ + newsize = (videotestsrc->width*videotestsrc->height*videotestsrc->bpp)>>3; GST_DEBUG(0,"size=%ld %dx%d",newsize, videotestsrc->width, videotestsrc->height); buf = gst_buffer_new(); - /* XXX this is wrong for anything but I420 */ GST_BUFFER_SIZE(buf) = newsize; GST_BUFFER_DATA(buf) = g_malloc (newsize); g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL); @@ -221,7 +260,7 @@ gst_videotestsrc_get (GstPad *pad) videotestsrc->timestamp += videotestsrc->interval; GST_BUFFER_TIMESTAMP(buf) = videotestsrc->timestamp; - gst_videotestsrc_random_yuv(videotestsrc, (void *)GST_BUFFER_DATA(buf), + videotestsrc->make_image(videotestsrc, (void *)GST_BUFFER_DATA(buf), videotestsrc->width, videotestsrc->height); return buf; @@ -349,32 +388,118 @@ paint_rect (unsigned char *dest, int stride, int x, int y, int w, int h, unsigne } } +static void +paint_rect2 (unsigned char *dest, int stride, int x, int y, int w, int h, unsigned char *col) +{ + unsigned char *d = dest + stride*y + x*2; + unsigned char *dp; + int i,j; + + for(i=0;i>3); + col[1] = (r_colors[i]&0xf8) | (g_colors[i]>>5); + paint_rect2(dest, w*2, x1, 0, x2-x1, y1, col); + } + + /* inverse blue bars */ + for(i=0;i<7;i++){ + int x1 = i*w/7; + int x2 = (i+1)*w/7; + unsigned char col[2]; + int k; + + if(i&1){ + k = 7; + }else{ + k = 6-i; + } + col[0] = (g_colors[k]&0xe0) | (b_colors[k]>>3); + col[1] = (r_colors[k]&0xf8) | (g_colors[k]>>5); + paint_rect2(dest, w*2, x1, y1, x2-x1, y2-y1, col); + } + + /* -I, white, Q regions */ + for(i=0;i<3;i++){ + int x1 = i*w/6; + int x2 = (i+1)*w/6; + unsigned char col[2]; + int k; + + if(i==0){ k = 8; } + else if(i==1){ k = 0; } + else k = 9; + + col[0] = (g_colors[k]&0xe0) | (b_colors[k]>>3); + col[1] = (r_colors[k]&0xf8) | (g_colors[k]>>5); + paint_rect2(dest, w*2, x1, y2, x2-x1, h-y2, col); + } + + { + int x1 = w/2; + int x2 = w-1; + paint_rect_random(dest, w*2, x1*2, y2, (x2-x1)*2, h-y2); + } +} + diff --git a/gst/videotestsrc/gstvideotestsrc.h b/gst/videotestsrc/gstvideotestsrc.h index 132b5ba..802288b 100644 --- a/gst/videotestsrc/gstvideotestsrc.h +++ b/gst/videotestsrc/gstvideotestsrc.h @@ -67,8 +67,9 @@ struct _GstVideotestsrc { /* private */ gint64 timestamp; gint64 interval; + gint bpp; - guchar *temp; + void (*make_image)(GstVideotestsrc *v, unsigned char *dest, int w, int h); }; struct _GstVideotestsrcClass {