mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 10:41:04 +00:00
utils: add helper functions to get codec or profile name.
This commit is contained in:
parent
690e85ff8e
commit
a6fe7698bc
2 changed files with 93 additions and 4 deletions
|
@ -34,13 +34,19 @@
|
||||||
#include "gstvaapiprofile.h"
|
#include "gstvaapiprofile.h"
|
||||||
#include "gstvaapiworkarounds.h"
|
#include "gstvaapiworkarounds.h"
|
||||||
|
|
||||||
|
typedef struct _GstVaapiCodecMap GstVaapiCodecMap;
|
||||||
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
|
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
|
||||||
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
|
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
|
||||||
|
|
||||||
|
struct _GstVaapiCodecMap {
|
||||||
|
GstVaapiCodec codec;
|
||||||
|
const gchar *name;
|
||||||
|
};
|
||||||
|
|
||||||
struct _GstVaapiProfileMap {
|
struct _GstVaapiProfileMap {
|
||||||
GstVaapiProfile profile;
|
GstVaapiProfile profile;
|
||||||
VAProfile va_profile;
|
VAProfile va_profile;
|
||||||
const char *caps_str;
|
const char *media_str;
|
||||||
const gchar *profile_str;
|
const gchar *profile_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,6 +55,19 @@ struct _GstVaapiEntrypointMap {
|
||||||
VAEntrypoint va_entrypoint;
|
VAEntrypoint va_entrypoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Codecs */
|
||||||
|
static const GstVaapiCodecMap gst_vaapi_codecs[] = {
|
||||||
|
{ GST_VAAPI_CODEC_MPEG1, "mpeg1" },
|
||||||
|
{ GST_VAAPI_CODEC_MPEG2, "mpeg2" },
|
||||||
|
{ GST_VAAPI_CODEC_MPEG4, "mpeg4" },
|
||||||
|
{ GST_VAAPI_CODEC_H263, "h263" },
|
||||||
|
{ GST_VAAPI_CODEC_H264, "h264" },
|
||||||
|
{ GST_VAAPI_CODEC_WMV3, "wmv3" },
|
||||||
|
{ GST_VAAPI_CODEC_VC1, "vc1" },
|
||||||
|
{ GST_VAAPI_CODEC_JPEG, "jpeg" },
|
||||||
|
{ 0, }
|
||||||
|
};
|
||||||
|
|
||||||
/* Profiles */
|
/* Profiles */
|
||||||
static const GstVaapiProfileMap gst_vaapi_profiles[] = {
|
static const GstVaapiProfileMap gst_vaapi_profiles[] = {
|
||||||
{ GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
|
{ GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
|
||||||
|
@ -120,6 +139,17 @@ static const GstVaapiEntrypointMap gst_vaapi_entrypoints[] = {
|
||||||
{ 0, }
|
{ 0, }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const GstVaapiCodecMap *
|
||||||
|
get_codecs_map(GstVaapiCodec codec)
|
||||||
|
{
|
||||||
|
const GstVaapiCodecMap *m;
|
||||||
|
|
||||||
|
for (m = gst_vaapi_codecs; m->codec; m++)
|
||||||
|
if (m->codec == codec)
|
||||||
|
return m;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static const GstVaapiProfileMap *
|
static const GstVaapiProfileMap *
|
||||||
get_profiles_map(GstVaapiProfile profile)
|
get_profiles_map(GstVaapiProfile profile)
|
||||||
{
|
{
|
||||||
|
@ -142,6 +172,22 @@ get_entrypoints_map(GstVaapiEntrypoint entrypoint)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_codec_get_name:
|
||||||
|
* @codec: a #GstVaapiCodec
|
||||||
|
*
|
||||||
|
* Returns a string representation for the supplied @codec type.
|
||||||
|
*
|
||||||
|
* Return value: the statically allocated string representation of @codec
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_codec_get_name(GstVaapiCodec codec)
|
||||||
|
{
|
||||||
|
const GstVaapiCodecMap * const m = get_codecs_map(codec);
|
||||||
|
|
||||||
|
return m ? m->name : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_profile:
|
* gst_vaapi_profile:
|
||||||
* @profile: a #VAProfile
|
* @profile: a #VAProfile
|
||||||
|
@ -163,6 +209,40 @@ gst_vaapi_profile(VAProfile profile)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_profile_get_name:
|
||||||
|
* @profile: a #GstVaapiProfile
|
||||||
|
*
|
||||||
|
* Returns a string representation for the supplied @profile.
|
||||||
|
*
|
||||||
|
* Return value: the statically allocated string representation of @profile
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_profile_get_name(GstVaapiProfile profile)
|
||||||
|
{
|
||||||
|
const GstVaapiProfileMap * const m = get_profiles_map(profile);
|
||||||
|
|
||||||
|
return m ? m->profile_str : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_profile_get_media_type_name:
|
||||||
|
* @profile: a #GstVaapiProfile
|
||||||
|
*
|
||||||
|
* Returns a string representation for the media type of the supplied
|
||||||
|
* @profile.
|
||||||
|
*
|
||||||
|
* Return value: the statically allocated string representation of
|
||||||
|
* @profile media type
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_profile_get_media_type_name(GstVaapiProfile profile)
|
||||||
|
{
|
||||||
|
const GstVaapiProfileMap * const m = get_profiles_map(profile);
|
||||||
|
|
||||||
|
return m ? m->media_str : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_profile_from_codec_data:
|
* gst_vaapi_profile_from_codec_data:
|
||||||
* @codec: a #GstVaapiCodec
|
* @codec: a #GstVaapiCodec
|
||||||
|
@ -256,9 +336,9 @@ gst_vaapi_profile_from_caps(const GstCaps *caps)
|
||||||
profile = 0;
|
profile = 0;
|
||||||
best_profile = 0;
|
best_profile = 0;
|
||||||
for (m = gst_vaapi_profiles; !profile && m->profile; m++) {
|
for (m = gst_vaapi_profiles; !profile && m->profile; m++) {
|
||||||
if (strncmp(name, m->caps_str, namelen) != 0)
|
if (strncmp(name, m->media_str, namelen) != 0)
|
||||||
continue;
|
continue;
|
||||||
caps_test = gst_caps_from_string(m->caps_str);;
|
caps_test = gst_caps_from_string(m->media_str);
|
||||||
if (gst_caps_is_always_compatible(caps, caps_test)) {
|
if (gst_caps_is_always_compatible(caps, caps_test)) {
|
||||||
best_profile = m->profile;
|
best_profile = m->profile;
|
||||||
if (profile_str && m->profile_str &&
|
if (profile_str && m->profile_str &&
|
||||||
|
@ -322,7 +402,7 @@ gst_vaapi_profile_get_caps(GstVaapiProfile profile)
|
||||||
for (m = gst_vaapi_profiles; m->profile; m++) {
|
for (m = gst_vaapi_profiles; m->profile; m++) {
|
||||||
if (m->profile != profile)
|
if (m->profile != profile)
|
||||||
continue;
|
continue;
|
||||||
caps = gst_caps_from_string(m->caps_str);
|
caps = gst_caps_from_string(m->media_str);
|
||||||
if (!caps)
|
if (!caps)
|
||||||
continue;
|
continue;
|
||||||
gst_caps_set_simple(
|
gst_caps_set_simple(
|
||||||
|
|
|
@ -169,12 +169,21 @@ typedef enum {
|
||||||
GST_VAAPI_ENTRYPOINT_SLICE_ENCODE
|
GST_VAAPI_ENTRYPOINT_SLICE_ENCODE
|
||||||
} GstVaapiEntrypoint;
|
} GstVaapiEntrypoint;
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_codec_get_name(GstVaapiCodec codec);
|
||||||
|
|
||||||
GstVaapiProfile
|
GstVaapiProfile
|
||||||
gst_vaapi_profile(VAProfile profile);
|
gst_vaapi_profile(VAProfile profile);
|
||||||
|
|
||||||
GstVaapiProfile
|
GstVaapiProfile
|
||||||
gst_vaapi_profile_from_caps(const GstCaps *caps);
|
gst_vaapi_profile_from_caps(const GstCaps *caps);
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_profile_get_name(GstVaapiProfile profile);
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_vaapi_profile_get_media_type_name(GstVaapiProfile profile);
|
||||||
|
|
||||||
VAProfile
|
VAProfile
|
||||||
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile);
|
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue