mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
Add helper to convert from GstVaapiImageFormat to GstCaps.
This commit is contained in:
parent
1689ee112d
commit
b5548b7efd
2 changed files with 28 additions and 8 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
#include "gstvaapiimageformat.h"
|
#include "gstvaapiimageformat.h"
|
||||||
|
|
||||||
typedef enum _GstVaapiImageFormatType GstVaapiImageFormatType;
|
typedef enum _GstVaapiImageFormatType GstVaapiImageFormatType;
|
||||||
|
@ -34,20 +35,20 @@ enum _GstVaapiImageFormatType {
|
||||||
struct _GstVaapiImageFormatMap {
|
struct _GstVaapiImageFormatMap {
|
||||||
GstVaapiImageFormatType type;
|
GstVaapiImageFormatType type;
|
||||||
GstVaapiImageFormat format;
|
GstVaapiImageFormat format;
|
||||||
|
GstStaticCaps caps;
|
||||||
VAImageFormat va_format;
|
VAImageFormat va_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEF(TYPE, FORMAT) \
|
#define DEF(TYPE, FORMAT, CAPS_STR) \
|
||||||
GST_VAAPI_IMAGE_FORMAT_TYPE_##TYPE, GST_VAAPI_IMAGE_##FORMAT
|
GST_VAAPI_IMAGE_FORMAT_TYPE_##TYPE, \
|
||||||
|
GST_VAAPI_IMAGE_##FORMAT, \
|
||||||
|
GST_STATIC_CAPS(CAPS_STR)
|
||||||
#define DEF_YUV(FORMAT, FOURCC, ENDIAN, BPP) \
|
#define DEF_YUV(FORMAT, FOURCC, ENDIAN, BPP) \
|
||||||
{ DEF(YCBCR, FORMAT), \
|
{ DEF(YCBCR, FORMAT, GST_VIDEO_CAPS_YUV(#FORMAT)), \
|
||||||
{ VA_FOURCC FOURCC, VA_##ENDIAN##_FIRST, BPP, }, }
|
{ VA_FOURCC FOURCC, VA_##ENDIAN##_FIRST, BPP, }, }
|
||||||
#define DEF_RGB(FORMAT, FOURCC, ENDIAN, BPP, DEPTH, R,G,B,A) \
|
#define DEF_RGB(FORMAT, FOURCC, ENDIAN, BPP, DEPTH, R,G,B,A) \
|
||||||
{ DEF(RGB, FORMAT), \
|
{ DEF(RGB, FORMAT, GST_VIDEO_CAPS_##FORMAT), \
|
||||||
{ VA_FOURCC FOURCC, VA_##ENDIAN##_FIRST, BPP, DEPTH, R,G,B,A }, }
|
{ VA_FOURCC FOURCC, VA_##ENDIAN##_FIRST, BPP, DEPTH, R,G,B,A }, }
|
||||||
#define DEF_IDX(FORMAT, FOURCC, ENDIAN, BPP, NPE, EB, C0,C1,C2,C3) \
|
|
||||||
{ DEF(TYPE, FORMAT), \
|
|
||||||
{ VA_FOURCC FOURCC, VA_##ENDIAN##_FIRST, BPP, }
|
|
||||||
|
|
||||||
static const GstVaapiImageFormatMap gst_vaapi_image_formats[] = {
|
static const GstVaapiImageFormatMap gst_vaapi_image_formats[] = {
|
||||||
DEF_YUV(NV12, ('N','V','1','2'), LSB, 12),
|
DEF_YUV(NV12, ('N','V','1','2'), LSB, 12),
|
||||||
|
@ -67,7 +68,6 @@ static const GstVaapiImageFormatMap gst_vaapi_image_formats[] = {
|
||||||
{ 0, }
|
{ 0, }
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef DEF_IDX
|
|
||||||
#undef DEF_RGB
|
#undef DEF_RGB
|
||||||
#undef DEF_YUV
|
#undef DEF_YUV
|
||||||
#undef DEF
|
#undef DEF
|
||||||
|
@ -151,3 +151,20 @@ gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format)
|
||||||
|
|
||||||
return &m->va_format;
|
return &m->va_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstCaps *
|
||||||
|
gst_vaapi_image_format_get_caps(GstVaapiImageFormat format)
|
||||||
|
{
|
||||||
|
GstCaps *caps;
|
||||||
|
const GstVaapiImageFormatMap *m;
|
||||||
|
|
||||||
|
m = get_map_from_gst_vaapi_image_format(format);
|
||||||
|
|
||||||
|
g_return_val_if_fail(m, NULL);
|
||||||
|
|
||||||
|
caps = gst_static_caps_get(&m->caps);
|
||||||
|
if (!caps)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return gst_caps_make_writable(caps);
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ 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);
|
||||||
|
|
||||||
|
GstCaps *
|
||||||
|
gst_vaapi_image_format_get_caps(GstVaapiImageFormat format);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_GST_VAAPI_IMAGE_H */
|
#endif /* GST_GST_VAAPI_IMAGE_H */
|
||||||
|
|
Loading…
Reference in a new issue