mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
vaapidecode: simplify codec lookup from caps.
Add new gst_vaapi_codec_from_caps() helper to determine codec type from the specified caps. Don't globally expose this function since this is really trivial and only used in the vaapidecode element.
This commit is contained in:
parent
9afe700005
commit
2b71db3059
1 changed files with 26 additions and 22 deletions
|
@ -303,12 +303,16 @@ gst_vaapidecode_ensure_display(GstVaapiDecode *decode)
|
|||
&decode->display);
|
||||
}
|
||||
|
||||
static inline guint
|
||||
gst_vaapi_codec_from_caps(GstCaps *caps)
|
||||
{
|
||||
return gst_vaapi_profile_get_codec(gst_vaapi_profile_from_caps(caps));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
|
||||
{
|
||||
GstVaapiDisplay *dpy;
|
||||
GstStructure *structure;
|
||||
int version;
|
||||
|
||||
if (!gst_vaapidecode_ensure_display(decode))
|
||||
return FALSE;
|
||||
|
@ -322,30 +326,30 @@ gst_vaapidecode_create(GstVaapiDecode *decode, GstCaps *caps)
|
|||
if (!decode->decoder_ready)
|
||||
return FALSE;
|
||||
|
||||
structure = gst_caps_get_structure(caps, 0);
|
||||
if (!structure)
|
||||
return FALSE;
|
||||
|
||||
if (gst_structure_has_name(structure, "video/x-h264"))
|
||||
decode->decoder = gst_vaapi_decoder_h264_new(dpy, caps);
|
||||
else if (gst_structure_has_name(structure, "video/mpeg")) {
|
||||
if (!gst_structure_get_int(structure, "mpegversion", &version))
|
||||
return FALSE;
|
||||
if (version == 2)
|
||||
decode->decoder = gst_vaapi_decoder_mpeg2_new(dpy, caps);
|
||||
else if (version == 4)
|
||||
decode->decoder = gst_vaapi_decoder_mpeg4_new(dpy, caps);
|
||||
}
|
||||
else if (gst_structure_has_name(structure, "video/x-wmv"))
|
||||
decode->decoder = gst_vaapi_decoder_vc1_new(dpy, caps);
|
||||
else if (gst_structure_has_name(structure, "video/x-h263") ||
|
||||
gst_structure_has_name(structure, "video/x-divx") ||
|
||||
gst_structure_has_name(structure, "video/x-xvid"))
|
||||
switch (gst_vaapi_codec_from_caps(caps)) {
|
||||
case GST_VAAPI_CODEC_MPEG2:
|
||||
decode->decoder = gst_vaapi_decoder_mpeg2_new(dpy, caps);
|
||||
break;
|
||||
case GST_VAAPI_CODEC_MPEG4:
|
||||
case GST_VAAPI_CODEC_H263:
|
||||
decode->decoder = gst_vaapi_decoder_mpeg4_new(dpy, caps);
|
||||
break;
|
||||
case GST_VAAPI_CODEC_H264:
|
||||
decode->decoder = gst_vaapi_decoder_h264_new(dpy, caps);
|
||||
break;
|
||||
case GST_VAAPI_CODEC_WMV3:
|
||||
case GST_VAAPI_CODEC_VC1:
|
||||
decode->decoder = gst_vaapi_decoder_vc1_new(dpy, caps);
|
||||
break;
|
||||
#if USE_JPEG_DECODER
|
||||
else if (gst_structure_has_name(structure, "image/jpeg"))
|
||||
case GST_VAAPI_CODEC_JPEG:
|
||||
decode->decoder = gst_vaapi_decoder_jpeg_new(dpy, caps);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
decode->decoder = NULL;
|
||||
break;
|
||||
}
|
||||
if (!decode->decoder)
|
||||
return FALSE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue