• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer Intel MSDK plugin
2  * Copyright (c) 2018, Intel Corporation, Inc.
3  * Author : Sreerenj Balachandran <sreerenj.balachandran@intel.com>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  *    this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef __GST_MSDKVPP_H__
34 #define __GST_MSDKVPP_H__
35 
36 #include "gstmsdkcontext.h"
37 #include "msdk-enums.h"
38 #include <gst/base/gstbasetransform.h>
39 G_BEGIN_DECLS
40 
41 #define GST_TYPE_MSDKVPP \
42   (gst_msdkvpp_get_type())
43 #define GST_MSDKVPP(obj) \
44   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MSDKVPP,GstMsdkVPP))
45 #define GST_MSDKVPP_CLASS(klass) \
46   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MSDKVPP,GstMsdkVPPClass))
47 #define GST_MSDKVPP_GET_CLASS(obj) \
48   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_MSDKVPP,GstMsdkVPPClass))
49 #define GST_IS_MSDKVPP(obj) \
50   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MSDKVPP))
51 #define GST_IS_MSDKVPP_CLASS(klass) \
52   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MSDKVPP))
53 
54 #define MAX_EXTRA_PARAMS                 8
55 
56 typedef struct _GstMsdkVPP GstMsdkVPP;
57 typedef struct _GstMsdkVPPClass GstMsdkVPPClass;
58 
59 typedef enum {
60   GST_MSDK_FLAG_DENOISE      = 1 << 0,
61   GST_MSDK_FLAG_ROTATION     = 1 << 1,
62   GST_MSDK_FLAG_DEINTERLACE  = 1 << 2,
63   GST_MSDK_FLAG_HUE          = 1 << 3,
64   GST_MSDK_FLAG_SATURATION   = 1 << 4,
65   GST_MSDK_FLAG_BRIGHTNESS   = 1 << 5,
66   GST_MSDK_FLAG_CONTRAST     = 1 << 6,
67   GST_MSDK_FLAG_DETAIL       = 1 << 7,
68   GST_MSDK_FLAG_MIRRORING    = 1 << 8,
69   GST_MSDK_FLAG_SCALING_MODE = 1 << 9,
70   GST_MSDK_FLAG_FRC          = 1 << 10,
71   GST_MSDK_FLAG_VIDEO_DIRECTION = 1 << 11,
72 } GstMsdkVppFlags;
73 
74 struct _GstMsdkVPP
75 {
76   GstBaseTransform element;
77 
78   /* sinkpad info */
79   GstPad *sinkpad;
80   GstVideoInfo sinkpad_info;
81   GstVideoInfo sinkpad_buffer_pool_info;
82   GstBufferPool *sinkpad_buffer_pool;
83 
84   /* srcpad info */
85   GstPad *srcpad;
86   GstVideoInfo srcpad_info;
87   GstVideoInfo srcpad_buffer_pool_info;
88   GstBufferPool *srcpad_buffer_pool;
89 
90   /* MFX context */
91   GstMsdkContext *context;
92   GstMsdkContext *old_context;
93   mfxVideoParam param;
94   guint in_num_surfaces;
95   mfxFrameAllocResponse in_alloc_resp;
96   mfxFrameAllocResponse out_alloc_resp;
97 
98   gboolean initialized;
99   gboolean use_video_memory;
100   gboolean use_sinkpad_dmabuf;
101   gboolean use_srcpad_dmabuf;
102   gboolean shared_context;
103   gboolean add_video_meta;
104   gboolean need_vpp;
105   guint flags;
106 
107   /* element properties */
108   gboolean hardware;
109   guint async_depth;
110   guint denoise_factor;
111   guint rotation;
112   guint deinterlace_mode;
113   guint deinterlace_method;
114   gfloat hue;
115   gfloat saturation;
116   gfloat brightness;
117   gfloat contrast;
118   guint detail;
119   guint mirroring;
120   guint scaling_mode;
121   gboolean keep_aspect;
122   guint frc_algm;
123   guint video_direction;
124   guint crop_left;
125   guint crop_right;
126   guint crop_top;
127   guint crop_bottom;
128 
129   GstClockTime buffer_duration;
130 
131   /* MFX Filters */
132   mfxExtVPPDoUse mfx_vpp_douse;
133   mfxExtVPPDenoise mfx_denoise;
134   mfxExtVPPRotation mfx_rotation;
135   mfxExtVPPDeinterlacing mfx_deinterlace;
136   mfxExtVPPProcAmp mfx_procamp;
137   mfxExtVPPDetail mfx_detail;
138   mfxExtVPPMirroring mfx_mirroring;
139   mfxExtVPPScaling mfx_scaling;
140   mfxExtVPPFrameRateConversion mfx_frc;
141 
142   /* Extended buffers */
143   mfxExtBuffer *extra_params[MAX_EXTRA_PARAMS];
144   guint num_extra_params;
145 
146   mfxFrameAllocRequest request[2];
147   GList* locked_in_surfaces;
148   GList* locked_out_surfaces;
149 };
150 
151 struct _GstMsdkVPPClass
152 {
153   GstBaseTransformClass parent_class;
154 };
155 
156 GType gst_msdkvpp_get_type (void);
157 
158 G_END_DECLS
159 
160 #endif /* __GST_MSDKVPP_H__ */
161