gstvaapidecoder_unit.h 5.66 KB
Newer Older
1 2 3
/*
 *  gstvaapidecoder_unit.h - VA decoder units
 *
4
 *  Copyright (C) 2012-2013 Intel Corporation
5
 *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
 *
 *  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_DECODER_UNIT_H
#define GST_VAAPI_DECODER_UNIT_H

G_BEGIN_DECLS

typedef struct _GstVaapiDecoderUnit             GstVaapiDecoderUnit;

#define GST_VAAPI_DECODER_UNIT(unit) \
    ((GstVaapiDecoderUnit *)(unit))

#define GST_VAAPI_IS_DECODER_UNIT(unit) \
    (GST_VAAPI_DECODER_UNIT(unit) != NULL)

/**
 * GstVaapiDecoderUnitFlags:
 * @GST_VAAPI_DECODER_UNIT_FLAG_FRAME_START: marks the start of a frame.
 * @GST_VAAPI_DECODER_UNIT_FLAG_FRAME_END: marks the end of a frame.
 * @GST_VAAPI_DECODER_UNIT_FLAG_STREAM_END: marks the end of a stream.
41
 * @GST_VAAPI_DECODER_UNIT_FLAG_SLICE: the unit contains slice data.
42 43 44 45 46 47 48 49 50 51 52 53 54
 * @GST_VAAPI_DECODER_UNIT_FLAG_SKIP: marks the unit as unused/skipped.
 *
 * Flags for #GstVaapiDecoderUnit.
 */
typedef enum {
    GST_VAAPI_DECODER_UNIT_FLAG_FRAME_START = (1 << 0),
    GST_VAAPI_DECODER_UNIT_FLAG_FRAME_END   = (1 << 1),
    GST_VAAPI_DECODER_UNIT_FLAG_STREAM_END  = (1 << 2),
    GST_VAAPI_DECODER_UNIT_FLAG_SLICE       = (1 << 3),
    GST_VAAPI_DECODER_UNIT_FLAG_SKIP        = (1 << 4),
    GST_VAAPI_DECODER_UNIT_FLAG_LAST        = (1 << 5)
} GstVaapiDecoderUnitFlags;

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
/**
 * GST_VAAPI_DECODER_UNIT_FLAGS:
 * @unit: a #GstVaapiDecoderUnit
 *
 * The entire set of flags for the @unit
 */
#define GST_VAAPI_DECODER_UNIT_FLAGS(unit) \
    ((unit)->flags)

/**
 * GST_VAAPI_DECODER_UNIT_FLAG_IS_SET:
 * @unit: a #GstVaapiDecoderUnit
 * @flag: a flag to check for
 *
 * Checks whether the given @flag is set
 */
#define GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit, flag) \
    ((GST_VAAPI_DECODER_UNIT_FLAGS(unit) & (flag)) != 0)

/**
 * GST_VAAPI_DECODER_UNIT_FLAG_SET:
 * @unit: a #GstVaapiDecoderUnit
 * @flags: flags to set
 *
 * This macro sets the given bits
 */
#define GST_VAAPI_DECODER_UNIT_FLAG_SET(unit, flags) \
    (GST_VAAPI_DECODER_UNIT_FLAGS(unit) |= (flags))

/**
 * GST_VAAPI_DECODER_UNIT_FLAG_UNSET:
 * @unit: a #GstVaapiDecoderUnit
 * @flags: flags to unset
 *
 * This macro unsets the given bits.
 */
#define GST_VAAPI_DECODER_UNIT_FLAG_UNSET(unit, flags) \
    (GST_VAAPI_DECODER_UNIT_FLAGS(unit) &= ~(flags))
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

/**
 * GST_VAAPI_DECODER_UNIT_IS_FRAME_START:
 * @unit: a #GstVaapiDecoderUnit
 *
 * Tests if the decoder unit marks the start of a frame.
 *
 * The start of a frame is codec dependent but it may include any new
 * sequence header.
 */
#define GST_VAAPI_DECODER_UNIT_IS_FRAME_START(unit) \
    (GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit,   \
        GST_VAAPI_DECODER_UNIT_FLAG_FRAME_START))

/**
 * GST_VAAPI_DECODER_UNIT_IS_FRAME_END:
 * @unit: a #GstVaapiDecoderUnit
 *
 * Tests if the decoder unit marks the end of a frame.
 *
 * The end of a frame is codec dependent but it is usually represented
 * by the last bitstream chunk that holds valid slice data.
 */
#define GST_VAAPI_DECODER_UNIT_IS_FRAME_END(unit) \
    (GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit,   \
        GST_VAAPI_DECODER_UNIT_FLAG_FRAME_END))

/**
 * GST_VAAPI_DECODER_UNIT_IS_STREAM_END:
 * @unit: a #GstVaapiDecoderUnit
 *
 * Tests if the decoder unit marks the end of the stream.
 */
#define GST_VAAPI_DECODER_UNIT_IS_STREAM_END(unit) \
    (GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit,   \
        GST_VAAPI_DECODER_UNIT_FLAG_STREAM_END))

/**
 * GST_VAAPI_DECODER_UNIT_IS_SLICE:
 * @unit: a #GstVaapiDecoderUnit
 *
 * Tests if the decoder unit contains slice data.
 */
#define GST_VAAPI_DECODER_UNIT_IS_SLICE(unit) \
    (GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit,   \
        GST_VAAPI_DECODER_UNIT_FLAG_SLICE))

/**
 * GST_VAAPI_DECODER_UNIT_IS_SKIPPED:
 * @unit: a #GstVaapiDecoderUnit
 *
 * Tests if the decoder unit is not needed for decoding an can be skipped.
 * i.e. #GstVaapiDecoder sub-classes won't see this chunk of bitstream
 * data.
 */
#define GST_VAAPI_DECODER_UNIT_IS_SKIPPED(unit) \
    (GST_VAAPI_DECODER_UNIT_FLAG_IS_SET(unit,   \
        GST_VAAPI_DECODER_UNIT_FLAG_SKIP))

/**
 * GstVaapiDecoderUnit:
 * @size: size in bytes of this bitstream unit
 * @offset: relative offset in bytes to bitstream unit within the
 *    associated #GstVideoCodecFrame input_buffer
 * @parsed_info: parser-specific data (this is codec specific)
 * @parsed_info_destroy_notify: function used to release @parsed_info data
 *
 * A chunk of bitstream data that was parsed.
 */
struct _GstVaapiDecoderUnit {
163
    guint               flags;
164 165 166 167 168 169 170 171
    guint               size;
    guint               offset;
    gpointer            parsed_info;
    GDestroyNotify      parsed_info_destroy_notify;
};

G_GNUC_INTERNAL
void
172
gst_vaapi_decoder_unit_init(GstVaapiDecoderUnit *unit);
173 174 175

G_GNUC_INTERNAL
void
176
gst_vaapi_decoder_unit_clear(GstVaapiDecoderUnit *unit);
177 178 179

G_GNUC_INTERNAL
GstVaapiDecoderUnit *
180
gst_vaapi_decoder_unit_new(void);
181 182 183 184 185 186 187 188 189

G_GNUC_INTERNAL
void
gst_vaapi_decoder_unit_set_parsed_info(GstVaapiDecoderUnit *unit,
    gpointer parsed_info, GDestroyNotify destroy_notify);

G_END_DECLS

#endif /* GST_VAAPI_DECODER_UNIT_H */