+2004-07-21 Julien MOUTTE <julien@moutte.net>
+
+ * sys/ximage/ximagesink.c: (gst_ximagesink_ximage_new),
+ (gst_ximagesink_renegotiate_size), (gst_ximagesink_sink_link),
+ (gst_ximagesink_chain), (gst_ximagesink_set_xwindow_id): Optimize
+ images creation for both elements. We don't create the image on caps
+ nego or renego, we just destroy the internal one if present if it does
+ not match the needs. The chain function takes care of creating a new
+ image when needed.
+ * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xvimage_new),
+ (gst_xvimagesink_xwindow_decorate), (gst_xvimagesink_sink_link),
+ (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc),
+ (gst_xvimagesink_set_xwindow_id): Additionally xvimage now contains
+ the image format information. The buffer pool checks for the context
+ image format and discard images with different formats.
+ * sys/xvimage/xvimagesink.h: Adding im_format in the xvimage structure.
+
2004-07-21 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
ximagesink->ximage->height))) {
/* We renew our ximage only if size changed */
gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink),
- GST_VIDEOSINK_HEIGHT (ximagesink));
+ ximagesink->ximage = NULL;
}
} else {
ximagesink->sw_scaling_failed = TRUE;
gst_structure_get_int (structure, "pixel_height", &ximagesink->pixel_height);
/* Creating our window and our image */
+ g_assert (GST_VIDEOSINK_WIDTH (ximagesink) > 0);
+ g_assert (GST_VIDEOSINK_HEIGHT (ximagesink) > 0);
if (!ximagesink->xwindow) {
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
}
}
- if ((ximagesink->ximage)
- && ((GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width)
- || (GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->ximage->height))) {
- /* We renew our ximage only if size changed */
+ /* If our ximage has changed we destroy it, next chain iteration will create
+ a new one */
+ if ((ximagesink->ximage) &&
+ ((GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) ||
+ (GST_VIDEOSINK_HEIGHT (ximagesink) != ximagesink->ximage->height))) {
gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage);
-
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
- } else if (!ximagesink->ximage) {
- /* If no ximage, creating one */
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ ximagesink->ximage = NULL;
}
gst_x_overlay_got_desired_size (GST_X_OVERLAY (ximagesink),
} else {
/* Else we have to copy the data into our private image, */
/* if we have one... */
- if (ximagesink->ximage) {
- memcpy (ximagesink->ximage->ximage->data,
- GST_BUFFER_DATA (buf),
- MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
- gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
- } else {
- /* No image available. Something went wrong during capsnego ! */
- gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
- ("no format defined before chain function"));
- return;
+ if (!ximagesink->ximage) {
+ ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
+ GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
+ if (!ximagesink->ximage) {
+ /* No image available. That's very bad ! */
+ gst_buffer_unref (buf);
+ GST_ELEMENT_ERROR (ximagesink, CORE, NEGOTIATION, (NULL),
+ ("Failed creating an XImage in ximagesink chain function."));
+ return;
+ }
}
+
+ memcpy (ximagesink->ximage->ximage->data,
+ GST_BUFFER_DATA (buf),
+ MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size));
+ gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
}
/* set correct time for next buffer */
}
}
- /* Recreating our ximage */
- if (!ximagesink->ximage &&
- GST_VIDEOSINK_WIDTH (ximagesink) && GST_VIDEOSINK_HEIGHT (ximagesink)) {
- ximagesink->ximage = gst_ximagesink_ximage_new (ximagesink,
- GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink));
- }
-
if (xwindow)
ximagesink->xwindow = xwindow;
}
xvimage->width = width;
xvimage->height = height;
+ xvimage->im_format = xvimagesink->xcontext->im_format;
xvimage->xvimagesink = xvimagesink;
g_mutex_lock (xvimagesink->x_lock);
if (xvimagesink->xcontext->use_xshm) {
xvimage->xvimage = XvShmCreateImage (xvimagesink->xcontext->disp,
xvimagesink->xcontext->xv_port_id,
- xvimagesink->xcontext->im_format,
- NULL, xvimage->width, xvimage->height, &xvimage->SHMInfo);
+ xvimage->im_format, NULL,
+ xvimage->width, xvimage->height, &xvimage->SHMInfo);
xvimage->SHMInfo.shmid = shmget (IPC_PRIVATE, xvimage->size,
IPC_CREAT | 0777);
/* We use image's internal data pointer */
xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,
xvimagesink->xcontext->xv_port_id,
- xvimagesink->xcontext->im_format,
- NULL, xvimage->width, xvimage->height);
+ xvimage->im_format, NULL, xvimage->width, xvimage->height);
/* Allocating memory for image's data */
xvimage->xvimage->data = g_malloc (xvimage->xvimage->data_size);
g_mutex_lock (xvimagesink->x_lock);
hints_atom = XInternAtom (xvimagesink->xcontext->disp, "_MOTIF_WM_HINTS", 1);
-
- hints = g_malloc0 (sizeof (MotifWmHints));
-
- if (!hints) {
+ if (hints_atom == None) {
return FALSE;
}
+ hints = g_malloc0 (sizeof (MotifWmHints));
+
hints->flags |= MWM_HINTS_DECORATIONS;
hints->decorations = 1 << 0;
/* We renew our xvimage only if size or format changed */
if ((xvimagesink->xvimage) &&
- ((xvimagesink->xcontext->im_format != im_format) ||
+ ((im_format != xvimagesink->xvimage->im_format) ||
(GST_VIDEOSINK_WIDTH (xvimagesink) != xvimagesink->xvimage->width) ||
(GST_VIDEOSINK_HEIGHT (xvimagesink) !=
xvimagesink->xvimage->height))) {
GST_FOURCC_ARGS (im_format));
GST_DEBUG_OBJECT (xvimagesink, "renewing xvimage");
gst_xvimagesink_xvimage_destroy (xvimagesink, xvimagesink->xvimage);
-
- xvimagesink->xcontext->im_format = im_format;
- xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
- } else if (!xvimagesink->xvimage) {
- /* If no xvimage, creating one */
- xvimagesink->xcontext->im_format = im_format;
- xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
+ xvimagesink->xvimage = NULL;
}
+ xvimagesink->xcontext->im_format = im_format;
+
gst_x_overlay_got_desired_size (GST_X_OVERLAY (xvimagesink),
GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
} else {
/* Else we have to copy the data into our private image, */
/* if we have one... */
- if (xvimagesink->xvimage) {
- memcpy (xvimagesink->xvimage->xvimage->data,
- GST_BUFFER_DATA (buf),
- MIN (GST_BUFFER_SIZE (buf), xvimagesink->xvimage->size));
- gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->xvimage);
- } else {
- /* No image available. Something went wrong during capsnego ! */
- gst_buffer_unref (buf);
- GST_ELEMENT_ERROR (xvimagesink, CORE, NEGOTIATION, (NULL),
- ("no format defined before chain function"));
- return;
+ if (!xvimagesink->xvimage) {
+ xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
+ GST_VIDEOSINK_WIDTH (xvimagesink),
+ GST_VIDEOSINK_HEIGHT (xvimagesink));
+ if (!xvimagesink->xvimage) {
+ /* No image available. That's very bad ! */
+ gst_buffer_unref (buf);
+ GST_ELEMENT_ERROR (xvimagesink, CORE, NEGOTIATION, (NULL),
+ ("Failed creating an XvImage in xvimagesink chain function."));
+ return;
+ }
}
+
+ memcpy (xvimagesink->xvimage->xvimage->data,
+ GST_BUFFER_DATA (buf),
+ MIN (GST_BUFFER_SIZE (buf), xvimagesink->xvimage->size));
+ gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->xvimage);
}
/* set correct time for next buffer */
xvimagesink->image_pool = g_slist_delete_link (xvimagesink->image_pool,
xvimagesink->image_pool);
+ /* We check for geometry or image format changes */
if ((xvimage->width != GST_VIDEOSINK_WIDTH (xvimagesink)) ||
- (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink))) {
+ (xvimage->height != GST_VIDEOSINK_HEIGHT (xvimagesink)) ||
+ (xvimage->im_format != xvimagesink->xcontext->im_format)) {
/* This image is unusable. Destroying... */
gst_xvimagesink_xvimage_destroy (xvimagesink, xvimage);
xvimage = NULL;
g_mutex_unlock (xvimagesink->x_lock);
}
- /* Recreating our xvimage */
- if (!xvimagesink->xvimage &&
- GST_VIDEOSINK_WIDTH (xvimagesink) && GST_VIDEOSINK_HEIGHT (xvimagesink)) {
- xvimagesink->xvimage = gst_xvimagesink_xvimage_new (xvimagesink,
- GST_VIDEOSINK_WIDTH (xvimagesink), GST_VIDEOSINK_HEIGHT (xvimagesink));
- }
-
if (xwindow)
xvimagesink->xwindow = xwindow;
}