~ubuntu-branches/ubuntu/vivid/gstreamer-vaapi/vivid

« back to all changes in this revision

Viewing changes to gst/vaapi/gstvaapiuploader.c

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2014-08-06 23:56:00 UTC
  • mfrom: (0.1.4 sid) (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140806235600-fg1kcmiu67k315q5
Tags: 0.5.9-2
* Remove spurious build-deps: libva-drm1, libavcodec-dev. (Closes: #757283)
* Drop Build-Depends-Indep and build docs unconditionally on all archs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <gst/vaapi/gstvaapisurfacepool.h>
31
31
 
32
32
#include "gstvaapiuploader.h"
 
33
#include "gstvaapipluginutil.h"
33
34
#include "gstvaapivideobuffer.h"
34
35
 
35
36
#define GST_HELPER_NAME "vaapiupload"
112
113
{
113
114
    GstVaapiUploaderPrivate * const priv = uploader->priv;
114
115
    GstVaapiSurface *surface = NULL;
115
 
    GstCaps *out_caps, *image_caps = NULL;
116
 
    guint i, n_structures;
 
116
    GArray *formats = NULL, *out_formats = NULL;
 
117
    GstCaps *out_caps;
 
118
    guint i;
117
119
    gboolean success = FALSE;
118
120
 
119
121
    enum { WIDTH = 64, HEIGHT = 64 };
121
123
    if (priv->allowed_caps)
122
124
        return TRUE;
123
125
 
124
 
    out_caps = gst_caps_new_empty();
125
 
    if (!out_caps)
126
 
        return FALSE;
 
126
    formats = gst_vaapi_display_get_image_formats(priv->display);
 
127
    if (!formats)
 
128
        goto cleanup;
127
129
 
128
 
    image_caps = gst_vaapi_display_get_image_caps(priv->display);
129
 
    if (!image_caps)
130
 
        goto end;
 
130
    out_formats = g_array_sized_new(FALSE, FALSE, sizeof(GstVideoFormat),
 
131
        formats->len);
 
132
    if (!out_formats)
 
133
        goto cleanup;
131
134
 
132
135
    surface = gst_vaapi_surface_new(priv->display,
133
136
        GST_VAAPI_CHROMA_TYPE_YUV420, WIDTH, HEIGHT);
134
137
    if (!surface)
135
 
        goto end;
 
138
        goto cleanup;
136
139
 
137
 
    n_structures = gst_caps_get_size(image_caps);
138
 
    for (i = 0; i < n_structures; i++) {
139
 
        GstStructure * const structure = gst_caps_get_structure(image_caps, i);
 
140
    for (i = 0; i < formats->len; i++) {
 
141
        const GstVideoFormat format =
 
142
            g_array_index(formats, GstVideoFormat, i);
140
143
        GstVaapiImage *image;
141
 
        GstVideoFormat format;
142
144
 
143
 
        format = gst_vaapi_video_format_from_structure(structure);
144
145
        if (format == GST_VIDEO_FORMAT_UNKNOWN)
145
146
            continue;
146
147
        image = gst_vaapi_image_new(priv->display, format, WIDTH, HEIGHT);
147
148
        if (!image)
148
149
            continue;
149
150
        if (ensure_image(image) && gst_vaapi_surface_put_image(surface, image))
150
 
            gst_caps_append_structure(out_caps, gst_structure_copy(structure));
 
151
            g_array_append_val(out_formats, format);
151
152
        gst_vaapi_object_unref(image);
152
153
    }
153
154
 
 
155
    out_caps = gst_vaapi_video_format_new_template_caps_from_list(out_formats);
 
156
    if (!out_caps)
 
157
        goto cleanup;
 
158
 
154
159
    gst_caps_replace(&priv->allowed_caps, out_caps);
 
160
    gst_caps_unref(out_caps);
155
161
    success = TRUE;
156
162
 
157
 
end:
158
 
    gst_caps_unref(out_caps);
159
 
    if (image_caps)
160
 
        gst_caps_unref(image_caps);
 
163
cleanup:
 
164
    if (out_formats)
 
165
        g_array_unref(out_formats);
 
166
    if (formats)
 
167
        g_array_unref(formats);
161
168
    if (surface)
162
169
        gst_vaapi_object_unref(surface);
163
170
    return success;
307
314
            "display",
308
315
            "Display",
309
316
            "The GstVaapiDisplay this object is bound to",
310
 
            G_PARAM_READWRITE));
 
317
            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
311
318
}
312
319
 
313
320
static void