gstvaapidecoder.h 5.45 KB
Newer Older
1 2 3
/*
 *  gstvaapidecoder.h - VA decoder abstraction
 *
4
 *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5
 *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6
 *  Copyright (C) 2011-2013 Intel Corporation
7
 *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8
 *
gb's avatar
gb committed
9 10 11 12
 *  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.
13
 *
gb's avatar
gb committed
14
 *  This library is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
gb's avatar
gb committed
16 17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
18
 *
gb's avatar
gb committed
19 20 21 22
 *  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
23 24 25 26 27 28
 */

#ifndef GST_VAAPI_DECODER_H
#define GST_VAAPI_DECODER_H

#include <gst/gstbuffer.h>
29
#include <gst/base/gstadapter.h>
30
#include <gst/vaapi/gstvaapisurfaceproxy.h>
31
#include <gst/video/gstvideoutils.h>
32 33 34

G_BEGIN_DECLS

35 36
#define GST_TYPE_VAAPI_DECODER \
    (gst_vaapi_decoder_get_type ())
37
#define GST_VAAPI_DECODER(obj) \
38 39 40
    (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))
41

42 43 44
typedef struct _GstVaapiDecoder GstVaapiDecoder;
typedef void (*GstVaapiDecoderStateChangedFunc) (GstVaapiDecoder * decoder,
    const GstVideoCodecState * codec_state, gpointer user_data);
45 46 47 48

/**
 * GstVaapiDecoderStatus:
 * @GST_VAAPI_DECODER_STATUS_SUCCESS: Success.
gb's avatar
gb committed
49 50 51
 * @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.
52
 * @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC: Unsupported codec.
gb's avatar
gb committed
53
 * @GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: Not enough input data to decode.
gb's avatar
gb committed
54
 * @GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE: No surface left to hold the decoded picture.
gb's avatar
gb committed
55
 * @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE: Invalid surface.
56 57 58
 * @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.
59
 * @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER: Unsupported parameter.
gb's avatar
gb committed
60
 * @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
61 62 63
 *
 * Decoder status for gst_vaapi_decoder_get_surface().
 */
Philip Lorenz's avatar
Philip Lorenz committed
64
typedef enum {
65 66 67 68 69 70 71 72 73 74 75 76 77
  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
Philip Lorenz's avatar
Philip Lorenz committed
78
} GstVaapiDecoderStatus;
79

80 81
GType
gst_vaapi_decoder_get_type (void) G_GNUC_CONST;
82

83
void
84
gst_vaapi_decoder_unref (GstVaapiDecoder * decoder);
85

86
void
87 88
gst_vaapi_decoder_replace (GstVaapiDecoder ** old_decoder_ptr,
    GstVaapiDecoder * new_decoder);
89 90

gpointer
91
gst_vaapi_decoder_get_user_data (GstVaapiDecoder * decoder);
92 93

void
94
gst_vaapi_decoder_set_user_data (GstVaapiDecoder * decoder, gpointer user_data);
95

96
GstVaapiCodec
97
gst_vaapi_decoder_get_codec (GstVaapiDecoder * decoder);
98

99
GstVideoCodecState *
100
gst_vaapi_decoder_get_codec_state (GstVaapiDecoder * decoder);
101

102
void
103
gst_vaapi_decoder_set_codec_state_changed_func (GstVaapiDecoder * decoder,
104 105
    GstVaapiDecoderStateChangedFunc func, gpointer user_data);

gb's avatar
gb committed
106
GstCaps *
107
gst_vaapi_decoder_get_caps (GstVaapiDecoder * decoder);
108 109 110

GArray *
gst_vaapi_decoder_get_surface_formats (GstVaapiDecoder * decoder);
gb's avatar
gb committed
111

112
gboolean
113
gst_vaapi_decoder_put_buffer (GstVaapiDecoder * decoder, GstBuffer * buf);
114

115
GstVaapiDecoderStatus
116 117
gst_vaapi_decoder_get_surface (GstVaapiDecoder * decoder,
    GstVaapiSurfaceProxy ** out_proxy_ptr);
118

119
GstVaapiDecoderStatus
120 121
gst_vaapi_decoder_get_frame (GstVaapiDecoder * decoder,
    GstVideoCodecFrame ** out_frame_ptr);
122

123
GstVaapiDecoderStatus
124 125
gst_vaapi_decoder_get_frame_with_timeout (GstVaapiDecoder * decoder,
    GstVideoCodecFrame ** out_frame_ptr, guint64 timeout);
126

127
GstVaapiDecoderStatus
128 129 130
gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
    GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos,
    guint * got_unit_size_ptr, gboolean * got_frame_ptr);
131 132

GstVaapiDecoderStatus
133 134
gst_vaapi_decoder_decode (GstVaapiDecoder * decoder,
    GstVideoCodecFrame * frame);
135

136
GstVaapiDecoderStatus
137
gst_vaapi_decoder_flush (GstVaapiDecoder * decoder);
138

139 140 141
GstVaapiDecoderStatus
gst_vaapi_decoder_reset (GstVaapiDecoder * decoder);

142 143 144
GstVaapiDecoderStatus
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder);

145 146 147
gboolean
gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps);

148 149 150 151
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDecoder, gst_vaapi_decoder_unref)
#endif

152 153 154
G_END_DECLS

#endif /* GST_VAAPI_DECODER_H */