2010-04-23 16:05:58 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidecoder.h - VA decoder abstraction
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-01-29 13:14:45 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-04-23 16:05:58 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +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.
|
2010-04-23 16:05:58 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-04-23 16:05:58 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-05-03 07:07:27 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-04-23 16:05:58 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* 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
|
2010-04-23 16:05:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GST_VAAPI_DECODER_H
|
|
|
|
#define GST_VAAPI_DECODER_H
|
|
|
|
|
|
|
|
#include <gst/gstbuffer.h>
|
2012-12-06 12:57:42 +00:00
|
|
|
#include <gst/base/gstadapter.h>
|
2010-04-23 16:05:58 +00:00
|
|
|
#include <gst/vaapi/gstvaapisurfaceproxy.h>
|
2012-12-06 12:57:42 +00:00
|
|
|
#include <gst/video/gstvideoutils.h>
|
2010-04-23 16:05:58 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2018-05-18 14:09:31 +00:00
|
|
|
#define GST_TYPE_VAAPI_DECODER \
|
|
|
|
(gst_vaapi_decoder_get_type ())
|
2013-05-06 12:07:17 +00:00
|
|
|
#define GST_VAAPI_DECODER(obj) \
|
2018-05-18 14:09:31 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_DECODER, GstVaapiDecoder))
|
|
|
|
#define GST_VAAPI_IS_DECODER(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_DECODER))
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2014-04-25 11:57:02 +00:00
|
|
|
typedef struct _GstVaapiDecoder GstVaapiDecoder;
|
|
|
|
typedef void (*GstVaapiDecoderStateChangedFunc) (GstVaapiDecoder * decoder,
|
|
|
|
const GstVideoCodecState * codec_state, gpointer user_data);
|
2010-04-23 16:05:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDecoderStatus:
|
|
|
|
* @GST_VAAPI_DECODER_STATUS_SUCCESS: Success.
|
2010-04-27 11:59:23 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_END_OF_STREAM: End-Of-Stream.
|
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED: No memory left.
|
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED: Decoder initialization failure.
|
2010-04-28 22:16:10 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC: Unsupported codec.
|
2010-04-27 11:59:23 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: Not enough input data to decode.
|
2010-05-15 05:36:15 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE: No surface left to hold the decoded picture.
|
2010-04-27 11:59:23 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE: Invalid surface.
|
2011-08-05 09:52:43 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER: Invalid or unsupported bitstream data.
|
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE: Unsupported codec profile.
|
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT: Unsupported chroma format.
|
2012-11-29 14:06:00 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER: Unsupported parameter.
|
2010-04-27 11:59:23 +00:00
|
|
|
* @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
|
2010-04-23 16:05:58 +00:00
|
|
|
*
|
|
|
|
* Decoder status for gst_vaapi_decoder_get_surface().
|
|
|
|
*/
|
2012-09-04 11:40:04 +00:00
|
|
|
typedef enum {
|
2014-04-25 11:57:02 +00:00
|
|
|
GST_VAAPI_DECODER_STATUS_SUCCESS = 0,
|
|
|
|
GST_VAAPI_DECODER_STATUS_END_OF_STREAM,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER,
|
|
|
|
GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
|
2012-09-04 11:40:04 +00:00
|
|
|
} GstVaapiDecoderStatus;
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2018-05-18 14:09:31 +00:00
|
|
|
GType
|
|
|
|
gst_vaapi_decoder_get_type (void) G_GNUC_CONST;
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2013-05-06 12:07:17 +00:00
|
|
|
void
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_replace (GstVaapiDecoder ** old_decoder_ptr,
|
|
|
|
GstVaapiDecoder * new_decoder);
|
2013-05-06 12:07:17 +00:00
|
|
|
|
|
|
|
gpointer
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_user_data (GstVaapiDecoder * decoder);
|
2013-05-06 12:07:17 +00:00
|
|
|
|
|
|
|
void
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_set_user_data (GstVaapiDecoder * decoder, gpointer user_data);
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2012-09-11 15:03:33 +00:00
|
|
|
GstVaapiCodec
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_codec (GstVaapiDecoder * decoder);
|
2012-09-11 15:03:33 +00:00
|
|
|
|
2012-12-12 14:09:21 +00:00
|
|
|
GstVideoCodecState *
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_codec_state (GstVaapiDecoder * decoder);
|
2012-12-12 14:09:21 +00:00
|
|
|
|
2013-05-06 12:07:17 +00:00
|
|
|
void
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_set_codec_state_changed_func (GstVaapiDecoder * decoder,
|
2013-05-06 12:07:17 +00:00
|
|
|
GstVaapiDecoderStateChangedFunc func, gpointer user_data);
|
|
|
|
|
2010-05-15 15:33:20 +00:00
|
|
|
GstCaps *
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_caps (GstVaapiDecoder * decoder);
|
2016-02-25 17:57:30 +00:00
|
|
|
|
2010-04-23 16:05:58 +00:00
|
|
|
gboolean
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_put_buffer (GstVaapiDecoder * decoder, GstBuffer * buf);
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2012-12-12 12:44:07 +00:00
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_surface (GstVaapiDecoder * decoder,
|
|
|
|
GstVaapiSurfaceProxy ** out_proxy_ptr);
|
2010-04-23 16:05:58 +00:00
|
|
|
|
2012-12-13 13:27:18 +00:00
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_frame (GstVaapiDecoder * decoder,
|
|
|
|
GstVideoCodecFrame ** out_frame_ptr);
|
2012-12-13 13:27:18 +00:00
|
|
|
|
2013-04-25 11:56:18 +00:00
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_get_frame_with_timeout (GstVaapiDecoder * decoder,
|
|
|
|
GstVideoCodecFrame ** out_frame_ptr, guint64 timeout);
|
2013-04-25 11:56:18 +00:00
|
|
|
|
2012-11-29 14:06:00 +00:00
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos,
|
|
|
|
guint * got_unit_size_ptr, gboolean * got_frame_ptr);
|
2012-11-29 14:06:00 +00:00
|
|
|
|
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_decode (GstVaapiDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
2012-11-29 14:06:00 +00:00
|
|
|
|
2013-01-17 17:33:32 +00:00
|
|
|
GstVaapiDecoderStatus
|
2014-04-25 11:57:02 +00:00
|
|
|
gst_vaapi_decoder_flush (GstVaapiDecoder * decoder);
|
2013-01-17 17:33:32 +00:00
|
|
|
|
2017-04-05 07:24:20 +00:00
|
|
|
GstVaapiDecoderStatus
|
|
|
|
gst_vaapi_decoder_reset (GstVaapiDecoder * decoder);
|
|
|
|
|
2017-01-13 20:26:15 +00:00
|
|
|
gboolean
|
|
|
|
gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps);
|
|
|
|
|
vaapidecode: build allowed srcpad caps from va context
Instead of generating allowed srcpad caps with generic information,
now it takes the size an formats limits from the decoder's context.
This is possible since srcpad caps are generated after the internal
decoder is created.
The patch replaces gst_vaapi_decoder_get_surface_formats() with
gst_vaapi_decoder_get_suface_attributes().
From these attributes, formats are only used for VASurface memory
caps feature. For system memory caps feature, the old
gst_vaapi_plugin_get_allowed_srcpad_caps() is still used, since
i965 jpeg decoder cannot deliver mappable format for gstreamer.
And for the other caps features (dmabuf and texture upload) the
same static list are used.
This patch also adds DMABuf caps feature only if the context
supports that memory type. Nonetheless, we keep the pre-defined
formats since they are the subset of common derive formats formats
supported either by amd/gallium and both intel drivers, since,
when exporting the fd through vaAcquireBufferHandle()/
vaReleaseBufferHandle(), the formats of the derivable image cannot
be retriebable from the driver. Later we'll use the attribute
formats for the DMABuf feature too, when the code be ported to
vaExportSurfaceHandle().
Finally, the allowed srcpad caps are removed if the internal decoder
is destroyed, since context attribues will change.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/366>
2020-01-22 16:41:28 +00:00
|
|
|
GArray *
|
|
|
|
gst_vaapi_decoder_get_surface_attributes (GstVaapiDecoder * decoder,
|
|
|
|
gint * min_width, gint * min_height, gint * max_width, gint * max_height,
|
|
|
|
guint * mem_types);
|
|
|
|
|
2018-05-21 09:56:11 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDecoder, gst_object_unref)
|
2018-05-18 14:09:31 +00:00
|
|
|
|
2010-04-23 16:05:58 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* GST_VAAPI_DECODER_H */
|