[FFmpeg-devel] [PATCH] vf_blend: Reduce number of arguments for kernel function
Timothy Gu
timothygu99 at gmail.com
Sun Feb 14 03:08:53 CET 2016
---
libavfilter/blend.h | 2 +-
libavfilter/vf_blend.c | 27 ++++++++++++++-------------
libavfilter/x86/vf_blend.asm | 3 +--
libavfilter/x86/vf_blend_init.c | 2 +-
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index 161055c..7003505 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -67,7 +67,7 @@ typedef struct FilterParams {
void (*blend)(const uint8_t *top, ptrdiff_t top_linesize,
const uint8_t *bottom, ptrdiff_t bottom_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t width, ptrdiff_t height,
struct FilterParams *param, double *values);
} FilterParams;
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 2b734b4..1c9924a 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -121,22 +121,22 @@ AVFILTER_DEFINE_CLASS(blend);
static void blend_normal(const uint8_t *top, ptrdiff_t top_linesize,
const uint8_t *bottom, ptrdiff_t bottom_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t width, ptrdiff_t height,
FilterParams *param, double *values)
{
- av_image_copy_plane(dst, dst_linesize, top, top_linesize, width, end - start);
+ av_image_copy_plane(dst, dst_linesize, top, top_linesize, width, height);
}
static void blend_normal_8bit(const uint8_t *top, ptrdiff_t top_linesize,
const uint8_t *bottom, ptrdiff_t bottom_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t width, ptrdiff_t height,
FilterParams *param, double *values)
{
const double opacity = param->opacity;
int i, j;
- for (i = start; i < end; i++) {
+ for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
dst[j] = top[j] * opacity + bottom[j] * (1. - opacity);
}
@@ -149,7 +149,7 @@ static void blend_normal_8bit(const uint8_t *top, ptrdiff_t top_linesize,
static void blend_normal_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
const uint8_t *_bottom, ptrdiff_t bottom_linesize,
uint8_t *_dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+ ptrdiff_t width, ptrdiff_t height,
FilterParams *param, double *values)
{
const uint16_t *top = (uint16_t*)_top;
@@ -161,7 +161,7 @@ static void blend_normal_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
top_linesize /= 2;
bottom_linesize /= 2;
- for (i = start; i < end; i++) {
+ for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
dst[j] = top[j] * opacity + bottom[j] * (1. - opacity);
}
@@ -175,13 +175,13 @@ static void blend_normal_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize, \
const uint8_t *bottom, ptrdiff_t bottom_linesize, \
uint8_t *dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end, \
+ ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values) \
{ \
double opacity = param->opacity; \
int i, j; \
\
- for (i = start; i < end; i++) { \
+ for (i = 0; i < height; i++) { \
for (j = 0; j < width; j++) { \
dst[j] = top[j] + ((expr) - top[j]) * opacity; \
} \
@@ -195,7 +195,7 @@ static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize,
static void blend_## name##_16bit(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end, \
+ ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values) \
{ \
const uint16_t *top = (uint16_t*)_top; \
@@ -207,7 +207,7 @@ static void blend_## name##_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
top_linesize /= 2; \
bottom_linesize /= 2; \
\
- for (i = start; i < end; i++) { \
+ for (i = 0; i < height; i++) { \
for (j = 0; j < width; j++) { \
dst[j] = top[j] + ((expr) - top[j]) * opacity; \
} \
@@ -299,7 +299,7 @@ DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B +
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end, \
+ ptrdiff_t width, ptrdiff_t height, \
FilterParams *param, double *values) \
{ \
const type *top = (type*)_top; \
@@ -311,7 +311,7 @@ static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize,
top_linesize /= div; \
bottom_linesize /= div; \
\
- for (y = start; y < end; y++) { \
+ for (y = 0; y < height; y++) { \
values[VAR_Y] = y; \
for (x = 0; x < width; x++) { \
values[VAR_X] = x; \
@@ -333,6 +333,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
ThreadData *td = arg;
int slice_start = (td->h * jobnr ) / nb_jobs;
int slice_end = (td->h * (jobnr+1)) / nb_jobs;
+ int height = slice_end - slice_start;
const uint8_t *top = td->top->data[td->plane];
const uint8_t *bottom = td->bottom->data[td->plane];
uint8_t *dst = td->dst->data[td->plane];
@@ -351,7 +352,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
td->bottom->linesize[td->plane],
dst + slice_start * td->dst->linesize[td->plane],
td->dst->linesize[td->plane],
- td->w, slice_start, slice_end, td->param, &values[0]);
+ td->w, height, td->param, &values[0]);
return 0;
}
diff --git a/libavfilter/x86/vf_blend.asm b/libavfilter/x86/vf_blend.asm
index a5ea74c..47471aa 100644
--- a/libavfilter/x86/vf_blend.asm
+++ b/libavfilter/x86/vf_blend.asm
@@ -42,11 +42,10 @@ cglobal blend_%1, 5, 7, %2, top, top_linesize, bottom, bottom_linesize, dst, end
%define dst_linesizeq r5mp
%define widthq r6mp
%endif
- mov endd, dword r8m
+ mov endd, dword r7m
add topq, widthq
add bottomq, widthq
add dstq, widthq
- sub endd, dword r7m ; start
neg widthq
%endmacro
diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c
index a6baf94..555e1e5 100644
--- a/libavfilter/x86/vf_blend_init.c
+++ b/libavfilter/x86/vf_blend_init.c
@@ -27,7 +27,7 @@
void ff_blend_##name##_##opt(const uint8_t *top, ptrdiff_t top_linesize, \
const uint8_t *bottom, ptrdiff_t bottom_linesize, \
uint8_t *dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t start, ptrdiff_t end, \
+ ptrdiff_t width, ptrdiff_t height, \
struct FilterParams *param, double *values);
BLEND_FUNC(addition, sse2)
--
2.1.4
More information about the ffmpeg-devel
mailing list