Exemplo n.º 1
0
static GstVdpBuffer *
gst_vdp_video_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool,
    GError ** error)
{
  GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
  GstVdpDevice *device;

  device = gst_vdp_buffer_pool_get_device (bpool);
  return GST_VDP_BUFFER_CAST (gst_vdp_video_buffer_new (device,
          vpool->chroma_type, vpool->width, vpool->height, error));
}
Exemplo n.º 2
0
static GstFlowReturn
gst_vdp_vpp_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
    GstCaps * caps, GstBuffer ** buf)
{
  GstVdpVideoPostProcess *vpp =
      GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad));
  GstVdpOutputBuffer *outbuf;
  GstFlowReturn ret = GST_FLOW_ERROR;
  GstVdpDevice *device = NULL;
  GstStructure *structure;
  gint width, height;
  gint chroma_type;

  if (!vpp->device) {
    /* if we haven't got a device yet we must alloc a buffer downstream to get it */
    GstCaps *src_caps = gst_pad_get_allowed_caps (vpp->srcpad);
    gst_pad_fixate_caps (vpp->srcpad, src_caps);
    ret = gst_pad_alloc_buffer (vpp->srcpad, 0, 0, src_caps,
        (GstBuffer **) & outbuf);

    gst_caps_unref (src_caps);
    if (ret != GST_FLOW_OK)
      goto error;

    device = outbuf->device;
    gst_buffer_unref (GST_BUFFER (outbuf));
  } else
    device = vpp->device;

  structure = gst_caps_get_structure (caps, 0);

  if (!gst_structure_get_int (structure, "width", &width) ||
      !gst_structure_get_int (structure, "height", &height) ||
      !gst_structure_get_int (structure, "chroma-type", &chroma_type))
    goto error;

  *buf = GST_BUFFER (gst_vdp_video_buffer_new (device,
          chroma_type, width, height));

  if (*buf == NULL)
    goto error;

  GST_BUFFER_SIZE (*buf) = size;
  GST_BUFFER_OFFSET (*buf) = offset;

  gst_buffer_set_caps (*buf, caps);

  ret = GST_FLOW_OK;

error:

  gst_object_unref (vpp);
  return ret;
}
Exemplo n.º 3
0
static GstFlowReturn
gst_vdp_video_yuv_buffer_alloc (GstPad * pad, guint64 offset,
    guint size, GstCaps * caps, GstBuffer ** buf)
{
  GstVdpVideoYUV *video_yuv = GST_VDP_VIDEO_YUV (gst_pad_get_parent (pad));
  GstFlowReturn ret = GST_FLOW_ERROR;
  GstStructure *structure;
  gint width, height;
  gint chroma_type;

  structure = gst_caps_get_structure (caps, 0);
  if (!structure)
    goto error;

  if (!gst_structure_get_int (structure, "width", &width))
    goto error;
  if (!gst_structure_get_int (structure, "height", &height))
    goto error;

  if (!gst_structure_get_int (structure, "chroma-type", &chroma_type))
    goto error;

  *buf = GST_BUFFER (gst_vdp_video_buffer_new (video_yuv->device,
          chroma_type, width, height));

  if (*buf == NULL)
    goto error;

  GST_BUFFER_SIZE (*buf) = size;
  GST_BUFFER_OFFSET (*buf) = offset;

  gst_buffer_set_caps (*buf, caps);

  ret = GST_FLOW_OK;

error:
  gst_object_unref (video_yuv);
  return ret;
}