mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
libs: re-indent all source code related to VA utilities.
This commit is contained in:
parent
84044f28f7
commit
449727ea31
11 changed files with 1069 additions and 1121 deletions
|
@ -47,182 +47,187 @@
|
|||
|
||||
/* Check VA status for success or print out an error */
|
||||
gboolean
|
||||
vaapi_check_status(VAStatus status, const char *msg)
|
||||
vaapi_check_status (VAStatus status, const gchar * msg)
|
||||
{
|
||||
if (status != VA_STATUS_SUCCESS) {
|
||||
GST_DEBUG("%s: %s", msg, vaErrorStr(status));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
if (status != VA_STATUS_SUCCESS) {
|
||||
GST_DEBUG ("%s: %s", msg, vaErrorStr (status));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Maps VA buffer */
|
||||
void *
|
||||
vaapi_map_buffer(VADisplay dpy, VABufferID buf_id)
|
||||
gpointer
|
||||
vaapi_map_buffer (VADisplay dpy, VABufferID buf_id)
|
||||
{
|
||||
VAStatus status;
|
||||
void *data = NULL;
|
||||
VAStatus status;
|
||||
gpointer data = NULL;
|
||||
|
||||
status = vaMapBuffer(dpy, buf_id, &data);
|
||||
if (!vaapi_check_status(status, "vaMapBuffer()"))
|
||||
return NULL;
|
||||
return data;
|
||||
status = vaMapBuffer (dpy, buf_id, &data);
|
||||
if (!vaapi_check_status (status, "vaMapBuffer()"))
|
||||
return NULL;
|
||||
return data;
|
||||
}
|
||||
|
||||
/* Unmaps VA buffer */
|
||||
void
|
||||
vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf)
|
||||
vaapi_unmap_buffer (VADisplay dpy, VABufferID buf_id, gpointer * pbuf)
|
||||
{
|
||||
VAStatus status;
|
||||
VAStatus status;
|
||||
|
||||
if (pbuf)
|
||||
*pbuf = NULL;
|
||||
if (pbuf)
|
||||
*pbuf = NULL;
|
||||
|
||||
status = vaUnmapBuffer(dpy, buf_id);
|
||||
if (!vaapi_check_status(status, "vaUnmapBuffer()"))
|
||||
return;
|
||||
status = vaUnmapBuffer (dpy, buf_id);
|
||||
if (!vaapi_check_status (status, "vaUnmapBuffer()"))
|
||||
return;
|
||||
}
|
||||
|
||||
/* Creates and maps VA buffer */
|
||||
gboolean
|
||||
vaapi_create_buffer(
|
||||
VADisplay dpy,
|
||||
VAContextID ctx,
|
||||
int type,
|
||||
unsigned int size,
|
||||
gconstpointer buf,
|
||||
VABufferID *buf_id_ptr,
|
||||
gpointer *mapped_data
|
||||
)
|
||||
vaapi_create_buffer (VADisplay dpy, VAContextID ctx, int type, guint size,
|
||||
gconstpointer buf, VABufferID * buf_id_ptr, gpointer * mapped_data)
|
||||
{
|
||||
VABufferID buf_id;
|
||||
VAStatus status;
|
||||
gpointer data = (gpointer)buf;
|
||||
VABufferID buf_id;
|
||||
VAStatus status;
|
||||
gpointer data = (gpointer) buf;
|
||||
|
||||
status = vaCreateBuffer(dpy, ctx, type, size, 1, data, &buf_id);
|
||||
if (!vaapi_check_status(status, "vaCreateBuffer()"))
|
||||
return FALSE;
|
||||
status = vaCreateBuffer (dpy, ctx, type, size, 1, data, &buf_id);
|
||||
if (!vaapi_check_status (status, "vaCreateBuffer()"))
|
||||
return FALSE;
|
||||
|
||||
if (mapped_data) {
|
||||
data = vaapi_map_buffer(dpy, buf_id);
|
||||
if (!data)
|
||||
goto error;
|
||||
*mapped_data = data;
|
||||
}
|
||||
if (mapped_data) {
|
||||
data = vaapi_map_buffer (dpy, buf_id);
|
||||
if (!data)
|
||||
goto error;
|
||||
*mapped_data = data;
|
||||
}
|
||||
|
||||
*buf_id_ptr = buf_id;
|
||||
return TRUE;
|
||||
*buf_id_ptr = buf_id;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
vaapi_destroy_buffer(dpy, &buf_id);
|
||||
return FALSE;
|
||||
vaapi_destroy_buffer (dpy, &buf_id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Destroy VA buffer */
|
||||
void
|
||||
vaapi_destroy_buffer(VADisplay dpy, VABufferID *buf_id_ptr)
|
||||
vaapi_destroy_buffer (VADisplay dpy, VABufferID * buf_id_ptr)
|
||||
{
|
||||
if (!buf_id_ptr || *buf_id_ptr == VA_INVALID_ID)
|
||||
return;
|
||||
if (!buf_id_ptr || *buf_id_ptr == VA_INVALID_ID)
|
||||
return;
|
||||
|
||||
vaDestroyBuffer(dpy, *buf_id_ptr);
|
||||
*buf_id_ptr = VA_INVALID_ID;
|
||||
vaDestroyBuffer (dpy, *buf_id_ptr);
|
||||
*buf_id_ptr = VA_INVALID_ID;
|
||||
}
|
||||
|
||||
/* Return a string representation of a VAProfile */
|
||||
const char *string_of_VAProfile(VAProfile profile)
|
||||
const gchar *
|
||||
string_of_VAProfile (VAProfile profile)
|
||||
{
|
||||
switch (profile) {
|
||||
switch (profile) {
|
||||
#define MAP(profile) \
|
||||
STRCASEP(VAProfile, profile)
|
||||
MAP(MPEG2Simple);
|
||||
MAP(MPEG2Main);
|
||||
MAP(MPEG4Simple);
|
||||
MAP(MPEG4AdvancedSimple);
|
||||
MAP(MPEG4Main);
|
||||
MAP (MPEG2Simple);
|
||||
MAP (MPEG2Main);
|
||||
MAP (MPEG4Simple);
|
||||
MAP (MPEG4AdvancedSimple);
|
||||
MAP (MPEG4Main);
|
||||
#if VA_CHECK_VERSION(0,32,0)
|
||||
MAP(JPEGBaseline);
|
||||
MAP(H263Baseline);
|
||||
MAP(H264ConstrainedBaseline);
|
||||
MAP (JPEGBaseline);
|
||||
MAP (H263Baseline);
|
||||
MAP (H264ConstrainedBaseline);
|
||||
#endif
|
||||
MAP(H264Baseline);
|
||||
MAP(H264Main);
|
||||
MAP(H264High);
|
||||
MAP(VC1Simple);
|
||||
MAP(VC1Main);
|
||||
MAP(VC1Advanced);
|
||||
MAP (H264Baseline);
|
||||
MAP (H264Main);
|
||||
MAP (H264High);
|
||||
MAP (VC1Simple);
|
||||
MAP (VC1Main);
|
||||
MAP (VC1Advanced);
|
||||
#undef MAP
|
||||
default: break;
|
||||
}
|
||||
return "<unknown>";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
/* Return a string representation of a VAEntrypoint */
|
||||
const char *string_of_VAEntrypoint(VAEntrypoint entrypoint)
|
||||
const gchar *
|
||||
string_of_VAEntrypoint (VAEntrypoint entrypoint)
|
||||
{
|
||||
switch (entrypoint) {
|
||||
switch (entrypoint) {
|
||||
#define MAP(entrypoint) \
|
||||
STRCASEP(VAEntrypoint, entrypoint)
|
||||
MAP(VLD);
|
||||
MAP(IZZ);
|
||||
MAP(IDCT);
|
||||
MAP(MoComp);
|
||||
MAP(Deblocking);
|
||||
MAP (VLD);
|
||||
MAP (IZZ);
|
||||
MAP (IDCT);
|
||||
MAP (MoComp);
|
||||
MAP (Deblocking);
|
||||
#undef MAP
|
||||
default: break;
|
||||
}
|
||||
return "<unknown>";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
/* Return a string representation of a VADisplayAttributeType */
|
||||
const char *
|
||||
string_of_VADisplayAttributeType(VADisplayAttribType attribute_type)
|
||||
const gchar *
|
||||
string_of_VADisplayAttributeType (VADisplayAttribType attribute_type)
|
||||
{
|
||||
switch (attribute_type) {
|
||||
switch (attribute_type) {
|
||||
#define MAP(attribute_type) \
|
||||
STRCASEP(VADisplayAttrib, attribute_type)
|
||||
MAP(Brightness);
|
||||
MAP(Contrast);
|
||||
MAP(Hue);
|
||||
MAP(Saturation);
|
||||
MAP(BackgroundColor);
|
||||
MAP (Brightness);
|
||||
MAP (Contrast);
|
||||
MAP (Hue);
|
||||
MAP (Saturation);
|
||||
MAP (BackgroundColor);
|
||||
#if !VA_CHECK_VERSION(0,34,0)
|
||||
MAP(DirectSurface);
|
||||
MAP (DirectSurface);
|
||||
#endif
|
||||
MAP(Rotation);
|
||||
MAP(OutofLoopDeblock);
|
||||
MAP (Rotation);
|
||||
MAP (OutofLoopDeblock);
|
||||
#if VA_CHECK_VERSION(0,31,1) && !VA_CHECK_VERSION(0,34,0)
|
||||
MAP(BLEBlackMode);
|
||||
MAP(BLEWhiteMode);
|
||||
MAP(BlueStretch);
|
||||
MAP(SkinColorCorrection);
|
||||
MAP (BLEBlackMode);
|
||||
MAP (BLEWhiteMode);
|
||||
MAP (BlueStretch);
|
||||
MAP (SkinColorCorrection);
|
||||
#endif
|
||||
MAP(CSCMatrix);
|
||||
MAP(BlendColor);
|
||||
MAP(OverlayAutoPaintColorKey);
|
||||
MAP(OverlayColorKey);
|
||||
MAP(RenderMode);
|
||||
MAP(RenderDevice);
|
||||
MAP(RenderRect);
|
||||
MAP (CSCMatrix);
|
||||
MAP (BlendColor);
|
||||
MAP (OverlayAutoPaintColorKey);
|
||||
MAP (OverlayColorKey);
|
||||
MAP (RenderMode);
|
||||
MAP (RenderDevice);
|
||||
MAP (RenderRect);
|
||||
#undef MAP
|
||||
default: break;
|
||||
}
|
||||
return "<unknown>";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
const char *
|
||||
string_of_VARateControl(guint rate_control)
|
||||
const gchar *
|
||||
string_of_VARateControl (guint rate_control)
|
||||
{
|
||||
switch (rate_control) {
|
||||
case VA_RC_NONE: return "None";
|
||||
case VA_RC_CQP: return "CQP";
|
||||
case VA_RC_CBR: return "CBR";
|
||||
case VA_RC_VCM: return "VCM";
|
||||
case VA_RC_VBR: return "VBR";
|
||||
case VA_RC_VBR_CONSTRAINED: return "VBR-Constrained";
|
||||
default: break;
|
||||
}
|
||||
return "<unknown>";
|
||||
switch (rate_control) {
|
||||
case VA_RC_NONE:
|
||||
return "None";
|
||||
case VA_RC_CQP:
|
||||
return "CQP";
|
||||
case VA_RC_CBR:
|
||||
return "CBR";
|
||||
case VA_RC_VCM:
|
||||
return "VCM";
|
||||
case VA_RC_VBR:
|
||||
return "VBR";
|
||||
case VA_RC_VBR_CONSTRAINED:
|
||||
return "VBR-Constrained";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,39 +238,39 @@ string_of_VARateControl(guint rate_control)
|
|||
* vaCreateSurfaces().
|
||||
*/
|
||||
guint
|
||||
from_GstVaapiChromaType(guint chroma_type)
|
||||
from_GstVaapiChromaType (guint chroma_type)
|
||||
{
|
||||
guint format;
|
||||
guint format;
|
||||
|
||||
switch (chroma_type) {
|
||||
switch (chroma_type) {
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV420:
|
||||
format = VA_RT_FORMAT_YUV420;
|
||||
break;
|
||||
format = VA_RT_FORMAT_YUV420;
|
||||
break;
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV422:
|
||||
format = VA_RT_FORMAT_YUV422;
|
||||
break;
|
||||
format = VA_RT_FORMAT_YUV422;
|
||||
break;
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV444:
|
||||
format = VA_RT_FORMAT_YUV444;
|
||||
break;
|
||||
format = VA_RT_FORMAT_YUV444;
|
||||
break;
|
||||
#if VA_CHECK_VERSION(0,34,0)
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV411:
|
||||
format = VA_RT_FORMAT_YUV411;
|
||||
break;
|
||||
format = VA_RT_FORMAT_YUV411;
|
||||
break;
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV400:
|
||||
format = VA_RT_FORMAT_YUV400;
|
||||
break;
|
||||
format = VA_RT_FORMAT_YUV400;
|
||||
break;
|
||||
case GST_VAAPI_CHROMA_TYPE_RGB32:
|
||||
format = VA_RT_FORMAT_RGB32;
|
||||
break;
|
||||
format = VA_RT_FORMAT_RGB32;
|
||||
break;
|
||||
case GST_VAAPI_CHROMA_TYPE_RGB16:
|
||||
format = VA_RT_FORMAT_RGB16;
|
||||
break;
|
||||
format = VA_RT_FORMAT_RGB16;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
format = 0;
|
||||
break;
|
||||
}
|
||||
return format;
|
||||
format = 0;
|
||||
break;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,17 +281,17 @@ from_GstVaapiChromaType(guint chroma_type)
|
|||
* vaAssociateSubpicture().
|
||||
*/
|
||||
guint
|
||||
from_GstVaapiSubpictureFlags(guint flags)
|
||||
from_GstVaapiSubpictureFlags (guint flags)
|
||||
{
|
||||
guint va_flags = 0;
|
||||
guint va_flags = 0;
|
||||
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA)
|
||||
va_flags |= VA_SUBPICTURE_GLOBAL_ALPHA;
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA)
|
||||
va_flags |= VA_SUBPICTURE_GLOBAL_ALPHA;
|
||||
#ifdef VA_SUBPICTURE_PREMULTIPLIED_ALPHA
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA)
|
||||
flags |= VA_SUBPICTURE_PREMULTIPLIED_ALPHA;
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA)
|
||||
flags |= VA_SUBPICTURE_PREMULTIPLIED_ALPHA;
|
||||
#endif
|
||||
return va_flags;
|
||||
return va_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,17 +304,17 @@ from_GstVaapiSubpictureFlags(guint flags)
|
|||
* Return value: the #GstVaapiSubpictureFlags flags
|
||||
*/
|
||||
guint
|
||||
to_GstVaapiSubpictureFlags(guint va_flags)
|
||||
to_GstVaapiSubpictureFlags (guint va_flags)
|
||||
{
|
||||
guint flags = 0;
|
||||
guint flags = 0;
|
||||
|
||||
if (va_flags & VA_SUBPICTURE_GLOBAL_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA;
|
||||
if (va_flags & VA_SUBPICTURE_GLOBAL_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA;
|
||||
#ifdef VA_SUBPICTURE_PREMULTIPLIED_ALPHA
|
||||
if (va_flags & VA_SUBPICTURE_PREMULTIPLIED_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA;
|
||||
if (va_flags & VA_SUBPICTURE_PREMULTIPLIED_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA;
|
||||
#endif
|
||||
return flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,17 +326,17 @@ to_GstVaapiSubpictureFlags(guint va_flags)
|
|||
* Return value: the #GstVaapiSubpictureFlags flags
|
||||
*/
|
||||
guint
|
||||
from_GstVideoOverlayFormatFlags(guint ovl_flags)
|
||||
from_GstVideoOverlayFormatFlags (guint ovl_flags)
|
||||
{
|
||||
guint flags = 0;
|
||||
guint flags = 0;
|
||||
|
||||
#ifdef HAVE_GST_VIDEO_OVERLAY_HWCAPS
|
||||
if (ovl_flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA;
|
||||
if (ovl_flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA;
|
||||
if (ovl_flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA;
|
||||
if (ovl_flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA)
|
||||
flags |= GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA;
|
||||
#endif
|
||||
return flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,17 +348,17 @@ from_GstVideoOverlayFormatFlags(guint ovl_flags)
|
|||
* Return value: the #GstVideoOverlayFormatFlags flags
|
||||
*/
|
||||
guint
|
||||
to_GstVideoOverlayFormatFlags(guint flags)
|
||||
to_GstVideoOverlayFormatFlags (guint flags)
|
||||
{
|
||||
guint ovl_flags = 0;
|
||||
guint ovl_flags = 0;
|
||||
|
||||
#ifdef HAVE_GST_VIDEO_OVERLAY_HWCAPS
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA)
|
||||
ovl_flags |= GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA;
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA)
|
||||
ovl_flags |= GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA;
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_PREMULTIPLIED_ALPHA)
|
||||
ovl_flags |= GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA;
|
||||
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA)
|
||||
ovl_flags |= GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA;
|
||||
#endif
|
||||
return ovl_flags;
|
||||
return ovl_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,45 +369,45 @@ to_GstVideoOverlayFormatFlags(guint flags)
|
|||
* vaPutSurface().
|
||||
*/
|
||||
guint
|
||||
from_GstVaapiSurfaceRenderFlags(guint flags)
|
||||
from_GstVaapiSurfaceRenderFlags (guint flags)
|
||||
{
|
||||
guint va_fields, va_csc;
|
||||
guint va_fields, va_csc;
|
||||
|
||||
/* Picture structure */
|
||||
switch (flags & GST_VAAPI_PICTURE_STRUCTURE_MASK) {
|
||||
/* Picture structure */
|
||||
switch (flags & GST_VAAPI_PICTURE_STRUCTURE_MASK) {
|
||||
case GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD:
|
||||
va_fields = VA_TOP_FIELD;
|
||||
break;
|
||||
va_fields = VA_TOP_FIELD;
|
||||
break;
|
||||
case GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD:
|
||||
va_fields = VA_BOTTOM_FIELD;
|
||||
break;
|
||||
va_fields = VA_BOTTOM_FIELD;
|
||||
break;
|
||||
default:
|
||||
va_fields = VA_FRAME_PICTURE;
|
||||
break;
|
||||
}
|
||||
va_fields = VA_FRAME_PICTURE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Color standard */
|
||||
switch (flags & GST_VAAPI_COLOR_STANDARD_MASK) {
|
||||
/* Color standard */
|
||||
switch (flags & GST_VAAPI_COLOR_STANDARD_MASK) {
|
||||
#ifdef VA_SRC_BT601
|
||||
case GST_VAAPI_COLOR_STANDARD_ITUR_BT_601:
|
||||
va_csc = VA_SRC_BT601;
|
||||
break;
|
||||
va_csc = VA_SRC_BT601;
|
||||
break;
|
||||
#endif
|
||||
#ifdef VA_SRC_BT709
|
||||
case GST_VAAPI_COLOR_STANDARD_ITUR_BT_709:
|
||||
va_csc = VA_SRC_BT709;
|
||||
break;
|
||||
va_csc = VA_SRC_BT709;
|
||||
break;
|
||||
#endif
|
||||
#ifdef VA_SRC_SMPTE_240
|
||||
case GST_VAAPI_COLOR_STANDARD_SMPTE_240M:
|
||||
va_csc = VA_SRC_SMPTE_240;
|
||||
break;
|
||||
va_csc = VA_SRC_SMPTE_240;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
va_csc = 0;
|
||||
break;
|
||||
}
|
||||
return va_fields|va_csc;
|
||||
va_csc = 0;
|
||||
break;
|
||||
}
|
||||
return va_fields | va_csc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,132 +420,151 @@ from_GstVaapiSurfaceRenderFlags(guint flags)
|
|||
* Return value: the #GstVaapiSurfaceStatus flags
|
||||
*/
|
||||
guint
|
||||
to_GstVaapiSurfaceStatus(guint va_flags)
|
||||
to_GstVaapiSurfaceStatus (guint va_flags)
|
||||
{
|
||||
guint flags;
|
||||
const guint va_flags_mask = (VASurfaceReady|
|
||||
VASurfaceRendering|
|
||||
VASurfaceDisplaying);
|
||||
guint flags;
|
||||
const guint va_flags_mask = (VASurfaceReady |
|
||||
VASurfaceRendering | VASurfaceDisplaying);
|
||||
|
||||
/* Check for core status */
|
||||
switch (va_flags & va_flags_mask) {
|
||||
/* Check for core status */
|
||||
switch (va_flags & va_flags_mask) {
|
||||
case VASurfaceReady:
|
||||
flags = GST_VAAPI_SURFACE_STATUS_IDLE;
|
||||
break;
|
||||
flags = GST_VAAPI_SURFACE_STATUS_IDLE;
|
||||
break;
|
||||
case VASurfaceRendering:
|
||||
flags = GST_VAAPI_SURFACE_STATUS_RENDERING;
|
||||
break;
|
||||
flags = GST_VAAPI_SURFACE_STATUS_RENDERING;
|
||||
break;
|
||||
case VASurfaceDisplaying:
|
||||
flags = GST_VAAPI_SURFACE_STATUS_DISPLAYING;
|
||||
break;
|
||||
flags = GST_VAAPI_SURFACE_STATUS_DISPLAYING;
|
||||
break;
|
||||
default:
|
||||
flags = 0;
|
||||
break;
|
||||
}
|
||||
flags = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for encoder status */
|
||||
/* Check for encoder status */
|
||||
#if VA_CHECK_VERSION(0,30,0)
|
||||
if (va_flags & VASurfaceSkipped)
|
||||
flags |= GST_VAAPI_SURFACE_STATUS_SKIPPED;
|
||||
if (va_flags & VASurfaceSkipped)
|
||||
flags |= GST_VAAPI_SURFACE_STATUS_SKIPPED;
|
||||
#endif
|
||||
return flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* Translate GstVaapiRotation value to VA-API rotation value */
|
||||
guint
|
||||
from_GstVaapiRotation(guint value)
|
||||
from_GstVaapiRotation (guint value)
|
||||
{
|
||||
switch (value) {
|
||||
case GST_VAAPI_ROTATION_0: return VA_ROTATION_NONE;
|
||||
case GST_VAAPI_ROTATION_90: return VA_ROTATION_90;
|
||||
case GST_VAAPI_ROTATION_180: return VA_ROTATION_180;
|
||||
case GST_VAAPI_ROTATION_270: return VA_ROTATION_270;
|
||||
}
|
||||
GST_ERROR("unsupported GstVaapiRotation value %d", value);
|
||||
return VA_ROTATION_NONE;
|
||||
switch (value) {
|
||||
case GST_VAAPI_ROTATION_0:
|
||||
return VA_ROTATION_NONE;
|
||||
case GST_VAAPI_ROTATION_90:
|
||||
return VA_ROTATION_90;
|
||||
case GST_VAAPI_ROTATION_180:
|
||||
return VA_ROTATION_180;
|
||||
case GST_VAAPI_ROTATION_270:
|
||||
return VA_ROTATION_270;
|
||||
}
|
||||
GST_ERROR ("unsupported GstVaapiRotation value %d", value);
|
||||
return VA_ROTATION_NONE;
|
||||
}
|
||||
|
||||
/* Translate VA-API rotation value to GstVaapiRotation value */
|
||||
guint
|
||||
to_GstVaapiRotation(guint value)
|
||||
to_GstVaapiRotation (guint value)
|
||||
{
|
||||
switch (value) {
|
||||
case VA_ROTATION_NONE: return GST_VAAPI_ROTATION_0;
|
||||
case VA_ROTATION_90: return GST_VAAPI_ROTATION_90;
|
||||
case VA_ROTATION_180: return GST_VAAPI_ROTATION_180;
|
||||
case VA_ROTATION_270: return GST_VAAPI_ROTATION_270;
|
||||
}
|
||||
GST_ERROR("unsupported VA-API rotation value %d", value);
|
||||
return GST_VAAPI_ROTATION_0;
|
||||
switch (value) {
|
||||
case VA_ROTATION_NONE:
|
||||
return GST_VAAPI_ROTATION_0;
|
||||
case VA_ROTATION_90:
|
||||
return GST_VAAPI_ROTATION_90;
|
||||
case VA_ROTATION_180:
|
||||
return GST_VAAPI_ROTATION_180;
|
||||
case VA_ROTATION_270:
|
||||
return GST_VAAPI_ROTATION_270;
|
||||
}
|
||||
GST_ERROR ("unsupported VA-API rotation value %d", value);
|
||||
return GST_VAAPI_ROTATION_0;
|
||||
}
|
||||
|
||||
guint
|
||||
from_GstVaapiRateControl(guint value)
|
||||
from_GstVaapiRateControl (guint value)
|
||||
{
|
||||
switch (value) {
|
||||
case GST_VAAPI_RATECONTROL_NONE: return VA_RC_NONE;
|
||||
case GST_VAAPI_RATECONTROL_CQP: return VA_RC_CQP;
|
||||
case GST_VAAPI_RATECONTROL_CBR: return VA_RC_CBR;
|
||||
case GST_VAAPI_RATECONTROL_VCM: return VA_RC_VCM;
|
||||
case GST_VAAPI_RATECONTROL_VBR: return VA_RC_VBR;
|
||||
case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: return VA_RC_VBR_CONSTRAINED;
|
||||
}
|
||||
GST_ERROR("unsupported GstVaapiRateControl value %u", value);
|
||||
return VA_RC_NONE;
|
||||
switch (value) {
|
||||
case GST_VAAPI_RATECONTROL_NONE:
|
||||
return VA_RC_NONE;
|
||||
case GST_VAAPI_RATECONTROL_CQP:
|
||||
return VA_RC_CQP;
|
||||
case GST_VAAPI_RATECONTROL_CBR:
|
||||
return VA_RC_CBR;
|
||||
case GST_VAAPI_RATECONTROL_VCM:
|
||||
return VA_RC_VCM;
|
||||
case GST_VAAPI_RATECONTROL_VBR:
|
||||
return VA_RC_VBR;
|
||||
case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED:
|
||||
return VA_RC_VBR_CONSTRAINED;
|
||||
}
|
||||
GST_ERROR ("unsupported GstVaapiRateControl value %u", value);
|
||||
return VA_RC_NONE;
|
||||
}
|
||||
|
||||
guint
|
||||
to_GstVaapiRateControl(guint value)
|
||||
to_GstVaapiRateControl (guint value)
|
||||
{
|
||||
switch (value) {
|
||||
case VA_RC_NONE: return GST_VAAPI_RATECONTROL_NONE;
|
||||
case VA_RC_CQP: return GST_VAAPI_RATECONTROL_CQP;
|
||||
case VA_RC_CBR: return GST_VAAPI_RATECONTROL_CBR;
|
||||
case VA_RC_VCM: return GST_VAAPI_RATECONTROL_VCM;
|
||||
case VA_RC_VBR: return GST_VAAPI_RATECONTROL_VBR;
|
||||
case VA_RC_VBR_CONSTRAINED: return GST_VAAPI_RATECONTROL_VBR_CONSTRAINED;
|
||||
}
|
||||
GST_ERROR("unsupported VA-API Rate Control value %u", value);
|
||||
return GST_VAAPI_RATECONTROL_NONE;
|
||||
switch (value) {
|
||||
case VA_RC_NONE:
|
||||
return GST_VAAPI_RATECONTROL_NONE;
|
||||
case VA_RC_CQP:
|
||||
return GST_VAAPI_RATECONTROL_CQP;
|
||||
case VA_RC_CBR:
|
||||
return GST_VAAPI_RATECONTROL_CBR;
|
||||
case VA_RC_VCM:
|
||||
return GST_VAAPI_RATECONTROL_VCM;
|
||||
case VA_RC_VBR:
|
||||
return GST_VAAPI_RATECONTROL_VBR;
|
||||
case VA_RC_VBR_CONSTRAINED:
|
||||
return GST_VAAPI_RATECONTROL_VBR_CONSTRAINED;
|
||||
}
|
||||
GST_ERROR ("unsupported VA-API Rate Control value %u", value);
|
||||
return GST_VAAPI_RATECONTROL_NONE;
|
||||
}
|
||||
|
||||
/* VPP: translate GstVaapiDeinterlaceMethod to VA deinterlacing algorithm */
|
||||
guint
|
||||
from_GstVaapiDeinterlaceMethod(guint value)
|
||||
from_GstVaapiDeinterlaceMethod (guint value)
|
||||
{
|
||||
switch (value) {
|
||||
switch (value) {
|
||||
case GST_VAAPI_DEINTERLACE_METHOD_NONE:
|
||||
return 0;
|
||||
return 0;
|
||||
#if USE_VA_VPP
|
||||
case GST_VAAPI_DEINTERLACE_METHOD_BOB:
|
||||
return VAProcDeinterlacingBob;
|
||||
return VAProcDeinterlacingBob;
|
||||
case GST_VAAPI_DEINTERLACE_METHOD_WEAVE:
|
||||
return VAProcDeinterlacingWeave;
|
||||
return VAProcDeinterlacingWeave;
|
||||
case GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE:
|
||||
return VAProcDeinterlacingMotionAdaptive;
|
||||
return VAProcDeinterlacingMotionAdaptive;
|
||||
case GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED:
|
||||
return VAProcDeinterlacingMotionCompensated;
|
||||
return VAProcDeinterlacingMotionCompensated;
|
||||
#endif
|
||||
}
|
||||
GST_ERROR("unsupported GstVaapiDeinterlaceMethod value %d", value);
|
||||
return 0;
|
||||
}
|
||||
GST_ERROR ("unsupported GstVaapiDeinterlaceMethod value %d", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* VPP: translate GstVaapiDeinterlaceFlags into VA deinterlacing flags */
|
||||
guint
|
||||
from_GstVaapiDeinterlaceFlags(guint flags)
|
||||
from_GstVaapiDeinterlaceFlags (guint flags)
|
||||
{
|
||||
guint va_flags = 0;
|
||||
guint va_flags = 0;
|
||||
|
||||
#if USE_VA_VPP
|
||||
if (!(flags & GST_VAAPI_DEINTERLACE_FLAG_TFF))
|
||||
va_flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
|
||||
if (!(flags & GST_VAAPI_DEINTERLACE_FLAG_TFF))
|
||||
va_flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
|
||||
|
||||
if (flags & GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD)
|
||||
va_flags |= VA_DEINTERLACING_ONE_FIELD;
|
||||
if (flags & GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD)
|
||||
va_flags |= VA_DEINTERLACING_ONE_FIELD;
|
||||
|
||||
if (!(flags & GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD))
|
||||
va_flags |= VA_DEINTERLACING_BOTTOM_FIELD;
|
||||
if (!(flags & GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD))
|
||||
va_flags |= VA_DEINTERLACING_BOTTOM_FIELD;
|
||||
#endif
|
||||
return va_flags;
|
||||
return va_flags;
|
||||
}
|
||||
|
|
|
@ -33,103 +33,98 @@
|
|||
/** Check VA status for success or print out an error */
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
vaapi_check_status(VAStatus status, const char *msg);
|
||||
vaapi_check_status (VAStatus status, const gchar *msg);
|
||||
|
||||
/** Maps VA buffer */
|
||||
G_GNUC_INTERNAL
|
||||
void *
|
||||
vaapi_map_buffer(VADisplay dpy, VABufferID buf_id);
|
||||
gpointer
|
||||
vaapi_map_buffer (VADisplay dpy, VABufferID buf_id);
|
||||
|
||||
/** Unmaps VA buffer */
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
vaapi_unmap_buffer(VADisplay dpy, VABufferID buf_id, void **pbuf);
|
||||
vaapi_unmap_buffer (VADisplay dpy, VABufferID buf_id, void **pbuf);
|
||||
|
||||
/** Creates and maps VA buffer */
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
vaapi_create_buffer(
|
||||
VADisplay dpy,
|
||||
VAContextID ctx,
|
||||
int type,
|
||||
unsigned int size,
|
||||
gconstpointer data,
|
||||
VABufferID *buf_id,
|
||||
gpointer *mapped_data
|
||||
);
|
||||
vaapi_create_buffer (VADisplay dpy, VAContextID ctx, int type, guint size,
|
||||
gconstpointer data, VABufferID * buf_id, gpointer * mapped_data);
|
||||
|
||||
/** Destroy VA buffer */
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
vaapi_destroy_buffer(VADisplay dpy, VABufferID *buf_id);
|
||||
vaapi_destroy_buffer (VADisplay dpy, VABufferID * buf_id);
|
||||
|
||||
/** Return a string representation of a VAProfile */
|
||||
G_GNUC_INTERNAL
|
||||
const char *string_of_VAProfile(VAProfile profile);
|
||||
const gchar *
|
||||
string_of_VAProfile (VAProfile profile);
|
||||
|
||||
/** Return a string representation of a VAEntrypoint */
|
||||
G_GNUC_INTERNAL
|
||||
const char *string_of_VAEntrypoint(VAEntrypoint entrypoint);
|
||||
const gchar *
|
||||
string_of_VAEntrypoint (VAEntrypoint entrypoint);
|
||||
|
||||
/* Return a string representation of a VADisplayAttributeType */
|
||||
G_GNUC_INTERNAL
|
||||
const char *
|
||||
string_of_VADisplayAttributeType(VADisplayAttribType attribute_type);
|
||||
const gchar *
|
||||
string_of_VADisplayAttributeType (VADisplayAttribType attribute_type);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const char *
|
||||
string_of_VARateControl(guint rate_control);
|
||||
const gchar *
|
||||
string_of_VARateControl (guint rate_control);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiChromaType(guint chroma_type);
|
||||
from_GstVaapiChromaType (guint chroma_type);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiSubpictureFlags(guint flags);
|
||||
from_GstVaapiSubpictureFlags (guint flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiSubpictureFlags(guint va_flags);
|
||||
to_GstVaapiSubpictureFlags (guint va_flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVideoOverlayFormatFlags(guint ovl_flags);
|
||||
from_GstVideoOverlayFormatFlags (guint ovl_flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVideoOverlayFormatFlags(guint flags);
|
||||
to_GstVideoOverlayFormatFlags (guint flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiSurfaceRenderFlags(guint flags);
|
||||
from_GstVaapiSurfaceRenderFlags (guint flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiSurfaceStatus(guint va_flags);
|
||||
to_GstVaapiSurfaceStatus (guint va_flags);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiRotation(guint value);
|
||||
from_GstVaapiRotation (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiRotation(guint value);
|
||||
to_GstVaapiRotation (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiRateControl(guint value);
|
||||
from_GstVaapiRateControl (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
to_GstVaapiRateControl(guint value);
|
||||
to_GstVaapiRateControl (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiDeinterlaceMethod(guint value);
|
||||
from_GstVaapiDeinterlaceMethod (guint value);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
guint
|
||||
from_GstVaapiDeinterlaceFlags(guint flags);
|
||||
from_GstVaapiDeinterlaceFlags (guint flags);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_H */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,15 +34,17 @@
|
|||
#include <glib.h>
|
||||
|
||||
#if GLX_GLXEXT_VERSION < 18
|
||||
typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *);
|
||||
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int);
|
||||
typedef void (*PFNGLXBINDTEXIMAGEEXTPROC) (Display *, GLXDrawable, int,
|
||||
const int *);
|
||||
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC) (Display *, GLXDrawable, int);
|
||||
#endif
|
||||
|
||||
#if GLX_GLXEXT_VERSION < 27
|
||||
/* XXX: this is not exactly that version but this is the only means to
|
||||
make sure we have the correct <GL/glx.h> with those signatures */
|
||||
typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC)(Display *, GLXFBConfig, Pixmap, const int *);
|
||||
typedef void (*PFNGLXDESTROYPIXMAPPROC)(Display *, GLXPixmap);
|
||||
typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC) (Display *, GLXFBConfig, Pixmap,
|
||||
const int *);
|
||||
typedef void (*PFNGLXDESTROYPIXMAPPROC) (Display *, GLXPixmap);
|
||||
#endif
|
||||
|
||||
#ifndef GL_FRAMEBUFFER_BINDING
|
||||
|
@ -50,163 +52,164 @@ typedef void (*PFNGLXDESTROYPIXMAPPROC)(Display *, GLXPixmap);
|
|||
#endif
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const char *
|
||||
gl_get_error_string(GLenum error);
|
||||
const gchar *
|
||||
gl_get_error_string (GLenum error);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_purge_errors(void);
|
||||
gl_purge_errors (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_check_error(void);
|
||||
gl_check_error (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_get_param(GLenum param, guint *pval);
|
||||
gl_get_param (GLenum param, guint * pval);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_get_texture_param(GLenum target, GLenum param, guint *pval);
|
||||
gl_get_texture_param (GLenum target, GLenum param, guint * pval);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_set_bgcolor(guint32 color);
|
||||
gl_set_bgcolor (guint32 color);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_resize(guint width, guint height);
|
||||
gl_resize (guint width, guint height);
|
||||
|
||||
typedef struct _GLContextState GLContextState;
|
||||
struct _GLContextState {
|
||||
Display *display;
|
||||
Window window;
|
||||
XVisualInfo *visual;
|
||||
GLXContext context;
|
||||
guint swapped_buffers : 1;
|
||||
struct _GLContextState
|
||||
{
|
||||
Display *display;
|
||||
Window window;
|
||||
XVisualInfo *visual;
|
||||
GLXContext context;
|
||||
guint swapped_buffers:1;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GLContextState *
|
||||
gl_create_context(Display *dpy, int screen, GLContextState *parent);
|
||||
gl_create_context (Display * dpy, int screen, GLContextState * parent);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_destroy_context(GLContextState *cs);
|
||||
gl_destroy_context (GLContextState * cs);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_get_current_context(GLContextState *cs);
|
||||
gl_get_current_context (GLContextState * cs);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_set_current_context(GLContextState *new_cs, GLContextState *old_cs);
|
||||
gl_set_current_context (GLContextState * new_cs, GLContextState * old_cs);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_swap_buffers(GLContextState *cs);
|
||||
gl_swap_buffers (GLContextState * cs);
|
||||
|
||||
typedef struct _GLTextureState GLTextureState;
|
||||
struct _GLTextureState {
|
||||
GLenum target;
|
||||
GLuint old_texture;
|
||||
guint was_enabled : 1;
|
||||
guint was_bound : 1;
|
||||
struct _GLTextureState
|
||||
{
|
||||
GLenum target;
|
||||
GLuint old_texture;
|
||||
guint was_enabled:1;
|
||||
guint was_bound:1;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_bind_texture(GLTextureState *ts, GLenum target, GLuint texture);
|
||||
gl_bind_texture (GLTextureState * ts, GLenum target, GLuint texture);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_unbind_texture(GLTextureState *ts);
|
||||
gl_unbind_texture (GLTextureState * ts);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GLuint
|
||||
gl_create_texture(GLenum target, GLenum format, guint width, guint height);
|
||||
gl_create_texture (GLenum target, GLenum format, guint width, guint height);
|
||||
|
||||
typedef struct _GLVTable GLVTable;
|
||||
struct _GLVTable {
|
||||
PFNGLXCREATEPIXMAPPROC glx_create_pixmap;
|
||||
PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap;
|
||||
PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
|
||||
PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
|
||||
PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
|
||||
PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
|
||||
PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
|
||||
PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
|
||||
PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
|
||||
PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
|
||||
PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
|
||||
guint has_texture_from_pixmap : 1;
|
||||
guint has_framebuffer_object : 1;
|
||||
struct _GLVTable
|
||||
{
|
||||
PFNGLXCREATEPIXMAPPROC glx_create_pixmap;
|
||||
PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap;
|
||||
PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
|
||||
PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
|
||||
PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
|
||||
PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
|
||||
PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
|
||||
PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
|
||||
PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
|
||||
PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
|
||||
PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
|
||||
guint has_texture_from_pixmap:1;
|
||||
guint has_framebuffer_object:1;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GLVTable *
|
||||
gl_get_vtable(void);
|
||||
gl_get_vtable (void);
|
||||
|
||||
typedef struct _GLPixmapObject GLPixmapObject;
|
||||
struct _GLPixmapObject {
|
||||
Display *dpy;
|
||||
GLenum target;
|
||||
GLuint texture;
|
||||
GLTextureState old_texture;
|
||||
guint width;
|
||||
guint height;
|
||||
Pixmap pixmap;
|
||||
GLXPixmap glx_pixmap;
|
||||
guint is_bound : 1;
|
||||
struct _GLPixmapObject
|
||||
{
|
||||
Display *dpy;
|
||||
GLenum target;
|
||||
GLuint texture;
|
||||
GLTextureState old_texture;
|
||||
guint width;
|
||||
guint height;
|
||||
Pixmap pixmap;
|
||||
GLXPixmap glx_pixmap;
|
||||
guint is_bound:1;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GLPixmapObject *
|
||||
gl_create_pixmap_object(Display *dpy, guint width, guint height);
|
||||
gl_create_pixmap_object (Display * dpy, guint width, guint height);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_destroy_pixmap_object(GLPixmapObject *pixo);
|
||||
gl_destroy_pixmap_object (GLPixmapObject * pixo);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_bind_pixmap_object(GLPixmapObject *pixo);
|
||||
gl_bind_pixmap_object (GLPixmapObject * pixo);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_unbind_pixmap_object(GLPixmapObject *pixo);
|
||||
gl_unbind_pixmap_object (GLPixmapObject * pixo);
|
||||
|
||||
typedef struct _GLFramebufferObject GLFramebufferObject;
|
||||
struct _GLFramebufferObject {
|
||||
guint width;
|
||||
guint height;
|
||||
GLuint fbo;
|
||||
GLuint old_fbo;
|
||||
guint is_bound : 1;
|
||||
struct _GLFramebufferObject
|
||||
{
|
||||
guint width;
|
||||
guint height;
|
||||
GLuint fbo;
|
||||
GLuint old_fbo;
|
||||
guint is_bound:1;
|
||||
};
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
GLFramebufferObject *
|
||||
gl_create_framebuffer_object(
|
||||
GLenum target,
|
||||
GLuint texture,
|
||||
guint width,
|
||||
guint height
|
||||
);
|
||||
gl_create_framebuffer_object (GLenum target,
|
||||
GLuint texture, guint width, guint height);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
gl_destroy_framebuffer_object(GLFramebufferObject *fbo);
|
||||
gl_destroy_framebuffer_object (GLFramebufferObject * fbo);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_bind_framebuffer_object(GLFramebufferObject *fbo);
|
||||
gl_bind_framebuffer_object (GLFramebufferObject * fbo);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
gl_unbind_framebuffer_object(GLFramebufferObject *fbo);
|
||||
gl_unbind_framebuffer_object (GLFramebufferObject * fbo);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_GLX_H */
|
||||
|
|
|
@ -276,7 +276,7 @@ guint8
|
|||
gst_vaapi_utils_h264_get_level_idc (GstVaapiLevelH264 level)
|
||||
{
|
||||
const GstVaapiH264LevelLimits *const llp =
|
||||
gst_vaapi_utils_h264_get_level_limits (level);
|
||||
gst_vaapi_utils_h264_get_level_limits (level);
|
||||
|
||||
return llp ? llp->level_idc : 0;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* The set of all levels for #GstVaapiLevelH264.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GST_VAAPI_LEVEL_H264_L1 = 1,
|
||||
GST_VAAPI_LEVEL_H264_L1b,
|
||||
GST_VAAPI_LEVEL_H264_L1_1,
|
||||
|
|
|
@ -40,8 +40,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* The data structure that describes the limits of an H.264 level.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
GstVaapiLevelH264 level;
|
||||
guint8 level_idc;
|
||||
guint32 MaxMBPS;
|
||||
|
@ -79,7 +78,7 @@ gst_vaapi_utils_h264_get_level_limits (GstVaapiLevelH264 level);
|
|||
/* Returns the Table A-1 specification */
|
||||
G_GNUC_INTERNAL
|
||||
const GstVaapiH264LevelLimits *
|
||||
gst_vaapi_utils_h264_get_level_limits_table (guint *out_length_ptr);
|
||||
gst_vaapi_utils_h264_get_level_limits_table (guint * out_length_ptr);
|
||||
|
||||
/* Returns GstVaapiChromaType from H.264 chroma_format_idc value */
|
||||
G_GNUC_INTERNAL
|
||||
|
|
|
@ -38,8 +38,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* The set of all levels for #GstVaapiLevelMPEG2.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
GST_VAAPI_LEVEL_MPEG2_LOW = 1,
|
||||
GST_VAAPI_LEVEL_MPEG2_MAIN,
|
||||
GST_VAAPI_LEVEL_MPEG2_HIGH_1440,
|
||||
|
|
|
@ -41,8 +41,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* The data structure that describes the limits of an MPEG-2 level.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
GstVaapiLevelMPEG2 level;
|
||||
guint8 level_idc;
|
||||
guint16 horizontal_size_value;
|
||||
|
|
|
@ -29,35 +29,39 @@
|
|||
|
||||
// X error trap
|
||||
static int x11_error_code = 0;
|
||||
static int (*old_error_handler)(Display *, XErrorEvent *);
|
||||
static int (*old_error_handler) (Display *, XErrorEvent *);
|
||||
|
||||
static int error_handler(Display *dpy, XErrorEvent *error)
|
||||
static int
|
||||
error_handler (Display * dpy, XErrorEvent * error)
|
||||
{
|
||||
x11_error_code = error->error_code;
|
||||
return 0;
|
||||
x11_error_code = error->error_code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void x11_trap_errors(void)
|
||||
void
|
||||
x11_trap_errors (void)
|
||||
{
|
||||
x11_error_code = 0;
|
||||
old_error_handler = XSetErrorHandler(error_handler);
|
||||
x11_error_code = 0;
|
||||
old_error_handler = XSetErrorHandler (error_handler);
|
||||
}
|
||||
|
||||
int x11_untrap_errors(void)
|
||||
int
|
||||
x11_untrap_errors (void)
|
||||
{
|
||||
XSetErrorHandler(old_error_handler);
|
||||
return x11_error_code;
|
||||
XSetErrorHandler (old_error_handler);
|
||||
return x11_error_code;
|
||||
}
|
||||
|
||||
// X window management
|
||||
static const int x11_event_mask = (KeyPressMask |
|
||||
KeyReleaseMask |
|
||||
ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
PointerMotionMask |
|
||||
EnterWindowMask |
|
||||
ExposureMask |
|
||||
StructureNotifyMask);
|
||||
static const int x11_event_mask =
|
||||
(KeyPressMask |
|
||||
KeyReleaseMask |
|
||||
ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
PointerMotionMask |
|
||||
EnterWindowMask |
|
||||
ExposureMask |
|
||||
StructureNotifyMask);
|
||||
|
||||
/**
|
||||
* x11_create_window:
|
||||
|
@ -75,84 +79,68 @@ static const int x11_event_mask = (KeyPressMask |
|
|||
* Return value: the newly created X #Window.
|
||||
*/
|
||||
Window
|
||||
x11_create_window(Display *dpy, guint w, guint h, Visual *vis, Colormap cmap)
|
||||
x11_create_window (Display * dpy, guint w, guint h, Visual * vis, Colormap cmap)
|
||||
{
|
||||
Window rootwin, win;
|
||||
int screen, depth;
|
||||
XSetWindowAttributes xswa;
|
||||
unsigned long xswa_mask;
|
||||
XWindowAttributes wattr;
|
||||
unsigned long black_pixel;
|
||||
Window rootwin, win;
|
||||
int screen, depth;
|
||||
XSetWindowAttributes xswa;
|
||||
unsigned long xswa_mask;
|
||||
XWindowAttributes wattr;
|
||||
unsigned long black_pixel;
|
||||
|
||||
screen = DefaultScreen(dpy);
|
||||
rootwin = RootWindow(dpy, screen);
|
||||
black_pixel = BlackPixel(dpy, screen);
|
||||
screen = DefaultScreen (dpy);
|
||||
rootwin = RootWindow (dpy, screen);
|
||||
black_pixel = BlackPixel (dpy, screen);
|
||||
|
||||
if (!vis)
|
||||
vis = DefaultVisual(dpy, screen);
|
||||
if (!vis)
|
||||
vis = DefaultVisual (dpy, screen);
|
||||
|
||||
XGetWindowAttributes(dpy, rootwin, &wattr);
|
||||
depth = wattr.depth;
|
||||
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
|
||||
depth = 24;
|
||||
XGetWindowAttributes (dpy, rootwin, &wattr);
|
||||
depth = wattr.depth;
|
||||
if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
|
||||
depth = 24;
|
||||
|
||||
xswa_mask = CWBorderPixel | CWBackPixel;
|
||||
xswa.border_pixel = black_pixel;
|
||||
xswa.background_pixel = black_pixel;
|
||||
xswa_mask = CWBorderPixel | CWBackPixel;
|
||||
xswa.border_pixel = black_pixel;
|
||||
xswa.background_pixel = black_pixel;
|
||||
|
||||
if (cmap) {
|
||||
xswa_mask |= CWColormap;
|
||||
xswa.colormap = cmap;
|
||||
}
|
||||
if (cmap) {
|
||||
xswa_mask |= CWColormap;
|
||||
xswa.colormap = cmap;
|
||||
}
|
||||
|
||||
win = XCreateWindow(
|
||||
dpy,
|
||||
rootwin,
|
||||
0, 0, w, h,
|
||||
0,
|
||||
depth,
|
||||
InputOutput,
|
||||
vis,
|
||||
xswa_mask, &xswa
|
||||
);
|
||||
if (!win)
|
||||
return None;
|
||||
win = XCreateWindow (dpy, rootwin, 0, 0, w, h, 0, depth, InputOutput, vis,
|
||||
xswa_mask, &xswa);
|
||||
if (!win)
|
||||
return None;
|
||||
|
||||
XSelectInput(dpy, win, x11_event_mask);
|
||||
return win;
|
||||
XSelectInput (dpy, win, x11_event_mask);
|
||||
return win;
|
||||
}
|
||||
|
||||
gboolean
|
||||
x11_get_geometry(
|
||||
Display *dpy,
|
||||
Drawable drawable,
|
||||
gint *px,
|
||||
gint *py,
|
||||
guint *pwidth,
|
||||
guint *pheight,
|
||||
guint *pdepth
|
||||
)
|
||||
x11_get_geometry (Display * dpy, Drawable drawable, gint * px, gint * py,
|
||||
guint * pwidth, guint * pheight, guint * pdepth)
|
||||
{
|
||||
Window rootwin;
|
||||
int x, y;
|
||||
guint width, height, border_width, depth;
|
||||
Window rootwin;
|
||||
int x, y;
|
||||
guint width, height, border_width, depth;
|
||||
|
||||
x11_trap_errors();
|
||||
XGetGeometry(
|
||||
dpy,
|
||||
drawable,
|
||||
&rootwin,
|
||||
&x, &y, &width, &height,
|
||||
&border_width,
|
||||
&depth
|
||||
);
|
||||
if (x11_untrap_errors())
|
||||
return FALSE;
|
||||
x11_trap_errors ();
|
||||
XGetGeometry (dpy, drawable, &rootwin, &x, &y, &width, &height,
|
||||
&border_width, &depth);
|
||||
if (x11_untrap_errors ())
|
||||
return FALSE;
|
||||
|
||||
if (px) *px = x;
|
||||
if (py) *py = y;
|
||||
if (pwidth) *pwidth = width;
|
||||
if (pheight) *pheight = height;
|
||||
if (pdepth) *pdepth = depth;
|
||||
return TRUE;
|
||||
if (px)
|
||||
*px = x;
|
||||
if (py)
|
||||
*py = y;
|
||||
if (pwidth)
|
||||
*pwidth = width;
|
||||
if (pheight)
|
||||
*pheight = height;
|
||||
if (pdepth)
|
||||
*pdepth = depth;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -32,26 +32,20 @@
|
|||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
x11_trap_errors(void);
|
||||
x11_trap_errors (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
int
|
||||
x11_untrap_errors(void);
|
||||
x11_untrap_errors (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
Window
|
||||
x11_create_window(Display *dpy, guint w, guint h, Visual *vis, Colormap cmap);
|
||||
x11_create_window (Display * dpy, guint w, guint h, Visual * vis,
|
||||
Colormap cmap);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean
|
||||
x11_get_geometry(
|
||||
Display *dpy,
|
||||
Drawable drawable,
|
||||
gint *px,
|
||||
gint *py,
|
||||
guint *pwidth,
|
||||
guint *pheight,
|
||||
guint *pdepth
|
||||
);
|
||||
x11_get_geometry (Display * dpy, Drawable drawable, gint * px, gint * py,
|
||||
guint * pwidth, guint * pheight, guint * pdepth);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_X11_H */
|
||||
|
|
Loading…
Reference in a new issue