2013-07-29 05:34:06 +00:00
|
|
|
/*
|
|
|
|
* gstvaapiencoder_objects.h - VA encoder objects abstraction
|
|
|
|
*
|
2014-01-22 17:54:14 +00:00
|
|
|
* Copyright (C) 2013-2014 Intel Corporation
|
2014-01-22 17:49:20 +00:00
|
|
|
* Author: Wind Yuan <feng.yuan@intel.com>
|
2013-07-29 05:34:06 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GST_VAAPI_ENCODER_OBJECTS_H
|
|
|
|
#define GST_VAAPI_ENCODER_OBJECTS_H
|
|
|
|
|
|
|
|
#include <gst/vaapi/gstvaapicodec_objects.h>
|
|
|
|
#include <gst/vaapi/gstvaapidecoder_objects.h>
|
|
|
|
#include <gst/vaapi/gstvaapiencoder.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef struct _GstVaapiEncPicture GstVaapiEncPicture;
|
|
|
|
typedef struct _GstVaapiEncSequence GstVaapiEncSequence;
|
|
|
|
typedef struct _GstVaapiEncMiscParam GstVaapiEncMiscParam;
|
|
|
|
typedef struct _GstVaapiEncSlice GstVaapiEncSlice;
|
|
|
|
typedef struct _GstVaapiCodedBuffer GstVaapiCodedBuffer;
|
|
|
|
typedef struct _GstVaapiEncPackedHeader GstVaapiEncPackedHeader;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Encoder Packed Header --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
#define GST_VAAPI_ENC_PACKED_HEADER(obj) \
|
|
|
|
((GstVaapiEncPackedHeader *) (obj))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiEncPackedHeader:
|
|
|
|
*
|
2014-01-14 11:01:11 +00:00
|
|
|
* A #GstVaapiCodecObject holding a packed header (param/data) for the
|
|
|
|
* encoder.
|
2013-07-29 05:34:06 +00:00
|
|
|
*/
|
|
|
|
struct _GstVaapiEncPackedHeader
|
|
|
|
{
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< private >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiCodecObject parent_instance;
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< public >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
VABufferID param_id;
|
|
|
|
gpointer param;
|
|
|
|
VABufferID data_id;
|
|
|
|
gpointer data;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiEncPackedHeader *
|
|
|
|
gst_vaapi_enc_packed_header_new (GstVaapiEncoder * encoder,
|
|
|
|
gconstpointer param, guint param_size, gconstpointer data, guint data_size);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
2014-01-14 11:01:11 +00:00
|
|
|
gst_vaapi_enc_packed_header_set_data (GstVaapiEncPackedHeader * header,
|
2013-07-29 05:34:06 +00:00
|
|
|
gconstpointer data, guint data_size);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Encoder Sequence --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
#define GST_VAAPI_ENC_SEQUENCE(obj) \
|
|
|
|
((GstVaapiEncSequence *) (obj))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiEncSequence:
|
|
|
|
*
|
2014-01-14 11:01:11 +00:00
|
|
|
* A #GstVaapiCodecObject holding a sequence parameter for encoding.
|
2013-07-29 05:34:06 +00:00
|
|
|
*/
|
|
|
|
struct _GstVaapiEncSequence
|
|
|
|
{
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< private >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiCodecObject parent_instance;
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< public >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
VABufferID param_id;
|
|
|
|
gpointer param;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiEncSequence *
|
|
|
|
gst_vaapi_enc_sequence_new (GstVaapiEncoder * encoder,
|
|
|
|
gconstpointer param, guint param_size);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Encoder Slice --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
#define GST_VAAPI_ENC_SLICE(obj) \
|
|
|
|
((GstVaapiEncSlice *) (obj))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiEncSlice:
|
|
|
|
*
|
2014-01-14 11:01:11 +00:00
|
|
|
* A #GstVaapiCodecObject holding a slice parameter used for encoding.
|
2013-07-29 05:34:06 +00:00
|
|
|
*/
|
|
|
|
struct _GstVaapiEncSlice
|
|
|
|
{
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< private >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiCodecObject parent_instance;
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< public >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
VABufferID param_id;
|
|
|
|
gpointer param;
|
2014-06-05 12:30:38 +00:00
|
|
|
GPtrArray *packed_headers;
|
2013-07-29 05:34:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiEncSlice *
|
|
|
|
gst_vaapi_enc_slice_new (GstVaapiEncoder * encoder,
|
|
|
|
gconstpointer param, guint param_size);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Encoder Misc Parameter Buffer --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
#define GST_VAAPI_ENC_MISC_PARAM(obj) \
|
|
|
|
((GstVaapiEncMiscParam *) (obj))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiEncMiscParam:
|
|
|
|
*
|
2014-01-14 11:01:11 +00:00
|
|
|
* A #GstVaapiCodecObject holding a misc parameter and associated data
|
|
|
|
* used for controlling the encoder dynamically.
|
2013-07-29 05:34:06 +00:00
|
|
|
*/
|
|
|
|
struct _GstVaapiEncMiscParam
|
|
|
|
{
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< private >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiCodecObject parent_instance;
|
|
|
|
gpointer param;
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< public >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
VABufferID param_id;
|
2014-01-14 11:01:11 +00:00
|
|
|
gpointer data;
|
2013-07-29 05:34:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiEncMiscParam *
|
|
|
|
gst_vaapi_enc_misc_param_new (GstVaapiEncoder * encoder,
|
2014-01-14 11:01:11 +00:00
|
|
|
VAEncMiscParameterType type, guint data_size);
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Encoder Picture --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define GST_VAAPI_ENC_PICTURE(obj) \
|
2014-01-14 11:01:11 +00:00
|
|
|
((GstVaapiEncPicture *) (obj))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_VAAPI_ENC_PICTURE_FLAG_IDR = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 0),
|
|
|
|
GST_VAAPI_ENC_PICTURE_FLAG_LAST = (GST_VAAPI_CODEC_OBJECT_FLAG_LAST << 1),
|
|
|
|
} GstVaapiEncPictureFlags;
|
|
|
|
|
|
|
|
#define GST_VAAPI_ENC_PICTURE_FLAGS GST_VAAPI_MINI_OBJECT_FLAGS
|
|
|
|
#define GST_VAAPI_ENC_PICTURE_FLAG_IS_SET GST_VAAPI_MINI_OBJECT_FLAG_IS_SET
|
|
|
|
#define GST_VAAPI_ENC_PICTURE_FLAG_SET GST_VAAPI_MINI_OBJECT_FLAG_SET
|
|
|
|
#define GST_VAAPI_ENC_PICTURE_FLAG_UNSET GST_VAAPI_MINI_OBJECT_FLAG_UNSET
|
|
|
|
|
|
|
|
#define GST_VAAPI_ENC_PICTURE_IS_IDR(picture) \
|
|
|
|
GST_VAAPI_ENC_PICTURE_FLAG_IS_SET(picture, GST_VAAPI_ENC_PICTURE_FLAG_IDR)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiEncPicture:
|
|
|
|
*
|
2014-01-14 11:01:11 +00:00
|
|
|
* A #GstVaapiCodecObject holding a picture parameter for encoding.
|
2013-07-29 05:34:06 +00:00
|
|
|
*/
|
|
|
|
struct _GstVaapiEncPicture
|
|
|
|
{
|
2014-01-14 11:01:11 +00:00
|
|
|
/*< private >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiCodecObject parent_instance;
|
|
|
|
GstVideoCodecFrame *frame;
|
2013-11-28 14:56:53 +00:00
|
|
|
GstVaapiSurfaceProxy *proxy;
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiSurface *surface;
|
|
|
|
VABufferID param_id;
|
|
|
|
guint param_size;
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/* Additional data to pass down */
|
|
|
|
GstVaapiEncSequence *sequence;
|
|
|
|
GPtrArray *packed_headers;
|
|
|
|
GPtrArray *misc_params;
|
|
|
|
|
|
|
|
/*< public >*/
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiPictureType type;
|
|
|
|
VASurfaceID surface_id;
|
|
|
|
gpointer param;
|
2014-01-14 11:01:11 +00:00
|
|
|
GPtrArray *slices;
|
2013-07-29 05:34:06 +00:00
|
|
|
GstClockTime pts;
|
|
|
|
guint frame_num;
|
|
|
|
guint poc;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiEncPicture *
|
|
|
|
gst_vaapi_enc_picture_new (GstVaapiEncoder * encoder,
|
|
|
|
gconstpointer param, guint param_size, GstVideoCodecFrame * frame);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_vaapi_enc_picture_set_sequence (GstVaapiEncPicture * picture,
|
|
|
|
GstVaapiEncSequence * sequence);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_vaapi_enc_picture_add_packed_header (GstVaapiEncPicture * picture,
|
|
|
|
GstVaapiEncPackedHeader * header);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
2014-01-14 11:01:11 +00:00
|
|
|
gst_vaapi_enc_picture_add_misc_param (GstVaapiEncPicture * picture,
|
2013-07-29 05:34:06 +00:00
|
|
|
GstVaapiEncMiscParam * misc);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_vaapi_enc_picture_add_slice (GstVaapiEncPicture * picture,
|
|
|
|
GstVaapiEncSlice * slice);
|
|
|
|
|
2014-06-05 12:30:38 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_vaapi_enc_slice_add_packed_header (GstVaapiEncSlice *slice,
|
|
|
|
GstVaapiEncPackedHeader * header);
|
|
|
|
|
2013-07-29 05:34:06 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_enc_picture_encode (GstVaapiEncPicture * picture);
|
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
#define gst_vaapi_enc_picture_ref(picture) \
|
|
|
|
gst_vaapi_codec_object_ref (picture)
|
|
|
|
#define gst_vaapi_enc_picture_unref(picture) \
|
|
|
|
gst_vaapi_codec_object_unref (picture)
|
|
|
|
#define gst_vaapi_enc_picture_replace(old_picture_ptr, new_picture) \
|
|
|
|
gst_vaapi_codec_object_replace (old_picture_ptr, new_picture)
|
2013-07-29 05:34:06 +00:00
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* --- Helpers to create codec-dependent objects --- */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2013-07-29 05:34:06 +00:00
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/* GstVaapiEncSequence */
|
2013-07-29 05:34:06 +00:00
|
|
|
#define GST_VAAPI_ENC_SEQUENCE_NEW(codec, encoder) \
|
2014-01-14 11:01:11 +00:00
|
|
|
gst_vaapi_enc_sequence_new (GST_VAAPI_ENCODER_CAST (encoder), \
|
|
|
|
NULL, sizeof (G_PASTE (VAEncSequenceParameterBuffer, codec)))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/* GstVaapiEncMiscParam */
|
2013-07-29 05:34:06 +00:00
|
|
|
#define GST_VAAPI_ENC_MISC_PARAM_NEW(type, encoder) \
|
2014-01-14 11:01:11 +00:00
|
|
|
gst_vaapi_enc_misc_param_new (GST_VAAPI_ENCODER_CAST (encoder), \
|
|
|
|
G_PASTE (VAEncMiscParameterType, type), \
|
|
|
|
sizeof (G_PASTE (VAEncMiscParameter, type)))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
2014-01-14 11:01:11 +00:00
|
|
|
/* GstVaapiEncPicture */
|
2013-07-29 05:34:06 +00:00
|
|
|
#define GST_VAAPI_ENC_PICTURE_NEW(codec, encoder, frame) \
|
2014-01-14 11:01:11 +00:00
|
|
|
gst_vaapi_enc_picture_new (GST_VAAPI_ENCODER_CAST (encoder), \
|
|
|
|
NULL, sizeof (G_PASTE (VAEncPictureParameterBuffer, codec)), frame)
|
|
|
|
|
|
|
|
/* GstVaapiEncSlice */
|
|
|
|
#define GST_VAAPI_ENC_SLICE_NEW(codec, encoder) \
|
|
|
|
gst_vaapi_enc_slice_new (GST_VAAPI_ENCODER_CAST (encoder), \
|
|
|
|
NULL, sizeof(G_PASTE (VAEncSliceParameterBuffer, codec)))
|
2013-07-29 05:34:06 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* GST_VAAPI_ENCODER_OBJECTS_H */
|