From: Limin Wang <lance.lmw...@gmail.com>

---
 libavfilter/vf_overlay.c | 52 ++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index ba8147f579..ee51a54659 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -441,7 +441,8 @@ static av_always_inline void 
blend_slice_packed_rgb(AVFilterContext *ctx,
     }
 }
 
-static av_always_inline void blend_plane(AVFilterContext *ctx,                 
                                        \
+#define DEFINE_BLEND_PLANE(depth, nbits)                                       
                                        \
+static av_always_inline void 
blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx,                       
          \
                                          AVFrame *dst, const AVFrame *src,     
                                        \
                                          int src_w, int src_h,                 
                                        \
                                          int dst_w, int dst_h,                 
                                        \
@@ -549,8 +550,10 @@ static av_always_inline void blend_plane(AVFilterContext 
*ctx,
         dap += (1 << vsub) * dst->linesize[3];                                 
                                        \
     }                                                                          
                                        \
 }
+DEFINE_BLEND_PLANE(8, 8);
 
-static inline void alpha_composite(const AVFrame *src, const AVFrame *dst,     
                                        \
+#define DEFINE_ALPHA_COMPOSITE(depth, nbits)                                   
                                        \
+static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, 
const AVFrame *dst,                     \
                                    int src_w, int src_h,                       
                                        \
                                    int dst_w, int dst_h,                       
                                        \
                                    int x, int y,                               
                                        \
@@ -597,8 +600,10 @@ static inline void alpha_composite(const AVFrame *src, 
const AVFrame *dst,
         sa += src->linesize[3];                                                
                                        \
     }                                                                          
                                        \
 }
+DEFINE_ALPHA_COMPOSITE(8, 8);
 
-static av_always_inline void blend_slice_yuv(AVFilterContext *ctx,             
                                        \
+#define DEFINE_BLEND_SLICE_YUV(depth, nbits)                                   
                                        \
+static av_always_inline void 
blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,                   
          \
                                              AVFrame *dst, const AVFrame *src, 
                                        \
                                              int hsub, int vsub,               
                                        \
                                              int main_has_alpha,               
                                        \
@@ -612,19 +617,20 @@ static av_always_inline void 
blend_slice_yuv(AVFilterContext *ctx,
     const int dst_w = dst->width;                                              
                                        \
     const int dst_h = dst->height;                                             
                                        \
                                                                                
                                        \
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0,       0, x, 
y, main_has_alpha,                        \
+    blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, 
dst_h, 0, 0,       0, x, y, main_has_alpha,\
                 s->main_desc->comp[0].plane, s->main_desc->comp[0].offset, 
s->main_desc->comp[0].step, is_straight, 1, \
                 jobnr, nb_jobs);                                               
                                        \
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, vsub, x, 
y, main_has_alpha,                        \
+    blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, 
dst_h, 1, hsub, vsub, x, y, main_has_alpha,\
                 s->main_desc->comp[1].plane, s->main_desc->comp[1].offset, 
s->main_desc->comp[1].step, is_straight, 1, \
                 jobnr, nb_jobs);                                               
                                        \
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, vsub, x, 
y, main_has_alpha,                        \
+    blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, 
dst_h, 2, hsub, vsub, x, y, main_has_alpha,\
                 s->main_desc->comp[2].plane, s->main_desc->comp[2].offset, 
s->main_desc->comp[2].step, is_straight, 1, \
                 jobnr, nb_jobs);                                               
                                        \
                                                                                
                                        \
     if (main_has_alpha)                                                        
                                        \
-        alpha_composite(src, dst, src_w, src_h, dst_w, dst_h, x, y, jobnr, 
nb_jobs);                                   \
+        alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h, dst_w, 
dst_h, x, y, jobnr, nb_jobs);           \
 }
+DEFINE_BLEND_SLICE_YUV(8, 8);
 
 static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
                                                     AVFrame *dst, const 
AVFrame *src,
@@ -641,25 +647,25 @@ static av_always_inline void 
blend_slice_planar_rgb(AVFilterContext *ctx,
     const int dst_w = dst->width;
     const int dst_h = dst->height;
 
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0,       0, x, 
y, main_has_alpha,
+    blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0,       
0, x, y, main_has_alpha,
                 s->main_desc->comp[1].plane, s->main_desc->comp[1].offset, 
s->main_desc->comp[1].step, is_straight, 0,
                 jobnr, nb_jobs);
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, vsub, x, 
y, main_has_alpha,
+    blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, 
vsub, x, y, main_has_alpha,
                 s->main_desc->comp[2].plane, s->main_desc->comp[2].offset, 
s->main_desc->comp[2].step, is_straight, 0,
                 jobnr, nb_jobs);
-    blend_plane(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, vsub, x, 
y, main_has_alpha,
+    blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, 
vsub, x, y, main_has_alpha,
                 s->main_desc->comp[0].plane, s->main_desc->comp[0].offset, 
s->main_desc->comp[0].step, is_straight, 0,
                 jobnr, nb_jobs);
 
     if (main_has_alpha)
-        alpha_composite(src, dst, src_w, src_h, dst_w, dst_h, x, y, jobnr, 
nb_jobs);
+        alpha_composite_8_8bits(src, dst, src_w, src_h, dst_w, dst_h, x, y, 
jobnr, nb_jobs);
 }
 
 static int blend_slice_yuv420(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -667,7 +673,7 @@ static int blend_slice_yuva420(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -675,7 +681,7 @@ static int blend_slice_yuv422(AVFilterContext *ctx, void 
*arg, int jobnr, int nb
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -683,7 +689,7 @@ static int blend_slice_yuva422(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -691,7 +697,7 @@ static int blend_slice_yuv444(AVFilterContext *ctx, void 
*arg, int jobnr, int nb
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -699,7 +705,7 @@ static int blend_slice_yuva444(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 1, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 1, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -723,7 +729,7 @@ static int blend_slice_yuv420_pm(AVFilterContext *ctx, void 
*arg, int jobnr, int
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -731,7 +737,7 @@ static int blend_slice_yuva420_pm(AVFilterContext *ctx, 
void *arg, int jobnr, in
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -739,7 +745,7 @@ static int blend_slice_yuv422_pm(AVFilterContext *ctx, void 
*arg, int jobnr, int
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -747,7 +753,7 @@ static int blend_slice_yuva422_pm(AVFilterContext *ctx, 
void *arg, int jobnr, in
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -755,7 +761,7 @@ static int blend_slice_yuv444_pm(AVFilterContext *ctx, void 
*arg, int jobnr, int
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
@@ -763,7 +769,7 @@ static int blend_slice_yuva444_pm(AVFilterContext *ctx, 
void *arg, int jobnr, in
 {
     OverlayContext *s = ctx->priv;
     ThreadData *td = arg;
-    blend_slice_yuv(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 0, jobnr, 
nb_jobs);
+    blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 0, 
jobnr, nb_jobs);
     return 0;
 }
 
-- 
2.21.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to