gstvaapidecoder.h 4.81 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_VAAPI_DECODER(obj) \
    ((GstVaapiDecoder *)(obj))
37 38

typedef struct _GstVaapiDecoder                 GstVaapiDecoder;
39 40
typedef void (*GstVaapiDecoderStateChangedFunc)(GstVaapiDecoder *decoder,
    const GstVideoCodecState *codec_state, gpointer user_data);
41 42 43 44

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

76 77
GstVaapiDecoder *
gst_vaapi_decoder_ref(GstVaapiDecoder *decoder);
78

79 80
void
gst_vaapi_decoder_unref(GstVaapiDecoder *decoder);
81

82 83 84 85 86 87 88 89 90
void
gst_vaapi_decoder_replace(GstVaapiDecoder **old_decoder_ptr,
    GstVaapiDecoder *new_decoder);

gpointer
gst_vaapi_decoder_get_user_data(GstVaapiDecoder *decoder);

void
gst_vaapi_decoder_set_user_data(GstVaapiDecoder *decoder, gpointer user_data);
91

92 93 94
GstVaapiCodec
gst_vaapi_decoder_get_codec(GstVaapiDecoder *decoder);

95 96 97
GstVideoCodecState *
gst_vaapi_decoder_get_codec_state(GstVaapiDecoder *decoder);

98 99 100 101
void
gst_vaapi_decoder_set_codec_state_changed_func(GstVaapiDecoder *decoder,
    GstVaapiDecoderStateChangedFunc func, gpointer user_data);

gb's avatar
gb committed
102 103 104
GstCaps *
gst_vaapi_decoder_get_caps(GstVaapiDecoder *decoder);

105 106 107
gboolean
gst_vaapi_decoder_put_buffer(GstVaapiDecoder *decoder, GstBuffer *buf);

108 109 110
GstVaapiDecoderStatus
gst_vaapi_decoder_get_surface(GstVaapiDecoder *decoder,
    GstVaapiSurfaceProxy **out_proxy_ptr);
111

112 113 114 115
GstVaapiDecoderStatus
gst_vaapi_decoder_get_frame(GstVaapiDecoder *decoder,
    GstVideoCodecFrame **out_frame_ptr);

116 117 118 119
GstVaapiDecoderStatus
gst_vaapi_decoder_get_frame_with_timeout(GstVaapiDecoder *decoder,
    GstVideoCodecFrame **out_frame_ptr, guint64 timeout);

120 121 122 123 124 125
GstVaapiDecoderStatus
gst_vaapi_decoder_parse(GstVaapiDecoder *decoder,
    GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos,
    guint *got_unit_size_ptr, gboolean *got_frame_ptr);

GstVaapiDecoderStatus
126
gst_vaapi_decoder_decode(GstVaapiDecoder *decoder, GstVideoCodecFrame *frame);
127

128 129 130
GstVaapiDecoderStatus
gst_vaapi_decoder_flush(GstVaapiDecoder *decoder);

131 132 133
G_END_DECLS

#endif /* GST_VAAPI_DECODER_H */