Add VA profile abstraction.

This commit is contained in:
gb 2010-04-20 13:36:04 +00:00
parent fa11094655
commit 508edba9a0
9 changed files with 546 additions and 24 deletions

View file

@ -23,6 +23,7 @@
<xi:include href="xml/gstvaapiimageformat.xml"/>
<xi:include href="xml/gstvaapisubpicture.xml"/>
<xi:include href="xml/gstvaapitexture.xml"/>
<xi:include href="xml/gstvaapiprofile.xml"/>
<xi:include href="xml/gstvaapivideopool.xml"/>
<xi:include href="xml/gstvaapisurfacepool.xml"/>
<xi:include href="xml/gstvaapiimagepool.xml"/>

View file

@ -142,7 +142,10 @@ gst_vaapi_display_get_width
gst_vaapi_display_get_height
gst_vaapi_display_get_size
gst_vaapi_display_get_pixel_aspect_ratio
gst_vaapi_display_has_profile
gst_vaapi_display_get_decode_caps
gst_vaapi_display_has_decoder
gst_vaapi_display_get_encode_caps
gst_vaapi_display_has_encoder
gst_vaapi_display_get_image_caps
gst_vaapi_display_has_image_format
gst_vaapi_display_get_subpicture_caps
@ -369,6 +372,18 @@ gst_vaapi_image_format_get_caps
gst_vaapi_image_format_get_score
</SECTION>
<SECTION>
<FILE>gstvaapiprofile</FILE>
<TITLE>GstVaapiProfile</TITLE>
GstVaapiCodec
GstVaapiProfile
gst_vaapi_profile
gst_vaapi_profile_from_caps
gst_vaapi_profile_get_va_profile
gst_vaapi_profile_get_caps
gst_vaapi_profile_get_codec
</SECTION>
<SECTION>
<FILE>gstvaapitexture</FILE>
<TITLE>GstVaapiTexture</TITLE>

View file

@ -18,6 +18,7 @@ libgstvaapi_source_c = \
gstvaapimarshal.c \
gstvaapiobject.c \
gstvaapiparamspecs.c \
gstvaapiprofile.c \
gstvaapisubpicture.c \
gstvaapisurface.c \
gstvaapisurfacepool.c \
@ -36,6 +37,7 @@ libgstvaapi_source_h = \
gstvaapiimagepool.h \
gstvaapiobject.h \
gstvaapiparamspecs.h \
gstvaapiprofile.h \
gstvaapisubpicture.h \
gstvaapisurface.h \
gstvaapisurfacepool.h \

View file

@ -126,16 +126,37 @@ compare_rgb_formats(gconstpointer a, gconstpointer b)
/* Check if profiles array contains profile */
static inline gboolean
find_profile(GArray *profiles, VAProfile profile)
find_profile(GArray *profiles, GstVaapiProfile profile)
{
guint i;
for (i = 0; i < profiles->len; i++)
if (g_array_index(profiles, VAProfile, i) == profile)
if (g_array_index(profiles, GstVaapiProfile, i) == profile)
return TRUE;
return FALSE;
}
/* Convert profiles array to GstCaps */
static GstCaps *
get_profile_caps(GArray *profiles)
{
GstVaapiProfile profile;
GstCaps *out_caps, *caps;
guint i;
out_caps = gst_caps_new_empty();
if (!out_caps)
return NULL;
for (i = 0; i < profiles->len; i++) {
profile = g_array_index(profiles, GstVaapiProfile, i);
caps = gst_vaapi_profile_get_caps(profile);
if (caps)
gst_caps_append(out_caps, caps);
}
return out_caps;
}
/* Check if formats array contains format */
static inline gboolean
find_format(GArray *formats, GstVaapiImageFormat format)
@ -150,7 +171,7 @@ find_format(GArray *formats, GstVaapiImageFormat format)
/* Convert formats array to GstCaps */
static GstCaps *
get_caps(GArray *formats)
get_format_caps(GArray *formats)
{
GstVaapiImageFormat format;
GstCaps *out_caps, *caps;
@ -219,9 +240,14 @@ gst_vaapi_display_destroy(GstVaapiDisplay *display)
{
GstVaapiDisplayPrivate * const priv = display->priv;
if (priv->profiles) {
g_array_free(priv->profiles, TRUE);
priv->profiles = NULL;
if (priv->decoders) {
g_array_free(priv->decoders, TRUE);
priv->decoders = NULL;
}
if (priv->encoders) {
g_array_free(priv->encoders, TRUE);
priv->encoders = NULL;
}
if (priv->image_formats) {
@ -252,9 +278,10 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
GstVaapiDisplayPrivate * const priv = display->priv;
gboolean has_errors = TRUE;
VAProfile *profiles = NULL;
VAEntrypoint *entrypoints = NULL;
VAImageFormat *formats = NULL;
unsigned int *flags = NULL;
gint i, n, major_version, minor_version;
gint i, j, n, num_entrypoints, major_version, minor_version;
VAStatus status;
if (!priv->display && priv->create_display) {
@ -284,6 +311,9 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
profiles = g_new(VAProfile, vaMaxNumProfiles(priv->display));
if (!profiles)
goto end;
entrypoints = g_new(VAEntrypoint, vaMaxNumEntrypoints(priv->display));
if (!entrypoints)
goto end;
status = vaQueryConfigProfiles(priv->display, profiles, &n);
if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
goto end;
@ -292,10 +322,50 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
for (i = 0; i < n; i++)
GST_DEBUG(" %s", string_of_VAProfile(profiles[i]));
priv->profiles = g_array_new(FALSE, FALSE, sizeof(VAProfile));
if (!priv->profiles)
priv->decoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiProfile));
if (!priv->decoders)
goto end;
g_array_append_vals(priv->profiles, profiles, n);
priv->encoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiProfile));
if (!priv->encoders)
goto end;
for (i = 0; i < n; i++) {
GstVaapiProfile profile;
gboolean has_decoder = FALSE, has_encoder = FALSE;
profile = gst_vaapi_profile(profiles[i]);
if (!profile)
continue;
status = vaQueryConfigEntrypoints(
priv->display,
profiles[i],
entrypoints, &num_entrypoints
);
if (!vaapi_check_status(status, "vaQueryConfigEntrypoints()"))
goto end;
for (j = 0; j < num_entrypoints; j++) {
switch (entrypoints[j]) {
case VAEntrypointVLD:
case VAEntrypointIZZ:
case VAEntrypointIDCT:
case VAEntrypointMoComp:
case VAEntrypointDeblocking:
has_decoder = TRUE;
break;
#if VA_CHECK_VERSION(0,30,0)
case VAEntrypointEncSlice:
has_encoder = TRUE;
break;
#endif
}
}
if (has_decoder)
g_array_append_val(priv->decoders, profile);
if (has_encoder)
g_array_append_val(priv->encoders, profile);
}
/* VA image formats */
formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
@ -340,6 +410,7 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
has_errors = FALSE;
end:
g_free(profiles);
g_free(entrypoints);
g_free(formats);
g_free(flags);
return !has_errors;
@ -485,7 +556,8 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
priv->height_mm = 0;
priv->par_n = 1;
priv->par_d = 1;
priv->profiles = NULL;
priv->decoders = NULL;
priv->encoders = NULL;
priv->image_formats = NULL;
priv->subpicture_formats = NULL;
priv->create_display = TRUE;
@ -689,20 +761,75 @@ gst_vaapi_display_get_pixel_aspect_ratio(
}
/**
* gst_vaapi_display_has_profile:
* gst_vaapi_display_get_decode_caps:
* @display: a #GstVaapiDisplay
*
* Gets the supported profiles for decoding as #GstCaps capabilities.
*
* Return value: a newly allocated #GstCaps object, possibly empty
*/
GstCaps *
gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
return get_profile_caps(display->priv->decoders);
}
/**
* gst_vaapi_display_has_decoder:
* @display: a #GstVaapiDisplay
* @profile: a #VAProfile
*
* Returns whether VA @display supports @profile.
* Returns whether VA @display supports @profile for decoding.
*
* Return value: %TRUE if VA @display supports @profile
* Return value: %TRUE if VA @display supports @profile for decoding.
*/
gboolean
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
gst_vaapi_display_has_decoder(
GstVaapiDisplay *display,
GstVaapiProfile profile
)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
return find_profile(display->priv->profiles, profile);
return find_profile(display->priv->decoders, profile);
}
/**
* gst_vaapi_display_get_encode_caps:
* @display: a #GstVaapiDisplay
*
* Gets the supported profiles for decoding as #GstCaps capabilities.
*
* Return value: a newly allocated #GstCaps object, possibly empty
*/
GstCaps *
gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
return get_profile_caps(display->priv->encoders);
}
/**
* gst_vaapi_display_has_encoder:
* @display: a #GstVaapiDisplay
* @profile: a #VAProfile
*
* Returns whether VA @display supports @profile for encoding.
*
* Return value: %TRUE if VA @display supports @profile for encoding.
*/
gboolean
gst_vaapi_display_has_encoder(
GstVaapiDisplay *display,
GstVaapiProfile profile
)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
return find_profile(display->priv->encoders, profile);
}
/**
@ -726,7 +853,7 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
return get_caps(display->priv->image_formats);
return get_format_caps(display->priv->image_formats);
}
/**
@ -768,7 +895,7 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
return get_caps(display->priv->subpicture_formats);
return get_format_caps(display->priv->subpicture_formats);
}
/**

View file

@ -29,6 +29,7 @@
#include <gst/gst.h>
#include <gst/vaapi/gstvaapiimageformat.h>
#include <gst/vaapi/gstvaapiprofile.h>
G_BEGIN_DECLS
@ -141,8 +142,23 @@ gst_vaapi_display_get_pixel_aspect_ratio(
guint *par_d
);
GstCaps *
gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display);
gboolean
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile);
gst_vaapi_display_has_decoder(
GstVaapiDisplay *display,
GstVaapiProfile profile
);
GstCaps *
gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display);
gboolean
gst_vaapi_display_has_encoder(
GstVaapiDisplay *display,
GstVaapiProfile profile
);
GstCaps *
gst_vaapi_display_get_image_caps(GstVaapiDisplay *display);

View file

@ -77,7 +77,8 @@ struct _GstVaapiDisplayPrivate {
guint height_mm;
guint par_n;
guint par_d;
GArray *profiles;
GArray *decoders;
GArray *encoders;
GArray *image_formats;
GArray *subpicture_formats;
guint create_display : 1;

View file

@ -0,0 +1,200 @@
/*
* gstvaapiprofile.c - VA profile abstraction
*
* gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* SECTION:gstvaapiprofile
* @short_description: VA profile abstraction
*/
#include "config.h"
#include <string.h>
#include "gstvaapicompat.h"
#include "gstvaapiprofile.h"
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
struct _GstVaapiProfileMap {
GstVaapiProfile profile;
VAProfile va_profile;
const char *caps_str;
};
/* Profiles */
static const GstVaapiProfileMap gst_vaapi_profiles[] = {
{ GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
"video/mpeg, mpegversion=2, profile=simple"
},
{ GST_VAAPI_PROFILE_MPEG2_MAIN, VAProfileMPEG2Main,
"video/mpeg, mpegversion=2, profile=main"
},
{ GST_VAAPI_PROFILE_MPEG4_SIMPLE, VAProfileMPEG4Simple,
"video/mpeg, mpegversion=4, profile=simple"
},
{ GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/mpeg, mpegversion=4, profile=advanced-simple"
},
{ GST_VAAPI_PROFILE_MPEG4_MAIN, VAProfileMPEG4Main,
"video/mpeg, mpegversion=4, profile=main"
},
#if VA_CHECK_VERSION(0,30,0)
{ GST_VAAPI_PROFILE_H263_BASELINE, VAProfileH263Baseline,
"video/x-h263, variant=itu, h263version=h263, profile=baseline"
},
#endif
{ GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline,
"video/x-h264, variant=itu, profile=baseline"
},
{ GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main,
"video/x-h264, variant=itu, profile=main"
},
{ GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High,
"video/x-h264, variant=itu, profile=high"
},
{ GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple,
"video/x-vc1, profile=simple"
},
{ GST_VAAPI_PROFILE_VC1_MAIN, VAProfileVC1Main,
"video/x-vc1, profile=main"
},
{ GST_VAAPI_PROFILE_VC1_ADVANCED, VAProfileVC1Advanced,
"video/x-vc1, profile=advanced"
},
{ 0, }
};
static const GstVaapiProfileMap *
get_map(GstVaapiProfile profile)
{
const GstVaapiProfileMap *m;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->profile == profile)
return m;
return NULL;
}
/**
* gst_vaapi_profile:
* @va_profile: a #VAProfile
*
* Converts a VA profile into the corresponding #GstVaapiProfile. If the profile cannot be represented by #GstVaapiProfile, then zero is returned.
*
* Return value: the #GstVaapiProfile describing the @va_profile
*/
GstVaapiProfile
gst_vaapi_profile(VAProfile profile)
{
const GstVaapiProfileMap *m;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->va_profile == profile)
return m->profile;
return 0;
}
/**
* gst_vaapi_profile_from_caps:
* @caps: a #GstCaps
*
* Converts @caps into the corresponding #GstVaapiProfile. If the
* profile cannot be represented by #GstVaapiProfile, then zero is
* returned.
*
* Return value: the #GstVaapiProfile describing the @caps
*/
GstVaapiProfile
gst_vaapi_profile_from_caps(GstCaps *caps)
{
const GstVaapiProfileMap *m;
GstCaps *caps_test;
GstStructure *structure;
const gchar *name;
gsize namelen;
gboolean found;
if (!caps)
return 0;
structure = gst_caps_get_structure(caps, 0);
if (!structure)
return 0;
name = gst_structure_get_name(structure);
namelen = strlen(name);
found = FALSE;
for (m = gst_vaapi_profiles; !found && m->profile; m++) {
if (strncmp(name, m->caps_str, namelen) != 0)
continue;
caps_test = gst_caps_from_string(m->caps_str);
found = gst_caps_is_always_compatible(caps_test, caps);
gst_caps_unref(caps_test);
}
return found ? m->va_profile : 0;
}
/**
* gst_vaapi_profile_get_va_profile:
* @profile: a #GstVaapiProfile
*
* Converts a #GstVaapiProfile into the corresponding VA profile. If
* no matching VA profile was found, -1 is returned and this error
* must be reported to be fixed.
*
* Return value: the VA profile, or -1 if none was found
*/
VAProfile
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile)
{
const GstVaapiProfileMap * const m = get_map(profile);
return m ? m->va_profile : (VAProfile)-1;
}
/**
* gst_vaapi_profile_get_caps:
* @profile: a #GstVaapiProfile
*
* Converts a #GstVaapiProfile into the corresponding #GstCaps. If no
* matching caps were found, %NULL is returned.
*
* Return value: the newly allocated #GstCaps, or %NULL if none was found
*/
GstCaps *
gst_vaapi_profile_get_caps(GstVaapiProfile profile)
{
const GstVaapiProfileMap * const m = get_map(profile);
return m ? gst_caps_from_string(m->caps_str) : NULL;
}
/**
* gst_vaapi_profile_get_codec:
* @profile: a #GstVaapiProfile
*
* Extracts the #GstVaapiCodec from @profile.
*
* Return value: the #GstVaapiCodec from @profile
*/
GstVaapiCodec
gst_vaapi_profile_get_codec(GstVaapiProfile profile)
{
return (GstVaapiCodec)(((guint32)profile) & 0xffffff00);
}

View file

@ -0,0 +1,115 @@
/*
* gstvaapiprofile.h - VA profile abstraction
*
* gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef GST_VAAPI_PROFILE_H
#define GST_VAAPI_PROFILE_H
#include <gst/gstvalue.h>
G_BEGIN_DECLS
typedef enum _GstVaapiCodec GstVaapiCodec;
typedef enum _GstVaapiProfile GstVaapiProfile;
/**
* GstVaapiCodec:
* @GST_VAAPI_CODEC_MPEG1: MPEG-1 (ISO/IEC 11172)
* @GST_VAAPI_CODEC_MPEG2: MPEG-2 (ISO/IEC 13818-2)
* @GST_VAAPI_CODEC_MPEG4: MPEG-4 Part 2 (ISO/IEC 14496-2)
* @GST_VAAPI_CODEC_H263: H.263
* @GST_VAAPI_CODEC_H264: H.264 aka MPEG-4 Part 10 (ISO/IEC 14496-10)
* @GST_VAAPI_CODEC_VC1: VC-1 (SMPTE 421M)
*
* The set of all codecs for #GstVaapiCodec.
*/
enum _GstVaapiCodec {
GST_VAAPI_CODEC_MPEG1 = GST_MAKE_FOURCC('M','P','1',0),
GST_VAAPI_CODEC_MPEG2 = GST_MAKE_FOURCC('M','P','2',0),
GST_VAAPI_CODEC_MPEG4 = GST_MAKE_FOURCC('M','P','4',0),
GST_VAAPI_CODEC_H263 = GST_MAKE_FOURCC('2','6','3',0),
GST_VAAPI_CODEC_H264 = GST_MAKE_FOURCC('2','6','4',0),
GST_VAAPI_CODEC_VC1 = GST_MAKE_FOURCC('V','C','1',0),
};
/**
* GstVaapiProfile:
* @GST_VAAPI_PROFILE_MPEG1:
* MPEG-1
* @GST_VAAPI_PROFILE_MPEG2_SIMPLE:
* MPEG-2 simple profile
* @GST_VAAPI_PROFILE_MPEG2_MAIN:
* MPEG-2 main profile
* @GST_VAAPI_PROFILE_MPEG4_SIMPLE:
* MPEG-4 Part-2 simple profile
* @GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE:
* MPEG-4 Part-2 advanced simple profile
* @GST_VAAPI_PROFILE_MPEG4_MAIN:
* MPEG-4 Part-2 main profile
* @GST_VAAPI_PROFILE_H263_BASELINE:
* H.263 baseline profile
* @GST_VAAPI_PROFILE_H264_BASELINE:
* H.264 (MPEG-4 Part-10) baseline profile
* @GST_VAAPI_PROFILE_H264_MAIN:
* H.264 (MPEG-4 Part-10) main profile
* @GST_VAAPI_PROFILE_H264_HIGH:
* H.264 (MPEG-4 Part-10) high profile
* @GST_VAAPI_PROFILE_VC1_SIMPLE:
* VC-1 simple profile
* @GST_VAAPI_PROFILE_VC1_MAIN:
* VC-1 main profile (WMV3)
* @GST_VAAPI_PROFILE_VC1_ADVANCED:
* VC-1 advanced profile
*
* The set of all profile for #GstVaapiProfile.
*/
enum _GstVaapiProfile {
GST_VAAPI_PROFILE_MPEG1 = GST_VAAPI_CODEC_MPEG1|1,
GST_VAAPI_PROFILE_MPEG2_SIMPLE = GST_VAAPI_CODEC_MPEG2|1,
GST_VAAPI_PROFILE_MPEG2_MAIN = GST_VAAPI_CODEC_MPEG2|2,
GST_VAAPI_PROFILE_MPEG4_SIMPLE = GST_VAAPI_CODEC_MPEG4|1,
GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE = GST_VAAPI_CODEC_MPEG4|2,
GST_VAAPI_PROFILE_MPEG4_MAIN = GST_VAAPI_CODEC_MPEG4|3,
GST_VAAPI_PROFILE_H263_BASELINE = GST_VAAPI_CODEC_H263|1,
GST_VAAPI_PROFILE_H264_BASELINE = GST_VAAPI_CODEC_H264|1,
GST_VAAPI_PROFILE_H264_MAIN = GST_VAAPI_CODEC_H264|2,
GST_VAAPI_PROFILE_H264_HIGH = GST_VAAPI_CODEC_H264|3,
GST_VAAPI_PROFILE_VC1_SIMPLE = GST_VAAPI_CODEC_VC1|1,
GST_VAAPI_PROFILE_VC1_MAIN = GST_VAAPI_CODEC_VC1|2,
GST_VAAPI_PROFILE_VC1_ADVANCED = GST_VAAPI_CODEC_VC1|3,
};
GstVaapiProfile
gst_vaapi_profile(VAProfile profile);
GstVaapiProfile
gst_vaapi_profile_from_caps(GstCaps *caps);
VAProfile
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile);
GstCaps *
gst_vaapi_profile_get_caps(GstVaapiProfile profile);
GstVaapiCodec
gst_vaapi_profile_get_codec(GstVaapiProfile profile);
G_END_DECLS
#endif /* GST_GST_VAAPI_IMAGE_H */

View file

@ -33,7 +33,38 @@
#endif
static void
print_caps(GstCaps *caps, const gchar *name)
print_profile_caps(GstCaps *caps, const gchar *name)
{
guint i, n_caps = gst_caps_get_size(caps);
gint version;
const gchar *profile;
gboolean has_version;
g_print("%u %s caps\n", n_caps, name);
for (i = 0; i < gst_caps_get_size(caps); i++) {
GstStructure * const structure = gst_caps_get_structure(caps, i);
if (!structure)
g_error("could not get caps structure %d", i);
has_version = (
gst_structure_get_int(structure, "version", &version) ||
gst_structure_get_int(structure, "mpegversion", &version)
);
g_print(" %s", gst_structure_get_name(structure));
if (has_version)
g_print("%d", version);
profile = gst_structure_get_string(structure, "profile");
if (!profile)
g_error("could not get structure profile");
g_print(": %s profile\n", profile);
}
}
static void
print_format_caps(GstCaps *caps, const gchar *name)
{
guint i, n_caps = gst_caps_get_size(caps);
@ -84,18 +115,32 @@ dump_caps(GstVaapiDisplay *display)
{
GstCaps *caps;
caps = gst_vaapi_display_get_decode_caps(display);
if (!caps)
g_error("could not get VA decode caps");
print_profile_caps(caps, "decoders");
gst_caps_unref(caps);
caps = gst_vaapi_display_get_encode_caps(display);
if (!caps)
g_error("could not get VA encode caps");
print_profile_caps(caps, "encoders");
gst_caps_unref(caps);
caps = gst_vaapi_display_get_image_caps(display);
if (!caps)
g_error("could not get VA image caps");
print_caps(caps, "image");
print_format_caps(caps, "image");
gst_caps_unref(caps);
caps = gst_vaapi_display_get_subpicture_caps(display);
if (!caps)
g_error("could not get VA subpicture caps");
print_caps(caps, "subpicture");
print_format_caps(caps, "subpicture");
gst_caps_unref(caps);
}