1 /* GStreamer 2 * Copyright (C) 2020 Igalia, S.L. 3 * Author: Víctor Jáquez <vjaquez@igalia.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #pragma once 22 23 #include <gst/va/gstvadisplay.h> 24 #include <gst/video/video.h> 25 26 #include <va/va.h> 27 #include <va/va_vpp.h> 28 29 G_BEGIN_DECLS 30 31 #define GST_TYPE_VA_FILTER (gst_va_filter_get_type()) 32 G_DECLARE_FINAL_TYPE (GstVaFilter, gst_va_filter, GST, VA_FILTER, GstObject) 33 34 typedef enum { 35 GST_VA_DEINTERLACE_BOB = VAProcDeinterlacingBob, 36 GST_VA_DEINTERLACE_WEAVE = VAProcDeinterlacingWeave, 37 GST_VA_DEINTERLACE_ADAPTIVE = VAProcDeinterlacingMotionAdaptive, 38 GST_VA_DEINTERLACE_COMPENSATED = VAProcDeinterlacingMotionCompensated, 39 } GstVaDeinterlaceMethods; 40 41 enum { 42 GST_VA_FILTER_PROP_DENOISE = 1, 43 GST_VA_FILTER_PROP_SHARPEN, 44 GST_VA_FILTER_PROP_SKINTONE, 45 GST_VA_FILTER_PROP_VIDEO_DIR, 46 GST_VA_FILTER_PROP_HUE, 47 GST_VA_FILTER_PROP_SATURATION, 48 GST_VA_FILTER_PROP_BRIGHTNESS, 49 GST_VA_FILTER_PROP_CONTRAST, 50 GST_VA_FILTER_PROP_AUTO_SATURATION, 51 GST_VA_FILTER_PROP_AUTO_BRIGHTNESS, 52 GST_VA_FILTER_PROP_AUTO_CONTRAST, 53 GST_VA_FILTER_PROP_DISABLE_PASSTHROUGH, 54 GST_VA_FILTER_PROP_DEINTERLACE_METHOD, 55 GST_VA_FILTER_PROP_ADD_BORDERS, 56 GST_VA_FILTER_PROP_LAST 57 }; 58 59 typedef struct _GstVaSample GstVaSample; 60 struct _GstVaSample 61 { 62 GstBuffer *buffer; 63 guint32 flags; 64 65 /* references for (de)interlacing */ 66 VASurfaceID *forward_references; 67 guint num_forward_references; 68 VASurfaceID *backward_references; 69 guint num_backward_references; 70 71 /* borders to preserve dar */ 72 gint borders_h; 73 gint borders_w; 74 75 /*< private >*/ 76 VASurfaceID surface; 77 VARectangle rect; 78 }; 79 80 GstVaFilter * gst_va_filter_new (GstVaDisplay * display); 81 gboolean gst_va_filter_open (GstVaFilter * self); 82 gboolean gst_va_filter_close (GstVaFilter * self); 83 gboolean gst_va_filter_is_open (GstVaFilter * self); 84 gboolean gst_va_filter_has_filter (GstVaFilter * self, 85 VAProcFilterType type); 86 gboolean gst_va_filter_install_properties (GstVaFilter * self, 87 GObjectClass * klass); 88 gboolean gst_va_filter_install_deinterlace_properties 89 (GstVaFilter * self, 90 GObjectClass * klass); 91 gboolean gst_va_filter_set_orientation (GstVaFilter * self, 92 GstVideoOrientationMethod orientation); 93 GstVideoOrientationMethod gst_va_filter_get_orientation (GstVaFilter * self); 94 void gst_va_filter_enable_cropping (GstVaFilter * self, 95 gboolean cropping); 96 const gpointer gst_va_filter_get_filter_caps (GstVaFilter * self, 97 VAProcFilterType type, 98 guint * num_caps); 99 guint32 gst_va_filter_get_mem_types (GstVaFilter * self); 100 GArray * gst_va_filter_get_surface_formats (GstVaFilter * self); 101 GstCaps * gst_va_filter_get_caps (GstVaFilter * self); 102 gboolean gst_va_filter_set_video_info (GstVaFilter * self, 103 GstVideoInfo * in_info, 104 GstVideoInfo * out_info); 105 gboolean gst_va_filter_add_filter_buffer (GstVaFilter * self, 106 gpointer data, 107 gsize size, 108 guint num); 109 gboolean gst_va_filter_add_deinterlace_buffer(GstVaFilter * self, 110 VAProcDeinterlacingType method, 111 guint32 * forward, 112 guint32 * backward); 113 gboolean gst_va_filter_drop_filter_buffers (GstVaFilter * self); 114 gboolean gst_va_filter_process (GstVaFilter * self, 115 GstVaSample * src, 116 GstVaSample * dest); 117 118 guint32 gst_va_buffer_get_surface_flags (GstBuffer * buffer, 119 GstVideoInfo * info); 120 121 gboolean gst_va_filter_has_video_format (GstVaFilter * self, 122 GstVideoFormat format, 123 GstCapsFeatures * feature); 124 125 G_END_DECLS 126