mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
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:
parent
4b5be5973e
commit
ac730d0a62
13 changed files with 8565 additions and 8730 deletions
|
@ -37,11 +37,12 @@
|
|||
*
|
||||
* A decoded picture buffer (DPB) object.
|
||||
*/
|
||||
struct _GstVaapiDpb {
|
||||
/*< private >*/
|
||||
struct _GstVaapiDpb
|
||||
{
|
||||
/*< private > */
|
||||
GstVaapiMiniObject parent_instance;
|
||||
|
||||
/*< protected >*/
|
||||
/*< protected > */
|
||||
GstVaapiPicture **pictures;
|
||||
guint num_pictures;
|
||||
guint max_pictures;
|
||||
|
@ -52,59 +53,59 @@ struct _GstVaapiDpb {
|
|||
*
|
||||
* The #GstVaapiDpb base class.
|
||||
*/
|
||||
struct _GstVaapiDpbClass {
|
||||
/*< private >*/
|
||||
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;
|
||||
|
||||
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());
|
||||
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->pictures = g_new0(GstVaapiPicture *, max_pictures);
|
||||
dpb->pictures = g_new0 (GstVaapiPicture *, max_pictures);
|
||||
if (!dpb->pictures)
|
||||
goto error;
|
||||
return dpb;
|
||||
|
||||
error:
|
||||
gst_vaapi_dpb_unref(dpb);
|
||||
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;
|
||||
|
||||
for (i = 0; i < dpb->num_pictures; i++) {
|
||||
if ((GST_VAAPI_PICTURE_IS_OUTPUT(dpb->pictures[i]) ^ output) == 0)
|
||||
if ((GST_VAAPI_PICTURE_IS_OUTPUT (dpb->pictures[i]) ^ output) == 0)
|
||||
break;
|
||||
}
|
||||
if (i == dpb->num_pictures)
|
||||
|
@ -112,8 +113,8 @@ dpb_get_oldest(GstVaapiDpb *dpb, gboolean output)
|
|||
|
||||
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)
|
||||
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;
|
||||
|
@ -122,54 +123,53 @@ dpb_get_oldest(GstVaapiDpb *dpb, gboolean output)
|
|||
}
|
||||
|
||||
static void
|
||||
dpb_remove_index(GstVaapiDpb *dpb, guint index)
|
||||
dpb_remove_index (GstVaapiDpb * dpb, guint index)
|
||||
{
|
||||
GstVaapiPicture ** const pictures = dpb->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);
|
||||
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;
|
||||
|
||||
index = dpb_get_oldest(dpb, 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);
|
||||
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;
|
||||
|
||||
for (i = 0; i < dpb->num_pictures; i++)
|
||||
gst_vaapi_picture_replace(&dpb->pictures[i], NULL);
|
||||
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,52 +177,51 @@ dpb_flush(GstVaapiDpb *dpb)
|
|||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
dpb_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
|
||||
dpb_add (GstVaapiDpb * dpb, GstVaapiPicture * picture)
|
||||
{
|
||||
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);
|
||||
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)) {
|
||||
if (GST_VAAPI_PICTURE_IS_REFERENCE (picture)) {
|
||||
while (dpb->num_pictures == dpb->max_pictures) {
|
||||
if (!dpb_bump(dpb))
|
||||
if (!dpb_bump (dpb))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Store non-reference decoded picture into the DPB
|
||||
else {
|
||||
if (GST_VAAPI_PICTURE_IS_SKIPPED(picture))
|
||||
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) &&
|
||||
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 dpb_output (dpb, picture);
|
||||
if (!dpb_bump (dpb))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
gst_vaapi_picture_replace(&dpb->pictures[dpb->num_pictures++], picture);
|
||||
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;
|
||||
|
@ -230,15 +229,14 @@ dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
|
|||
|
||||
/* Find the first picture with POC > specified picture POC */
|
||||
for (i = 0; i < dpb->num_pictures; i++) {
|
||||
GstVaapiPicture * const ref_picture = dpb->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) {
|
||||
} else if (ref_picture->poc > picture->poc) {
|
||||
next_picture = ref_picture;
|
||||
if (i > 0)
|
||||
prev_picture = dpb->pictures[i - 1];
|
||||
|
@ -246,8 +244,8 @@ dpb_get_neighbours(GstVaapiDpb *dpb, GstVaapiPicture *picture,
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -260,13 +258,13 @@ 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;
|
||||
|
||||
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
|
||||
|
@ -276,35 +274,35 @@ dpb2_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
|
|||
* - ... 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)) {
|
||||
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))
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
@ -327,18 +325,19 @@ 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 },
|
||||
{sizeof (GstVaapiDpb),
|
||||
(GDestroyNotify) gst_vaapi_dpb_finalize}
|
||||
,
|
||||
|
||||
dpb_flush,
|
||||
dpb_add,
|
||||
|
@ -348,11 +347,12 @@ gst_vaapi_dpb_class(void)
|
|||
}
|
||||
|
||||
static const GstVaapiMiniObjectClass *
|
||||
gst_vaapi_dpb2_class(void)
|
||||
gst_vaapi_dpb2_class (void)
|
||||
{
|
||||
static const GstVaapiDpbClass GstVaapiDpb2Class = {
|
||||
{ sizeof(GstVaapiDpb),
|
||||
(GDestroyNotify)gst_vaapi_dpb_finalize },
|
||||
{sizeof (GstVaapiDpb),
|
||||
(GDestroyNotify) gst_vaapi_dpb_finalize}
|
||||
,
|
||||
|
||||
dpb_flush,
|
||||
dpb2_add,
|
||||
|
@ -362,57 +362,57 @@ gst_vaapi_dpb2_class(void)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
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))
|
||||
klass = GST_VAAPI_DPB_GET_CLASS (dpb);
|
||||
if (G_UNLIKELY (!klass || !klass->add))
|
||||
return;
|
||||
klass->flush(dpb);
|
||||
klass->flush (dpb);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_dpb_add(GstVaapiDpb *dpb, GstVaapiPicture *picture)
|
||||
gst_vaapi_dpb_add (GstVaapiDpb * dpb, GstVaapiPicture * picture)
|
||||
{
|
||||
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))
|
||||
klass = GST_VAAPI_DPB_GET_CLASS (dpb);
|
||||
if (G_UNLIKELY (!klass || !klass->add))
|
||||
return FALSE;
|
||||
return klass->add(dpb, picture);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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))
|
||||
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->get_neighbours (dpb, picture, prev_picture_ptr, next_picture_ptr);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -49,20 +49,20 @@
|
|||
typedef struct _GstVaapiDecoderJpegPrivate GstVaapiDecoderJpegPrivate;
|
||||
typedef struct _GstVaapiDecoderJpegClass GstVaapiDecoderJpegClass;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOI = 1 << 0,
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOF = 1 << 1,
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOS = 1 << 2,
|
||||
GST_JPEG_VIDEO_STATE_GOT_HUF_TABLE = 1 << 3,
|
||||
GST_JPEG_VIDEO_STATE_GOT_IQ_TABLE = 1 << 4,
|
||||
|
||||
GST_JPEG_VIDEO_STATE_VALID_PICTURE = (
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOI |
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOF |
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOS),
|
||||
GST_JPEG_VIDEO_STATE_VALID_PICTURE = (GST_JPEG_VIDEO_STATE_GOT_SOI |
|
||||
GST_JPEG_VIDEO_STATE_GOT_SOF | GST_JPEG_VIDEO_STATE_GOT_SOS),
|
||||
} GstJpegVideoState;
|
||||
|
||||
struct _GstVaapiDecoderJpegPrivate {
|
||||
struct _GstVaapiDecoderJpegPrivate
|
||||
{
|
||||
GstVaapiProfile profile;
|
||||
guint width;
|
||||
guint height;
|
||||
|
@ -73,8 +73,8 @@ struct _GstVaapiDecoderJpegPrivate {
|
|||
guint mcu_restart;
|
||||
guint parser_state;
|
||||
guint decoder_state;
|
||||
guint is_opened : 1;
|
||||
guint profile_changed : 1;
|
||||
guint is_opened:1;
|
||||
guint profile_changed:1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -82,8 +82,9 @@ struct _GstVaapiDecoderJpegPrivate {
|
|||
*
|
||||
* A decoder based on Jpeg.
|
||||
*/
|
||||
struct _GstVaapiDecoderJpeg {
|
||||
/*< private >*/
|
||||
struct _GstVaapiDecoderJpeg
|
||||
{
|
||||
/*< private > */
|
||||
GstVaapiDecoder parent_instance;
|
||||
GstVaapiDecoderJpegPrivate priv;
|
||||
};
|
||||
|
@ -93,29 +94,30 @@ struct _GstVaapiDecoderJpeg {
|
|||
*
|
||||
* A decoder class based on Jpeg.
|
||||
*/
|
||||
struct _GstVaapiDecoderJpegClass {
|
||||
/*< private >*/
|
||||
struct _GstVaapiDecoderJpegClass
|
||||
{
|
||||
/*< private > */
|
||||
GstVaapiDecoderClass parent_class;
|
||||
};
|
||||
|
||||
static inline void
|
||||
unit_set_marker_code(GstVaapiDecoderUnit *unit, GstJpegMarker marker)
|
||||
unit_set_marker_code (GstVaapiDecoderUnit * unit, GstJpegMarker marker)
|
||||
{
|
||||
unit->parsed_info = GSIZE_TO_POINTER(marker);
|
||||
unit->parsed_info = GSIZE_TO_POINTER (marker);
|
||||
}
|
||||
|
||||
static inline GstJpegMarker
|
||||
unit_get_marker_code(GstVaapiDecoderUnit *unit)
|
||||
unit_get_marker_code (GstVaapiDecoderUnit * unit)
|
||||
{
|
||||
return GPOINTER_TO_SIZE(unit->parsed_info);
|
||||
return GPOINTER_TO_SIZE (unit->parsed_info);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_decoder_jpeg_close(GstVaapiDecoderJpeg *decoder)
|
||||
gst_vaapi_decoder_jpeg_close (GstVaapiDecoderJpeg * decoder)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
gst_vaapi_picture_replace(&priv->current_picture, NULL);
|
||||
gst_vaapi_picture_replace (&priv->current_picture, NULL);
|
||||
|
||||
/* Reset all */
|
||||
priv->profile = GST_VAAPI_PROFILE_JPEG_BASELINE;
|
||||
|
@ -126,11 +128,11 @@ gst_vaapi_decoder_jpeg_close(GstVaapiDecoderJpeg *decoder)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_decoder_jpeg_open(GstVaapiDecoderJpeg *decoder)
|
||||
gst_vaapi_decoder_jpeg_open (GstVaapiDecoderJpeg * decoder)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
gst_vaapi_decoder_jpeg_close(decoder);
|
||||
gst_vaapi_decoder_jpeg_close (decoder);
|
||||
|
||||
priv->parser_state = 0;
|
||||
priv->decoder_state = 0;
|
||||
|
@ -138,20 +140,20 @@ gst_vaapi_decoder_jpeg_open(GstVaapiDecoderJpeg *decoder)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_decoder_jpeg_destroy(GstVaapiDecoder *base_decoder)
|
||||
gst_vaapi_decoder_jpeg_destroy (GstVaapiDecoder * base_decoder)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
|
||||
gst_vaapi_decoder_jpeg_close(decoder);
|
||||
gst_vaapi_decoder_jpeg_close (decoder);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_decoder_jpeg_create(GstVaapiDecoder *base_decoder)
|
||||
gst_vaapi_decoder_jpeg_create (GstVaapiDecoder * base_decoder)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
priv->profile = GST_VAAPI_PROFILE_JPEG_BASELINE;
|
||||
priv->profile_changed = TRUE;
|
||||
|
@ -159,16 +161,16 @@ gst_vaapi_decoder_jpeg_create(GstVaapiDecoder *base_decoder)
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
ensure_context(GstVaapiDecoderJpeg *decoder)
|
||||
ensure_context (GstVaapiDecoderJpeg * decoder)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiProfile profiles[2];
|
||||
GstVaapiEntrypoint entrypoint = GST_VAAPI_ENTRYPOINT_VLD;
|
||||
guint i, n_profiles = 0;
|
||||
gboolean reset_context = FALSE;
|
||||
|
||||
if (priv->profile_changed) {
|
||||
GST_DEBUG("profile changed");
|
||||
GST_DEBUG ("profile changed");
|
||||
priv->profile_changed = FALSE;
|
||||
reset_context = TRUE;
|
||||
|
||||
|
@ -177,7 +179,7 @@ ensure_context(GstVaapiDecoderJpeg *decoder)
|
|||
// profiles[n_profiles++] = GST_VAAPI_PROFILE_JPEG_BASELINE;
|
||||
|
||||
for (i = 0; i < n_profiles; i++) {
|
||||
if (gst_vaapi_display_has_decoder(GST_VAAPI_DECODER_DISPLAY(decoder),
|
||||
if (gst_vaapi_display_has_decoder (GST_VAAPI_DECODER_DISPLAY (decoder),
|
||||
profiles[i], entrypoint))
|
||||
break;
|
||||
}
|
||||
|
@ -195,10 +197,8 @@ ensure_context(GstVaapiDecoderJpeg *decoder)
|
|||
info.width = priv->width;
|
||||
info.height = priv->height;
|
||||
info.ref_frames = 2;
|
||||
reset_context = gst_vaapi_decoder_ensure_context(
|
||||
GST_VAAPI_DECODER(decoder),
|
||||
&info
|
||||
);
|
||||
reset_context =
|
||||
gst_vaapi_decoder_ensure_context (GST_VAAPI_DECODER (decoder), &info);
|
||||
if (!reset_context)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ ensure_context(GstVaapiDecoderJpeg *decoder)
|
|||
}
|
||||
|
||||
static inline gboolean
|
||||
is_valid_state(guint state, guint ref_state)
|
||||
is_valid_state (guint state, guint ref_state)
|
||||
{
|
||||
return (state & ref_state) == ref_state;
|
||||
}
|
||||
|
@ -216,27 +216,27 @@ is_valid_state(guint state, guint ref_state)
|
|||
G_PASTE(GST_JPEG_VIDEO_STATE_,STATE))
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_current_picture(GstVaapiDecoderJpeg *decoder)
|
||||
decode_current_picture (GstVaapiDecoderJpeg * decoder)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiPicture * const picture = priv->current_picture;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiPicture *const picture = priv->current_picture;
|
||||
|
||||
if (!VALID_STATE(decoder, VALID_PICTURE))
|
||||
if (!VALID_STATE (decoder, VALID_PICTURE))
|
||||
goto drop_frame;
|
||||
priv->decoder_state = 0;
|
||||
|
||||
if (!picture)
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
if (!gst_vaapi_picture_decode(picture))
|
||||
if (!gst_vaapi_picture_decode (picture))
|
||||
goto error;
|
||||
if (!gst_vaapi_picture_output(picture))
|
||||
if (!gst_vaapi_picture_output (picture))
|
||||
goto error;
|
||||
gst_vaapi_picture_replace(&priv->current_picture, NULL);
|
||||
gst_vaapi_picture_replace (&priv->current_picture, NULL);
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
error:
|
||||
gst_vaapi_picture_replace(&priv->current_picture, NULL);
|
||||
gst_vaapi_picture_replace (&priv->current_picture, NULL);
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
drop_frame:
|
||||
|
@ -245,16 +245,13 @@ drop_frame:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
fill_picture(
|
||||
GstVaapiDecoderJpeg *decoder,
|
||||
GstVaapiPicture *picture,
|
||||
GstJpegFrameHdr *frame_hdr
|
||||
)
|
||||
fill_picture (GstVaapiDecoderJpeg * decoder,
|
||||
GstVaapiPicture * picture, GstJpegFrameHdr * frame_hdr)
|
||||
{
|
||||
VAPictureParameterBufferJPEGBaseline * const pic_param = picture->param;
|
||||
VAPictureParameterBufferJPEGBaseline *const pic_param = picture->param;
|
||||
guint i;
|
||||
|
||||
memset(pic_param, 0, sizeof(VAPictureParameterBufferJPEGBaseline));
|
||||
memset (pic_param, 0, sizeof (VAPictureParameterBufferJPEGBaseline));
|
||||
pic_param->picture_width = frame_hdr->width;
|
||||
pic_param->picture_height = frame_hdr->height;
|
||||
|
||||
|
@ -262,8 +259,7 @@ fill_picture(
|
|||
if (frame_hdr->num_components > 4)
|
||||
return FALSE;
|
||||
for (i = 0; i < pic_param->num_components; i++) {
|
||||
pic_param->components[i].component_id =
|
||||
frame_hdr->components[i].identifier;
|
||||
pic_param->components[i].component_id = frame_hdr->components[i].identifier;
|
||||
pic_param->components[i].h_sampling_factor =
|
||||
frame_hdr->components[i].horizontal_factor;
|
||||
pic_param->components[i].v_sampling_factor =
|
||||
|
@ -275,28 +271,28 @@ fill_picture(
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
fill_quantization_table(GstVaapiDecoderJpeg *decoder, GstVaapiPicture *picture)
|
||||
fill_quantization_table (GstVaapiDecoderJpeg * decoder,
|
||||
GstVaapiPicture * picture)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
VAIQMatrixBufferJPEGBaseline *iq_matrix;
|
||||
guint i, j, num_tables;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_IQ_TABLE))
|
||||
gst_jpeg_get_default_quantization_tables(&priv->quant_tables);
|
||||
if (!VALID_STATE (decoder, GOT_IQ_TABLE))
|
||||
gst_jpeg_get_default_quantization_tables (&priv->quant_tables);
|
||||
|
||||
picture->iq_matrix = GST_VAAPI_IQ_MATRIX_NEW(JPEGBaseline, decoder);
|
||||
picture->iq_matrix = GST_VAAPI_IQ_MATRIX_NEW (JPEGBaseline, decoder);
|
||||
if (!picture->iq_matrix) {
|
||||
GST_ERROR("failed to allocate quantiser table");
|
||||
GST_ERROR ("failed to allocate quantiser table");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
iq_matrix = picture->iq_matrix->param;
|
||||
|
||||
num_tables = MIN(G_N_ELEMENTS(iq_matrix->quantiser_table),
|
||||
num_tables = MIN (G_N_ELEMENTS (iq_matrix->quantiser_table),
|
||||
GST_JPEG_MAX_QUANT_ELEMENTS);
|
||||
|
||||
for (i = 0; i < num_tables; i++) {
|
||||
GstJpegQuantTable * const quant_table =
|
||||
&priv->quant_tables.quant_tables[i];
|
||||
GstJpegQuantTable *const quant_table = &priv->quant_tables.quant_tables[i];
|
||||
|
||||
iq_matrix->load_quantiser_table[i] = quant_table->valid;
|
||||
if (!iq_matrix->load_quantiser_table[i])
|
||||
|
@ -304,7 +300,7 @@ fill_quantization_table(GstVaapiDecoderJpeg *decoder, GstVaapiPicture *picture)
|
|||
|
||||
if (quant_table->quant_precision != 0) {
|
||||
// Only Baseline profile is supported, thus 8-bit Qk values
|
||||
GST_ERROR("unsupported quantization table element precision");
|
||||
GST_ERROR ("unsupported quantization table element precision");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT;
|
||||
}
|
||||
|
||||
|
@ -317,38 +313,38 @@ fill_quantization_table(GstVaapiDecoderJpeg *decoder, GstVaapiPicture *picture)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
huffman_tables_updated(const GstJpegHuffmanTables *huf_tables)
|
||||
huffman_tables_updated (const GstJpegHuffmanTables * huf_tables)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(huf_tables->dc_tables); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (huf_tables->dc_tables); i++)
|
||||
if (huf_tables->dc_tables[i].valid)
|
||||
return TRUE;
|
||||
for (i = 0; i < G_N_ELEMENTS(huf_tables->ac_tables); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (huf_tables->ac_tables); i++)
|
||||
if (huf_tables->ac_tables[i].valid)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
huffman_tables_reset(GstJpegHuffmanTables *huf_tables)
|
||||
huffman_tables_reset (GstJpegHuffmanTables * huf_tables)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(huf_tables->dc_tables); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (huf_tables->dc_tables); i++)
|
||||
huf_tables->dc_tables[i].valid = FALSE;
|
||||
for (i = 0; i < G_N_ELEMENTS(huf_tables->ac_tables); i++)
|
||||
for (i = 0; i < G_N_ELEMENTS (huf_tables->ac_tables); i++)
|
||||
huf_tables->ac_tables[i].valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_huffman_table(GstVaapiHuffmanTable *huf_table,
|
||||
const GstJpegHuffmanTables *huf_tables)
|
||||
fill_huffman_table (GstVaapiHuffmanTable * huf_table,
|
||||
const GstJpegHuffmanTables * huf_tables)
|
||||
{
|
||||
VAHuffmanTableBufferJPEGBaseline * const huffman_table = huf_table->param;
|
||||
VAHuffmanTableBufferJPEGBaseline *const huffman_table = huf_table->param;
|
||||
guint i, num_tables;
|
||||
|
||||
num_tables = MIN(G_N_ELEMENTS(huffman_table->huffman_table),
|
||||
num_tables = MIN (G_N_ELEMENTS (huffman_table->huffman_table),
|
||||
GST_JPEG_MAX_SCAN_COMPONENTS);
|
||||
|
||||
for (i = 0; i < num_tables; i++) {
|
||||
|
@ -357,34 +353,33 @@ fill_huffman_table(GstVaapiHuffmanTable *huf_table,
|
|||
if (!huffman_table->load_huffman_table[i])
|
||||
continue;
|
||||
|
||||
memcpy(huffman_table->huffman_table[i].num_dc_codes,
|
||||
memcpy (huffman_table->huffman_table[i].num_dc_codes,
|
||||
huf_tables->dc_tables[i].huf_bits,
|
||||
sizeof(huffman_table->huffman_table[i].num_dc_codes));
|
||||
memcpy(huffman_table->huffman_table[i].dc_values,
|
||||
sizeof (huffman_table->huffman_table[i].num_dc_codes));
|
||||
memcpy (huffman_table->huffman_table[i].dc_values,
|
||||
huf_tables->dc_tables[i].huf_values,
|
||||
sizeof(huffman_table->huffman_table[i].dc_values));
|
||||
memcpy(huffman_table->huffman_table[i].num_ac_codes,
|
||||
sizeof (huffman_table->huffman_table[i].dc_values));
|
||||
memcpy (huffman_table->huffman_table[i].num_ac_codes,
|
||||
huf_tables->ac_tables[i].huf_bits,
|
||||
sizeof(huffman_table->huffman_table[i].num_ac_codes));
|
||||
memcpy(huffman_table->huffman_table[i].ac_values,
|
||||
sizeof (huffman_table->huffman_table[i].num_ac_codes));
|
||||
memcpy (huffman_table->huffman_table[i].ac_values,
|
||||
huf_tables->ac_tables[i].huf_values,
|
||||
sizeof(huffman_table->huffman_table[i].ac_values));
|
||||
memset(huffman_table->huffman_table[i].pad,
|
||||
0,
|
||||
sizeof(huffman_table->huffman_table[i].pad));
|
||||
sizeof (huffman_table->huffman_table[i].ac_values));
|
||||
memset (huffman_table->huffman_table[i].pad,
|
||||
0, sizeof (huffman_table->huffman_table[i].pad));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_max_sampling_factors(const GstJpegFrameHdr *frame_hdr,
|
||||
guint *h_max_ptr, guint *v_max_ptr)
|
||||
get_max_sampling_factors (const GstJpegFrameHdr * frame_hdr,
|
||||
guint * h_max_ptr, guint * v_max_ptr)
|
||||
{
|
||||
guint h_max = frame_hdr->components[0].horizontal_factor;
|
||||
guint v_max = frame_hdr->components[0].vertical_factor;
|
||||
guint i;
|
||||
|
||||
for (i = 1; i < frame_hdr->num_components; i++) {
|
||||
const GstJpegFrameComponent * const fcp = &frame_hdr->components[i];
|
||||
const GstJpegFrameComponent *const fcp = &frame_hdr->components[i];
|
||||
if (h_max < fcp->horizontal_factor)
|
||||
h_max = fcp->horizontal_factor;
|
||||
if (v_max < fcp->vertical_factor)
|
||||
|
@ -398,12 +393,12 @@ get_max_sampling_factors(const GstJpegFrameHdr *frame_hdr,
|
|||
}
|
||||
|
||||
static const GstJpegFrameComponent *
|
||||
get_component(const GstJpegFrameHdr *frame_hdr, guint selector)
|
||||
get_component (const GstJpegFrameHdr * frame_hdr, guint selector)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < frame_hdr->num_components; i++) {
|
||||
const GstJpegFrameComponent * const fcp = &frame_hdr->components[i];
|
||||
const GstJpegFrameComponent *const fcp = &frame_hdr->components[i];
|
||||
if (fcp->identifier == selector)
|
||||
return fcp;
|
||||
}
|
||||
|
@ -411,12 +406,12 @@ get_component(const GstJpegFrameHdr *frame_hdr, guint selector)
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_picture(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
||||
decode_picture (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstJpegFrameHdr * const frame_hdr = &priv->frame_hdr;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstJpegFrameHdr *const frame_hdr = &priv->frame_hdr;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOI))
|
||||
if (!VALID_STATE (decoder, GOT_SOI))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
switch (seg->marker) {
|
||||
|
@ -424,13 +419,13 @@ decode_picture(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
|||
priv->profile = GST_VAAPI_PROFILE_JPEG_BASELINE;
|
||||
break;
|
||||
default:
|
||||
GST_ERROR("unsupported profile %d", seg->marker);
|
||||
GST_ERROR ("unsupported profile %d", seg->marker);
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||
}
|
||||
|
||||
memset(frame_hdr, 0, sizeof(*frame_hdr));
|
||||
if (!gst_jpeg_segment_parse_frame_header(seg, frame_hdr)) {
|
||||
GST_ERROR("failed to parse image");
|
||||
memset (frame_hdr, 0, sizeof (*frame_hdr));
|
||||
if (!gst_jpeg_segment_parse_frame_header (seg, frame_hdr)) {
|
||||
GST_ERROR ("failed to parse image");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
}
|
||||
priv->height = frame_hdr->height;
|
||||
|
@ -441,18 +436,15 @@ decode_picture(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_huffman_table(
|
||||
GstVaapiDecoderJpeg *decoder,
|
||||
GstJpegSegment *seg
|
||||
)
|
||||
decode_huffman_table (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOI))
|
||||
if (!VALID_STATE (decoder, GOT_SOI))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
if (!gst_jpeg_segment_parse_huffman_table(seg, &priv->huf_tables)) {
|
||||
GST_ERROR("failed to parse Huffman table");
|
||||
if (!gst_jpeg_segment_parse_huffman_table (seg, &priv->huf_tables)) {
|
||||
GST_ERROR ("failed to parse Huffman table");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
}
|
||||
|
||||
|
@ -461,18 +453,15 @@ decode_huffman_table(
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_quant_table(
|
||||
GstVaapiDecoderJpeg *decoder,
|
||||
GstJpegSegment *seg
|
||||
)
|
||||
decode_quant_table (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOI))
|
||||
if (!VALID_STATE (decoder, GOT_SOI))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
if (!gst_jpeg_segment_parse_quantization_table(seg, &priv->quant_tables)) {
|
||||
GST_ERROR("failed to parse quantization table");
|
||||
if (!gst_jpeg_segment_parse_quantization_table (seg, &priv->quant_tables)) {
|
||||
GST_ERROR ("failed to parse quantization table");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
}
|
||||
|
||||
|
@ -481,67 +470,64 @@ decode_quant_table(
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_restart_interval(
|
||||
GstVaapiDecoderJpeg *decoder,
|
||||
GstJpegSegment *seg
|
||||
)
|
||||
decode_restart_interval (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOI))
|
||||
if (!VALID_STATE (decoder, GOT_SOI))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
if (!gst_jpeg_segment_parse_restart_interval(seg, &priv->mcu_restart)) {
|
||||
GST_ERROR("failed to parse restart interval");
|
||||
if (!gst_jpeg_segment_parse_restart_interval (seg, &priv->mcu_restart)) {
|
||||
GST_ERROR ("failed to parse restart interval");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
}
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_scan(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
||||
decode_scan (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiPicture * const picture = priv->current_picture;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiPicture *const picture = priv->current_picture;
|
||||
GstVaapiSlice *slice;
|
||||
VASliceParameterBufferJPEGBaseline *slice_param;
|
||||
GstJpegScanHdr scan_hdr;
|
||||
guint scan_hdr_size, scan_data_size;
|
||||
guint i, h_max, v_max, mcu_width, mcu_height;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOF))
|
||||
if (!VALID_STATE (decoder, GOT_SOF))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
scan_hdr_size = (seg->data[seg->offset] << 8) | seg->data[seg->offset + 1];
|
||||
scan_data_size = seg->size - scan_hdr_size;
|
||||
|
||||
memset(&scan_hdr, 0, sizeof(scan_hdr));
|
||||
if (!gst_jpeg_segment_parse_scan_header(seg, &scan_hdr)) {
|
||||
GST_ERROR("failed to parse scan header");
|
||||
memset (&scan_hdr, 0, sizeof (scan_hdr));
|
||||
if (!gst_jpeg_segment_parse_scan_header (seg, &scan_hdr)) {
|
||||
GST_ERROR ("failed to parse scan header");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
}
|
||||
|
||||
slice = GST_VAAPI_SLICE_NEW(JPEGBaseline, decoder,
|
||||
slice = GST_VAAPI_SLICE_NEW (JPEGBaseline, decoder,
|
||||
seg->data + seg->offset + scan_hdr_size, scan_data_size);
|
||||
if (!slice) {
|
||||
GST_ERROR("failed to allocate slice");
|
||||
GST_ERROR ("failed to allocate slice");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
gst_vaapi_picture_add_slice(picture, slice);
|
||||
gst_vaapi_picture_add_slice (picture, slice);
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_HUF_TABLE))
|
||||
gst_jpeg_get_default_huffman_tables(&priv->huf_tables);
|
||||
if (!VALID_STATE (decoder, GOT_HUF_TABLE))
|
||||
gst_jpeg_get_default_huffman_tables (&priv->huf_tables);
|
||||
|
||||
// Update VA Huffman table if it changed for this scan
|
||||
if (huffman_tables_updated(&priv->huf_tables)) {
|
||||
slice->huf_table = GST_VAAPI_HUFFMAN_TABLE_NEW(JPEGBaseline, decoder);
|
||||
if (huffman_tables_updated (&priv->huf_tables)) {
|
||||
slice->huf_table = GST_VAAPI_HUFFMAN_TABLE_NEW (JPEGBaseline, decoder);
|
||||
if (!slice->huf_table) {
|
||||
GST_ERROR("failed to allocate Huffman tables");
|
||||
huffman_tables_reset(&priv->huf_tables);
|
||||
GST_ERROR ("failed to allocate Huffman tables");
|
||||
huffman_tables_reset (&priv->huf_tables);
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
fill_huffman_table(slice->huf_table, &priv->huf_tables);
|
||||
huffman_tables_reset(&priv->huf_tables);
|
||||
fill_huffman_table (slice->huf_table, &priv->huf_tables);
|
||||
huffman_tables_reset (&priv->huf_tables);
|
||||
}
|
||||
|
||||
slice_param = slice->param;
|
||||
|
@ -558,17 +544,17 @@ decode_scan(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
|||
slice_param->slice_horizontal_position = 0;
|
||||
slice_param->slice_vertical_position = 0;
|
||||
|
||||
get_max_sampling_factors(&priv->frame_hdr, &h_max, &v_max);
|
||||
get_max_sampling_factors (&priv->frame_hdr, &h_max, &v_max);
|
||||
mcu_width = 8 * h_max;
|
||||
mcu_height = 8 * v_max;
|
||||
|
||||
if (scan_hdr.num_components == 1) { // Non-interleaved
|
||||
const guint Csj = slice_param->components[0].component_selector;
|
||||
const GstJpegFrameComponent * const fcp =
|
||||
get_component(&priv->frame_hdr, Csj);
|
||||
const GstJpegFrameComponent *const fcp =
|
||||
get_component (&priv->frame_hdr, Csj);
|
||||
|
||||
if (!fcp || fcp->horizontal_factor == 0 || fcp->vertical_factor == 0) {
|
||||
GST_ERROR("failed to validate image component %u", Csj);
|
||||
GST_ERROR ("failed to validate image component %u", Csj);
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
mcu_width /= fcp->horizontal_factor;
|
||||
|
@ -583,9 +569,9 @@ decode_scan(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
|||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
decode_segment(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
||||
decode_segment (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiDecoderStatus status;
|
||||
|
||||
// Decode segment
|
||||
|
@ -599,38 +585,38 @@ decode_segment(GstVaapiDecoderJpeg *decoder, GstJpegSegment *seg)
|
|||
priv->decoder_state = 0;
|
||||
break;
|
||||
case GST_JPEG_MARKER_DAC:
|
||||
GST_ERROR("unsupported arithmetic coding mode");
|
||||
GST_ERROR ("unsupported arithmetic coding mode");
|
||||
status = GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
|
||||
break;
|
||||
case GST_JPEG_MARKER_DHT:
|
||||
status = decode_huffman_table(decoder, seg);
|
||||
status = decode_huffman_table (decoder, seg);
|
||||
break;
|
||||
case GST_JPEG_MARKER_DQT:
|
||||
status = decode_quant_table(decoder, seg);
|
||||
status = decode_quant_table (decoder, seg);
|
||||
break;
|
||||
case GST_JPEG_MARKER_DRI:
|
||||
status = decode_restart_interval(decoder, seg);
|
||||
status = decode_restart_interval (decoder, seg);
|
||||
break;
|
||||
case GST_JPEG_MARKER_SOS:
|
||||
status = decode_scan(decoder, seg);
|
||||
status = decode_scan (decoder, seg);
|
||||
break;
|
||||
default:
|
||||
// SOFn segments
|
||||
if (seg->marker >= GST_JPEG_MARKER_SOF_MIN &&
|
||||
seg->marker <= GST_JPEG_MARKER_SOF_MAX)
|
||||
status = decode_picture(decoder, seg);
|
||||
status = decode_picture (decoder, seg);
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
ensure_decoder(GstVaapiDecoderJpeg *decoder)
|
||||
ensure_decoder (GstVaapiDecoderJpeg * decoder)
|
||||
{
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
|
||||
if (!priv->is_opened) {
|
||||
priv->is_opened = gst_vaapi_decoder_jpeg_open(decoder);
|
||||
priv->is_opened = gst_vaapi_decoder_jpeg_open (decoder);
|
||||
if (!priv->is_opened)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC;
|
||||
}
|
||||
|
@ -638,20 +624,20 @@ ensure_decoder(GstVaapiDecoderJpeg *decoder)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
is_scan_complete(GstJpegMarker marker)
|
||||
is_scan_complete (GstJpegMarker marker)
|
||||
{
|
||||
// Scan is assumed to be complete when the new segment is not RSTi
|
||||
return marker < GST_JPEG_MARKER_RST_MIN || marker > GST_JPEG_MARKER_RST_MAX;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
|
||||
GstAdapter *adapter, gboolean at_eos, GstVaapiDecoderUnit *unit)
|
||||
gst_vaapi_decoder_jpeg_parse (GstVaapiDecoder * base_decoder,
|
||||
GstAdapter * adapter, gboolean at_eos, GstVaapiDecoderUnit * unit)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiParserState * const ps = GST_VAAPI_PARSER_STATE(base_decoder);
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiParserState *const ps = GST_VAAPI_PARSER_STATE (base_decoder);
|
||||
GstVaapiDecoderStatus status;
|
||||
GstJpegMarker marker;
|
||||
GstJpegSegment seg;
|
||||
|
@ -659,16 +645,16 @@ gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
|
|||
guint buf_size, flags;
|
||||
gint ofs1, ofs2;
|
||||
|
||||
status = ensure_decoder(decoder);
|
||||
status = ensure_decoder (decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
/* Expect at least 2 bytes for the marker */
|
||||
buf_size = gst_adapter_available(adapter);
|
||||
buf_size = gst_adapter_available (adapter);
|
||||
if (buf_size < 2)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
|
||||
buf = gst_adapter_map(adapter, buf_size);
|
||||
buf = gst_adapter_map (adapter, buf_size);
|
||||
if (!buf)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
|
||||
|
@ -678,15 +664,15 @@ gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
|
|||
|
||||
for (;;) {
|
||||
// Skip any garbage until we reach SOI, if needed
|
||||
if (!gst_jpeg_parse(&seg, buf, buf_size, ofs1)) {
|
||||
gst_adapter_unmap(adapter);
|
||||
if (!gst_jpeg_parse (&seg, buf, buf_size, ofs1)) {
|
||||
gst_adapter_unmap (adapter);
|
||||
ps->input_offset1 = buf_size;
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
}
|
||||
ofs1 = seg.offset;
|
||||
|
||||
marker = seg.marker;
|
||||
if (!VALID_STATE(parser, GOT_SOI) && marker != GST_JPEG_MARKER_SOI)
|
||||
if (!VALID_STATE (parser, GOT_SOI) && marker != GST_JPEG_MARKER_SOI)
|
||||
continue;
|
||||
if (marker == GST_JPEG_MARKER_SOS) {
|
||||
ofs2 = ps->input_offset2 - 2;
|
||||
|
@ -695,35 +681,34 @@ gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
|
|||
|
||||
// Parse the whole scan + ECSs, including RSTi
|
||||
for (;;) {
|
||||
if (!gst_jpeg_parse(&seg, buf, buf_size, ofs2)) {
|
||||
gst_adapter_unmap(adapter);
|
||||
if (!gst_jpeg_parse (&seg, buf, buf_size, ofs2)) {
|
||||
gst_adapter_unmap (adapter);
|
||||
ps->input_offset1 = ofs1;
|
||||
ps->input_offset2 = buf_size;
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
}
|
||||
|
||||
if (is_scan_complete(seg.marker))
|
||||
if (is_scan_complete (seg.marker))
|
||||
break;
|
||||
ofs2 = seg.offset + seg.size;
|
||||
}
|
||||
ofs2 = seg.offset - 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Check that the whole segment is actually available (in buffer)
|
||||
ofs2 = ofs1 + seg.size;
|
||||
if (ofs2 > buf_size) {
|
||||
gst_adapter_unmap(adapter);
|
||||
gst_adapter_unmap (adapter);
|
||||
ps->input_offset1 = ofs1;
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
gst_adapter_unmap(adapter);
|
||||
gst_adapter_unmap (adapter);
|
||||
|
||||
unit->size = ofs2 - ofs1;
|
||||
unit_set_marker_code(unit, marker);
|
||||
gst_adapter_flush(adapter, ofs1);
|
||||
unit_set_marker_code (unit, marker);
|
||||
gst_adapter_flush (adapter, ofs1);
|
||||
ps->input_offset1 = 2;
|
||||
ps->input_offset2 = 2;
|
||||
|
||||
|
@ -773,100 +758,100 @@ gst_vaapi_decoder_jpeg_parse(GstVaapiDecoder *base_decoder,
|
|||
flags |= GST_VAAPI_DECODER_UNIT_FLAG_SKIP;
|
||||
break;
|
||||
}
|
||||
GST_VAAPI_DECODER_UNIT_FLAG_SET(unit, flags);
|
||||
GST_VAAPI_DECODER_UNIT_FLAG_SET (unit, flags);
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_jpeg_decode(GstVaapiDecoder *base_decoder,
|
||||
GstVaapiDecoderUnit *unit)
|
||||
gst_vaapi_decoder_jpeg_decode (GstVaapiDecoder * base_decoder,
|
||||
GstVaapiDecoderUnit * unit)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
GstVaapiDecoderStatus status;
|
||||
GstJpegSegment seg;
|
||||
GstBuffer * const buffer =
|
||||
GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer;
|
||||
GstBuffer *const buffer =
|
||||
GST_VAAPI_DECODER_CODEC_FRAME (decoder)->input_buffer;
|
||||
GstMapInfo map_info;
|
||||
|
||||
status = ensure_decoder(decoder);
|
||||
status = ensure_decoder (decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (!gst_buffer_map(buffer, &map_info, GST_MAP_READ)) {
|
||||
GST_ERROR("failed to map buffer");
|
||||
if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ)) {
|
||||
GST_ERROR ("failed to map buffer");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
seg.marker = unit_get_marker_code(unit);
|
||||
seg.marker = unit_get_marker_code (unit);
|
||||
seg.data = map_info.data;
|
||||
seg.offset = unit->offset;
|
||||
seg.size = unit->size;
|
||||
|
||||
status = decode_segment(decoder, &seg);
|
||||
gst_buffer_unmap(buffer, &map_info);
|
||||
status = decode_segment (decoder, &seg);
|
||||
gst_buffer_unmap (buffer, &map_info);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_jpeg_start_frame(GstVaapiDecoder *base_decoder,
|
||||
GstVaapiDecoderUnit *base_unit)
|
||||
gst_vaapi_decoder_jpeg_start_frame (GstVaapiDecoder * base_decoder,
|
||||
GstVaapiDecoderUnit * base_unit)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpegPrivate * const priv = &decoder->priv;
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
GstVaapiDecoderJpegPrivate *const priv = &decoder->priv;
|
||||
GstVaapiPicture *picture;
|
||||
GstVaapiDecoderStatus status;
|
||||
|
||||
if (!VALID_STATE(decoder, GOT_SOF))
|
||||
if (!VALID_STATE (decoder, GOT_SOF))
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
|
||||
status = ensure_context(decoder);
|
||||
status = ensure_context (decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
|
||||
GST_ERROR("failed to reset context");
|
||||
GST_ERROR ("failed to reset context");
|
||||
return status;
|
||||
}
|
||||
|
||||
picture = GST_VAAPI_PICTURE_NEW(JPEGBaseline, decoder);
|
||||
picture = GST_VAAPI_PICTURE_NEW (JPEGBaseline, decoder);
|
||||
if (!picture) {
|
||||
GST_ERROR("failed to allocate picture");
|
||||
GST_ERROR ("failed to allocate picture");
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
gst_vaapi_picture_replace(&priv->current_picture, picture);
|
||||
gst_vaapi_picture_unref(picture);
|
||||
gst_vaapi_picture_replace (&priv->current_picture, picture);
|
||||
gst_vaapi_picture_unref (picture);
|
||||
|
||||
if (!fill_picture(decoder, picture, &priv->frame_hdr))
|
||||
if (!fill_picture (decoder, picture, &priv->frame_hdr))
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
||||
|
||||
status = fill_quantization_table(decoder, picture);
|
||||
status = fill_quantization_table (decoder, picture);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
/* Update presentation time */
|
||||
picture->pts = GST_VAAPI_DECODER_CODEC_FRAME(decoder)->pts;
|
||||
picture->pts = GST_VAAPI_DECODER_CODEC_FRAME (decoder)->pts;
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_jpeg_end_frame(GstVaapiDecoder *base_decoder)
|
||||
gst_vaapi_decoder_jpeg_end_frame (GstVaapiDecoder * base_decoder)
|
||||
{
|
||||
GstVaapiDecoderJpeg * const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST(base_decoder);
|
||||
GstVaapiDecoderJpeg *const decoder =
|
||||
GST_VAAPI_DECODER_JPEG_CAST (base_decoder);
|
||||
|
||||
return decode_current_picture(decoder);
|
||||
return decode_current_picture (decoder);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_decoder_jpeg_class_init(GstVaapiDecoderJpegClass *klass)
|
||||
gst_vaapi_decoder_jpeg_class_init (GstVaapiDecoderJpegClass * klass)
|
||||
{
|
||||
GstVaapiMiniObjectClass * const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS(klass);
|
||||
GstVaapiDecoderClass * const decoder_class = GST_VAAPI_DECODER_CLASS(klass);
|
||||
GstVaapiMiniObjectClass *const object_class =
|
||||
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
||||
GstVaapiDecoderClass *const decoder_class = GST_VAAPI_DECODER_CLASS (klass);
|
||||
|
||||
object_class->size = sizeof(GstVaapiDecoderJpeg);
|
||||
object_class->finalize = (GDestroyNotify)gst_vaapi_decoder_finalize;
|
||||
object_class->size = sizeof (GstVaapiDecoderJpeg);
|
||||
object_class->finalize = (GDestroyNotify) gst_vaapi_decoder_finalize;
|
||||
|
||||
decoder_class->create = gst_vaapi_decoder_jpeg_create;
|
||||
decoder_class->destroy = gst_vaapi_decoder_jpeg_destroy;
|
||||
|
@ -877,16 +862,16 @@ gst_vaapi_decoder_jpeg_class_init(GstVaapiDecoderJpegClass *klass)
|
|||
}
|
||||
|
||||
static inline const GstVaapiDecoderClass *
|
||||
gst_vaapi_decoder_jpeg_class(void)
|
||||
gst_vaapi_decoder_jpeg_class (void)
|
||||
{
|
||||
static GstVaapiDecoderJpegClass g_class;
|
||||
static gsize g_class_init = FALSE;
|
||||
|
||||
if (g_once_init_enter(&g_class_init)) {
|
||||
gst_vaapi_decoder_jpeg_class_init(&g_class);
|
||||
g_once_init_leave(&g_class_init, TRUE);
|
||||
if (g_once_init_enter (&g_class_init)) {
|
||||
gst_vaapi_decoder_jpeg_class_init (&g_class);
|
||||
g_once_init_leave (&g_class_init, TRUE);
|
||||
}
|
||||
return GST_VAAPI_DECODER_CLASS(&g_class);
|
||||
return GST_VAAPI_DECODER_CLASS (&g_class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,7 +885,7 @@ gst_vaapi_decoder_jpeg_class(void)
|
|||
* Return value: the newly allocated #GstVaapiDecoder object
|
||||
*/
|
||||
GstVaapiDecoder *
|
||||
gst_vaapi_decoder_jpeg_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||
gst_vaapi_decoder_jpeg_new (GstVaapiDisplay * display, GstCaps * caps)
|
||||
{
|
||||
return gst_vaapi_decoder_new(gst_vaapi_decoder_jpeg_class(), display, caps);
|
||||
return gst_vaapi_decoder_new (gst_vaapi_decoder_jpeg_class (), display, caps);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -38,7 +38,7 @@
|
|||
* sub-classes.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit)
|
||||
gst_vaapi_decoder_unit_init (GstVaapiDecoderUnit * unit)
|
||||
{
|
||||
unit->flags = 0;
|
||||
unit->size = 0;
|
||||
|
@ -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_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
|
@ -45,20 +45,19 @@
|
|||
} while (0)
|
||||
|
||||
static gboolean
|
||||
_gst_vaapi_image_map(GstVaapiImage *image, GstVaapiImageRaw *raw_image);
|
||||
_gst_vaapi_image_map (GstVaapiImage * image, GstVaapiImageRaw * raw_image);
|
||||
|
||||
static gboolean _gst_vaapi_image_unmap (GstVaapiImage * image);
|
||||
|
||||
static gboolean
|
||||
_gst_vaapi_image_unmap(GstVaapiImage *image);
|
||||
|
||||
static gboolean
|
||||
_gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image);
|
||||
_gst_vaapi_image_set_image (GstVaapiImage * image, const VAImage * va_image);
|
||||
|
||||
/*
|
||||
* VAImage wrapper
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
vaapi_image_is_linear(const VAImage *va_image)
|
||||
vaapi_image_is_linear (const VAImage * va_image)
|
||||
{
|
||||
guint i, width, height, width2, height2, data_size;
|
||||
|
||||
|
@ -72,83 +71,79 @@ vaapi_image_is_linear(const VAImage *va_image)
|
|||
height2 = (height + 1) / 2;
|
||||
|
||||
switch (va_image->format.fourcc) {
|
||||
case VA_FOURCC('N','V','1','2'):
|
||||
case VA_FOURCC('Y','V','1','2'):
|
||||
case VA_FOURCC('I','4','2','0'):
|
||||
case VA_FOURCC ('N', 'V', '1', '2'):
|
||||
case VA_FOURCC ('Y', 'V', '1', '2'):
|
||||
case VA_FOURCC ('I', '4', '2', '0'):
|
||||
data_size = width * height + 2 * width2 * height2;
|
||||
break;
|
||||
case VA_FOURCC('Y','U','Y','2'):
|
||||
case VA_FOURCC('U','Y','V','Y'):
|
||||
case VA_FOURCC ('Y', 'U', 'Y', '2'):
|
||||
case VA_FOURCC ('U', 'Y', 'V', 'Y'):
|
||||
data_size = 2 * width * height;
|
||||
break;
|
||||
case VA_FOURCC('Y','8','0','0'):
|
||||
case VA_FOURCC ('Y', '8', '0', '0'):
|
||||
data_size = width * height;
|
||||
break;
|
||||
case VA_FOURCC('A','Y','U','V'):
|
||||
case VA_FOURCC('A','R','G','B'):
|
||||
case VA_FOURCC('R','G','B','A'):
|
||||
case VA_FOURCC('A','B','G','R'):
|
||||
case VA_FOURCC('B','G','R','A'):
|
||||
case VA_FOURCC('X','R','G','B'):
|
||||
case VA_FOURCC('R','G','B','X'):
|
||||
case VA_FOURCC('X','B','G','R'):
|
||||
case VA_FOURCC('B','G','R','X'):
|
||||
case VA_FOURCC ('A', 'Y', 'U', 'V'):
|
||||
case VA_FOURCC ('A', 'R', 'G', 'B'):
|
||||
case VA_FOURCC ('R', 'G', 'B', 'A'):
|
||||
case VA_FOURCC ('A', 'B', 'G', 'R'):
|
||||
case VA_FOURCC ('B', 'G', 'R', 'A'):
|
||||
case VA_FOURCC ('X', 'R', 'G', 'B'):
|
||||
case VA_FOURCC ('R', 'G', 'B', 'X'):
|
||||
case VA_FOURCC ('X', 'B', 'G', 'R'):
|
||||
case VA_FOURCC ('B', 'G', 'R', 'X'):
|
||||
data_size = 4 * width * height;
|
||||
break;
|
||||
default:
|
||||
g_error("FIXME: incomplete formats %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS(va_image->format.fourcc));
|
||||
g_error ("FIXME: incomplete formats %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (va_image->format.fourcc));
|
||||
break;
|
||||
}
|
||||
return va_image->data_size == data_size;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_image_destroy(GstVaapiImage *image)
|
||||
gst_vaapi_image_destroy (GstVaapiImage * image)
|
||||
{
|
||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(image);
|
||||
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (image);
|
||||
VAImageID image_id;
|
||||
VAStatus status;
|
||||
|
||||
_gst_vaapi_image_unmap(image);
|
||||
_gst_vaapi_image_unmap (image);
|
||||
|
||||
image_id = GST_VAAPI_OBJECT_ID(image);
|
||||
GST_DEBUG("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(image_id));
|
||||
image_id = GST_VAAPI_OBJECT_ID (image);
|
||||
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
||||
|
||||
if (image_id != VA_INVALID_ID) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDestroyImage(GST_VAAPI_DISPLAY_VADISPLAY(display), image_id);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaDestroyImage()"))
|
||||
g_warning("failed to destroy image %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS(image_id));
|
||||
GST_VAAPI_OBJECT_ID(image) = VA_INVALID_ID;
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
status = vaDestroyImage (GST_VAAPI_DISPLAY_VADISPLAY (display), image_id);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
if (!vaapi_check_status (status, "vaDestroyImage()"))
|
||||
g_warning ("failed to destroy image %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS (image_id));
|
||||
GST_VAAPI_OBJECT_ID (image) = VA_INVALID_ID;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format)
|
||||
_gst_vaapi_image_create (GstVaapiImage * image, GstVideoFormat format)
|
||||
{
|
||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(image);
|
||||
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (image);
|
||||
const VAImageFormat *va_format;
|
||||
VAStatus status;
|
||||
|
||||
if (!gst_vaapi_display_has_image_format(display, format))
|
||||
if (!gst_vaapi_display_has_image_format (display, format))
|
||||
return FALSE;
|
||||
|
||||
va_format = gst_vaapi_video_format_to_va_format(format);
|
||||
va_format = gst_vaapi_video_format_to_va_format (format);
|
||||
if (!va_format)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaCreateImage(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
(VAImageFormat *)va_format,
|
||||
image->width,
|
||||
image->height,
|
||||
&image->internal_image
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
status = vaCreateImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||
(VAImageFormat *) va_format,
|
||||
image->width, image->height, &image->internal_image);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
if (status != VA_STATUS_SUCCESS ||
|
||||
image->internal_image.format.fourcc != va_format->fourcc)
|
||||
return FALSE;
|
||||
|
@ -158,7 +153,7 @@ _gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format,
|
||||
gst_vaapi_image_create (GstVaapiImage * image, GstVideoFormat format,
|
||||
guint width, guint height)
|
||||
{
|
||||
const VAImageFormat *va_format;
|
||||
|
@ -168,7 +163,7 @@ gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format,
|
|||
image->width = width;
|
||||
image->height = height;
|
||||
|
||||
if (!_gst_vaapi_image_create(image, format)) {
|
||||
if (!_gst_vaapi_image_create (image, format)) {
|
||||
switch (format) {
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
format = GST_VIDEO_FORMAT_YV12;
|
||||
|
@ -180,7 +175,7 @@ gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format,
|
|||
format = 0;
|
||||
break;
|
||||
}
|
||||
if (!format || !_gst_vaapi_image_create(image, format))
|
||||
if (!format || !_gst_vaapi_image_create (image, format))
|
||||
return FALSE;
|
||||
}
|
||||
image->image = image->internal_image;
|
||||
|
@ -190,26 +185,26 @@ gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format,
|
|||
switch (image->format) {
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
va_format = gst_vaapi_video_format_to_va_format(image->format);
|
||||
va_format = gst_vaapi_video_format_to_va_format (image->format);
|
||||
if (!va_format)
|
||||
return FALSE;
|
||||
image->image.format = *va_format;
|
||||
SWAP_UINT(image->image.offsets[1], image->image.offsets[2]);
|
||||
SWAP_UINT(image->image.pitches[1], image->image.pitches[2]);
|
||||
SWAP_UINT (image->image.offsets[1], image->image.offsets[2]);
|
||||
SWAP_UINT (image->image.pitches[1], image->image.pitches[2]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
image->is_linear = vaapi_image_is_linear(&image->image);
|
||||
image->is_linear = vaapi_image_is_linear (&image->image);
|
||||
|
||||
GST_DEBUG("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(image_id));
|
||||
GST_VAAPI_OBJECT_ID(image) = image_id;
|
||||
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
||||
GST_VAAPI_OBJECT_ID (image) = image_id;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_image_init(GstVaapiImage *image)
|
||||
gst_vaapi_image_init (GstVaapiImage * image)
|
||||
{
|
||||
image->internal_image.image_id = VA_INVALID_ID;
|
||||
image->internal_image.buf = VA_INVALID_ID;
|
||||
|
@ -218,19 +213,16 @@ gst_vaapi_image_init(GstVaapiImage *image)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_image_class_init(GstVaapiImageClass *klass)
|
||||
gst_vaapi_image_class_init (GstVaapiImageClass * klass)
|
||||
{
|
||||
GstVaapiObjectClass * const object_class =
|
||||
GST_VAAPI_OBJECT_CLASS(klass);
|
||||
GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->init = (GstVaapiObjectInitFunc)gst_vaapi_image_init;
|
||||
object_class->init = (GstVaapiObjectInitFunc) gst_vaapi_image_init;
|
||||
}
|
||||
|
||||
#define gst_vaapi_image_finalize gst_vaapi_image_destroy
|
||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
||||
GstVaapiImage,
|
||||
gst_vaapi_image,
|
||||
gst_vaapi_image_class_init(&g_class))
|
||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
|
||||
gst_vaapi_image, gst_vaapi_image_class_init (&g_class))
|
||||
|
||||
/**
|
||||
* gst_vaapi_image_new:
|
||||
|
@ -244,32 +236,27 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
|
|||
*
|
||||
* Return value: the newly allocated #GstVaapiImage object
|
||||
*/
|
||||
GstVaapiImage *
|
||||
gst_vaapi_image_new(
|
||||
GstVaapiDisplay *display,
|
||||
GstVideoFormat format,
|
||||
guint width,
|
||||
guint height
|
||||
)
|
||||
GstVaapiImage *gst_vaapi_image_new (GstVaapiDisplay * display,
|
||||
GstVideoFormat format, guint width, guint height)
|
||||
{
|
||||
GstVaapiImage *image;
|
||||
|
||||
g_return_val_if_fail(width > 0, NULL);
|
||||
g_return_val_if_fail(height > 0, NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
|
||||
GST_DEBUG("format %s, size %ux%u", gst_vaapi_video_format_to_string(format),
|
||||
GST_DEBUG ("format %s, size %ux%u", gst_vaapi_video_format_to_string (format),
|
||||
width, height);
|
||||
|
||||
image = gst_vaapi_object_new(gst_vaapi_image_class(), display);
|
||||
image = gst_vaapi_object_new (gst_vaapi_image_class (), display);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
if (!gst_vaapi_image_create(image, format, width, height))
|
||||
if (!gst_vaapi_image_create (image, format, width, height))
|
||||
goto error;
|
||||
return image;
|
||||
|
||||
error:
|
||||
gst_vaapi_object_unref(image);
|
||||
gst_vaapi_object_unref (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -286,29 +273,29 @@ error:
|
|||
* Return value: the newly allocated #GstVaapiImage object
|
||||
*/
|
||||
GstVaapiImage *
|
||||
gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image)
|
||||
gst_vaapi_image_new_with_image (GstVaapiDisplay * display, VAImage * va_image)
|
||||
{
|
||||
GstVaapiImage *image;
|
||||
|
||||
g_return_val_if_fail(va_image, NULL);
|
||||
g_return_val_if_fail(va_image->image_id != VA_INVALID_ID, NULL);
|
||||
g_return_val_if_fail(va_image->buf != VA_INVALID_ID, NULL);
|
||||
g_return_val_if_fail (va_image, NULL);
|
||||
g_return_val_if_fail (va_image->image_id != VA_INVALID_ID, NULL);
|
||||
g_return_val_if_fail (va_image->buf != VA_INVALID_ID, NULL);
|
||||
|
||||
GST_DEBUG("VA image 0x%08x, format %" GST_FOURCC_FORMAT ", size %ux%u",
|
||||
GST_DEBUG ("VA image 0x%08x, format %" GST_FOURCC_FORMAT ", size %ux%u",
|
||||
va_image->image_id,
|
||||
GST_FOURCC_ARGS(va_image->format.fourcc),
|
||||
GST_FOURCC_ARGS (va_image->format.fourcc),
|
||||
va_image->width, va_image->height);
|
||||
|
||||
image = gst_vaapi_object_new(gst_vaapi_image_class(), display);
|
||||
image = gst_vaapi_object_new (gst_vaapi_image_class (), display);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
if (!_gst_vaapi_image_set_image(image, va_image))
|
||||
if (!_gst_vaapi_image_set_image (image, va_image))
|
||||
goto error;
|
||||
return image;
|
||||
|
||||
error:
|
||||
gst_vaapi_object_unref(image);
|
||||
gst_vaapi_object_unref (image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -321,11 +308,11 @@ error:
|
|||
* Return value: the underlying VA image id
|
||||
*/
|
||||
GstVaapiID
|
||||
gst_vaapi_image_get_id(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_id (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, VA_INVALID_ID);
|
||||
g_return_val_if_fail (image != NULL, VA_INVALID_ID);
|
||||
|
||||
return GST_VAAPI_OBJECT_ID(image);
|
||||
return GST_VAAPI_OBJECT_ID (image);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,9 +325,9 @@ gst_vaapi_image_get_id(GstVaapiImage *image)
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image)
|
||||
gst_vaapi_image_get_image (GstVaapiImage * image, VAImage * va_image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
if (va_image)
|
||||
*va_image = image->image;
|
||||
|
@ -363,25 +350,25 @@ gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image)
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
_gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
|
||||
_gst_vaapi_image_set_image (GstVaapiImage * image, const VAImage * va_image)
|
||||
{
|
||||
GstVideoFormat format;
|
||||
VAImage alt_va_image;
|
||||
const VAImageFormat *alt_va_format;
|
||||
|
||||
format = gst_vaapi_video_format_from_va_format(&va_image->format);
|
||||
format = gst_vaapi_video_format_from_va_format (&va_image->format);
|
||||
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
image->internal_image = *va_image;
|
||||
image->internal_format = format;
|
||||
image->is_linear = vaapi_image_is_linear(va_image);
|
||||
image->is_linear = vaapi_image_is_linear (va_image);
|
||||
image->image = *va_image;
|
||||
image->format = format;
|
||||
image->width = va_image->width;
|
||||
image->height = va_image->height;
|
||||
|
||||
GST_VAAPI_OBJECT_ID(image) = va_image->image_id;
|
||||
GST_VAAPI_OBJECT_ID (image) = va_image->image_id;
|
||||
|
||||
/* Try to linearize image */
|
||||
if (!image->is_linear) {
|
||||
|
@ -397,17 +384,17 @@ _gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
|
|||
break;
|
||||
}
|
||||
if (format &&
|
||||
(alt_va_format = gst_vaapi_video_format_to_va_format(format))) {
|
||||
(alt_va_format = gst_vaapi_video_format_to_va_format (format))) {
|
||||
alt_va_image = *va_image;
|
||||
alt_va_image.format = *alt_va_format;
|
||||
SWAP_UINT(alt_va_image.offsets[1], alt_va_image.offsets[2]);
|
||||
SWAP_UINT(alt_va_image.pitches[1], alt_va_image.pitches[2]);
|
||||
if (vaapi_image_is_linear(&alt_va_image)) {
|
||||
SWAP_UINT (alt_va_image.offsets[1], alt_va_image.offsets[2]);
|
||||
SWAP_UINT (alt_va_image.pitches[1], alt_va_image.pitches[2]);
|
||||
if (vaapi_image_is_linear (&alt_va_image)) {
|
||||
image->image = alt_va_image;
|
||||
image->format = format;
|
||||
image->is_linear = TRUE;
|
||||
GST_DEBUG("linearized image to %s format",
|
||||
gst_vaapi_video_format_to_string(format));
|
||||
GST_DEBUG ("linearized image to %s format",
|
||||
gst_vaapi_video_format_to_string (format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -423,9 +410,9 @@ _gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
|
|||
* Return value: the #GstVideoFormat
|
||||
*/
|
||||
GstVideoFormat
|
||||
gst_vaapi_image_get_format(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_format (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
return image->format;
|
||||
}
|
||||
|
@ -439,9 +426,9 @@ gst_vaapi_image_get_format(GstVaapiImage *image)
|
|||
* Return value: the image width, in pixels
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_image_get_width(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_width (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
return image->width;
|
||||
}
|
||||
|
@ -455,9 +442,9 @@ gst_vaapi_image_get_width(GstVaapiImage *image)
|
|||
* Return value: the image height, in pixels.
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_image_get_height(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_height (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
return image->height;
|
||||
}
|
||||
|
@ -471,9 +458,10 @@ gst_vaapi_image_get_height(GstVaapiImage *image)
|
|||
* Retrieves the dimensions of a #GstVaapiImage.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight)
|
||||
gst_vaapi_image_get_size (GstVaapiImage * image, guint * pwidth,
|
||||
guint * pheight)
|
||||
{
|
||||
g_return_if_fail(image != NULL);
|
||||
g_return_if_fail (image != NULL);
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = image->width;
|
||||
|
@ -493,9 +481,9 @@ gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight)
|
|||
* Return value: %TRUE if image data planes are allocated from a single buffer
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_is_linear(GstVaapiImage *image)
|
||||
gst_vaapi_image_is_linear (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
return image->is_linear;
|
||||
}
|
||||
|
@ -509,17 +497,17 @@ gst_vaapi_image_is_linear(GstVaapiImage *image)
|
|||
* Return value: %TRUE if the @image is mapped
|
||||
*/
|
||||
static inline gboolean
|
||||
_gst_vaapi_image_is_mapped(GstVaapiImage *image)
|
||||
_gst_vaapi_image_is_mapped (GstVaapiImage * image)
|
||||
{
|
||||
return image->image_data != NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_vaapi_image_is_mapped(GstVaapiImage *image)
|
||||
gst_vaapi_image_is_mapped (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
return _gst_vaapi_image_is_mapped(image);
|
||||
return _gst_vaapi_image_is_mapped (image);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -532,46 +520,43 @@ gst_vaapi_image_is_mapped(GstVaapiImage *image)
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_map(GstVaapiImage *image)
|
||||
gst_vaapi_image_map (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
return _gst_vaapi_image_map(image, NULL);
|
||||
return _gst_vaapi_image_map (image, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gst_vaapi_image_map(GstVaapiImage *image, GstVaapiImageRaw *raw_image)
|
||||
_gst_vaapi_image_map (GstVaapiImage * image, GstVaapiImageRaw * raw_image)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
VAStatus status;
|
||||
guint i;
|
||||
|
||||
if (_gst_vaapi_image_is_mapped(image))
|
||||
if (_gst_vaapi_image_is_mapped (image))
|
||||
goto map_success;
|
||||
|
||||
display = GST_VAAPI_OBJECT_DISPLAY(image);
|
||||
display = GST_VAAPI_OBJECT_DISPLAY (image);
|
||||
if (!display)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaMapBuffer(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
image->image.buf,
|
||||
(void **)&image->image_data
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaMapBuffer()"))
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
status = vaMapBuffer (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||
image->image.buf, (void **) &image->image_data);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
if (!vaapi_check_status (status, "vaMapBuffer()"))
|
||||
return FALSE;
|
||||
|
||||
map_success:
|
||||
if (raw_image) {
|
||||
const VAImage * const va_image = &image->image;
|
||||
const VAImage *const va_image = &image->image;
|
||||
raw_image->format = image->format;
|
||||
raw_image->width = va_image->width;
|
||||
raw_image->height = va_image->height;
|
||||
raw_image->num_planes = va_image->num_planes;
|
||||
for (i = 0; i < raw_image->num_planes; i++) {
|
||||
raw_image->pixels[i] = (guchar *)image->image_data +
|
||||
raw_image->pixels[i] = (guchar *) image->image_data +
|
||||
va_image->offsets[i];
|
||||
raw_image->stride[i] = va_image->pitches[i];
|
||||
}
|
||||
|
@ -589,33 +574,31 @@ map_success:
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_unmap(GstVaapiImage *image)
|
||||
gst_vaapi_image_unmap (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
return _gst_vaapi_image_unmap(image);
|
||||
return _gst_vaapi_image_unmap (image);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gst_vaapi_image_unmap(GstVaapiImage *image)
|
||||
_gst_vaapi_image_unmap (GstVaapiImage * image)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
VAStatus status;
|
||||
|
||||
if (!_gst_vaapi_image_is_mapped(image))
|
||||
if (!_gst_vaapi_image_is_mapped (image))
|
||||
return TRUE;
|
||||
|
||||
display = GST_VAAPI_OBJECT_DISPLAY(image);
|
||||
display = GST_VAAPI_OBJECT_DISPLAY (image);
|
||||
if (!display)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaUnmapBuffer(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
image->image.buf
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaUnmapBuffer()"))
|
||||
GST_VAAPI_DISPLAY_LOCK (display);
|
||||
status = vaUnmapBuffer (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||
image->image.buf);
|
||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||
if (!vaapi_check_status (status, "vaUnmapBuffer()"))
|
||||
return FALSE;
|
||||
|
||||
image->image_data = NULL;
|
||||
|
@ -632,10 +615,10 @@ _gst_vaapi_image_unmap(GstVaapiImage *image)
|
|||
* Return value: the number of planes available in the @image
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_image_get_plane_count(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_plane_count (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail(_gst_vaapi_image_is_mapped(image), 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
g_return_val_if_fail (_gst_vaapi_image_is_mapped (image), 0);
|
||||
|
||||
return image->image.num_planes;
|
||||
}
|
||||
|
@ -651,11 +634,11 @@ gst_vaapi_image_get_plane_count(GstVaapiImage *image)
|
|||
* Return value: the pixels data of the specified @plane
|
||||
*/
|
||||
guchar *
|
||||
gst_vaapi_image_get_plane(GstVaapiImage *image, guint plane)
|
||||
gst_vaapi_image_get_plane (GstVaapiImage * image, guint plane)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, NULL);
|
||||
g_return_val_if_fail(_gst_vaapi_image_is_mapped(image), NULL);
|
||||
g_return_val_if_fail(plane < image->image.num_planes, NULL);
|
||||
g_return_val_if_fail (image != NULL, NULL);
|
||||
g_return_val_if_fail (_gst_vaapi_image_is_mapped (image), NULL);
|
||||
g_return_val_if_fail (plane < image->image.num_planes, NULL);
|
||||
|
||||
return image->image_data + image->image.offsets[plane];
|
||||
}
|
||||
|
@ -671,11 +654,11 @@ gst_vaapi_image_get_plane(GstVaapiImage *image, guint plane)
|
|||
* Return value: the line size (stride) of the specified plane
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_image_get_pitch(GstVaapiImage *image, guint plane)
|
||||
gst_vaapi_image_get_pitch (GstVaapiImage * image, guint plane)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail(_gst_vaapi_image_is_mapped(image), 0);
|
||||
g_return_val_if_fail(plane < image->image.num_planes, 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
g_return_val_if_fail (_gst_vaapi_image_is_mapped (image), 0);
|
||||
g_return_val_if_fail (plane < image->image.num_planes, 0);
|
||||
|
||||
return image->image.pitches[plane];
|
||||
}
|
||||
|
@ -691,9 +674,9 @@ gst_vaapi_image_get_pitch(GstVaapiImage *image, guint plane)
|
|||
* Return value: the whole image data size of the @image
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_image_get_data_size(GstVaapiImage *image)
|
||||
gst_vaapi_image_get_data_size (GstVaapiImage * image)
|
||||
{
|
||||
g_return_val_if_fail(image != NULL, 0);
|
||||
g_return_val_if_fail (image != NULL, 0);
|
||||
|
||||
return image->image.data_size;
|
||||
}
|
||||
|
@ -701,35 +684,30 @@ gst_vaapi_image_get_data_size(GstVaapiImage *image)
|
|||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
static gboolean
|
||||
init_image_from_video_meta(GstVaapiImageRaw *raw_image, GstVideoMeta *vmeta)
|
||||
init_image_from_video_meta (GstVaapiImageRaw * raw_image, GstVideoMeta * vmeta)
|
||||
{
|
||||
GST_FIXME("map from GstVideoMeta + add fini_image_from_buffer()");
|
||||
GST_FIXME ("map from GstVideoMeta + add fini_image_from_buffer()");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
|
||||
init_image_from_buffer (GstVaapiImageRaw * raw_image, GstBuffer * buffer)
|
||||
{
|
||||
GstVideoMeta * const vmeta = gst_buffer_get_video_meta(buffer);
|
||||
GstVideoMeta *const vmeta = gst_buffer_get_video_meta (buffer);
|
||||
|
||||
return vmeta ? init_image_from_video_meta(raw_image, vmeta) : FALSE;
|
||||
return vmeta ? init_image_from_video_meta (raw_image, vmeta) : FALSE;
|
||||
}
|
||||
|
||||
/* Copy N lines of an image */
|
||||
static inline void
|
||||
memcpy_pic(
|
||||
guchar *dst,
|
||||
memcpy_pic (guchar * dst,
|
||||
guint dst_stride,
|
||||
const guchar *src,
|
||||
guint src_stride,
|
||||
guint len,
|
||||
guint height
|
||||
)
|
||||
const guchar * src, guint src_stride, guint len, guint height)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
memcpy(dst, src, len);
|
||||
memcpy (dst, src, len);
|
||||
dst += dst_stride;
|
||||
src += src_stride;
|
||||
}
|
||||
|
@ -737,11 +715,8 @@ memcpy_pic(
|
|||
|
||||
/* Copy NV12 images */
|
||||
static void
|
||||
copy_image_NV12(
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
const GstVaapiRectangle *rect
|
||||
)
|
||||
copy_image_NV12 (GstVaapiImageRaw * dst_image,
|
||||
GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
|
||||
{
|
||||
guchar *dst, *src;
|
||||
guint dst_stride, src_stride;
|
||||
|
@ -751,23 +726,20 @@ copy_image_NV12(
|
|||
dst = dst_image->pixels[0] + rect->y * dst_stride + rect->x;
|
||||
src_stride = src_image->stride[0];
|
||||
src = src_image->pixels[0] + rect->y * src_stride + rect->x;
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, rect->width, rect->height);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, rect->width, rect->height);
|
||||
|
||||
/* UV plane */
|
||||
dst_stride = dst_image->stride[1];
|
||||
dst = dst_image->pixels[1] + (rect->y / 2) * dst_stride + (rect->x & -2);
|
||||
src_stride = src_image->stride[1];
|
||||
src = src_image->pixels[1] + (rect->y / 2) * src_stride + (rect->x & -2);
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, rect->width, rect->height / 2);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, rect->width, rect->height / 2);
|
||||
}
|
||||
|
||||
/* Copy YV12 images */
|
||||
static void
|
||||
copy_image_YV12(
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
const GstVaapiRectangle *rect
|
||||
)
|
||||
copy_image_YV12 (GstVaapiImageRaw * dst_image,
|
||||
GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
|
||||
{
|
||||
guchar *dst, *src;
|
||||
guint dst_stride, src_stride;
|
||||
|
@ -778,7 +750,7 @@ copy_image_YV12(
|
|||
dst = dst_image->pixels[0] + rect->y * dst_stride + rect->x;
|
||||
src_stride = src_image->stride[0];
|
||||
src = src_image->pixels[0] + rect->y * src_stride + rect->x;
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, rect->width, rect->height);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, rect->width, rect->height);
|
||||
|
||||
/* U/V planes */
|
||||
x = rect->x / 2;
|
||||
|
@ -790,17 +762,14 @@ copy_image_YV12(
|
|||
dst = dst_image->pixels[i] + y * dst_stride + x;
|
||||
src_stride = src_image->stride[i];
|
||||
src = src_image->pixels[i] + y * src_stride + x;
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, w, h);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy YUY2 images */
|
||||
static void
|
||||
copy_image_YUY2(
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
const GstVaapiRectangle *rect
|
||||
)
|
||||
copy_image_YUY2 (GstVaapiImageRaw * dst_image,
|
||||
GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
|
||||
{
|
||||
guchar *dst, *src;
|
||||
guint dst_stride, src_stride;
|
||||
|
@ -810,16 +779,13 @@ copy_image_YUY2(
|
|||
dst = dst_image->pixels[0] + rect->y * dst_stride + rect->x * 2;
|
||||
src_stride = src_image->stride[0];
|
||||
src = src_image->pixels[0] + rect->y * src_stride + rect->x * 2;
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, rect->width * 2, rect->height);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, rect->width * 2, rect->height);
|
||||
}
|
||||
|
||||
/* Copy RGBA images */
|
||||
static void
|
||||
copy_image_RGBA(
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
const GstVaapiRectangle *rect
|
||||
)
|
||||
copy_image_RGBA (GstVaapiImageRaw * dst_image,
|
||||
GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
|
||||
{
|
||||
guchar *dst, *src;
|
||||
guint dst_stride, src_stride;
|
||||
|
@ -828,15 +794,12 @@ copy_image_RGBA(
|
|||
dst = dst_image->pixels[0] + rect->y * dst_stride + rect->x;
|
||||
src_stride = src_image->stride[0];
|
||||
src = src_image->pixels[0] + rect->y * src_stride + rect->x;
|
||||
memcpy_pic(dst, dst_stride, src, src_stride, 4 * rect->width, rect->height);
|
||||
memcpy_pic (dst, dst_stride, src, src_stride, 4 * rect->width, rect->height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
copy_image(
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
const GstVaapiRectangle *rect
|
||||
)
|
||||
copy_image (GstVaapiImageRaw * dst_image,
|
||||
GstVaapiImageRaw * src_image, const GstVaapiRectangle * rect)
|
||||
{
|
||||
GstVaapiRectangle default_rect;
|
||||
|
||||
|
@ -851,8 +814,7 @@ copy_image(
|
|||
rect->y >= src_image->height ||
|
||||
rect->y + rect->height > src_image->height)
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
default_rect.x = 0;
|
||||
default_rect.y = 0;
|
||||
default_rect.width = src_image->width;
|
||||
|
@ -862,24 +824,24 @@ copy_image(
|
|||
|
||||
switch (dst_image->format) {
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
copy_image_NV12(dst_image, src_image, rect);
|
||||
copy_image_NV12 (dst_image, src_image, rect);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
copy_image_YV12(dst_image, src_image, rect);
|
||||
copy_image_YV12 (dst_image, src_image, rect);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
copy_image_YUY2(dst_image, src_image, rect);
|
||||
copy_image_YUY2 (dst_image, src_image, rect);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
case GST_VIDEO_FORMAT_ABGR:
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
copy_image_RGBA(dst_image, src_image, rect);
|
||||
copy_image_RGBA (dst_image, src_image, rect);
|
||||
break;
|
||||
default:
|
||||
GST_ERROR("unsupported image format for copy");
|
||||
GST_ERROR ("unsupported image format for copy");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -898,31 +860,28 @@ copy_image(
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_get_buffer(
|
||||
GstVaapiImage *image,
|
||||
GstBuffer *buffer,
|
||||
GstVaapiRectangle *rect
|
||||
)
|
||||
gst_vaapi_image_get_buffer (GstVaapiImage * image,
|
||||
GstBuffer * buffer, GstVaapiRectangle * rect)
|
||||
{
|
||||
GstVaapiImageRaw dst_image, src_image;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail(GST_IS_BUFFER(buffer), FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||
|
||||
if (!init_image_from_buffer(&dst_image, buffer))
|
||||
if (!init_image_from_buffer (&dst_image, buffer))
|
||||
return FALSE;
|
||||
if (dst_image.format != image->format)
|
||||
return FALSE;
|
||||
if (dst_image.width != image->width || dst_image.height != image->height)
|
||||
return FALSE;
|
||||
|
||||
if (!_gst_vaapi_image_map(image, &src_image))
|
||||
if (!_gst_vaapi_image_map (image, &src_image))
|
||||
return FALSE;
|
||||
|
||||
success = copy_image(&dst_image, &src_image, rect);
|
||||
success = copy_image (&dst_image, &src_image, rect);
|
||||
|
||||
if (!_gst_vaapi_image_unmap(image))
|
||||
if (!_gst_vaapi_image_unmap (image))
|
||||
return FALSE;
|
||||
|
||||
return success;
|
||||
|
@ -941,23 +900,20 @@ gst_vaapi_image_get_buffer(
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_get_raw(
|
||||
GstVaapiImage *image,
|
||||
GstVaapiImageRaw *dst_image,
|
||||
GstVaapiRectangle *rect
|
||||
)
|
||||
gst_vaapi_image_get_raw (GstVaapiImage * image,
|
||||
GstVaapiImageRaw * dst_image, GstVaapiRectangle * rect)
|
||||
{
|
||||
GstVaapiImageRaw src_image;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
if (!_gst_vaapi_image_map(image, &src_image))
|
||||
if (!_gst_vaapi_image_map (image, &src_image))
|
||||
return FALSE;
|
||||
|
||||
success = copy_image(dst_image, &src_image, rect);
|
||||
success = copy_image (dst_image, &src_image, rect);
|
||||
|
||||
if (!_gst_vaapi_image_unmap(image))
|
||||
if (!_gst_vaapi_image_unmap (image))
|
||||
return FALSE;
|
||||
|
||||
return success;
|
||||
|
@ -976,31 +932,28 @@ gst_vaapi_image_get_raw(
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_update_from_buffer(
|
||||
GstVaapiImage *image,
|
||||
GstBuffer *buffer,
|
||||
GstVaapiRectangle *rect
|
||||
)
|
||||
gst_vaapi_image_update_from_buffer (GstVaapiImage * image,
|
||||
GstBuffer * buffer, GstVaapiRectangle * rect)
|
||||
{
|
||||
GstVaapiImageRaw dst_image, src_image;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail(GST_IS_BUFFER(buffer), FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||
|
||||
if (!init_image_from_buffer(&src_image, buffer))
|
||||
if (!init_image_from_buffer (&src_image, buffer))
|
||||
return FALSE;
|
||||
if (src_image.format != image->format)
|
||||
return FALSE;
|
||||
if (src_image.width != image->width || src_image.height != image->height)
|
||||
return FALSE;
|
||||
|
||||
if (!_gst_vaapi_image_map(image, &dst_image))
|
||||
if (!_gst_vaapi_image_map (image, &dst_image))
|
||||
return FALSE;
|
||||
|
||||
success = copy_image(&dst_image, &src_image, rect);
|
||||
success = copy_image (&dst_image, &src_image, rect);
|
||||
|
||||
if (!_gst_vaapi_image_unmap(image))
|
||||
if (!_gst_vaapi_image_unmap (image))
|
||||
return FALSE;
|
||||
|
||||
return success;
|
||||
|
@ -1020,23 +973,20 @@ gst_vaapi_image_update_from_buffer(
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_update_from_raw(
|
||||
GstVaapiImage *image,
|
||||
GstVaapiImageRaw *src_image,
|
||||
GstVaapiRectangle *rect
|
||||
)
|
||||
gst_vaapi_image_update_from_raw (GstVaapiImage * image,
|
||||
GstVaapiImageRaw * src_image, GstVaapiRectangle * rect)
|
||||
{
|
||||
GstVaapiImageRaw dst_image;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail(image != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
|
||||
if (!_gst_vaapi_image_map(image, &dst_image))
|
||||
if (!_gst_vaapi_image_map (image, &dst_image))
|
||||
return FALSE;
|
||||
|
||||
success = copy_image(&dst_image, src_image, rect);
|
||||
success = copy_image (&dst_image, src_image, rect);
|
||||
|
||||
if (!_gst_vaapi_image_unmap(image))
|
||||
if (!_gst_vaapi_image_unmap (image))
|
||||
return FALSE;
|
||||
|
||||
return success;
|
||||
|
@ -1053,23 +1003,23 @@ gst_vaapi_image_update_from_raw(
|
|||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_image_copy(GstVaapiImage *dst_image, GstVaapiImage *src_image)
|
||||
gst_vaapi_image_copy (GstVaapiImage * dst_image, GstVaapiImage * src_image)
|
||||
{
|
||||
GstVaapiImageRaw dst_image_raw, src_image_raw;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail(dst_image != NULL, FALSE);
|
||||
g_return_val_if_fail(src_image != NULL, FALSE);
|
||||
g_return_val_if_fail (dst_image != NULL, FALSE);
|
||||
g_return_val_if_fail (src_image != NULL, FALSE);
|
||||
|
||||
if (!_gst_vaapi_image_map(dst_image, &dst_image_raw))
|
||||
if (!_gst_vaapi_image_map (dst_image, &dst_image_raw))
|
||||
goto end;
|
||||
if (!_gst_vaapi_image_map(src_image, &src_image_raw))
|
||||
if (!_gst_vaapi_image_map (src_image, &src_image_raw))
|
||||
goto end;
|
||||
|
||||
success = copy_image(&dst_image_raw, &src_image_raw, NULL);
|
||||
success = copy_image (&dst_image_raw, &src_image_raw, NULL);
|
||||
|
||||
end:
|
||||
_gst_vaapi_image_unmap(src_image);
|
||||
_gst_vaapi_image_unmap(dst_image);
|
||||
_gst_vaapi_image_unmap (src_image);
|
||||
_gst_vaapi_image_unmap (dst_image);
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -29,38 +29,38 @@
|
|||
#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
|
||||
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;
|
||||
|
||||
units = g_array_sized_new(FALSE, FALSE, sizeof(GstVaapiDecoderUnit), size);
|
||||
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;
|
||||
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);
|
||||
GstVaapiDecoderUnit *const unit =
|
||||
&g_array_index (units, GstVaapiDecoderUnit, i);
|
||||
gst_vaapi_decoder_unit_clear (unit);
|
||||
}
|
||||
g_array_free(units, TRUE);
|
||||
g_array_free (units, TRUE);
|
||||
*units_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ 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;
|
||||
|
||||
frame = (GstVaapiParserFrame *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_parser_frame_class());
|
||||
gst_vaapi_mini_object_new (gst_vaapi_parser_frame_class ());
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
|
@ -89,17 +89,17 @@ gst_vaapi_parser_frame_new(guint width, guint height)
|
|||
height = 1088;
|
||||
num_slices = (height + 15) / 16;
|
||||
|
||||
if (!alloc_units(&frame->pre_units, 16))
|
||||
if (!alloc_units (&frame->pre_units, 16))
|
||||
goto error;
|
||||
if (!alloc_units(&frame->units, num_slices))
|
||||
if (!alloc_units (&frame->units, num_slices))
|
||||
goto error;
|
||||
if (!alloc_units(&frame->post_units, 1))
|
||||
if (!alloc_units (&frame->post_units, 1))
|
||||
goto error;
|
||||
frame->output_offset = 0;
|
||||
return frame;
|
||||
|
||||
error:
|
||||
gst_vaapi_parser_frame_unref(frame);
|
||||
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;
|
||||
|
||||
unit->offset = frame->output_offset;
|
||||
frame->output_offset += unit->size;
|
||||
|
||||
if (GST_VAAPI_DECODER_UNIT_IS_SLICE(unit))
|
||||
if (GST_VAAPI_DECODER_UNIT_IS_SLICE (unit))
|
||||
unit_array_ptr = &frame->units;
|
||||
else if (GST_VAAPI_DECODER_UNIT_IS_FRAME_END(unit))
|
||||
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);
|
||||
g_array_append_val (*unit_array_ptr, *unit);
|
||||
}
|
||||
|
|
|
@ -39,60 +39,60 @@
|
|||
#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;
|
||||
|
||||
g_return_val_if_fail(format != GST_VIDEO_FORMAT_UNKNOWN &&
|
||||
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 (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
|
||||
pixmap = gst_vaapi_pixmap_new_internal(pixmap_class, display);
|
||||
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))
|
||||
if (!pixmap_class->create (pixmap))
|
||||
goto error;
|
||||
return pixmap;
|
||||
|
||||
error:
|
||||
gst_vaapi_pixmap_unref_internal(pixmap);
|
||||
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;
|
||||
|
||||
pixmap = gst_vaapi_pixmap_new_internal(pixmap_class, display);
|
||||
pixmap = gst_vaapi_pixmap_new_internal (pixmap_class, display);
|
||||
if (!pixmap)
|
||||
return NULL;
|
||||
|
||||
GST_VAAPI_OBJECT_ID(pixmap) = GPOINTER_TO_SIZE(native_pixmap);
|
||||
GST_VAAPI_OBJECT_ID (pixmap) = GPOINTER_TO_SIZE (native_pixmap);
|
||||
pixmap->use_foreign_pixmap = TRUE;
|
||||
if (!pixmap_class->create(pixmap))
|
||||
if (!pixmap_class->create (pixmap))
|
||||
goto error;
|
||||
return pixmap;
|
||||
|
||||
error:
|
||||
gst_vaapi_pixmap_unref_internal(pixmap);
|
||||
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);
|
||||
*width = GST_VAAPI_PIXMAP_WIDTH (pixmap);
|
||||
|
||||
if (height)
|
||||
*height = GST_VAAPI_PIXMAP_HEIGHT(pixmap);
|
||||
*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;
|
||||
|
||||
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);
|
||||
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,
|
||||
return GST_VAAPI_PIXMAP_GET_CLASS (pixmap)->render (pixmap, surface,
|
||||
crop_rect, flags);
|
||||
}
|
||||
|
|
|
@ -40,16 +40,18 @@
|
|||
|
||||
typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class;
|
||||
|
||||
struct _GstVaapiPixmapX11 {
|
||||
struct _GstVaapiPixmapX11
|
||||
{
|
||||
GstVaapiPixmap parent_instance;
|
||||
};
|
||||
|
||||
struct _GstVaapiPixmapX11Class {
|
||||
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;
|
||||
|
@ -57,100 +59,97 @@ gst_vaapi_pixmap_x11_create_from_xid(GstVaapiPixmap *pixmap, Pixmap xid)
|
|||
if (!xid)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY(pixmap);
|
||||
success = x11_get_geometry(GST_VAAPI_OBJECT_NATIVE_DISPLAY(pixmap), xid,
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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));
|
||||
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);
|
||||
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;
|
||||
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_LOCK_DISPLAY (pixmap);
|
||||
XFreePixmap (GST_VAAPI_OBJECT_NATIVE_DISPLAY (pixmap), xid);
|
||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
|
||||
}
|
||||
GST_VAAPI_OBJECT_ID(pixmap) = None;
|
||||
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;
|
||||
|
||||
surface_id = GST_VAAPI_OBJECT_ID(surface);
|
||||
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),
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
|
||||
status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (pixmap),
|
||||
surface_id,
|
||||
GST_VAAPI_OBJECT_ID(pixmap),
|
||||
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_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]"))
|
||||
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;
|
||||
|
@ -162,10 +161,8 @@ gst_vaapi_pixmap_x11_class_init(GstVaapiPixmapX11Class *klass)
|
|||
#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;
|
||||
}
|
||||
|
|
|
@ -38,139 +38,120 @@ typedef struct _GstVaapiCodecMap GstVaapiCodecMap;
|
|||
typedef struct _GstVaapiProfileMap GstVaapiProfileMap;
|
||||
typedef struct _GstVaapiEntrypointMap GstVaapiEntrypointMap;
|
||||
|
||||
struct _GstVaapiCodecMap {
|
||||
struct _GstVaapiCodecMap
|
||||
{
|
||||
GstVaapiCodec codec;
|
||||
const gchar *name;
|
||||
};
|
||||
|
||||
struct _GstVaapiProfileMap {
|
||||
struct _GstVaapiProfileMap
|
||||
{
|
||||
GstVaapiProfile profile;
|
||||
VAProfile va_profile;
|
||||
const char *media_str;
|
||||
const gchar *profile_str;
|
||||
};
|
||||
|
||||
struct _GstVaapiEntrypointMap {
|
||||
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,
|
||||
{GST_VAAPI_PROFILE_H264_CONSTRAINED_BASELINE,
|
||||
VAProfileH264ConstrainedBaseline,
|
||||
"video/x-h264", "constrained-baseline"
|
||||
},
|
||||
"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;
|
||||
|
||||
|
@ -181,7 +162,7 @@ get_codecs_map(GstVaapiCodec codec)
|
|||
}
|
||||
|
||||
static const GstVaapiProfileMap *
|
||||
get_profiles_map(GstVaapiProfile profile)
|
||||
get_profiles_map (GstVaapiProfile profile)
|
||||
{
|
||||
const GstVaapiProfileMap *m;
|
||||
|
||||
|
@ -192,7 +173,7 @@ get_profiles_map(GstVaapiProfile profile)
|
|||
}
|
||||
|
||||
static const GstVaapiEntrypointMap *
|
||||
get_entrypoints_map(GstVaapiEntrypoint entrypoint)
|
||||
get_entrypoints_map (GstVaapiEntrypoint entrypoint)
|
||||
{
|
||||
const GstVaapiEntrypointMap *m;
|
||||
|
||||
|
@ -211,9 +192,9 @@ 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;
|
||||
}
|
||||
|
@ -229,7 +210,7 @@ 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;
|
||||
|
||||
|
@ -248,9 +229,9 @@ 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;
|
||||
}
|
||||
|
@ -266,9 +247,9 @@ 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;
|
||||
}
|
||||
|
@ -283,37 +264,42 @@ 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];
|
||||
|
||||
if (gst_buffer_extract(buffer, 0, buf, sizeof(buf)) != sizeof(buf))
|
||||
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) ?
|
||||
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;
|
||||
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];
|
||||
|
||||
if (gst_buffer_extract(buffer, 0, buf, sizeof(buf)) != sizeof(buf))
|
||||
if (gst_buffer_extract (buffer, 0, buf, sizeof (buf)) != sizeof (buf))
|
||||
return 0;
|
||||
|
||||
if (buf[0] != 1) /* configurationVersion = 1 */
|
||||
|
@ -323,15 +309,18 @@ gst_vaapi_profile_from_codec_data_h265(GstBuffer *buffer)
|
|||
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;
|
||||
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;
|
||||
|
||||
|
@ -340,10 +329,10 @@ gst_vaapi_profile_from_codec_data(GstVaapiCodec codec, GstBuffer *buffer)
|
|||
|
||||
switch (codec) {
|
||||
case GST_VAAPI_CODEC_H264:
|
||||
profile = gst_vaapi_profile_from_codec_data_h264(buffer);
|
||||
profile = gst_vaapi_profile_from_codec_data_h264 (buffer);
|
||||
break;
|
||||
case GST_VAAPI_CODEC_H265:
|
||||
profile = gst_vaapi_profile_from_codec_data_h265(buffer);
|
||||
profile = gst_vaapi_profile_from_codec_data_h265 (buffer);
|
||||
break;
|
||||
default:
|
||||
profile = 0;
|
||||
|
@ -363,7 +352,7 @@ 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;
|
||||
|
@ -377,46 +366,44 @@ gst_vaapi_profile_from_caps(const GstCaps *caps)
|
|||
if (!caps)
|
||||
return 0;
|
||||
|
||||
structure = gst_caps_get_structure(caps, 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");
|
||||
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");
|
||||
v_codec_data = gst_structure_get_value (structure, "codec_data");
|
||||
if (v_codec_data)
|
||||
codec_data = gst_value_get_buffer(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)
|
||||
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)) {
|
||||
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)
|
||||
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) {
|
||||
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);
|
||||
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,27 +436,23 @@ 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;
|
||||
|
||||
out_caps = gst_caps_new_empty();
|
||||
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);
|
||||
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);
|
||||
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,7 +466,7 @@ 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;
|
||||
|
||||
|
@ -499,7 +482,7 @@ gst_vaapi_profile_get_codec(GstVaapiProfile profile)
|
|||
codec = GST_VAAPI_CODEC_JPEG;
|
||||
break;
|
||||
default:
|
||||
codec = (guint32)profile & GST_MAKE_FOURCC(0xff,0xff,0xff,0);
|
||||
codec = (guint32) profile & GST_MAKE_FOURCC (0xff, 0xff, 0xff, 0);
|
||||
break;
|
||||
}
|
||||
return codec;
|
||||
|
@ -516,7 +499,7 @@ 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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,9 @@ typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
|
|||
*
|
||||
* A VA subpicture wrapper
|
||||
*/
|
||||
struct _GstVaapiSubpicture {
|
||||
/*< private >*/
|
||||
struct _GstVaapiSubpicture
|
||||
{
|
||||
/*< private > */
|
||||
GstVaapiObject parent_instance;
|
||||
|
||||
GstVaapiImage *image;
|
||||
|
@ -59,66 +60,62 @@ struct _GstVaapiSubpicture {
|
|||
*
|
||||
* A VA subpicture wrapper class
|
||||
*/
|
||||
struct _GstVaapiSubpictureClass {
|
||||
/*< private >*/
|
||||
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);
|
||||
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_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;
|
||||
GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID;
|
||||
}
|
||||
gst_vaapi_object_replace(&subpicture->image, NULL);
|
||||
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);
|
||||
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()"))
|
||||
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);
|
||||
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,37 +127,37 @@ 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;
|
||||
|
||||
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))
|
||||
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);
|
||||
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))
|
||||
if (!gst_vaapi_subpicture_set_image (subpicture, image))
|
||||
goto error;
|
||||
return subpicture;
|
||||
|
||||
error:
|
||||
gst_vaapi_object_unref(subpicture);
|
||||
gst_vaapi_object_unref (subpicture);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -177,10 +174,8 @@ 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;
|
||||
|
@ -194,7 +189,7 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
|
|||
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() */
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
|
@ -202,28 +197,30 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
|
|||
#else
|
||||
format = GST_VIDEO_FORMAT_ARGB;
|
||||
#endif
|
||||
if (!gst_vaapi_display_has_subpicture_format(display, format, &hw_flags))
|
||||
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));
|
||||
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect,
|
||||
to_GstVideoOverlayFormatFlags (flags));
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
vmeta = gst_buffer_get_video_meta(buffer);
|
||||
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))
|
||||
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);
|
||||
image = gst_vaapi_image_new (display, format, width, height);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
|
@ -233,21 +230,21 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
|
|||
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);
|
||||
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);
|
||||
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))
|
||||
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,9 +275,9 @@ 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;
|
||||
}
|
||||
|
@ -294,9 +291,9 @@ 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;
|
||||
}
|
||||
|
@ -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,9 +328,9 @@ 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;
|
||||
}
|
||||
|
@ -350,13 +347,13 @@ 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;
|
||||
|
||||
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;
|
||||
|
@ -364,16 +361,13 @@ gst_vaapi_subpicture_set_global_alpha(GstVaapiSubpicture *subpicture,
|
|||
if (subpicture->global_alpha == global_alpha)
|
||||
return TRUE;
|
||||
|
||||
display = GST_VAAPI_OBJECT_DISPLAY(subpicture);
|
||||
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()"))
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue