mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 21:51:09 +00:00
Simplify format conversion code.
This commit is contained in:
parent
d5253e6e2c
commit
56827ae5b6
1 changed files with 19 additions and 48 deletions
|
@ -83,21 +83,8 @@ match_va_format_rgb(const VAImageFormat *fmt1, const VAImageFormat *fmt2)
|
||||||
fmt1->alpha_mask == fmt2->alpha_mask);
|
fmt1->alpha_mask == fmt2->alpha_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GstVaapiImageFormatMap *get_map(const VAImageFormat *va_format)
|
|
||||||
{
|
|
||||||
const GstVaapiImageFormatMap *m;
|
|
||||||
|
|
||||||
for (m = gst_vaapi_image_formats; m->format; m++)
|
|
||||||
if (m->va_format.fourcc == va_format->fourcc &&
|
|
||||||
(m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB ?
|
|
||||||
match_va_format_rgb(&m->va_format, va_format) :
|
|
||||||
TRUE))
|
|
||||||
return m;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const GstVaapiImageFormatMap *
|
static const GstVaapiImageFormatMap *
|
||||||
get_map_from_gst_vaapi_image_format(GstVaapiImageFormat format)
|
get_map(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap *m;
|
||||||
|
|
||||||
|
@ -110,36 +97,32 @@ get_map_from_gst_vaapi_image_format(GstVaapiImageFormat format)
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_image_format_is_rgb(GstVaapiImageFormat format)
|
gst_vaapi_image_format_is_rgb(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap * const m = get_map(format);
|
||||||
|
|
||||||
m = get_map_from_gst_vaapi_image_format(format);
|
return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB) : FALSE;
|
||||||
if (!m)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_image_format_is_yuv(GstVaapiImageFormat format)
|
gst_vaapi_image_format_is_yuv(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap * const m = get_map(format);
|
||||||
|
|
||||||
m = get_map_from_gst_vaapi_image_format(format);
|
return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR) : FALSE;
|
||||||
if (!m)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiImageFormat
|
GstVaapiImageFormat
|
||||||
gst_vaapi_image_format(const VAImageFormat *va_format)
|
gst_vaapi_image_format(const VAImageFormat *va_format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap * const m = get_map(va_format);
|
const GstVaapiImageFormatMap *m;
|
||||||
|
|
||||||
if (!m)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
for (m = gst_vaapi_image_formats; m->format; m++)
|
||||||
|
if (m->va_format.fourcc == va_format->fourcc &&
|
||||||
|
(m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB ?
|
||||||
|
match_va_format_rgb(&m->va_format, va_format) :
|
||||||
|
TRUE))
|
||||||
return m->format;
|
return m->format;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiImageFormat
|
GstVaapiImageFormat
|
||||||
|
@ -200,35 +183,23 @@ gst_vaapi_image_format_from_fourcc(guint32 fourcc)
|
||||||
const VAImageFormat *
|
const VAImageFormat *
|
||||||
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format)
|
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap * const m = get_map(format);
|
||||||
|
|
||||||
m = get_map_from_gst_vaapi_image_format(format);
|
return m ? &m->va_format : NULL;
|
||||||
if (!m)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return &m->va_format;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
GstCaps *
|
||||||
gst_vaapi_image_format_get_caps(GstVaapiImageFormat format)
|
gst_vaapi_image_format_get_caps(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap * const m = get_map(format);
|
||||||
|
|
||||||
m = get_map_from_gst_vaapi_image_format(format);
|
return m ? gst_caps_from_string(m->caps_str) : NULL;
|
||||||
if (!m)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return gst_caps_from_string(m->caps_str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_image_format_get_score(GstVaapiImageFormat format)
|
gst_vaapi_image_format_get_score(GstVaapiImageFormat format)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormatMap *m;
|
const GstVaapiImageFormatMap * const m = get_map(format);
|
||||||
|
|
||||||
m = get_map_from_gst_vaapi_image_format(format);
|
return m ? (m - &gst_vaapi_image_formats[0]) : G_MAXUINT;
|
||||||
if (!m)
|
|
||||||
return G_MAXUINT;
|
|
||||||
|
|
||||||
return m - &gst_vaapi_image_formats[0];
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue