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 } GstMsdkVppFlags;
72 
73 struct _GstMsdkVPP
74 {
75   GstBaseTransform element;
76 
77   /* sinkpad info */
78   GstPad *sinkpad;
79   GstVideoInfo sinkpad_info;
80   GstVideoInfo sinkpad_buffer_pool_info;
81   GstBufferPool *sinkpad_buffer_pool;
82 
83   /* srcpad info */
84   GstPad *srcpad;
85   GstVideoInfo srcpad_info;
86   GstVideoInfo srcpad_buffer_pool_info;
87   GstBufferPool *srcpad_buffer_pool;
88 
89   /* MFX context */
90   GstMsdkContext *context;
91   mfxVideoParam param;
92   guint in_num_surfaces;
93   guint out_num_surfaces;
94   mfxFrameAllocResponse in_alloc_resp;
95   mfxFrameAllocResponse out_alloc_resp;
96 
97   gboolean initialized;
98   gboolean use_video_memory;
99   gboolean use_sinkpad_dmabuf;
100   gboolean use_srcpad_dmabuf;
101   gboolean shared_context;
102   gboolean add_video_meta;
103   gboolean need_vpp;
104   guint flags;
105 
106   /* element properties */
107   gboolean hardware;
108   guint async_depth;
109   guint denoise_factor;
110   guint rotation;
111   guint deinterlace_mode;
112   guint deinterlace_method;
113   gfloat hue;
114   gfloat saturation;
115   gfloat brightness;
116   gfloat contrast;
117   guint detail;
118   guint mirroring;
119   guint scaling_mode;
120   gboolean keep_aspect;
121   guint frc_algm;
122 
123   GstClockTime buffer_duration;
124 
125   /* MFX Filters */
126   mfxExtVPPDoUse mfx_vpp_douse;
127   mfxExtVPPDenoise mfx_denoise;
128   mfxExtVPPRotation mfx_rotation;
129   mfxExtVPPDeinterlacing mfx_deinterlace;
130   mfxExtVPPProcAmp mfx_procamp;
131   mfxExtVPPDetail mfx_detail;
132   mfxExtVPPMirroring mfx_mirroring;
133   mfxExtVPPScaling mfx_scaling;
134   mfxExtVPPFrameRateConversion mfx_frc;
135 
136   /* Extended buffers */
137   mfxExtBuffer *extra_params[MAX_EXTRA_PARAMS];
138   guint num_extra_params;
139 };
140 
141 struct _GstMsdkVPPClass
142 {
143   GstBaseTransformClass parent_class;
144 };
145 
146 GType gst_msdkvpp_get_type (void);
147 
148 G_END_DECLS
149 
150 #endif /* __GST_MSDKVPP_H__ */
151