libs: humongous code style fix

As part of the upstreaming process of gstreamer-vaapi into the GStreamer
umbrella, we need to comply with the project's code style. This meant to
change a lot of code.

It was decided to use a single massive patch to update the code style.

I would like to apologize with the original developers of this code because of
the history breakage.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-02-03 11:50:13 +01:00
parent 4b5be5973e
commit ac730d0a62
13 changed files with 8565 additions and 8730 deletions

View file

@ -37,14 +37,15 @@
*
* A decoded picture buffer (DPB) object.
*/
struct _GstVaapiDpb {
/*< private >*/
GstVaapiMiniObject parent_instance;
struct _GstVaapiDpb
{
/*< private > */
GstVaapiMiniObject parent_instance;
/*< protected >*/
GstVaapiPicture **pictures;
guint num_pictures;
guint max_pictures;
/*< protected > */
GstVaapiPicture **pictures;
guint num_pictures;
guint max_pictures;
};
/**
@ -52,124 +53,123 @@ struct _GstVaapiDpb {
*
* The #GstVaapiDpb base class.
*/
struct _GstVaapiDpbClass {
/*< private >*/
GstVaapiMiniObjectClass parent_class;
struct _GstVaapiDpbClass
{
/*< private > */
GstVaapiMiniObjectClass parent_class;
/*< protected >*/
void (*flush) (GstVaapiDpb *dpb);
gboolean (*add) (GstVaapiDpb *dpb, GstVaapiPicture *picture);
void (*get_neighbours) (GstVaapiDpb *dpb, GstVaapiPicture *picture,
GstVaapiPicture **prev_picture_ptr, GstVaapiPicture **next_picture_ptr);
/*< protected > */
void (*flush) (GstVaapiDpb * dpb);
gboolean (*add) (GstVaapiDpb * dpb, GstVaapiPicture * picture);
void (*get_neighbours) (GstVaapiDpb * dpb, GstVaapiPicture * picture,
GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr);
};
static const GstVaapiMiniObjectClass *
gst_vaapi_dpb_class(void);
static const GstVaapiMiniObjectClass *gst_vaapi_dpb_class (void);
static const GstVaapiMiniObjectClass *
gst_vaapi_dpb2_class(void);
static const GstVaapiMiniObjectClass *gst_vaapi_dpb2_class (void);
/* ------------------------------------------------------------------------- */
/* --- Common utilities --- */
/* ------------------------------------------------------------------------- */
static inline GstVaapiDpb *
dpb_new(guint max_pictures)
dpb_new (guint max_pictures)
{
GstVaapiDpb *dpb;
GstVaapiDpb *dpb;
g_return_val_if_fail(max_pictures > 0, NULL);
g_return_val_if_fail (max_pictures > 0, NULL);
dpb = (GstVaapiDpb *)gst_vaapi_mini_object_new(
max_pictures == 2 ? gst_vaapi_dpb2_class() : gst_vaapi_dpb_class());
if (!dpb)
return NULL;
dpb =
(GstVaapiDpb *) gst_vaapi_mini_object_new (max_pictures ==
2 ? gst_vaapi_dpb2_class () : gst_vaapi_dpb_class ());
if (!dpb)
return NULL;
dpb->num_pictures = 0;
dpb->max_pictures = max_pictures;
dpb->num_pictures = 0;
dpb->max_pictures = max_pictures;
dpb->pictures = g_new0(GstVaapiPicture *, max_pictures);
if (!dpb->pictures)
goto error;
return dpb;
dpb->pictures = g_new0 (GstVaapiPicture *, max_pictures);
if (!dpb->pictures)
goto error;
return dpb;
error:
gst_vaapi_dpb_unref(dpb);
return NULL;
gst_vaapi_dpb_unref (dpb);
return NULL;
}
static gint
dpb_get_oldest(GstVaapiDpb *dpb, gboolean output)
dpb_get_oldest (GstVaapiDpb * dpb, gboolean output)
{
gint i, lowest_pts_index;
gint i, lowest_pts_index;
for (i = 0; i < dpb->num_pictures; i++) {
if ((GST_VAAPI_PICTURE_IS_OUTPUT(dpb->pictures[i]) ^ output) == 0)
break;
}
if (i == dpb->num_pictures)
return -1;
for (i = 0; i < dpb->num_pictures; i++) {
if ((GST_VAAPI_PICTURE_IS_OUTPUT (dpb->pictures[i]) ^ output) == 0)
break;
}
if (i == dpb->num_pictures)
return -1;
lowest_pts_index = i++;
for (; i < dpb->num_pictures; i++) {
GstVaapiPicture * const picture = dpb->pictures[i];
if ((GST_VAAPI_PICTURE_IS_OUTPUT(picture) ^ output) != 0)
continue;
if (picture->poc < dpb->pictures[lowest_pts_index]->poc)
lowest_pts_index = i;
}
return lowest_pts_index;
lowest_pts_index = i++;
for (; i < dpb->num_pictures; i++) {
GstVaapiPicture *const picture = dpb->pictures[i];
if ((GST_VAAPI_PICTURE_IS_OUTPUT (picture) ^ output) != 0)
continue;
if (picture->poc < dpb->pictures[lowest_pts_index]->poc)
lowest_pts_index = i;
}
return lowest_pts_index;
}
static void
dpb_remove_index(GstVaapiDpb *dpb, guint index)
dpb_remove_index (GstVaapiDpb * dpb, guint index)
{
GstVaapiPicture ** const pictures = dpb->pictures;
guint num_pictures = --dpb->num_pictures;
GstVaapiPicture **const pictures = dpb->pictures;
guint num_pictures = --dpb->num_pictures;
if (index != num_pictures)
gst_vaapi_picture_replace(&pictures[index], pictures[num_pictures]);
gst_vaapi_picture_replace(&pictures[num_pictures], NULL);
if (index != num_pictures)
gst_vaapi_picture_replace (&pictures[index], pictures[num_pictures]);
gst_vaapi_picture_replace (&pictures[num_pictures], NULL);
}
static inline gboolean
dpb_output(GstVaapiDpb *dpb, GstVaapiPicture *picture)
dpb_output (GstVaapiDpb * dpb, GstVaapiPicture * picture)
{
return gst_vaapi_picture_output(picture);
return gst_vaapi_picture_output (picture);
}
static gboolean
dpb_bump(GstVaapiDpb *dpb)
dpb_bump (GstVaapiDpb * dpb)
{
gint index;
gboolean success;
gint index;
gboolean success;
index = dpb_get_oldest(dpb, FALSE);
if (index < 0)
return FALSE;
index = dpb_get_oldest (dpb, FALSE);
if (index < 0)
return FALSE;
success = dpb_output(dpb, dpb->pictures[index]);
if (!GST_VAAPI_PICTURE_IS_REFERENCE(dpb->pictures[index]))
dpb_remove_index(dpb, index);
return success;
success = dpb_output (dpb, dpb->pictures[index]);
if (!GST_VAAPI_PICTURE_IS_REFERENCE (dpb->pictures[index]))
dpb_remove_index (dpb, index);
return success;
}
static void
dpb_clear(GstVaapiDpb *dpb)
dpb_clear (GstVaapiDpb * dpb)
{
guint i;
guint i;
for (i = 0; i < dpb->num_pictures; i++)
gst_vaapi_picture_replace(&dpb->pictures[i], NULL);
dpb->num_pictures = 0;
for (i = 0; i < dpb->num_pictures; i++)
gst_vaapi_picture_replace (&dpb->pictures[i], NULL);
dpb->num_pictures = 0;
}
static void
dpb_flush(GstVaapiDpb *dpb)
dpb_flush (GstVaapiDpb * dpb)
{
while (dpb_bump(dpb))
;
dpb_clear(dpb);
while (dpb_bump (dpb));
dpb_clear (dpb);
}
/* ------------------------------------------------------------------------- */
@ -177,82 +177,80 @@ dpb_flush(GstVaapiDpb *dpb)
/* ------------------------------------------------------------------------- */
static gboolean
dpb_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
dpb_add (GstVaapiDpb * dpb, GstVaapiPicture * picture)
{
guint i;
guint i;
// Remove all unused pictures
i = 0;
while (i < dpb->num_pictures) {
GstVaapiPicture * const picture = dpb->pictures[i];
if (GST_VAAPI_PICTURE_IS_OUTPUT(picture) &&
!GST_VAAPI_PICTURE_IS_REFERENCE(picture))
dpb_remove_index(dpb, i);
else
i++;
}
// Remove all unused pictures
i = 0;
while (i < dpb->num_pictures) {
GstVaapiPicture *const picture = dpb->pictures[i];
if (GST_VAAPI_PICTURE_IS_OUTPUT (picture) &&
!GST_VAAPI_PICTURE_IS_REFERENCE (picture))
dpb_remove_index (dpb, i);
else
i++;
}
// Store reference decoded picture into the DPB
if (GST_VAAPI_PICTURE_IS_REFERENCE(picture)) {
while (dpb->num_pictures == dpb->max_pictures) {
if (!dpb_bump(dpb))
return FALSE;
}
// Store reference decoded picture into the DPB
if (GST_VAAPI_PICTURE_IS_REFERENCE (picture)) {
while (dpb->num_pictures == dpb->max_pictures) {
if (!dpb_bump (dpb))
return FALSE;
}
// Store non-reference decoded picture into the DPB
else {
if (GST_VAAPI_PICTURE_IS_SKIPPED(picture))
return TRUE;
while (dpb->num_pictures == dpb->max_pictures) {
for (i = 0; i < dpb->num_pictures; i++) {
if (!GST_VAAPI_PICTURE_IS_OUTPUT(picture) &&
dpb->pictures[i]->poc < picture->poc)
break;
}
if (i == dpb->num_pictures)
return dpb_output(dpb, picture);
if (!dpb_bump(dpb))
return FALSE;
}
}
// Store non-reference decoded picture into the DPB
else {
if (GST_VAAPI_PICTURE_IS_SKIPPED (picture))
return TRUE;
while (dpb->num_pictures == dpb->max_pictures) {
for (i = 0; i < dpb->num_pictures; i++) {
if (!GST_VAAPI_PICTURE_IS_OUTPUT (picture) &&
dpb->pictures[i]->poc < picture->poc)
break;
}
if (i == dpb->num_pictures)
return dpb_output (dpb, picture);
if (!dpb_bump (dpb))
return FALSE;
}
gst_vaapi_picture_replace(&dpb->pictures[dpb->num_pictures++], picture);
return TRUE;
}
gst_vaapi_picture_replace (&dpb->pictures[dpb->num_pictures++], picture);
return TRUE;
}
static void
dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
GstVaapiPicture **prev_picture_ptr, GstVaapiPicture **next_picture_ptr)
dpb_get_neighbours (GstVaapiDpb * dpb, GstVaapiPicture * picture,
GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr)
{
GstVaapiPicture *prev_picture = NULL;
GstVaapiPicture *next_picture = NULL;
guint i;
GstVaapiPicture *prev_picture = NULL;
GstVaapiPicture *next_picture = NULL;
guint i;
/* Find the first picture with POC > specified picture POC */
for (i = 0; i < dpb->num_pictures; i++) {
GstVaapiPicture * const ref_picture = dpb->pictures[i];
if (ref_picture->poc == picture->poc) {
if (i > 0)
prev_picture = dpb->pictures[i - 1];
if (i + 1 < dpb->num_pictures)
next_picture = dpb->pictures[i + 1];
break;
}
else if (ref_picture->poc > picture->poc) {
next_picture = ref_picture;
if (i > 0)
prev_picture = dpb->pictures[i - 1];
break;
}
/* Find the first picture with POC > specified picture POC */
for (i = 0; i < dpb->num_pictures; i++) {
GstVaapiPicture *const ref_picture = dpb->pictures[i];
if (ref_picture->poc == picture->poc) {
if (i > 0)
prev_picture = dpb->pictures[i - 1];
if (i + 1 < dpb->num_pictures)
next_picture = dpb->pictures[i + 1];
break;
} else if (ref_picture->poc > picture->poc) {
next_picture = ref_picture;
if (i > 0)
prev_picture = dpb->pictures[i - 1];
break;
}
}
g_assert(next_picture ? next_picture->poc > picture->poc : TRUE);
g_assert(prev_picture ? prev_picture->poc < picture->poc : TRUE);
g_assert (next_picture ? next_picture->poc > picture->poc : TRUE);
g_assert (prev_picture ? prev_picture->poc < picture->poc : TRUE);
if (prev_picture_ptr)
*prev_picture_ptr = prev_picture;
if (next_picture_ptr)
*next_picture_ptr = next_picture;
if (prev_picture_ptr)
*prev_picture_ptr = prev_picture;
if (next_picture_ptr)
*next_picture_ptr = next_picture;
}
/* ------------------------------------------------------------------------- */
@ -260,66 +258,66 @@ dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
/* ------------------------------------------------------------------------- */
static gboolean
dpb2_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
dpb2_add (GstVaapiDpb * dpb, GstVaapiPicture * picture)
{
GstVaapiPicture *ref_picture;
gint index = -1;
GstVaapiPicture *ref_picture;
gint index = -1;
g_return_val_if_fail(GST_VAAPI_IS_DPB(dpb), FALSE);
g_return_val_if_fail(dpb->max_pictures == 2, FALSE);
g_return_val_if_fail (GST_VAAPI_IS_DPB (dpb), FALSE);
g_return_val_if_fail (dpb->max_pictures == 2, FALSE);
/*
* Purpose: only store reference decoded pictures into the DPB
*
* This means:
* - non-reference decoded pictures are output immediately
* - ... thus causing older reference pictures to be output, if not already
* - the oldest reference picture is replaced with the new reference picture
*/
if (G_LIKELY(dpb->num_pictures == 2)) {
index = (dpb->pictures[0]->poc > dpb->pictures[1]->poc);
ref_picture = dpb->pictures[index];
if (!GST_VAAPI_PICTURE_IS_OUTPUT(ref_picture)) {
if (!dpb_output(dpb, ref_picture))
return FALSE;
}
/*
* Purpose: only store reference decoded pictures into the DPB
*
* This means:
* - non-reference decoded pictures are output immediately
* - ... thus causing older reference pictures to be output, if not already
* - the oldest reference picture is replaced with the new reference picture
*/
if (G_LIKELY (dpb->num_pictures == 2)) {
index = (dpb->pictures[0]->poc > dpb->pictures[1]->poc);
ref_picture = dpb->pictures[index];
if (!GST_VAAPI_PICTURE_IS_OUTPUT (ref_picture)) {
if (!dpb_output (dpb, ref_picture))
return FALSE;
}
}
if (!GST_VAAPI_PICTURE_IS_REFERENCE(picture))
return dpb_output(dpb, picture);
if (!GST_VAAPI_PICTURE_IS_REFERENCE (picture))
return dpb_output (dpb, picture);
if (index < 0)
index = dpb->num_pictures++;
gst_vaapi_picture_replace(&dpb->pictures[index], picture);
return TRUE;
if (index < 0)
index = dpb->num_pictures++;
gst_vaapi_picture_replace (&dpb->pictures[index], picture);
return TRUE;
}
static void
dpb2_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
GstVaapiPicture **prev_picture_ptr, GstVaapiPicture **next_picture_ptr)
dpb2_get_neighbours (GstVaapiDpb * dpb, GstVaapiPicture * picture,
GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr)
{
GstVaapiPicture *ref_picture, *ref_pictures[2];
GstVaapiPicture **picture_ptr;
guint i, index;
GstVaapiPicture *ref_picture, *ref_pictures[2];
GstVaapiPicture **picture_ptr;
guint i, index;
g_return_if_fail(GST_VAAPI_IS_DPB(dpb));
g_return_if_fail(dpb->max_pictures == 2);
g_return_if_fail(GST_VAAPI_IS_PICTURE(picture));
g_return_if_fail (GST_VAAPI_IS_DPB (dpb));
g_return_if_fail (dpb->max_pictures == 2);
g_return_if_fail (GST_VAAPI_IS_PICTURE (picture));
ref_pictures[0] = NULL;
ref_pictures[1] = NULL;
for (i = 0; i < dpb->num_pictures; i++) {
ref_picture = dpb->pictures[i];
index = ref_picture->poc > picture->poc;
picture_ptr = &ref_pictures[index];
if (!*picture_ptr || ((*picture_ptr)->poc > ref_picture->poc) == index)
*picture_ptr = ref_picture;
}
ref_pictures[0] = NULL;
ref_pictures[1] = NULL;
for (i = 0; i < dpb->num_pictures; i++) {
ref_picture = dpb->pictures[i];
index = ref_picture->poc > picture->poc;
picture_ptr = &ref_pictures[index];
if (!*picture_ptr || ((*picture_ptr)->poc > ref_picture->poc) == index)
*picture_ptr = ref_picture;
}
if (prev_picture_ptr)
*prev_picture_ptr = ref_pictures[0];
if (next_picture_ptr)
*next_picture_ptr = ref_pictures[1];
if (prev_picture_ptr)
*prev_picture_ptr = ref_pictures[0];
if (next_picture_ptr)
*next_picture_ptr = ref_pictures[1];
}
/* ------------------------------------------------------------------------- */
@ -327,92 +325,94 @@ dpb2_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
/* ------------------------------------------------------------------------- */
static void
gst_vaapi_dpb_finalize(GstVaapiDpb *dpb)
gst_vaapi_dpb_finalize (GstVaapiDpb * dpb)
{
dpb_clear(dpb);
g_free(dpb->pictures);
dpb_clear (dpb);
g_free (dpb->pictures);
}
static const GstVaapiMiniObjectClass *
gst_vaapi_dpb_class(void)
gst_vaapi_dpb_class (void)
{
static const GstVaapiDpbClass GstVaapiDpbClass = {
{ sizeof(GstVaapiDpb),
(GDestroyNotify)gst_vaapi_dpb_finalize },
static const GstVaapiDpbClass GstVaapiDpbClass = {
{sizeof (GstVaapiDpb),
(GDestroyNotify) gst_vaapi_dpb_finalize}
,
dpb_flush,
dpb_add,
dpb_get_neighbours
};
return &GstVaapiDpbClass.parent_class;
dpb_flush,
dpb_add,
dpb_get_neighbours
};
return &GstVaapiDpbClass.parent_class;
}
static const GstVaapiMiniObjectClass *
gst_vaapi_dpb2_class(void)
gst_vaapi_dpb2_class (void)
{
static const GstVaapiDpbClass GstVaapiDpb2Class = {
{ sizeof(GstVaapiDpb),
(GDestroyNotify)gst_vaapi_dpb_finalize },
static const GstVaapiDpbClass GstVaapiDpb2Class = {
{sizeof (GstVaapiDpb),
(GDestroyNotify) gst_vaapi_dpb_finalize}
,
dpb_flush,
dpb2_add,
dpb2_get_neighbours
};
return &GstVaapiDpb2Class.parent_class;
dpb_flush,
dpb2_add,
dpb2_get_neighbours
};
return &GstVaapiDpb2Class.parent_class;
}
GstVaapiDpb *
gst_vaapi_dpb_new(guint max_pictures)
gst_vaapi_dpb_new (guint max_pictures)
{
return dpb_new(max_pictures);
return dpb_new (max_pictures);
}
void
gst_vaapi_dpb_flush(GstVaapiDpb *dpb)
gst_vaapi_dpb_flush (GstVaapiDpb * dpb)
{
const GstVaapiDpbClass *klass;
const GstVaapiDpbClass *klass;
g_return_if_fail(GST_VAAPI_IS_DPB(dpb));
g_return_if_fail (GST_VAAPI_IS_DPB (dpb));
klass = GST_VAAPI_DPB_GET_CLASS(dpb);
if (G_UNLIKELY(!klass || !klass->add))
return;
klass->flush(dpb);
klass = GST_VAAPI_DPB_GET_CLASS (dpb);
if (G_UNLIKELY (!klass || !klass->add))
return;
klass->flush (dpb);
}
gboolean
gst_vaapi_dpb_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
gst_vaapi_dpb_add (GstVaapiDpb * dpb, GstVaapiPicture * picture)
{
const GstVaapiDpbClass *klass;
const GstVaapiDpbClass *klass;
g_return_val_if_fail(GST_VAAPI_IS_DPB(dpb), FALSE);
g_return_val_if_fail(GST_VAAPI_IS_PICTURE(picture), FALSE);
g_return_val_if_fail (GST_VAAPI_IS_DPB (dpb), FALSE);
g_return_val_if_fail (GST_VAAPI_IS_PICTURE (picture), FALSE);
klass = GST_VAAPI_DPB_GET_CLASS(dpb);
if (G_UNLIKELY(!klass || !klass->add))
return FALSE;
return klass->add(dpb, picture);
klass = GST_VAAPI_DPB_GET_CLASS (dpb);
if (G_UNLIKELY (!klass || !klass->add))
return FALSE;
return klass->add (dpb, picture);
}
guint
gst_vaapi_dpb_size(GstVaapiDpb *dpb)
gst_vaapi_dpb_size (GstVaapiDpb * dpb)
{
g_return_val_if_fail(GST_VAAPI_IS_DPB(dpb), 0);
g_return_val_if_fail (GST_VAAPI_IS_DPB (dpb), 0);
return dpb->num_pictures;
return dpb->num_pictures;
}
void
gst_vaapi_dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
GstVaapiPicture **prev_picture_ptr, GstVaapiPicture **next_picture_ptr)
gst_vaapi_dpb_get_neighbours (GstVaapiDpb * dpb, GstVaapiPicture * picture,
GstVaapiPicture ** prev_picture_ptr, GstVaapiPicture ** next_picture_ptr)
{
const GstVaapiDpbClass *klass;
const GstVaapiDpbClass *klass;
g_return_if_fail(GST_VAAPI_IS_DPB(dpb));
g_return_if_fail(GST_VAAPI_IS_PICTURE(picture));
g_return_if_fail (GST_VAAPI_IS_DPB (dpb));
g_return_if_fail (GST_VAAPI_IS_PICTURE (picture));
klass = GST_VAAPI_DPB_GET_CLASS(dpb);
if (G_UNLIKELY(!klass || !klass->get_neighbours))
return;
klass->get_neighbours(dpb, picture, prev_picture_ptr, next_picture_ptr);
klass = GST_VAAPI_DPB_GET_CLASS (dpb);
if (G_UNLIKELY (!klass || !klass->get_neighbours))
return;
klass->get_neighbours (dpb, picture, prev_picture_ptr, next_picture_ptr);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -38,14 +38,14 @@
* sub-classes.
*/
void
gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
gst_vaapi_decoder_unit_init (GstVaapiDecoderUnit * unit)
{
unit->flags = 0;
unit->size = 0;
unit->offset = 0;
unit->flags = 0;
unit->size = 0;
unit->offset = 0;
unit->parsed_info = NULL;
unit->parsed_info_destroy_notify = NULL;
unit->parsed_info = NULL;
unit->parsed_info_destroy_notify = NULL;
}
/**
@ -59,9 +59,9 @@ gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
* sub-classes.
*/
void
gst_vaapi_decoder_unit_clear(GstVaapiDecoderUnit *unit)
gst_vaapi_decoder_unit_clear (GstVaapiDecoderUnit * unit)
{
gst_vaapi_decoder_unit_set_parsed_info(unit, NULL, NULL);
gst_vaapi_decoder_unit_set_parsed_info (unit, NULL, NULL);
}
/**
@ -77,13 +77,13 @@ gst_vaapi_decoder_unit_clear(GstVaapiDecoderUnit *unit)
* function will be called before the @parsed_info is replaced.
*/
void
gst_vaapi_decoder_unit_set_parsed_info(GstVaapiDecoderUnit *unit,
gst_vaapi_decoder_unit_set_parsed_info (GstVaapiDecoderUnit * unit,
gpointer parsed_info, GDestroyNotify destroy_notify)
{
g_return_if_fail(GST_VAAPI_IS_DECODER_UNIT(unit));
g_return_if_fail (GST_VAAPI_IS_DECODER_UNIT (unit));
if (unit->parsed_info && unit->parsed_info_destroy_notify)
unit->parsed_info_destroy_notify(unit->parsed_info);
unit->parsed_info = parsed_info;
unit->parsed_info_destroy_notify = destroy_notify;
if (unit->parsed_info && unit->parsed_info_destroy_notify)
unit->parsed_info_destroy_notify (unit->parsed_info);
unit->parsed_info = parsed_info;
unit->parsed_info_destroy_notify = destroy_notify;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -29,40 +29,40 @@
#include "gstvaapiparser_frame.h"
static inline const GstVaapiMiniObjectClass *
gst_vaapi_parser_frame_class(void)
gst_vaapi_parser_frame_class (void)
{
static const GstVaapiMiniObjectClass GstVaapiParserFrameClass = {
sizeof(GstVaapiParserFrame),
(GDestroyNotify)gst_vaapi_parser_frame_free
};
return &GstVaapiParserFrameClass;
static const GstVaapiMiniObjectClass GstVaapiParserFrameClass = {
sizeof (GstVaapiParserFrame),
(GDestroyNotify) gst_vaapi_parser_frame_free
};
return &GstVaapiParserFrameClass;
}
static inline gboolean
alloc_units(GArray **units_ptr, guint size)
alloc_units (GArray ** units_ptr, guint size)
{
GArray *units;
GArray *units;
units = g_array_sized_new(FALSE, FALSE, sizeof(GstVaapiDecoderUnit), size);
*units_ptr = units;
return units != NULL;
units = g_array_sized_new (FALSE, FALSE, sizeof (GstVaapiDecoderUnit), size);
*units_ptr = units;
return units != NULL;
}
static inline void
free_units(GArray **units_ptr)
free_units (GArray ** units_ptr)
{
GArray * const units = *units_ptr;
guint i;
GArray *const units = *units_ptr;
guint i;
if (units) {
for (i = 0; i < units->len; i++) {
GstVaapiDecoderUnit * const unit =
&g_array_index(units, GstVaapiDecoderUnit, i);
gst_vaapi_decoder_unit_clear(unit);
}
g_array_free(units, TRUE);
*units_ptr = NULL;
if (units) {
for (i = 0; i < units->len; i++) {
GstVaapiDecoderUnit *const unit =
&g_array_index (units, GstVaapiDecoderUnit, i);
gst_vaapi_decoder_unit_clear (unit);
}
g_array_free (units, TRUE);
*units_ptr = NULL;
}
}
/**
@ -75,32 +75,32 @@ free_units(GArray **units_ptr)
* Returns: The newly allocated #GstVaapiParserFrame
*/
GstVaapiParserFrame *
gst_vaapi_parser_frame_new(guint width, guint height)
gst_vaapi_parser_frame_new (guint width, guint height)
{
GstVaapiParserFrame *frame;
guint num_slices;
GstVaapiParserFrame *frame;
guint num_slices;
frame = (GstVaapiParserFrame *)
gst_vaapi_mini_object_new(gst_vaapi_parser_frame_class());
if (!frame)
return NULL;
frame = (GstVaapiParserFrame *)
gst_vaapi_mini_object_new (gst_vaapi_parser_frame_class ());
if (!frame)
return NULL;
if (!height)
height = 1088;
num_slices = (height + 15) / 16;
if (!height)
height = 1088;
num_slices = (height + 15) / 16;
if (!alloc_units(&frame->pre_units, 16))
goto error;
if (!alloc_units(&frame->units, num_slices))
goto error;
if (!alloc_units(&frame->post_units, 1))
goto error;
frame->output_offset = 0;
return frame;
if (!alloc_units (&frame->pre_units, 16))
goto error;
if (!alloc_units (&frame->units, num_slices))
goto error;
if (!alloc_units (&frame->post_units, 1))
goto error;
frame->output_offset = 0;
return frame;
error:
gst_vaapi_parser_frame_unref(frame);
return NULL;
gst_vaapi_parser_frame_unref (frame);
return NULL;
}
/**
@ -114,11 +114,11 @@ error:
* sub-classes.
*/
void
gst_vaapi_parser_frame_free(GstVaapiParserFrame *frame)
gst_vaapi_parser_frame_free (GstVaapiParserFrame * frame)
{
free_units(&frame->units);
free_units(&frame->pre_units);
free_units(&frame->post_units);
free_units (&frame->units);
free_units (&frame->pre_units);
free_units (&frame->post_units);
}
/**
@ -129,19 +129,19 @@ gst_vaapi_parser_frame_free(GstVaapiParserFrame *frame)
* Appends unit to the @frame.
*/
void
gst_vaapi_parser_frame_append_unit(GstVaapiParserFrame *frame,
GstVaapiDecoderUnit *unit)
gst_vaapi_parser_frame_append_unit (GstVaapiParserFrame * frame,
GstVaapiDecoderUnit * unit)
{
GArray **unit_array_ptr;
GArray **unit_array_ptr;
unit->offset = frame->output_offset;
frame->output_offset += unit->size;
unit->offset = frame->output_offset;
frame->output_offset += unit->size;
if (GST_VAAPI_DECODER_UNIT_IS_SLICE(unit))
unit_array_ptr = &frame->units;
else if (GST_VAAPI_DECODER_UNIT_IS_FRAME_END(unit))
unit_array_ptr = &frame->post_units;
else
unit_array_ptr = &frame->pre_units;
g_array_append_val(*unit_array_ptr, *unit);
if (GST_VAAPI_DECODER_UNIT_IS_SLICE (unit))
unit_array_ptr = &frame->units;
else if (GST_VAAPI_DECODER_UNIT_IS_FRAME_END (unit))
unit_array_ptr = &frame->post_units;
else
unit_array_ptr = &frame->pre_units;
g_array_append_val (*unit_array_ptr, *unit);
}

View file

@ -39,61 +39,61 @@
#undef gst_vaapi_pixmap_replace
static inline GstVaapiPixmap *
gst_vaapi_pixmap_new_internal(const GstVaapiPixmapClass *pixmap_class,
GstVaapiDisplay *display)
gst_vaapi_pixmap_new_internal (const GstVaapiPixmapClass * pixmap_class,
GstVaapiDisplay * display)
{
g_assert(pixmap_class->create != NULL);
g_assert(pixmap_class->render != NULL);
g_assert (pixmap_class->create != NULL);
g_assert (pixmap_class->render != NULL);
return gst_vaapi_object_new(GST_VAAPI_OBJECT_CLASS(pixmap_class), display);
return gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (pixmap_class), display);
}
GstVaapiPixmap *
gst_vaapi_pixmap_new(const GstVaapiPixmapClass *pixmap_class,
GstVaapiDisplay *display, GstVideoFormat format, guint width, guint height)
gst_vaapi_pixmap_new (const GstVaapiPixmapClass * pixmap_class,
GstVaapiDisplay * display, GstVideoFormat format, guint width, guint height)
{
GstVaapiPixmap *pixmap;
GstVaapiPixmap *pixmap;
g_return_val_if_fail(format != GST_VIDEO_FORMAT_UNKNOWN &&
format != GST_VIDEO_FORMAT_ENCODED, NULL);
g_return_val_if_fail(width > 0, NULL);
g_return_val_if_fail(height > 0, NULL);
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN &&
format != GST_VIDEO_FORMAT_ENCODED, NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
pixmap = gst_vaapi_pixmap_new_internal(pixmap_class, display);
if (!pixmap)
return NULL;
pixmap = gst_vaapi_pixmap_new_internal (pixmap_class, display);
if (!pixmap)
return NULL;
pixmap->format = format;
pixmap->width = width;
pixmap->height = height;
if (!pixmap_class->create(pixmap))
goto error;
return pixmap;
pixmap->format = format;
pixmap->width = width;
pixmap->height = height;
if (!pixmap_class->create (pixmap))
goto error;
return pixmap;
error:
gst_vaapi_pixmap_unref_internal(pixmap);
return NULL;
gst_vaapi_pixmap_unref_internal (pixmap);
return NULL;
}
GstVaapiPixmap *
gst_vaapi_pixmap_new_from_native(const GstVaapiPixmapClass *pixmap_class,
GstVaapiDisplay *display, gpointer native_pixmap)
gst_vaapi_pixmap_new_from_native (const GstVaapiPixmapClass * pixmap_class,
GstVaapiDisplay * display, gpointer native_pixmap)
{
GstVaapiPixmap *pixmap;
GstVaapiPixmap *pixmap;
pixmap = gst_vaapi_pixmap_new_internal(pixmap_class, display);
if (!pixmap)
return NULL;
pixmap = gst_vaapi_pixmap_new_internal (pixmap_class, display);
if (!pixmap)
return NULL;
GST_VAAPI_OBJECT_ID(pixmap) = GPOINTER_TO_SIZE(native_pixmap);
pixmap->use_foreign_pixmap = TRUE;
if (!pixmap_class->create(pixmap))
goto error;
return pixmap;
GST_VAAPI_OBJECT_ID (pixmap) = GPOINTER_TO_SIZE (native_pixmap);
pixmap->use_foreign_pixmap = TRUE;
if (!pixmap_class->create (pixmap))
goto error;
return pixmap;
error:
gst_vaapi_pixmap_unref_internal(pixmap);
return NULL;
gst_vaapi_pixmap_unref_internal (pixmap);
return NULL;
}
/**
@ -105,9 +105,9 @@ error:
* Returns: The same @pixmap argument
*/
GstVaapiPixmap *
gst_vaapi_pixmap_ref(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_ref (GstVaapiPixmap * pixmap)
{
return gst_vaapi_pixmap_ref_internal(pixmap);
return gst_vaapi_pixmap_ref_internal (pixmap);
}
/**
@ -118,9 +118,9 @@ gst_vaapi_pixmap_ref(GstVaapiPixmap *pixmap)
* the reference count reaches zero, the pixmap will be free'd.
*/
void
gst_vaapi_pixmap_unref(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_unref (GstVaapiPixmap * pixmap)
{
gst_vaapi_pixmap_unref_internal(pixmap);
gst_vaapi_pixmap_unref_internal (pixmap);
}
/**
@ -133,10 +133,10 @@ gst_vaapi_pixmap_unref(GstVaapiPixmap *pixmap)
* valid pixmap. However, @new_pixmap can be NULL.
*/
void
gst_vaapi_pixmap_replace(GstVaapiPixmap **old_pixmap_ptr,
GstVaapiPixmap *new_pixmap)
gst_vaapi_pixmap_replace (GstVaapiPixmap ** old_pixmap_ptr,
GstVaapiPixmap * new_pixmap)
{
gst_vaapi_pixmap_replace_internal(old_pixmap_ptr, new_pixmap);
gst_vaapi_pixmap_replace_internal (old_pixmap_ptr, new_pixmap);
}
/**
@ -148,11 +148,11 @@ gst_vaapi_pixmap_replace(GstVaapiPixmap **old_pixmap_ptr,
* Return value: the parent #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_pixmap_get_display(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_get_display (GstVaapiPixmap * pixmap)
{
g_return_val_if_fail(pixmap != NULL, NULL);
g_return_val_if_fail (pixmap != NULL, NULL);
return GST_VAAPI_OBJECT_DISPLAY(pixmap);
return GST_VAAPI_OBJECT_DISPLAY (pixmap);
}
/**
@ -164,11 +164,11 @@ gst_vaapi_pixmap_get_display(GstVaapiPixmap *pixmap)
* Return value: the format of the @pixmap
*/
GstVideoFormat
gst_vaapi_pixmap_get_format(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_get_format (GstVaapiPixmap * pixmap)
{
g_return_val_if_fail(pixmap != NULL, GST_VIDEO_FORMAT_UNKNOWN);
g_return_val_if_fail (pixmap != NULL, GST_VIDEO_FORMAT_UNKNOWN);
return GST_VAAPI_PIXMAP_FORMAT(pixmap);
return GST_VAAPI_PIXMAP_FORMAT (pixmap);
}
/**
@ -180,11 +180,11 @@ gst_vaapi_pixmap_get_format(GstVaapiPixmap *pixmap)
* Return value: the width of the @pixmap, in pixels
*/
guint
gst_vaapi_pixmap_get_width(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_get_width (GstVaapiPixmap * pixmap)
{
g_return_val_if_fail(pixmap != NULL, 0);
g_return_val_if_fail (pixmap != NULL, 0);
return GST_VAAPI_PIXMAP_WIDTH(pixmap);
return GST_VAAPI_PIXMAP_WIDTH (pixmap);
}
/**
@ -196,11 +196,11 @@ gst_vaapi_pixmap_get_width(GstVaapiPixmap *pixmap)
* Return value: the height of the @pixmap, in pixels
*/
guint
gst_vaapi_pixmap_get_height(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_get_height (GstVaapiPixmap * pixmap)
{
g_return_val_if_fail(pixmap != NULL, 0);
g_return_val_if_fail (pixmap != NULL, 0);
return GST_VAAPI_PIXMAP_HEIGHT(pixmap);
return GST_VAAPI_PIXMAP_HEIGHT (pixmap);
}
/**
@ -212,15 +212,16 @@ gst_vaapi_pixmap_get_height(GstVaapiPixmap *pixmap)
* Retrieves the dimensions of a #GstVaapiPixmap.
*/
void
gst_vaapi_pixmap_get_size(GstVaapiPixmap *pixmap, guint *width, guint *height)
gst_vaapi_pixmap_get_size (GstVaapiPixmap * pixmap, guint * width,
guint * height)
{
g_return_if_fail(pixmap != NULL);
g_return_if_fail (pixmap != NULL);
if (width)
*width = GST_VAAPI_PIXMAP_WIDTH(pixmap);
if (width)
*width = GST_VAAPI_PIXMAP_WIDTH (pixmap);
if (height)
*height = GST_VAAPI_PIXMAP_HEIGHT(pixmap);
if (height)
*height = GST_VAAPI_PIXMAP_HEIGHT (pixmap);
}
/**
@ -240,21 +241,21 @@ gst_vaapi_pixmap_get_size(GstVaapiPixmap *pixmap, guint *width, guint *height)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_pixmap_put_surface(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
const GstVaapiRectangle *crop_rect, guint flags)
gst_vaapi_pixmap_put_surface (GstVaapiPixmap * pixmap,
GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect, guint flags)
{
GstVaapiRectangle src_rect;
GstVaapiRectangle src_rect;
g_return_val_if_fail(pixmap != NULL, FALSE);
g_return_val_if_fail(surface != NULL, FALSE);
g_return_val_if_fail (pixmap != NULL, FALSE);
g_return_val_if_fail (surface != NULL, FALSE);
if (!crop_rect) {
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = GST_VAAPI_SURFACE_WIDTH(surface);
src_rect.height = GST_VAAPI_SURFACE_HEIGHT(surface);
crop_rect = &src_rect;
}
return GST_VAAPI_PIXMAP_GET_CLASS(pixmap)->render(pixmap, surface,
crop_rect, flags);
if (!crop_rect) {
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = GST_VAAPI_SURFACE_WIDTH (surface);
src_rect.height = GST_VAAPI_SURFACE_HEIGHT (surface);
crop_rect = &src_rect;
}
return GST_VAAPI_PIXMAP_GET_CLASS (pixmap)->render (pixmap, surface,
crop_rect, flags);
}

View file

@ -38,134 +38,131 @@
#define DEBUG 1
#include "gstvaapidebug.h"
typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class;
typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class;
struct _GstVaapiPixmapX11 {
GstVaapiPixmap parent_instance;
struct _GstVaapiPixmapX11
{
GstVaapiPixmap parent_instance;
};
struct _GstVaapiPixmapX11Class {
GstVaapiPixmapClass parent_class;
struct _GstVaapiPixmapX11Class
{
GstVaapiPixmapClass parent_class;
};
static gboolean
gst_vaapi_pixmap_x11_create_from_xid(GstVaapiPixmap *pixmap, Pixmap xid)
gst_vaapi_pixmap_x11_create_from_xid (GstVaapiPixmap * pixmap, Pixmap xid)
{
guint depth;
gboolean success;
guint depth;
gboolean success;
if (!xid)
return FALSE;
if (!xid)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(pixmap);
success = x11_get_geometry(GST_VAAPI_OBJECT_NATIVE_DISPLAY(pixmap), xid,
NULL, NULL, &pixmap->width, &pixmap->height, &depth);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(pixmap);
if (!success)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
success = x11_get_geometry (GST_VAAPI_OBJECT_NATIVE_DISPLAY (pixmap), xid,
NULL, NULL, &pixmap->width, &pixmap->height, &depth);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
if (!success)
return FALSE;
pixmap->format = gst_vaapi_display_x11_get_pixmap_format(
GST_VAAPI_OBJECT_DISPLAY_X11(pixmap), depth);
if (pixmap->format == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE;
return TRUE;
pixmap->format =
gst_vaapi_display_x11_get_pixmap_format (GST_VAAPI_OBJECT_DISPLAY_X11
(pixmap), depth);
if (pixmap->format == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE;
return TRUE;
}
static gboolean
gst_vaapi_pixmap_x11_create(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_x11_create (GstVaapiPixmap * pixmap)
{
GstVaapiDisplayX11 * const display =
GST_VAAPI_DISPLAY_X11(GST_VAAPI_OBJECT_DISPLAY(pixmap));
Display * const dpy = GST_VAAPI_OBJECT_NATIVE_DISPLAY(display);
Window rootwin;
Pixmap xid;
guint depth;
GstVaapiDisplayX11 *const display =
GST_VAAPI_DISPLAY_X11 (GST_VAAPI_OBJECT_DISPLAY (pixmap));
Display *const dpy = GST_VAAPI_OBJECT_NATIVE_DISPLAY (display);
Window rootwin;
Pixmap xid;
guint depth;
if (pixmap->use_foreign_pixmap)
return gst_vaapi_pixmap_x11_create_from_xid(pixmap,
GST_VAAPI_OBJECT_ID(pixmap));
if (pixmap->use_foreign_pixmap)
return gst_vaapi_pixmap_x11_create_from_xid (pixmap,
GST_VAAPI_OBJECT_ID (pixmap));
depth = gst_vaapi_display_x11_get_pixmap_depth(display, pixmap->format);
if (!depth)
return FALSE;
depth = gst_vaapi_display_x11_get_pixmap_depth (display, pixmap->format);
if (!depth)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(pixmap);
rootwin = RootWindow(dpy, DefaultScreen(dpy));
xid = XCreatePixmap(dpy, rootwin, pixmap->width, pixmap->height, depth);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(pixmap);
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
rootwin = RootWindow (dpy, DefaultScreen (dpy));
xid = XCreatePixmap (dpy, rootwin, pixmap->width, pixmap->height, depth);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
GST_DEBUG("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(xid));
GST_VAAPI_OBJECT_ID(pixmap) = xid;
return xid != None;
GST_DEBUG ("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (xid));
GST_VAAPI_OBJECT_ID (pixmap) = xid;
return xid != None;
}
static void
gst_vaapi_pixmap_x11_destroy(GstVaapiPixmap *pixmap)
gst_vaapi_pixmap_x11_destroy (GstVaapiPixmap * pixmap)
{
const Pixmap xid = GST_VAAPI_OBJECT_ID(pixmap);
const Pixmap xid = GST_VAAPI_OBJECT_ID (pixmap);
if (xid) {
if (!pixmap->use_foreign_pixmap) {
GST_VAAPI_OBJECT_LOCK_DISPLAY(pixmap);
XFreePixmap(GST_VAAPI_OBJECT_NATIVE_DISPLAY(pixmap), xid);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(pixmap);
}
GST_VAAPI_OBJECT_ID(pixmap) = None;
if (xid) {
if (!pixmap->use_foreign_pixmap) {
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
XFreePixmap (GST_VAAPI_OBJECT_NATIVE_DISPLAY (pixmap), xid);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
}
GST_VAAPI_OBJECT_ID (pixmap) = None;
}
}
static gboolean
gst_vaapi_pixmap_x11_render(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
const GstVaapiRectangle *crop_rect, guint flags)
gst_vaapi_pixmap_x11_render (GstVaapiPixmap * pixmap, GstVaapiSurface * surface,
const GstVaapiRectangle * crop_rect, guint flags)
{
VASurfaceID surface_id;
VAStatus status;
VASurfaceID surface_id;
VAStatus status;
surface_id = GST_VAAPI_OBJECT_ID(surface);
if (surface_id == VA_INVALID_ID)
return FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface);
if (surface_id == VA_INVALID_ID)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY(pixmap);
status = vaPutSurface(
GST_VAAPI_OBJECT_VADISPLAY(pixmap),
surface_id,
GST_VAAPI_OBJECT_ID(pixmap),
crop_rect->x, crop_rect->y,
crop_rect->width, crop_rect->height,
0, 0,
GST_VAAPI_PIXMAP_WIDTH(pixmap),
GST_VAAPI_PIXMAP_HEIGHT(pixmap),
NULL, 0,
from_GstVaapiSurfaceRenderFlags(flags)
);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY(pixmap);
if (!vaapi_check_status(status, "vaPutSurface() [pixmap]"))
return FALSE;
return TRUE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (pixmap),
surface_id,
GST_VAAPI_OBJECT_ID (pixmap),
crop_rect->x, crop_rect->y,
crop_rect->width, crop_rect->height,
0, 0,
GST_VAAPI_PIXMAP_WIDTH (pixmap),
GST_VAAPI_PIXMAP_HEIGHT (pixmap),
NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)
);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
if (!vaapi_check_status (status, "vaPutSurface() [pixmap]"))
return FALSE;
return TRUE;
}
void
gst_vaapi_pixmap_x11_class_init(GstVaapiPixmapX11Class *klass)
gst_vaapi_pixmap_x11_class_init (GstVaapiPixmapX11Class * klass)
{
GstVaapiObjectClass * const object_class =
GST_VAAPI_OBJECT_CLASS(klass);
GstVaapiPixmapClass * const pixmap_class =
GST_VAAPI_PIXMAP_CLASS(klass);
GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
GstVaapiPixmapClass *const pixmap_class = GST_VAAPI_PIXMAP_CLASS (klass);
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_pixmap_x11_destroy;
object_class->finalize = (GstVaapiObjectFinalizeFunc)
gst_vaapi_pixmap_x11_destroy;
pixmap_class->create = gst_vaapi_pixmap_x11_create;
pixmap_class->render = gst_vaapi_pixmap_x11_render;
pixmap_class->create = gst_vaapi_pixmap_x11_create;
pixmap_class->render = gst_vaapi_pixmap_x11_render;
}
#define gst_vaapi_pixmap_x11_finalize \
gst_vaapi_pixmap_x11_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiPixmapX11,
gst_vaapi_pixmap_x11,
gst_vaapi_pixmap_x11_class_init(&g_class))
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiPixmapX11,
gst_vaapi_pixmap_x11, gst_vaapi_pixmap_x11_class_init (&g_class))
/**
* gst_vaapi_pixmap_x11_new:
@ -179,17 +176,17 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
*
* Return value: the newly allocated #GstVaapiPixmap object
*/
GstVaapiPixmap *
gst_vaapi_pixmap_x11_new(GstVaapiDisplay *display, GstVideoFormat format,
guint width, guint height)
GstVaapiPixmap *gst_vaapi_pixmap_x11_new (GstVaapiDisplay * display,
GstVideoFormat format, guint width, guint height)
{
GST_DEBUG("new pixmap, format %s, size %ux%u",
gst_vaapi_video_format_to_string(format), width, height);
GST_DEBUG ("new pixmap, format %s, size %ux%u",
gst_vaapi_video_format_to_string (format), width, height);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
return gst_vaapi_pixmap_new(GST_VAAPI_PIXMAP_CLASS(
gst_vaapi_pixmap_x11_class()), display, format, width, height);
return
gst_vaapi_pixmap_new (GST_VAAPI_PIXMAP_CLASS (gst_vaapi_pixmap_x11_class
()), display, format, width, height);
}
/**
@ -205,15 +202,16 @@ gst_vaapi_pixmap_x11_new(GstVaapiDisplay *display, GstVideoFormat format,
* Return value: the newly allocated #GstVaapiPixmap object
*/
GstVaapiPixmap *
gst_vaapi_pixmap_x11_new_with_xid(GstVaapiDisplay *display, Pixmap xid)
gst_vaapi_pixmap_x11_new_with_xid (GstVaapiDisplay * display, Pixmap xid)
{
GST_DEBUG("new pixmap from xid 0x%08x", (guint)xid);
GST_DEBUG ("new pixmap from xid 0x%08x", (guint) xid);
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY_X11(display), NULL);
g_return_val_if_fail(xid != None, NULL);
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
g_return_val_if_fail (xid != None, NULL);
return gst_vaapi_pixmap_new_from_native(GST_VAAPI_PIXMAP_CLASS(
gst_vaapi_pixmap_x11_class()), display, GSIZE_TO_POINTER(xid));
return
gst_vaapi_pixmap_new_from_native (GST_VAAPI_PIXMAP_CLASS
(gst_vaapi_pixmap_x11_class ()), display, GSIZE_TO_POINTER (xid));
}
/**
@ -227,11 +225,11 @@ gst_vaapi_pixmap_x11_new_with_xid(GstVaapiDisplay *display, Pixmap xid)
* Return value: the underlying X11 Pixmap bound to @pixmap.
*/
Pixmap
gst_vaapi_pixmap_x11_get_xid(GstVaapiPixmapX11 *pixmap)
gst_vaapi_pixmap_x11_get_xid (GstVaapiPixmapX11 * pixmap)
{
g_return_val_if_fail(pixmap != NULL, None);
g_return_val_if_fail (pixmap != NULL, None);
return GST_VAAPI_OBJECT_ID(pixmap);
return GST_VAAPI_OBJECT_ID (pixmap);
}
/**
@ -245,9 +243,9 @@ gst_vaapi_pixmap_x11_get_xid(GstVaapiPixmapX11 *pixmap)
* caller (foreign pixmap)
*/
gboolean
gst_vaapi_pixmap_x11_is_foreign_xid(GstVaapiPixmapX11 *pixmap)
gst_vaapi_pixmap_x11_is_foreign_xid (GstVaapiPixmapX11 * pixmap)
{
g_return_val_if_fail(pixmap != NULL, FALSE);
g_return_val_if_fail (pixmap != NULL, FALSE);
return GST_VAAPI_PIXMAP(pixmap)->use_foreign_pixmap;
return GST_VAAPI_PIXMAP (pixmap)->use_foreign_pixmap;
}

View file

@ -34,172 +34,153 @@
#include "gstvaapiprofile.h"
#include "gstvaapiworkarounds.h"
typedef struct _GstVaapiCodecMap GstVaapiCodecMap;
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
typedef struct _GstVaapiCodecMap GstVaapiCodecMap;
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
struct _GstVaapiCodecMap {
GstVaapiCodec codec;
const gchar *name;
struct _GstVaapiCodecMap
{
GstVaapiCodec codec;
const gchar *name;
};
struct _GstVaapiProfileMap {
GstVaapiProfile profile;
VAProfile va_profile;
const char *media_str;
const gchar *profile_str;
struct _GstVaapiProfileMap
{
GstVaapiProfile profile;
VAProfile va_profile;
const char *media_str;
const gchar *profile_str;
};
struct _GstVaapiEntrypointMap {
GstVaapiEntrypoint entrypoint;
VAEntrypoint va_entrypoint;
struct _GstVaapiEntrypointMap
{
GstVaapiEntrypoint 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" },
{ GST_VAAPI_CODEC_VP8, "vp8" },
{ GST_VAAPI_CODEC_H265, "h265" },
{ GST_VAAPI_CODEC_VP9, "vp9" },
{ 0, }
{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"},
{GST_VAAPI_CODEC_VP8, "vp8"},
{GST_VAAPI_CODEC_H265, "h265"},
{GST_VAAPI_CODEC_VP9, "vp9"},
{0,}
};
/* Profiles */
static const GstVaapiProfileMap gst_vaapi_profiles[] = {
{ GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
"video/mpeg, mpegversion=2", "simple"
},
{ GST_VAAPI_PROFILE_MPEG2_MAIN, VAProfileMPEG2Main,
"video/mpeg, mpegversion=2", "main"
},
{ GST_VAAPI_PROFILE_MPEG4_SIMPLE, VAProfileMPEG4Simple,
"video/mpeg, mpegversion=4", "simple"
},
{ GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/mpeg, mpegversion=4", "advanced-simple"
},
{ GST_VAAPI_PROFILE_MPEG4_MAIN, VAProfileMPEG4Main,
"video/mpeg, mpegversion=4", "main"
},
{ GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-divx, divxversion=5", "advanced-simple"
},
{ GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-xvid", "advanced-simple"
},
{GST_VAAPI_PROFILE_MPEG2_SIMPLE, VAProfileMPEG2Simple,
"video/mpeg, mpegversion=2", "simple"},
{GST_VAAPI_PROFILE_MPEG2_MAIN, VAProfileMPEG2Main,
"video/mpeg, mpegversion=2", "main"},
{GST_VAAPI_PROFILE_MPEG4_SIMPLE, VAProfileMPEG4Simple,
"video/mpeg, mpegversion=4", "simple"},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/mpeg, mpegversion=4", "advanced-simple"},
{GST_VAAPI_PROFILE_MPEG4_MAIN, VAProfileMPEG4Main,
"video/mpeg, mpegversion=4", "main"},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-divx, divxversion=5", "advanced-simple"},
{GST_VAAPI_PROFILE_MPEG4_ADVANCED_SIMPLE, VAProfileMPEG4AdvancedSimple,
"video/x-xvid", "advanced-simple"},
#if VA_CHECK_VERSION(0,30,0)
{ GST_VAAPI_PROFILE_H263_BASELINE, VAProfileH263Baseline,
"video/x-h263, variant=itu, h263version=h263", "baseline"
},
{GST_VAAPI_PROFILE_H263_BASELINE, VAProfileH263Baseline,
"video/x-h263, variant=itu, h263version=h263", "baseline"},
#endif
{ GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline,
"video/x-h264", "baseline"
},
{GST_VAAPI_PROFILE_H264_BASELINE, VAProfileH264Baseline,
"video/x-h264", "baseline"},
#if VA_CHECK_VERSION(0,31,1)
{ GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE,
VAProfileH264ConstrainedBaseline,
"video/x-h264", "constrained-baseline"
},
{GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE,
VAProfileH264ConstrainedBaseline,
"video/x-h264", "constrained-baseline"},
#endif
{ GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main,
"video/x-h264", "main"
},
{ GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High,
"video/x-h264", "high"
},
{GST_VAAPI_PROFILE_H264_MAIN, VAProfileH264Main,
"video/x-h264", "main"},
{GST_VAAPI_PROFILE_H264_HIGH, VAProfileH264High,
"video/x-h264", "high"},
#if VA_CHECK_VERSION(0,35,2)
{ GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH, VAProfileH264MultiviewHigh,
"video/x-h264", "multiview-high"
},
{ GST_VAAPI_PROFILE_H264_STEREO_HIGH, VAProfileH264StereoHigh,
"video/x-h264", "stereo-high"
},
{GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH, VAProfileH264MultiviewHigh,
"video/x-h264", "multiview-high"},
{GST_VAAPI_PROFILE_H264_STEREO_HIGH, VAProfileH264StereoHigh,
"video/x-h264", "stereo-high"},
#endif
{ GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple,
"video/x-wmv, wmvversion=3", "simple"
},
{ GST_VAAPI_PROFILE_VC1_MAIN, VAProfileVC1Main,
"video/x-wmv, wmvversion=3", "main"
},
{ GST_VAAPI_PROFILE_VC1_ADVANCED, VAProfileVC1Advanced,
"video/x-wmv, wmvversion=3, format=(string)WVC1", "advanced"
},
{GST_VAAPI_PROFILE_VC1_SIMPLE, VAProfileVC1Simple,
"video/x-wmv, wmvversion=3", "simple"},
{GST_VAAPI_PROFILE_VC1_MAIN, VAProfileVC1Main,
"video/x-wmv, wmvversion=3", "main"},
{GST_VAAPI_PROFILE_VC1_ADVANCED, VAProfileVC1Advanced,
"video/x-wmv, wmvversion=3, format=(string)WVC1", "advanced"},
#if VA_CHECK_VERSION(0,32,0)
{ GST_VAAPI_PROFILE_JPEG_BASELINE, VAProfileJPEGBaseline,
"image/jpeg", NULL
},
{GST_VAAPI_PROFILE_JPEG_BASELINE, VAProfileJPEGBaseline,
"image/jpeg", NULL},
#endif
#if VA_CHECK_VERSION(0,35,0)
{ GST_VAAPI_PROFILE_VP8, VAProfileVP8Version0_3,
"video/x-vp8", NULL
},
{GST_VAAPI_PROFILE_VP8, VAProfileVP8Version0_3,
"video/x-vp8", NULL},
#endif
#if VA_CHECK_VERSION(0,37,0)
{ GST_VAAPI_PROFILE_H265_MAIN, VAProfileHEVCMain,
"video/x-h265", "main"
},
{ GST_VAAPI_PROFILE_H265_MAIN10, VAProfileHEVCMain10,
"video/x-h265", "main-10"
},
{GST_VAAPI_PROFILE_H265_MAIN, VAProfileHEVCMain,
"video/x-h265", "main"},
{GST_VAAPI_PROFILE_H265_MAIN10, VAProfileHEVCMain10,
"video/x-h265", "main-10"},
#endif
#if VA_CHECK_VERSION(0,38,0)
{ GST_VAAPI_PROFILE_VP9, VAProfileVP9Profile0,
"video/x-vp9", NULL
},
{GST_VAAPI_PROFILE_VP9, VAProfileVP9Profile0,
"video/x-vp9", NULL},
#endif
{ 0, }
{0,}
};
/* Entry-points */
static const GstVaapiEntrypointMap gst_vaapi_entrypoints[] = {
{ GST_VAAPI_ENTRYPOINT_VLD, VAEntrypointVLD },
{ GST_VAAPI_ENTRYPOINT_IDCT, VAEntrypointIDCT },
{ GST_VAAPI_ENTRYPOINT_MOCO, VAEntrypointMoComp },
{GST_VAAPI_ENTRYPOINT_VLD, VAEntrypointVLD},
{GST_VAAPI_ENTRYPOINT_IDCT, VAEntrypointIDCT},
{GST_VAAPI_ENTRYPOINT_MOCO, VAEntrypointMoComp},
#if VA_CHECK_VERSION(0,30,0)
{ GST_VAAPI_ENTRYPOINT_SLICE_ENCODE, VAEntrypointEncSlice },
{ GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE, VAEntrypointEncPicture },
{GST_VAAPI_ENTRYPOINT_SLICE_ENCODE, VAEntrypointEncSlice},
{GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE, VAEntrypointEncPicture},
#endif
{ 0, }
{0,}
};
static const GstVaapiCodecMap *
get_codecs_map(GstVaapiCodec codec)
get_codecs_map (GstVaapiCodec codec)
{
const GstVaapiCodecMap *m;
const GstVaapiCodecMap *m;
for (m = gst_vaapi_codecs; m->codec; m++)
if (m->codec == codec)
return m;
return NULL;
for (m = gst_vaapi_codecs; m->codec; m++)
if (m->codec == codec)
return m;
return NULL;
}
static const GstVaapiProfileMap *
get_profiles_map(GstVaapiProfile profile)
get_profiles_map (GstVaapiProfile profile)
{
const GstVaapiProfileMap *m;
const GstVaapiProfileMap *m;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->profile == profile)
return m;
return NULL;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->profile == profile)
return m;
return NULL;
}
static const GstVaapiEntrypointMap *
get_entrypoints_map(GstVaapiEntrypoint entrypoint)
get_entrypoints_map (GstVaapiEntrypoint entrypoint)
{
const GstVaapiEntrypointMap *m;
const GstVaapiEntrypointMap *m;
for (m = gst_vaapi_entrypoints; m->entrypoint; m++)
if (m->entrypoint == entrypoint)
return m;
return NULL;
for (m = gst_vaapi_entrypoints; m->entrypoint; m++)
if (m->entrypoint == entrypoint)
return m;
return NULL;
}
/**
@ -211,11 +192,11 @@ get_entrypoints_map(GstVaapiEntrypoint entrypoint)
* Return value: the statically allocated string representation of @codec
*/
const gchar *
gst_vaapi_codec_get_name(GstVaapiCodec codec)
gst_vaapi_codec_get_name (GstVaapiCodec codec)
{
const GstVaapiCodecMap * const m = get_codecs_map(codec);
const GstVaapiCodecMap *const m = get_codecs_map (codec);
return m ? m->name : NULL;
return m ? m->name : NULL;
}
/**
@ -229,14 +210,14 @@ gst_vaapi_codec_get_name(GstVaapiCodec codec)
* Return value: the #GstVaapiProfile describing the @profile
*/
GstVaapiProfile
gst_vaapi_profile(VAProfile profile)
gst_vaapi_profile (VAProfile profile)
{
const GstVaapiProfileMap *m;
const GstVaapiProfileMap *m;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->va_profile == profile)
return m->profile;
return 0;
for (m = gst_vaapi_profiles; m->profile; m++)
if (m->va_profile == profile)
return m->profile;
return 0;
}
/**
@ -248,11 +229,11 @@ gst_vaapi_profile(VAProfile profile)
* Return value: the statically allocated string representation of @profile
*/
const gchar *
gst_vaapi_profile_get_name(GstVaapiProfile profile)
gst_vaapi_profile_get_name (GstVaapiProfile profile)
{
const GstVaapiProfileMap * const m = get_profiles_map(profile);
const GstVaapiProfileMap *const m = get_profiles_map (profile);
return m ? m->profile_str : NULL;
return m ? m->profile_str : NULL;
}
/**
@ -266,11 +247,11 @@ gst_vaapi_profile_get_name(GstVaapiProfile profile)
* @profile media type
*/
const gchar *
gst_vaapi_profile_get_media_type_name(GstVaapiProfile profile)
gst_vaapi_profile_get_media_type_name (GstVaapiProfile profile)
{
const GstVaapiProfileMap * const m = get_profiles_map(profile);
const GstVaapiProfileMap *const m = get_profiles_map (profile);
return m ? m->media_str : NULL;
return m ? m->media_str : NULL;
}
/**
@ -283,73 +264,81 @@ gst_vaapi_profile_get_media_type_name(GstVaapiProfile profile)
* Return value: the #GstVaapiProfile described in @buffer
*/
static GstVaapiProfile
gst_vaapi_profile_from_codec_data_h264(GstBuffer *buffer)
gst_vaapi_profile_from_codec_data_h264 (GstBuffer * buffer)
{
/* MPEG-4 Part 15: Advanced Video Coding (AVC) file format */
guchar buf[3];
/* MPEG-4 Part 15: Advanced Video Coding (AVC) file format */
guchar buf[3];
if (gst_buffer_extract(buffer, 0, buf, sizeof(buf)) != sizeof(buf))
return 0;
if (buf[0] != 1) /* configurationVersion = 1 */
return 0;
switch (buf[1]) { /* AVCProfileIndication */
case 66: return ((buf[2] & 0x40) ?
GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE :
GST_VAAPI_PROFILE_H264_BASELINE);
case 77: return GST_VAAPI_PROFILE_H264_MAIN;
case 100: return GST_VAAPI_PROFILE_H264_HIGH;
case 118: return GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH;
case 128: return GST_VAAPI_PROFILE_H264_STEREO_HIGH;
}
if (gst_buffer_extract (buffer, 0, buf, sizeof (buf)) != sizeof (buf))
return 0;
if (buf[0] != 1) /* configurationVersion = 1 */
return 0;
switch (buf[1]) { /* AVCProfileIndication */
case 66:
return ((buf[2] & 0x40) ?
GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE :
GST_VAAPI_PROFILE_H264_BASELINE);
case 77:
return GST_VAAPI_PROFILE_H264_MAIN;
case 100:
return GST_VAAPI_PROFILE_H264_HIGH;
case 118:
return GST_VAAPI_PROFILE_H264_MULTIVIEW_HIGH;
case 128:
return GST_VAAPI_PROFILE_H264_STEREO_HIGH;
}
return 0;
}
static GstVaapiProfile
gst_vaapi_profile_from_codec_data_h265(GstBuffer *buffer)
gst_vaapi_profile_from_codec_data_h265 (GstBuffer * buffer)
{
/* ISO/IEC 14496-15: HEVC file format */
guchar buf[3];
/* ISO/IEC 14496-15: HEVC file format */
guchar buf[3];
if (gst_buffer_extract(buffer, 0, buf, sizeof(buf)) != sizeof(buf))
return 0;
if (buf[0] != 1) /* configurationVersion = 1 */
return 0;
if (buf[1] & 0xc0) /* general_profile_space = 0 */
return 0;
switch (buf[1] & 0x1f) { /* HEVCProfileIndication */
case 1: return GST_VAAPI_PROFILE_H265_MAIN;
case 2: return GST_VAAPI_PROFILE_H265_MAIN10;
case 3: return GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE;
}
if (gst_buffer_extract (buffer, 0, buf, sizeof (buf)) != sizeof (buf))
return 0;
if (buf[0] != 1) /* configurationVersion = 1 */
return 0;
if (buf[1] & 0xc0) /* general_profile_space = 0 */
return 0;
switch (buf[1] & 0x1f) { /* HEVCProfileIndication */
case 1:
return GST_VAAPI_PROFILE_H265_MAIN;
case 2:
return GST_VAAPI_PROFILE_H265_MAIN10;
case 3:
return GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE;
}
return 0;
}
static GstVaapiProfile
gst_vaapi_profile_from_codec_data(GstVaapiCodec codec, GstBuffer *buffer)
gst_vaapi_profile_from_codec_data (GstVaapiCodec codec, GstBuffer * buffer)
{
GstVaapiProfile profile;
GstVaapiProfile profile;
if (!codec || !buffer)
return 0;
if (!codec || !buffer)
return 0;
switch (codec) {
switch (codec) {
case GST_VAAPI_CODEC_H264:
profile = gst_vaapi_profile_from_codec_data_h264(buffer);
break;
profile = gst_vaapi_profile_from_codec_data_h264 (buffer);
break;
case GST_VAAPI_CODEC_H265:
profile = gst_vaapi_profile_from_codec_data_h265(buffer);
break;
profile = gst_vaapi_profile_from_codec_data_h265 (buffer);
break;
default:
profile = 0;
break;
}
return profile;
profile = 0;
break;
}
return profile;
}
/**
@ -363,62 +352,60 @@ gst_vaapi_profile_from_codec_data(GstVaapiCodec codec, GstBuffer *buffer)
* Return value: the #GstVaapiProfile describing the @caps
*/
GstVaapiProfile
gst_vaapi_profile_from_caps(const GstCaps *caps)
gst_vaapi_profile_from_caps (const GstCaps * caps)
{
const GstVaapiProfileMap *m;
GstCaps *caps_test;
GstStructure *structure;
const gchar *profile_str;
GstVaapiProfile profile, best_profile;
GstBuffer *codec_data = NULL;
const gchar *name;
gsize namelen;
const GstVaapiProfileMap *m;
GstCaps *caps_test;
GstStructure *structure;
const gchar *profile_str;
GstVaapiProfile profile, best_profile;
GstBuffer *codec_data = NULL;
const gchar *name;
gsize namelen;
if (!caps)
return 0;
if (!caps)
return 0;
structure = gst_caps_get_structure(caps, 0);
if (!structure)
return 0;
structure = gst_caps_get_structure (caps, 0);
if (!structure)
return 0;
name = gst_structure_get_name(structure);
namelen = strlen(name);
name = gst_structure_get_name (structure);
namelen = strlen (name);
profile_str = gst_structure_get_string(structure, "profile");
if (!profile_str) {
const GValue *v_codec_data;
v_codec_data = gst_structure_get_value(structure, "codec_data");
if (v_codec_data)
codec_data = gst_value_get_buffer(v_codec_data);
profile_str = gst_structure_get_string (structure, "profile");
if (!profile_str) {
const GValue *v_codec_data;
v_codec_data = gst_structure_get_value (structure, "codec_data");
if (v_codec_data)
codec_data = gst_value_get_buffer (v_codec_data);
}
profile = 0;
best_profile = 0;
for (m = gst_vaapi_profiles; !profile && m->profile; m++) {
if (strncmp (name, m->media_str, namelen) != 0)
continue;
caps_test = gst_caps_from_string (m->media_str);
if (gst_caps_is_always_compatible (caps, caps_test)) {
best_profile = m->profile;
if (profile_str && m->profile_str &&
strcmp (profile_str, m->profile_str) == 0)
profile = best_profile;
}
profile = 0;
best_profile = 0;
for (m = gst_vaapi_profiles; !profile && m->profile; m++) {
if (strncmp(name, m->media_str, namelen) != 0)
continue;
caps_test = gst_caps_from_string(m->media_str);
if (gst_caps_is_always_compatible(caps, caps_test)) {
best_profile = m->profile;
if (profile_str && m->profile_str &&
strcmp(profile_str, m->profile_str) == 0)
profile = best_profile;
}
if (!profile) {
profile = gst_vaapi_profile_from_codec_data(
gst_vaapi_profile_get_codec(m->profile),
codec_data
);
if (!profile &&
WORKAROUND_QTDEMUX_NO_H263_PROFILES &&
strncmp(name, "video/x-h263", namelen) == 0) {
/* HACK: qtdemux does not report profiles for h263 */
profile = m->profile;
}
}
gst_caps_unref(caps_test);
if (!profile) {
profile =
gst_vaapi_profile_from_codec_data (gst_vaapi_profile_get_codec
(m->profile), codec_data);
if (!profile && WORKAROUND_QTDEMUX_NO_H263_PROFILES
&& strncmp (name, "video/x-h263", namelen) == 0) {
/* HACK: qtdemux does not report profiles for h263 */
profile = m->profile;
}
}
return profile ? profile : best_profile;
gst_caps_unref (caps_test);
}
return profile ? profile : best_profile;
}
/**
@ -432,11 +419,11 @@ gst_vaapi_profile_from_caps(const GstCaps *caps)
* Return value: the VA profile, or -1 if none was found
*/
VAProfile
gst_vaapi_profile_get_va_profile(GstVaapiProfile profile)
gst_vaapi_profile_get_va_profile (GstVaapiProfile profile)
{
const GstVaapiProfileMap * const m = get_profiles_map(profile);
const GstVaapiProfileMap *const m = get_profiles_map (profile);
return m ? m->va_profile : (VAProfile)-1;
return m ? m->va_profile : (VAProfile) - 1;
}
/**
@ -449,29 +436,25 @@ gst_vaapi_profile_get_va_profile(GstVaapiProfile profile)
* Return value: the newly allocated #GstCaps, or %NULL if none was found
*/
GstCaps *
gst_vaapi_profile_get_caps(GstVaapiProfile profile)
gst_vaapi_profile_get_caps (GstVaapiProfile profile)
{
const GstVaapiProfileMap *m;
GstCaps *out_caps, *caps;
const GstVaapiProfileMap *m;
GstCaps *out_caps, *caps;
out_caps = gst_caps_new_empty();
if (!out_caps)
return NULL;
out_caps = gst_caps_new_empty ();
if (!out_caps)
return NULL;
for (m = gst_vaapi_profiles; m->profile; m++) {
if (m->profile != profile)
continue;
caps = gst_caps_from_string(m->media_str);
if (!caps)
continue;
gst_caps_set_simple(
caps,
"profile", G_TYPE_STRING, m->profile_str,
NULL
);
out_caps = gst_caps_merge(out_caps, caps);
}
return out_caps;
for (m = gst_vaapi_profiles; m->profile; m++) {
if (m->profile != profile)
continue;
caps = gst_caps_from_string (m->media_str);
if (!caps)
continue;
gst_caps_set_simple (caps, "profile", G_TYPE_STRING, m->profile_str, NULL);
out_caps = gst_caps_merge (out_caps, caps);
}
return out_caps;
}
/**
@ -483,26 +466,26 @@ gst_vaapi_profile_get_caps(GstVaapiProfile profile)
* Return value: the #GstVaapiCodec from @profile
*/
GstVaapiCodec
gst_vaapi_profile_get_codec(GstVaapiProfile profile)
gst_vaapi_profile_get_codec (GstVaapiProfile profile)
{
GstVaapiCodec codec;
GstVaapiCodec codec;
switch (profile) {
switch (profile) {
case GST_VAAPI_PROFILE_VC1_SIMPLE:
case GST_VAAPI_PROFILE_VC1_MAIN:
codec = GST_VAAPI_CODEC_WMV3;
break;
codec = GST_VAAPI_CODEC_WMV3;
break;
case GST_VAAPI_PROFILE_VC1_ADVANCED:
codec = GST_VAAPI_CODEC_VC1;
break;
codec = GST_VAAPI_CODEC_VC1;
break;
case GST_VAAPI_PROFILE_JPEG_BASELINE:
codec = GST_VAAPI_CODEC_JPEG;
break;
codec = GST_VAAPI_CODEC_JPEG;
break;
default:
codec = (guint32)profile & GST_MAKE_FOURCC(0xff,0xff,0xff,0);
break;
}
return codec;
codec = (guint32) profile & GST_MAKE_FOURCC (0xff, 0xff, 0xff, 0);
break;
}
return codec;
}
/**
@ -516,14 +499,14 @@ gst_vaapi_profile_get_codec(GstVaapiProfile profile)
* Return value: the #GstVaapiEntrypoint describing the @entrypoint
*/
GstVaapiEntrypoint
gst_vaapi_entrypoint(VAEntrypoint entrypoint)
gst_vaapi_entrypoint (VAEntrypoint entrypoint)
{
const GstVaapiEntrypointMap *m;
const GstVaapiEntrypointMap *m;
for (m = gst_vaapi_entrypoints; m->entrypoint; m++)
if (m->va_entrypoint == entrypoint)
return m->entrypoint;
return 0;
for (m = gst_vaapi_entrypoints; m->entrypoint; m++)
if (m->va_entrypoint == entrypoint)
return m->entrypoint;
return 0;
}
/**
@ -537,9 +520,9 @@ gst_vaapi_entrypoint(VAEntrypoint entrypoint)
* Return value: the VA entry-point, or -1 if none was found
*/
VAEntrypoint
gst_vaapi_entrypoint_get_va_entrypoint(GstVaapiEntrypoint entrypoint)
gst_vaapi_entrypoint_get_va_entrypoint (GstVaapiEntrypoint entrypoint)
{
const GstVaapiEntrypointMap * const m = get_entrypoints_map(entrypoint);
const GstVaapiEntrypointMap *const m = get_entrypoints_map (entrypoint);
return m ? m->va_entrypoint : (VAEntrypoint)-1;
return m ? m->va_entrypoint : (VAEntrypoint) - 1;
}

View file

@ -38,20 +38,21 @@
#define DEBUG 1
#include "gstvaapidebug.h"
typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
/**
* GstVaapiSubpicture:
*
* A VA subpicture wrapper
*/
struct _GstVaapiSubpicture {
/*< private >*/
GstVaapiObject parent_instance;
struct _GstVaapiSubpicture
{
/*< private > */
GstVaapiObject parent_instance;
GstVaapiImage *image;
guint flags;
gfloat global_alpha;
GstVaapiImage *image;
guint flags;
gfloat global_alpha;
};
/**
@ -59,66 +60,62 @@ struct _GstVaapiSubpicture {
*
* A VA subpicture wrapper class
*/
struct _GstVaapiSubpictureClass {
/*< private >*/
GstVaapiObjectClass parent_class;
struct _GstVaapiSubpictureClass
{
/*< private > */
GstVaapiObjectClass parent_class;
};
static void
gst_vaapi_subpicture_destroy(GstVaapiSubpicture *subpicture)
gst_vaapi_subpicture_destroy (GstVaapiSubpicture * subpicture)
{
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(subpicture);
VASubpictureID subpicture_id;
VAStatus status;
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
VASubpictureID subpicture_id;
VAStatus status;
subpicture_id = GST_VAAPI_OBJECT_ID(subpicture);
GST_DEBUG("subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS(subpicture_id));
subpicture_id = GST_VAAPI_OBJECT_ID (subpicture);
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (subpicture_id));
if (subpicture_id != VA_INVALID_ID) {
if (display) {
GST_VAAPI_DISPLAY_LOCK(display);
status = vaDestroySubpicture(
GST_VAAPI_DISPLAY_VADISPLAY(display),
subpicture_id
);
GST_VAAPI_DISPLAY_UNLOCK(display);
if (!vaapi_check_status(status, "vaDestroySubpicture()"))
g_warning("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS(subpicture_id));
}
GST_VAAPI_OBJECT_ID(subpicture) = VA_INVALID_ID;
if (subpicture_id != VA_INVALID_ID) {
if (display) {
GST_VAAPI_DISPLAY_LOCK (display);
status = vaDestroySubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
subpicture_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaDestroySubpicture()"))
g_warning ("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (subpicture_id));
}
gst_vaapi_object_replace(&subpicture->image, NULL);
GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID;
}
gst_vaapi_object_replace (&subpicture->image, NULL);
}
static gboolean
gst_vaapi_subpicture_create(GstVaapiSubpicture *subpicture,
GstVaapiImage *image)
gst_vaapi_subpicture_create (GstVaapiSubpicture * subpicture,
GstVaapiImage * image)
{
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(subpicture);
VASubpictureID subpicture_id;
VAStatus status;
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
VASubpictureID subpicture_id;
VAStatus status;
GST_VAAPI_DISPLAY_LOCK(display);
status = vaCreateSubpicture(
GST_VAAPI_DISPLAY_VADISPLAY(display),
GST_VAAPI_OBJECT_ID(image),
&subpicture_id
);
GST_VAAPI_DISPLAY_UNLOCK(display);
if (!vaapi_check_status(status, "vaCreateSubpicture()"))
return FALSE;
GST_VAAPI_DISPLAY_LOCK (display);
status = vaCreateSubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (image), &subpicture_id);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaCreateSubpicture()"))
return FALSE;
GST_DEBUG("subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS(subpicture_id));
GST_VAAPI_OBJECT_ID(subpicture) = subpicture_id;
subpicture->image = gst_vaapi_object_ref(image);
return TRUE;
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (subpicture_id));
GST_VAAPI_OBJECT_ID (subpicture) = subpicture_id;
subpicture->image = gst_vaapi_object_ref (image);
return TRUE;
}
#define gst_vaapi_subpicture_finalize gst_vaapi_subpicture_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS(GstVaapiSubpicture, gst_vaapi_subpicture)
GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSubpicture, gst_vaapi_subpicture)
/**
* gst_vaapi_subpicture_new:
@ -130,38 +127,38 @@ GST_VAAPI_OBJECT_DEFINE_CLASS(GstVaapiSubpicture, gst_vaapi_subpicture)
*
* Return value: the newly allocated #GstVaapiSubpicture object
*/
GstVaapiSubpicture *
gst_vaapi_subpicture_new(GstVaapiImage *image, guint flags)
GstVaapiSubpicture *gst_vaapi_subpicture_new (GstVaapiImage * image,
guint flags)
{
GstVaapiSubpicture *subpicture;
GstVaapiDisplay *display;
GstVideoFormat format;
guint va_flags;
GstVaapiSubpicture *subpicture;
GstVaapiDisplay *display;
GstVideoFormat format;
guint va_flags;
g_return_val_if_fail(image != NULL, NULL);
g_return_val_if_fail (image != NULL, NULL);
GST_DEBUG("create from image %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(image)));
GST_DEBUG ("create from image %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (image)));
display = GST_VAAPI_OBJECT_DISPLAY(image);
format = GST_VAAPI_IMAGE_FORMAT(image);
if (!gst_vaapi_display_has_subpicture_format(display, format, &va_flags))
return NULL;
if (flags & ~va_flags)
return NULL;
display = GST_VAAPI_OBJECT_DISPLAY (image);
format = GST_VAAPI_IMAGE_FORMAT (image);
if (!gst_vaapi_display_has_subpicture_format (display, format, &va_flags))
return NULL;
if (flags & ~va_flags)
return NULL;
subpicture = gst_vaapi_object_new(gst_vaapi_subpicture_class(), display);
if (!subpicture)
return NULL;
subpicture = gst_vaapi_object_new (gst_vaapi_subpicture_class (), display);
if (!subpicture)
return NULL;
subpicture->global_alpha = 1.0f;
if (!gst_vaapi_subpicture_set_image(subpicture, image))
goto error;
return subpicture;
subpicture->global_alpha = 1.0f;
if (!gst_vaapi_subpicture_set_image (subpicture, image))
goto error;
return subpicture;
error:
gst_vaapi_object_unref(subpicture);
return NULL;
gst_vaapi_object_unref (subpicture);
return NULL;
}
/**
@ -177,80 +174,80 @@ error:
* Return value: the newly allocated #GstVaapiSubpicture object
*/
GstVaapiSubpicture *
gst_vaapi_subpicture_new_from_overlay_rectangle(
GstVaapiDisplay *display,
GstVideoOverlayRectangle *rect
)
gst_vaapi_subpicture_new_from_overlay_rectangle (GstVaapiDisplay * display,
GstVideoOverlayRectangle * rect)
{
GstVaapiSubpicture *subpicture;
GstVideoFormat format;
GstVaapiImage *image;
GstVaapiImageRaw raw_image;
GstBuffer *buffer;
guint8 *data;
gfloat global_alpha;
guint width, height, stride;
guint hw_flags, flags;
GstVideoMeta *vmeta;
GstMapInfo map_info;
GstVaapiSubpicture *subpicture;
GstVideoFormat format;
GstVaapiImage *image;
GstVaapiImageRaw raw_image;
GstBuffer *buffer;
guint8 *data;
gfloat global_alpha;
guint width, height, stride;
guint hw_flags, flags;
GstVideoMeta *vmeta;
GstMapInfo map_info;
g_return_val_if_fail(GST_IS_VIDEO_OVERLAY_RECTANGLE(rect), NULL);
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rect), NULL);
/* XXX: use gst_vaapi_image_format_from_video() */
/* XXX: use gst_vaapi_image_format_from_video() */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GST_VIDEO_FORMAT_BGRA;
format = GST_VIDEO_FORMAT_BGRA;
#else
format = GST_VIDEO_FORMAT_ARGB;
format = GST_VIDEO_FORMAT_ARGB;
#endif
if (!gst_vaapi_display_has_subpicture_format(display, format, &hw_flags))
return NULL;
if (!gst_vaapi_display_has_subpicture_format (display, format, &hw_flags))
return NULL;
flags = hw_flags & from_GstVideoOverlayFormatFlags(
gst_video_overlay_rectangle_get_flags(rect));
flags =
hw_flags &
from_GstVideoOverlayFormatFlags (gst_video_overlay_rectangle_get_flags
(rect));
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb(rect,
to_GstVideoOverlayFormatFlags(flags));
if (!buffer)
return NULL;
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect,
to_GstVideoOverlayFormatFlags (flags));
if (!buffer)
return NULL;
vmeta = gst_buffer_get_video_meta(buffer);
if (!vmeta)
return NULL;
width = vmeta->width;
height = vmeta->height;
vmeta = gst_buffer_get_video_meta (buffer);
if (!vmeta)
return NULL;
width = vmeta->width;
height = vmeta->height;
if (!gst_video_meta_map(vmeta, 0, &map_info, (gpointer *)&data,
(gint *)&stride, GST_MAP_READ))
return NULL;
if (!gst_video_meta_map (vmeta, 0, &map_info, (gpointer *) & data,
(gint *) & stride, GST_MAP_READ))
return NULL;
image = gst_vaapi_image_new(display, format, width, height);
if (!image)
return NULL;
image = gst_vaapi_image_new (display, format, width, height);
if (!image)
return NULL;
raw_image.format = format;
raw_image.width = width;
raw_image.height = height;
raw_image.num_planes = 1;
raw_image.pixels[0] = data;
raw_image.stride[0] = stride;
if (!gst_vaapi_image_update_from_raw(image, &raw_image, NULL)) {
GST_WARNING("could not update VA image with subtitle data");
gst_vaapi_object_unref(image);
return NULL;
}
raw_image.format = format;
raw_image.width = width;
raw_image.height = height;
raw_image.num_planes = 1;
raw_image.pixels[0] = data;
raw_image.stride[0] = stride;
if (!gst_vaapi_image_update_from_raw (image, &raw_image, NULL)) {
GST_WARNING ("could not update VA image with subtitle data");
gst_vaapi_object_unref (image);
return NULL;
}
subpicture = gst_vaapi_subpicture_new(image, flags);
gst_vaapi_object_unref(image);
gst_video_meta_unmap(vmeta, 0, &map_info);
if (!subpicture)
return NULL;
subpicture = gst_vaapi_subpicture_new (image, flags);
gst_vaapi_object_unref (image);
gst_video_meta_unmap (vmeta, 0, &map_info);
if (!subpicture)
return NULL;
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA) {
global_alpha = gst_video_overlay_rectangle_get_global_alpha(rect);
if (!gst_vaapi_subpicture_set_global_alpha(subpicture, global_alpha))
return NULL;
}
return subpicture;
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA) {
global_alpha = gst_video_overlay_rectangle_get_global_alpha (rect);
if (!gst_vaapi_subpicture_set_global_alpha (subpicture, global_alpha))
return NULL;
}
return subpicture;
}
/**
@ -262,11 +259,11 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
* Return value: the underlying VA subpicture id
*/
GstVaapiID
gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture)
gst_vaapi_subpicture_get_id (GstVaapiSubpicture * subpicture)
{
g_return_val_if_fail(subpicture != NULL, VA_INVALID_ID);
g_return_val_if_fail (subpicture != NULL, VA_INVALID_ID);
return GST_VAAPI_OBJECT_ID(subpicture);
return GST_VAAPI_OBJECT_ID (subpicture);
}
/**
@ -278,11 +275,11 @@ gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture)
* Return value: the @subpicture flags
*/
guint
gst_vaapi_subpicture_get_flags(GstVaapiSubpicture *subpicture)
gst_vaapi_subpicture_get_flags (GstVaapiSubpicture * subpicture)
{
g_return_val_if_fail(subpicture != NULL, 0);
g_return_val_if_fail (subpicture != NULL, 0);
return subpicture->flags;
return subpicture->flags;
}
/**
@ -294,11 +291,11 @@ gst_vaapi_subpicture_get_flags(GstVaapiSubpicture *subpicture)
* Return value: the #GstVaapiImage this @subpicture is bound to
*/
GstVaapiImage *
gst_vaapi_subpicture_get_image(GstVaapiSubpicture *subpicture)
gst_vaapi_subpicture_get_image (GstVaapiSubpicture * subpicture)
{
g_return_val_if_fail(subpicture != NULL, NULL);
g_return_val_if_fail (subpicture != NULL, NULL);
return subpicture->image;
return subpicture->image;
}
/**
@ -312,14 +309,14 @@ gst_vaapi_subpicture_get_image(GstVaapiSubpicture *subpicture)
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_subpicture_set_image(GstVaapiSubpicture *subpicture,
GstVaapiImage *image)
gst_vaapi_subpicture_set_image (GstVaapiSubpicture * subpicture,
GstVaapiImage * image)
{
g_return_val_if_fail(subpicture != NULL, FALSE);
g_return_val_if_fail(image != NULL, FALSE);
g_return_val_if_fail (subpicture != NULL, FALSE);
g_return_val_if_fail (image != NULL, FALSE);
gst_vaapi_subpicture_destroy(subpicture);
return gst_vaapi_subpicture_create(subpicture, image);
gst_vaapi_subpicture_destroy (subpicture);
return gst_vaapi_subpicture_create (subpicture, image);
}
/**
@ -331,11 +328,11 @@ gst_vaapi_subpicture_set_image(GstVaapiSubpicture *subpicture,
* Return value: the global_alpha value of this @subpicture
*/
gfloat
gst_vaapi_subpicture_get_global_alpha(GstVaapiSubpicture *subpicture)
gst_vaapi_subpicture_get_global_alpha (GstVaapiSubpicture * subpicture)
{
g_return_val_if_fail(subpicture != NULL, 1.0);
g_return_val_if_fail (subpicture != NULL, 1.0);
return subpicture->global_alpha;
return subpicture->global_alpha;
}
/**
@ -350,32 +347,29 @@ gst_vaapi_subpicture_get_global_alpha(GstVaapiSubpicture *subpicture)
* Return value: %TRUE if global_alpha could be set, %FALSE otherwise
*/
gboolean
gst_vaapi_subpicture_set_global_alpha(GstVaapiSubpicture *subpicture,
gst_vaapi_subpicture_set_global_alpha (GstVaapiSubpicture * subpicture,
gfloat global_alpha)
{
GstVaapiDisplay *display;
VAStatus status;
GstVaapiDisplay *display;
VAStatus status;
g_return_val_if_fail(subpicture != NULL, FALSE);
g_return_val_if_fail (subpicture != NULL, FALSE);
if (!(subpicture->flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA))
return FALSE;
if (!(subpicture->flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA))
return FALSE;
if (subpicture->global_alpha == global_alpha)
return TRUE;
display = GST_VAAPI_OBJECT_DISPLAY(subpicture);
GST_VAAPI_DISPLAY_LOCK(display);
status = vaSetSubpictureGlobalAlpha(
GST_VAAPI_DISPLAY_VADISPLAY(display),
GST_VAAPI_OBJECT_ID(subpicture),
global_alpha
);
GST_VAAPI_DISPLAY_UNLOCK(display);
if (!vaapi_check_status(status, "vaSetSubpictureGlobalAlpha()"))
return FALSE;
subpicture->global_alpha = global_alpha;
if (subpicture->global_alpha == global_alpha)
return TRUE;
display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
GST_VAAPI_DISPLAY_LOCK (display);
status = vaSetSubpictureGlobalAlpha (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (subpicture), global_alpha);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaSetSubpictureGlobalAlpha()"))
return FALSE;
subpicture->global_alpha = global_alpha;
return TRUE;
}