summarylogtreecommitdiffstats
path: root/video_filter_opencv_Fix_compilation.patch
blob: 0f3e9934dda9857e0f420eae250fcff44cd0da42 (plain)
1
2
3
4
5
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

 modules/video_filter/opencv_wrapper.c | 108 +++++++++++++-------------
 1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/modules/video_filter/opencv_wrapper.c b/modules/video_filter/opencv_wrapper.c
index ed48fe1f67..6560502fa6 100644
--- a/modules/video_filter/opencv_wrapper.c
+++ b/modules/video_filter/opencv_wrapper.c
@@ -158,6 +158,8 @@ static int Create( vlc_object_t *p_this )
     if( p_filter->p_sys == NULL )
         return VLC_ENOMEM;
 
+    filter_sys_t *p_sys = p_filter->p_sys;
+
     /* Load the internal OpenCV filter.
      *
      * This filter object is needed to call the internal OpenCV filter
@@ -167,39 +169,39 @@ static int Create( vlc_object_t *p_this )
      * We don't need to set up video formats for this filter as it not
      * actually using a picture_t.
      */
-    p_filter->p_sys->p_opencv = vlc_object_create( p_filter, sizeof(filter_t) );
-    if( !p_filter->p_sys->p_opencv ) {
-        free( p_filter->p_sys );
+    p_sys->p_opencv = vlc_object_create( p_filter, sizeof(filter_t) );
+    if( !p_sys->p_opencv ) {
+        free( p_sys );
         return VLC_ENOMEM;
     }
 
-    p_filter->p_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
-    if( p_filter->p_sys->psz_inner_name )
-        p_filter->p_sys->p_opencv->p_module =
-            module_need( p_filter->p_sys->p_opencv,
+    p_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
+    if( p_sys->psz_inner_name )
+        p_sys->p_opencv->p_module =
+            module_need( p_sys->p_opencv,
                          "opencv internal filter",
-                         p_filter->p_sys->psz_inner_name,
+                         p_sys->psz_inner_name,
                          true );
 
-    if( !p_filter->p_sys->p_opencv->p_module )
+    if( !p_sys->p_opencv->p_module )
     {
-        msg_Err( p_filter, "can't open internal opencv filter: %s", p_filter->p_sys->psz_inner_name );
-        free( p_filter->p_sys->psz_inner_name );
-        p_filter->p_sys->psz_inner_name = NULL;
-        vlc_object_release( p_filter->p_sys->p_opencv );
-        free( p_filter->p_sys );
+        msg_Err( p_filter, "can't open internal opencv filter: %s", p_sys->psz_inner_name );
+        free( p_sys->psz_inner_name );
+        p_sys->psz_inner_name = NULL;
+        vlc_object_release( p_sys->p_opencv );
+        free( p_sys );
 
         return VLC_ENOMOD;
     }
 
 
     /* Init structure */
-    p_filter->p_sys->p_image = image_HandlerCreate( p_filter );
+    p_sys->p_image = image_HandlerCreate( p_filter );
     for( int i = 0; i < VOUT_MAX_PLANES; i++ )
-        p_filter->p_sys->p_cv_image[i] = NULL;
-    p_filter->p_sys->p_proc_image = NULL;
-    p_filter->p_sys->p_to_be_freed = NULL;
-    p_filter->p_sys->i_cv_image_size = 0;
+        p_sys->p_cv_image[i] = NULL;
+    p_sys->p_proc_image = NULL;
+    p_sys->p_to_be_freed = NULL;
+    p_sys->i_cv_image_size = 0;
 
     /* Retrieve and apply config */
     psz_chroma = var_InheritString( p_filter, "opencv-chroma" );
@@ -207,16 +209,16 @@ static int Create( vlc_object_t *p_this )
     {
         msg_Err( p_filter, "configuration variable %s empty, using 'grey'",
                          "opencv-chroma" );
-        p_filter->p_sys->i_internal_chroma = GREY;
+        p_sys->i_internal_chroma = GREY;
     } else if( !strcmp( psz_chroma, "input" ) )
-        p_filter->p_sys->i_internal_chroma = CINPUT;
+        p_sys->i_internal_chroma = CINPUT;
     else if( !strcmp( psz_chroma, "I420" ) )
-        p_filter->p_sys->i_internal_chroma = GREY;
+        p_sys->i_internal_chroma = GREY;
     else if( !strcmp( psz_chroma, "RGB32" ) )
-        p_filter->p_sys->i_internal_chroma = RGB;
+        p_sys->i_internal_chroma = RGB;
     else {
         msg_Err( p_filter, "no valid opencv-chroma provided, using 'grey'" );
-        p_filter->p_sys->i_internal_chroma = GREY;
+        p_sys->i_internal_chroma = GREY;
     }
 
     free( psz_chroma );
@@ -226,28 +228,28 @@ static int Create( vlc_object_t *p_this )
     {
         msg_Err( p_filter, "configuration variable %s empty, using 'input'",
                          "opencv-output" );
-        p_filter->p_sys->i_wrapper_output = VINPUT;
+        p_sys->i_wrapper_output = VINPUT;
     } else if( !strcmp( psz_output, "none" ) )
-        p_filter->p_sys->i_wrapper_output = NONE;
+        p_sys->i_wrapper_output = NONE;
     else if( !strcmp( psz_output, "input" ) )
-        p_filter->p_sys->i_wrapper_output = VINPUT;
+        p_sys->i_wrapper_output = VINPUT;
     else if( !strcmp( psz_output, "processed" ) )
-        p_filter->p_sys->i_wrapper_output = PROCESSED;
+        p_sys->i_wrapper_output = PROCESSED;
     else {
         msg_Err( p_filter, "no valid opencv-output provided, using 'input'" );
-        p_filter->p_sys->i_wrapper_output = VINPUT;
+        p_sys->i_wrapper_output = VINPUT;
     }
     free( psz_output );
 
-    p_filter->p_sys->f_scale =
+    p_sys->f_scale =
         var_InheritFloat( p_filter, "opencv-scale" );
 
     msg_Info(p_filter, "Configuration: opencv-scale: %f, opencv-chroma: %d, "
         "opencv-output: %d, opencv-filter %s",
-        p_filter->p_sys->f_scale,
-        p_filter->p_sys->i_internal_chroma,
-        p_filter->p_sys->i_wrapper_output,
-        p_filter->p_sys->psz_inner_name);
+        p_sys->f_scale,
+        p_sys->i_internal_chroma,
+        p_sys->i_wrapper_output,
+        p_sys->psz_inner_name);
 
 #ifndef NDEBUG
     msg_Dbg( p_filter, "opencv_wrapper successfully started" );
@@ -266,14 +268,15 @@ static int Create( vlc_object_t *p_this )
 static void Destroy( vlc_object_t *p_this )
 {
     filter_t* p_filter = (filter_t*)p_this;
+    filter_sys_t* p_sys = p_filter->p_sys;
     ReleaseImages( p_filter );
 
     // Release the internal OpenCV filter.
-    module_unneed( p_filter->p_sys->p_opencv, p_filter->p_sys->p_opencv->p_module );
-    vlc_object_release( p_filter->p_sys->p_opencv );
-    p_filter->p_sys->p_opencv = NULL;
+    module_unneed( p_sys->p_opencv, p_sys->p_opencv->p_module );
+    vlc_object_release( p_sys->p_opencv );
+    p_sys->p_opencv = NULL;
 
-    free( p_filter->p_sys );
+    free( p_sys );
 }
 
 /*****************************************************************************
@@ -403,6 +406,7 @@ static void VlcPictureToIplImage( filter_t* p_filter, picture_t* p_in )
  *****************************************************************************/
 static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
 {
+    filter_sys_t* p_sys = p_filter->p_sys;
     picture_t* p_outpic = filter_NewPicture( p_filter );
     if( p_outpic == NULL ) {
         msg_Err( p_filter, "couldn't get a p_outpic!" );
@@ -413,20 +417,20 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
     video_format_t fmt_out;
 
     // Make a copy if we want to show the original input
-    if (p_filter->p_sys->i_wrapper_output == VINPUT)
+    if (p_sys->i_wrapper_output == VINPUT)
         picture_Copy( p_outpic, p_pic );
 
     VlcPictureToIplImage( p_filter, p_pic );
     // Pass the image (as a pointer to the first IplImage*) to the
     // internal OpenCV filter for processing.
-    p_filter->p_sys->p_opencv->pf_video_filter( p_filter->p_sys->p_opencv, (picture_t*)&(p_filter->p_sys->p_cv_image[0]) );
+    p_sys->p_opencv->pf_video_filter( p_sys->p_opencv, (picture_t*)&(p_sys->p_cv_image[0]) );
 
-    if(p_filter->p_sys->i_wrapper_output == PROCESSED) {
+    if(p_sys->i_wrapper_output == PROCESSED) {
         // Processed video
-        if( (p_filter->p_sys->p_proc_image) &&
-            (p_filter->p_sys->p_proc_image->i_planes > 0) &&
-            (p_filter->p_sys->i_internal_chroma != CINPUT) ) {
-            //p_filter->p_sys->p_proc_image->format.i_chroma = VLC_CODEC_RGB24;
+        if( (p_sys->p_proc_image) &&
+            (p_sys->p_proc_image->i_planes > 0) &&
+            (p_sys->i_internal_chroma != CINPUT) ) {
+            //p_sys->p_proc_image->format.i_chroma = VLC_CODEC_RGB24;
 
             memset( &fmt_out, 0, sizeof(video_format_t) );
             fmt_out = p_pic->format;
@@ -438,16 +442,16 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
              * main video output error: pictures leaked, trying to workaround
              */
             picture_t* p_outpic_tmp = image_Convert(
-                        p_filter->p_sys->p_image,
-                        p_filter->p_sys->p_proc_image,
-                        &(p_filter->p_sys->p_proc_image->format),
+                        p_sys->p_image,
+                        p_sys->p_proc_image,
+                        &(p_sys->p_proc_image->format),
                         &fmt_out );
 
             picture_CopyPixels( p_outpic, p_outpic_tmp );
             CopyInfoAndRelease( p_outpic, p_outpic_tmp );
-        } else if( p_filter->p_sys->i_internal_chroma == CINPUT ) {
-            picture_CopyPixels( p_outpic, p_filter->p_sys->p_proc_image );
-            picture_CopyProperties( p_outpic, p_filter->p_sys->p_proc_image );
+        } else if( p_sys->i_internal_chroma == CINPUT ) {
+            picture_CopyPixels( p_outpic, p_sys->p_proc_image );
+            picture_CopyProperties( p_outpic, p_sys->p_proc_image );
         }
     }
 
@@ -458,7 +462,7 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
     msg_Dbg( p_filter, "Filter() done" );
 #endif
 
-    if( p_filter->p_sys->i_wrapper_output != NONE ) {
+    if( p_sys->i_wrapper_output != NONE ) {
         return p_outpic;
     } else { // NONE
         picture_Release( p_outpic );
-- 
2.17.0