gstvaapifilter.h 7.09 KB
Newer Older
1 2 3 4
/*
 *  gstvaapifilter.h - Video processing abstraction
 *
 *  Copyright (C) 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
 *
 *  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_FILTER_H
#define GST_VAAPI_FILTER_H

#include <gst/vaapi/gstvaapisurface.h>
#include <gst/vaapi/video-format.h>

G_BEGIN_DECLS

typedef struct _GstVaapiFilter                  GstVaapiFilter;
typedef struct _GstVaapiFilterOpInfo            GstVaapiFilterOpInfo;

/**
 * @GST_VAAPI_FILTER_OP_FORMAT: Force output pixel format (#GstVideoFormat).
36
 * @GST_VAAPI_FILTER_OP_CROP: Crop source surface (#GstVaapiRectangle).
37
 * @GST_VAAPI_FILTER_OP_DENOISE: Noise reduction (float).
38
 * @GST_VAAPI_FILTER_OP_SHARPEN: Sharpening (float).
39 40 41 42
 * @GST_VAAPI_FILTER_OP_HUE: Change color hue (float).
 * @GST_VAAPI_FILTER_OP_SATURATION: Change saturation (float).
 * @GST_VAAPI_FILTER_OP_BRIGHTNESS: Change brightness (float).
 * @GST_VAAPI_FILTER_OP_CONTRAST: Change contrast (float).
43 44 45 46 47
 *
 * The set of operations that could be applied to the filter.
 */
typedef enum {
    GST_VAAPI_FILTER_OP_FORMAT = 1,
48
    GST_VAAPI_FILTER_OP_CROP,
49
    GST_VAAPI_FILTER_OP_DENOISE,
50
    GST_VAAPI_FILTER_OP_SHARPEN,
51 52 53 54
    GST_VAAPI_FILTER_OP_HUE,
    GST_VAAPI_FILTER_OP_SATURATION,
    GST_VAAPI_FILTER_OP_BRIGHTNESS,
    GST_VAAPI_FILTER_OP_CONTRAST,
55
    GST_VAAPI_FILTER_OP_DEINTERLACING,
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
} GstVaapiFilterOp;

/**
 * GstVaapiFilterOpInfo:
 * @operation: the #GstVaapiFilterOp
 * @pspec: the #GParamSpec describing the associated configurable value
 *
 * A #GstVaapiFilterOp descriptor.
 */
struct _GstVaapiFilterOpInfo {
    const GstVaapiFilterOp      op;
    GParamSpec * const          pspec;
};

/**
 * GstVaapiFilterStatus:
 * @GST_VAAPI_FILTER_STATUS_SUCCESS: Success.
 * @GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED: No memory left.
 * @GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED: Operation failed.
 * @GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER: Invalid parameter.
 * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION: Unsupported operation.
 * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT: Unsupported target format.
 *
 * Video processing status for gst_vaapi_filter_process().
 */
typedef enum {
    GST_VAAPI_FILTER_STATUS_SUCCESS = 0,
    GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED,
    GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED,
    GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER,
    GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION,
    GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT,
} GstVaapiFilterStatus;

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
/**
 * GstVaapiDeinterlaceMethod:
 * @GST_VAAPI_DEINTERLACE_METHOD_NONE: No deinterlacing.
 * @GST_VAAPI_DEINTERLACE_METHOD_BOB: Basic bob deinterlacing algorithm.
 * @GST_VAAPI_DEINTERLACE_METHOD_WEAVE: Weave deinterlacing algorithm.
 * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE: Motion adaptive
 *   deinterlacing algorithm.
 * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED: Motion compensated
 *   deinterlacing algorithm.
 *
 * Deinterlacing algorithms.
 */
typedef enum {
    GST_VAAPI_DEINTERLACE_METHOD_NONE,
    GST_VAAPI_DEINTERLACE_METHOD_BOB,
    GST_VAAPI_DEINTERLACE_METHOD_WEAVE,
    GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE,
    GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED,
} GstVaapiDeinterlaceMethod;

/**
 * GstVaapiDeinterlaceFlags:
 * @GST_VAAPI_DEINTERLACE_FLAG_TFF: Top-field first. If this flag is
113 114 115
 *   not set, then bottom-field first order is assumed. Note: this
 *   only affects the way reference frames are organized for advanced
 *   deinterlacing modes.
116 117
 * @GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD: The input frame represents a
 *   single field. If this flag is not set, then the whole frame holds
118 119 120 121 122
 *   two interleaved fields.
 * @GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD: The top field of the input
 *   frame is to be used for deinterlacing. Otherwise, if this flag is
 *   not set, then the bottom field of the input frame will be used
 *   for deinterlacing.
123 124 125 126 127 128
 *
 * The set of gst_vaapi_filter_set_deinterlacing() flags.
 */
typedef enum {
    GST_VAAPI_DEINTERLACE_FLAG_TFF      = 1 << 31,
    GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD = 1 << 30,
129
    GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD = 1 << 29,
130 131 132 133 134 135 136 137 138 139 140 141 142 143
} GstVaapiDeinterlaceFlags;

#define GST_VAAPI_TYPE_DEINTERLACE_METHOD \
    gst_vaapi_deinterlace_method_get_type()

#define GST_VAAPI_TYPE_DEINTERLACE_FLAGS \
    gst_vaapi_deinterlace_flags_get_type()

GType
gst_vaapi_deinterlace_method_get_type(void) G_GNUC_CONST;

GType
gst_vaapi_deinterlace_flags_get_type(void) G_GNUC_CONST;

144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
GstVaapiFilter *
gst_vaapi_filter_new(GstVaapiDisplay *display);

GstVaapiFilter *
gst_vaapi_filter_ref(GstVaapiFilter *filter);

void
gst_vaapi_filter_unref(GstVaapiFilter *filter);

void
gst_vaapi_filter_replace(GstVaapiFilter **old_filter_ptr,
    GstVaapiFilter *new_filter);

GPtrArray *
gst_vaapi_filter_get_operations(GstVaapiFilter *filter);

160 161 162 163 164 165
gboolean
gst_vaapi_filter_has_operation(GstVaapiFilter *filter, GstVaapiFilterOp op);

gboolean
gst_vaapi_filter_use_operation(GstVaapiFilter *filter, GstVaapiFilterOp op);

166 167 168 169 170 171 172 173 174 175 176 177 178 179
gboolean
gst_vaapi_filter_set_operation(GstVaapiFilter *filter, GstVaapiFilterOp op,
    const GValue *value);

GstVaapiFilterStatus
gst_vaapi_filter_process(GstVaapiFilter *filter, GstVaapiSurface *src_surface,
    GstVaapiSurface *dst_surface, guint flags);

GArray *
gst_vaapi_filter_get_formats(GstVaapiFilter *filter);

gboolean
gst_vaapi_filter_set_format(GstVaapiFilter *filter, GstVideoFormat format);

180 181 182 183
gboolean
gst_vaapi_filter_set_cropping_rectangle(GstVaapiFilter *filter,
    const GstVaapiRectangle *rect);

184 185 186 187
gboolean
gst_vaapi_filter_set_target_rectangle(GstVaapiFilter *filter,
    const GstVaapiRectangle *rect);

188 189 190
gboolean
gst_vaapi_filter_set_denoising_level(GstVaapiFilter *filter, gfloat level);

191 192 193
gboolean
gst_vaapi_filter_set_sharpening_level(GstVaapiFilter *filter, gfloat level);

194 195 196 197 198 199 200 201 202 203 204 205
gboolean
gst_vaapi_filter_set_hue(GstVaapiFilter *filter, gfloat value);

gboolean
gst_vaapi_filter_set_saturation(GstVaapiFilter *filter, gfloat value);

gboolean
gst_vaapi_filter_set_brightness(GstVaapiFilter *filter, gfloat value);

gboolean
gst_vaapi_filter_set_contrast(GstVaapiFilter *filter, gfloat value);

206 207 208 209
gboolean
gst_vaapi_filter_set_deinterlacing(GstVaapiFilter *filter,
    GstVaapiDeinterlaceMethod method, guint flags);

210 211 212 213 214
gboolean
gst_vaapi_filter_set_deinterlacing_references(GstVaapiFilter *filter,
    GstVaapiSurface **forward_references, guint num_forward_references,
    GstVaapiSurface **backward_references, guint num_backward_references);

215
#endif /* GST_VAAPI_FILTER_H */