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

« back to all changes in this revision

Viewing changes to gst-libs/gst/vaapi/gstvaapiprofile.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:
34
34
#include "gstvaapiprofile.h"
35
35
#include "gstvaapiworkarounds.h"
36
36
 
 
37
typedef struct _GstVaapiCodecMap                GstVaapiCodecMap;
37
38
typedef struct _GstVaapiProfileMap              GstVaapiProfileMap;
38
39
typedef struct _GstVaapiEntrypointMap           GstVaapiEntrypointMap;
39
40
 
 
41
struct _GstVaapiCodecMap {
 
42
    GstVaapiCodec               codec;
 
43
    const gchar                *name;
 
44
};
 
45
 
40
46
struct _GstVaapiProfileMap {
41
47
    GstVaapiProfile             profile;
42
48
    VAProfile                   va_profile;
43
 
    const char                 *caps_str;
 
49
    const char                 *media_str;
44
50
    const gchar                *profile_str;
45
51
};
46
52
 
49
55
    VAEntrypoint                va_entrypoint;
50
56
};
51
57
 
 
58
/* Codecs */
 
59
static const GstVaapiCodecMap gst_vaapi_codecs[] = {
 
60
    { GST_VAAPI_CODEC_MPEG1,    "mpeg1" },
 
61
    { GST_VAAPI_CODEC_MPEG2,    "mpeg2" },
 
62
    { GST_VAAPI_CODEC_MPEG4,    "mpeg4" },
 
63
    { GST_VAAPI_CODEC_H263,     "h263"  },
 
64
    { GST_VAAPI_CODEC_H264,     "h264"  },
 
65
    { GST_VAAPI_CODEC_WMV3,     "wmv3"  },
 
66
    { GST_VAAPI_CODEC_VC1,      "vc1"   },
 
67
    { GST_VAAPI_CODEC_JPEG,     "jpeg"  },
 
68
    { GST_VAAPI_CODEC_VP8,      "vp8"   },
 
69
    { 0, }
 
70
};
 
71
 
52
72
/* Profiles */
53
73
static const GstVaapiProfileMap gst_vaapi_profiles[] = {
54
74
    { GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
80
100
    { GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline,
81
101
      "video/x-h264", "baseline"
82
102
    },
 
103
#if VA_CHECK_VERSION(0,31,1)
 
104
    { GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE,
 
105
      VAProfileH264ConstrainedBaseline,
 
106
      "video/x-h264", "constrained-baseline"
 
107
    },
 
108
#endif
83
109
    { GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main,
84
110
      "video/x-h264", "main"
85
111
    },
86
112
    { GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High,
87
113
      "video/x-h264", "high"
88
114
    },
 
115
#if VA_CHECK_VERSION(0,35,2)
 
116
    { GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH, VAProfileH264MultiviewHigh,
 
117
      "video/x-h264", "multiview-high"
 
118
    },
 
119
    { GST_VAAPI_PROFILE_H264_STEREO_HIGH, VAProfileH264StereoHigh,
 
120
      "video/x-h264", "stereo-high"
 
121
    },
 
122
#endif
89
123
    { GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple,
90
124
      "video/x-wmv, wmvversion=3", "simple"
91
125
    },
100
134
      "image/jpeg", "baseline"
101
135
    },
102
136
#endif
 
137
#if VA_CHECK_VERSION(0,35,0)
 
138
    {GST_VAAPI_PROFILE_VP8, VAProfileVP8Version0_3,
 
139
      "video/x-vp8", "Version0_3"},
 
140
#endif
103
141
    { 0, }
104
142
};
105
143
 
114
152
    { 0, }
115
153
};
116
154
 
 
155
static const GstVaapiCodecMap *
 
156
get_codecs_map(GstVaapiCodec codec)
 
157
{
 
158
    const GstVaapiCodecMap *m;
 
159
 
 
160
    for (m = gst_vaapi_codecs; m->codec; m++)
 
161
        if (m->codec == codec)
 
162
            return m;
 
163
    return NULL;
 
164
}
 
165
 
117
166
static const GstVaapiProfileMap *
118
167
get_profiles_map(GstVaapiProfile profile)
119
168
{
137
186
}
138
187
 
139
188
/**
 
189
 * gst_vaapi_codec_get_name:
 
190
 * @codec: a #GstVaapiCodec
 
191
 *
 
192
 * Returns a string representation for the supplied @codec type.
 
193
 *
 
194
 * Return value: the statically allocated string representation of @codec
 
195
 */
 
196
const gchar *
 
197
gst_vaapi_codec_get_name(GstVaapiCodec codec)
 
198
{
 
199
    const GstVaapiCodecMap * const m = get_codecs_map(codec);
 
200
 
 
201
    return m ? m->name : NULL;
 
202
}
 
203
 
 
204
/**
140
205
 * gst_vaapi_profile:
141
206
 * @profile: a #VAProfile
142
207
 *
158
223
}
159
224
 
160
225
/**
 
226
 * gst_vaapi_profile_get_name:
 
227
 * @profile: a #GstVaapiProfile
 
228
 *
 
229
 * Returns a string representation for the supplied @profile.
 
230
 *
 
231
 * Return value: the statically allocated string representation of @profile
 
232
 */
 
233
const gchar *
 
234
gst_vaapi_profile_get_name(GstVaapiProfile profile)
 
235
{
 
236
    const GstVaapiProfileMap * const m = get_profiles_map(profile);
 
237
 
 
238
    return m ? m->profile_str : NULL;
 
239
}
 
240
 
 
241
/**
 
242
 * gst_vaapi_profile_get_media_type_name:
 
243
 * @profile: a #GstVaapiProfile
 
244
 *
 
245
 * Returns a string representation for the media type of the supplied
 
246
 * @profile.
 
247
 *
 
248
 * Return value: the statically allocated string representation of
 
249
 *   @profile media type
 
250
 */
 
251
const gchar *
 
252
gst_vaapi_profile_get_media_type_name(GstVaapiProfile profile)
 
253
{
 
254
    const GstVaapiProfileMap * const m = get_profiles_map(profile);
 
255
 
 
256
    return m ? m->media_str : NULL;
 
257
}
 
258
 
 
259
/**
161
260
 * gst_vaapi_profile_from_codec_data:
162
261
 * @codec: a #GstVaapiCodec
163
262
 * @buffer: a #GstBuffer holding code data
170
269
gst_vaapi_profile_from_codec_data_h264(GstBuffer *buffer)
171
270
{
172
271
    /* MPEG-4 Part 15: Advanced Video Coding (AVC) file format */
173
 
    guchar buf[2];
 
272
    guchar buf[3];
174
273
 
175
274
    if (gst_buffer_extract(buffer, 0, buf, sizeof(buf)) != sizeof(buf))
176
275
        return 0;
179
278
        return 0;
180
279
 
181
280
    switch (buf[1]) {   /* AVCProfileIndication */
182
 
    case 66:    return GST_VAAPI_PROFILE_H264_BASELINE;
 
281
    case 66:    return ((buf[2] & 0x40) ?
 
282
                        GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE :
 
283
                        GST_VAAPI_PROFILE_H264_BASELINE);
183
284
    case 77:    return GST_VAAPI_PROFILE_H264_MAIN;
184
285
    case 100:   return GST_VAAPI_PROFILE_H264_HIGH;
 
286
    case 118:   return GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH;
 
287
    case 128:   return GST_VAAPI_PROFILE_H264_STEREO_HIGH;
 
288
 
185
289
    }
186
290
    return 0;
187
291
}
248
352
    profile = 0;
249
353
    best_profile = 0;
250
354
    for (m = gst_vaapi_profiles; !profile && m->profile; m++) {
251
 
        if (strncmp(name, m->caps_str, namelen) != 0)
 
355
        if (strncmp(name, m->media_str, namelen) != 0)
252
356
            continue;
253
 
        caps_test = gst_caps_from_string(m->caps_str);;
 
357
        caps_test = gst_caps_from_string(m->media_str);
254
358
        if (gst_caps_is_always_compatible(caps, caps_test)) {
255
359
            best_profile = m->profile;
256
360
            if (profile_str && m->profile_str &&
314
418
    for (m = gst_vaapi_profiles; m->profile; m++) {
315
419
        if (m->profile != profile)
316
420
            continue;
317
 
        caps = gst_caps_from_string(m->caps_str);
 
421
        caps = gst_caps_from_string(m->media_str);
318
422
        if (!caps)
319
423
            continue;
320
424
        gst_caps_set_simple(