diff options
author | Kieran Kunhya <kierank@obe.tv> | 2014-11-11 21:43:42 +0300 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2014-11-15 02:35:31 +0300 |
commit | 2e1704059ae8625beda2ffde847ad22c5ba416dc (patch) | |
tree | 31d07ed04dab0d25596c2f0d845f66bbb5e6c5ca /libavfilter/vf_interlace.c | |
parent | d16ec1b6db25bc348b0d4800c9a0c9b7070e3710 (diff) |
vf_interlace: Add SIMD for lowpass filter
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavfilter/vf_interlace.c')
-rw-r--r-- | libavfilter/vf_interlace.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/libavfilter/vf_interlace.c b/libavfilter/vf_interlace.c index c534b0ba58..3c36568546 100644 --- a/libavfilter/vf_interlace.c +++ b/libavfilter/vf_interlace.c @@ -28,27 +28,10 @@ #include "formats.h" #include "avfilter.h" +#include "interlace.h" #include "internal.h" #include "video.h" -enum ScanMode { - MODE_TFF = 0, - MODE_BFF = 1, -}; - -enum FieldType { - FIELD_UPPER = 0, - FIELD_LOWER = 1, -}; - -typedef struct InterlaceContext { - const AVClass *class; - enum ScanMode scan; // top or bottom field first scanning - int lowpass; // enable or disable low pass filterning - AVFrame *cur, *next; // the two frames from which the new one is obtained - int got_output; // signal an output frame is reday to request_frame() -} InterlaceContext; - #define OFFSET(x) offsetof(InterlaceContext, x) #define V AV_OPT_FLAG_VIDEO_PARAM static const AVOption options[] = { @@ -70,6 +53,19 @@ static const AVClass class = { .version = LIBAVUTIL_VERSION_INT, }; +static void lowpass_line_c(uint8_t *dstp, ptrdiff_t linesize, + const uint8_t *srcp, + const uint8_t *srcp_above, + const uint8_t *srcp_below) +{ + int i; + for (i = 0; i < linesize; i++) { + // this calculation is an integer representation of + // '0.5 * current + 0.25 * above + 0.25 * below' + // '1 +' is for rounding. + dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2; + } +} static const enum AVPixelFormat formats_supported[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, @@ -116,23 +112,31 @@ static int config_out_props(AVFilterLink *outlink) // half framerate outlink->time_base.num *= 2; + + if (s->lowpass) { + s->lowpass_line = lowpass_line_c; + if (ARCH_X86) + ff_interlace_init_x86(s); + } + av_log(ctx, AV_LOG_VERBOSE, "%s interlacing %s lowpass filter\n", s->scan == MODE_TFF ? "tff" : "bff", (s->lowpass) ? "with" : "without"); return 0; } -static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame, +static void copy_picture_field(InterlaceContext *s, + AVFrame *src_frame, AVFrame *dst_frame, AVFilterLink *inlink, enum FieldType field_type, int lowpass) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); int vsub = desc->log2_chroma_h; - int plane, i, j; + int plane, j; for (plane = 0; plane < desc->nb_components; plane++) { int lines = (plane == 1 || plane == 2) ? -(-inlink->h) >> vsub : inlink->h; - int linesize = av_image_get_linesize(inlink->format, inlink->w, plane); + ptrdiff_t linesize = av_image_get_linesize(inlink->format, inlink->w, plane); uint8_t *dstp = dst_frame->data[plane]; const uint8_t *srcp = src_frame->data[plane]; @@ -153,12 +157,7 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame, srcp_above = srcp; // there is no line above if (j == 1) srcp_below = srcp; // there is no line below - for (i = 0; i < linesize; i++) { - // this calculation is an integer representation of - // '0.5 * current + 0.25 * above + 0.25 * below' - // '1 +' is for rounding. - dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2; - } + s->lowpass_line(dstp, linesize, srcp, srcp_above, srcp_below); dstp += dstp_linesize; srcp += srcp_linesize; } @@ -209,11 +208,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) out->pts /= 2; // adjust pts to new framerate /* copy upper/lower field from cur */ - copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER, s->lowpass); + copy_picture_field(s, s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER, s->lowpass); av_frame_free(&s->cur); /* copy lower/upper field from next */ - copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER, s->lowpass); + copy_picture_field(s, s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER, s->lowpass); av_frame_free(&s->next); ret = ff_filter_frame(outlink, out); |