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 *
-get_map_from_gst_vaapi_image_format(GstVaapiImageFormat format)
+get_map(GstVaapiImageFormat format)
{
const GstVaapiImageFormatMap *m;
gboolean
gst_vaapi_image_format_is_rgb(GstVaapiImageFormat format)
{
- const GstVaapiImageFormatMap *m;
-
- m = get_map_from_gst_vaapi_image_format(format);
- if (!m)
- return FALSE;
+ const GstVaapiImageFormatMap * const m = get_map(format);
- return m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB;
+ return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_RGB) : FALSE;
}
gboolean
gst_vaapi_image_format_is_yuv(GstVaapiImageFormat format)
{
- const GstVaapiImageFormatMap *m;
-
- m = get_map_from_gst_vaapi_image_format(format);
- if (!m)
- return FALSE;
+ const GstVaapiImageFormatMap * const m = get_map(format);
- return m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR;
+ return m ? (m->type == GST_VAAPI_IMAGE_FORMAT_TYPE_YCBCR) : FALSE;
}
GstVaapiImageFormat
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
const VAImageFormat *
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);
- if (!m)
- return NULL;
-
- return &m->va_format;
+ return m ? &m->va_format : NULL;
}
GstCaps *
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);
- if (!m)
- return NULL;
-
- return gst_caps_from_string(m->caps_str);
+ return m ? gst_caps_from_string(m->caps_str) : NULL;
}
guint
gst_vaapi_image_format_get_score(GstVaapiImageFormat format)
{
- const GstVaapiImageFormatMap *m;
-
- m = get_map_from_gst_vaapi_image_format(format);
- if (!m)
- return G_MAXUINT;
+ const GstVaapiImageFormatMap * const m = get_map(format);
- return m - &gst_vaapi_image_formats[0];
+ return m ? (m - &gst_vaapi_image_formats[0]) : G_MAXUINT;
}