13
13
#include "libavutil/avassert.h"
14
14
#include "libavutil/avstring.h"
15
15
#include "libavutil/imgutils.h"
16
+ #include "libavutil/intreadwrite.h"
16
17
#include "libavutil/opt.h"
17
18
#include "libavutil/parseutils.h"
18
19
#include "video.h"
@@ -21,6 +22,7 @@ typedef struct {
21
22
const AVClass * class ;
22
23
char * filter_path ;
23
24
char * config ;
25
+ int clear ;
24
26
void * handle ;
25
27
void * user_data ;
26
28
int (* filter_init )(const char * , void * * );
@@ -109,6 +111,14 @@ static int query_formats(AVFilterContext* ctx) {
109
111
return ff_set_common_formats (ctx , fmts_list );
110
112
}
111
113
114
+ static void clear_image (AVFrame * out ) {
115
+ for (int i = 0 ; i < out -> height ; i ++ ) {
116
+ for (int j = 0 ; j < out -> width ; j ++ ) {
117
+ AV_WN32 (out -> data [0 ] + i * out -> linesize [0 ] + j * 4 , 0 );
118
+ }
119
+ }
120
+ }
121
+
112
122
static int filter_frame (AVFilterLink * inlink , AVFrame * in ) {
113
123
AVFilterContext * ctx = inlink -> dst ;
114
124
AVFilterLink * outlink = ctx -> outputs [0 ];
@@ -139,6 +149,10 @@ static int filter_frame(AVFilterLink* inlink, AVFrame* in) {
139
149
return data_size ;
140
150
}
141
151
152
+ if (pc -> clear ) {
153
+ clear_image (out );
154
+ }
155
+
142
156
double time_ms = in -> pts * av_q2d (inlink -> time_base ) * 1000 ;
143
157
144
158
int rc = pc -> filter_frame (out -> data [0 ], data_size , in -> width , in -> height ,
@@ -192,6 +206,14 @@ static const AVOption proxy_options[] = {
192
206
CHAR_MIN ,
193
207
CHAR_MAX ,
194
208
FLAGS },
209
+ {"clear" ,
210
+ "clear frame before filtering" ,
211
+ OFFSET (clear ),
212
+ AV_OPT_TYPE_BOOL ,
213
+ {.i64 = 0 },
214
+ 0 ,
215
+ 1 ,
216
+ FLAGS },
195
217
{NULL },
196
218
};
197
219
0 commit comments