Browse code

avfilter/tinterlace: use drawutils for pad mode

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Thomas Mundt <tmundt75@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>

Thomas Mundt authored on 2017/09/19 06:57:17
Showing 2 changed files
... ...
@@ -28,6 +28,7 @@
28 28
 #define AVFILTER_TINTERLACE_H
29 29
 
30 30
 #include "libavutil/opt.h"
31
+#include "drawutils.h"
31 32
 #include "avfilter.h"
32 33
 
33 34
 #define TINTERLACE_FLAG_VLPF 01
... ...
@@ -57,6 +58,8 @@ typedef struct TInterlaceContext {
57 57
     AVFrame *next;
58 58
     uint8_t *black_data[4];     ///< buffer used to fill padded lines
59 59
     int black_linesize[4];
60
+    FFDrawContext draw;
61
+    FFDrawColor color;
60 62
     void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp,
61 63
                          ptrdiff_t mref, ptrdiff_t pref);
62 64
 } TInterlaceContext;
... ...
@@ -156,21 +156,19 @@ static int config_out_props(AVFilterLink *outlink)
156 156
                                                 av_make_q(2, 1));
157 157
 
158 158
     if (tinterlace->mode == MODE_PAD) {
159
-        uint8_t black[4] = { 16, 128, 128, 16 };
160
-        int i, ret;
159
+        uint8_t black[4] = { 0, 0, 0, 16 };
160
+        int ret;
161
+        ff_draw_init(&tinterlace->draw, outlink->format, 0);
162
+        ff_draw_color(&tinterlace->draw, &tinterlace->color, black);
161 163
         if (ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts))
162
-            black[0] = black[3] = 0;
164
+            tinterlace->color.comp[0].u8[0] = 0;
163 165
         ret = av_image_alloc(tinterlace->black_data, tinterlace->black_linesize,
164 166
                              outlink->w, outlink->h, outlink->format, 16);
165 167
         if (ret < 0)
166 168
             return ret;
167 169
 
168
-        /* fill black picture with black */
169
-        for (i = 0; i < 4 && tinterlace->black_data[i]; i++) {
170
-            int h = i == 1 || i == 2 ? AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h) : outlink->h;
171
-            memset(tinterlace->black_data[i], black[i],
172
-                   tinterlace->black_linesize[i] * h);
173
-        }
170
+        ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, tinterlace->black_data,
171
+                          tinterlace->black_linesize, 0, 0, outlink->w, outlink->h);
174 172
     }
175 173
     if (tinterlace->flags & (TINTERLACE_FLAG_VLPF | TINTERLACE_FLAG_CVLPF)
176 174
             && !(tinterlace->mode == MODE_INTERLEAVE_TOP