aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-10-03 22:12:17 +0200
committerPaul B Mahol <onemda@gmail.com>2015-10-03 22:25:54 +0200
commite306e43633a2a14cd18e4e3bc6fdedaa36da2863 (patch)
treebdb91bd39f094d74fd3f4ee3dc23c490a924404e /libavfilter
parent8d1226e623b270969a04e455a14ed036dc8466bc (diff)
downloadffmpeg-e306e43633a2a14cd18e4e3bc6fdedaa36da2863.tar.gz
avfilter/vf_stereo3d: rewrite in preparation for SIMD
Also slightly faster. Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_stereo3d.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c
index 19cd59c9cb..f9d344a427 100644
--- a/libavfilter/vf_stereo3d.c
+++ b/libavfilter/vf_stereo3d.c
@@ -531,6 +531,26 @@ static inline uint8_t ana_convert(const int *coeff, const uint8_t *left, const u
return av_clip_uint8(sum >> 16);
}
+static void anaglyph(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc,
+ ptrdiff_t dst_linesize, ptrdiff_t l_linesize, ptrdiff_t r_linesize,
+ int width, int height,
+ const int *ana_matrix_r, const int *ana_matrix_g, const int *ana_matrix_b)
+{
+ int x, y, o;
+
+ for (y = 0; y < height; y++) {
+ for (o = 0, x = 0; x < width; x++, o+= 3) {
+ dst[o ] = ana_convert(ana_matrix_r, lsrc + o, rsrc + o);
+ dst[o + 1] = ana_convert(ana_matrix_g, lsrc + o, rsrc + o);
+ dst[o + 2] = ana_convert(ana_matrix_b, lsrc + o, rsrc + o);
+ }
+
+ dst += dst_linesize;
+ lsrc += l_linesize;
+ rsrc += r_linesize;
+ }
+}
+
typedef struct ThreadData {
AVFrame *ileft, *iright;
AVFrame *out;
@@ -546,23 +566,16 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int height = s->out.height;
int start = (height * jobnr ) / nb_jobs;
int end = (height * (jobnr+1)) / nb_jobs;
- uint8_t *dst = out->data[0];
const int **ana_matrix = s->ana_matrix;
- int x, y, il, ir, o;
- const uint8_t *lsrc = ileft->data[0];
- const uint8_t *rsrc = iright->data[0];
- int out_width = s->out.width;
-
- for (y = start; y < end; y++) {
- o = out->linesize[0] * y;
- il = s->in_off_left[0] + y * ileft->linesize[0] * s->in.row_step;
- ir = s->in_off_right[0] + y * iright->linesize[0] * s->in.row_step;
- for (x = 0; x < out_width; x++, il += 3, ir += 3, o+= 3) {
- dst[o ] = ana_convert(ana_matrix[0], lsrc + il, rsrc + ir);
- dst[o + 1] = ana_convert(ana_matrix[1], lsrc + il, rsrc + ir);
- dst[o + 2] = ana_convert(ana_matrix[2], lsrc + il, rsrc + ir);
- }
- }
+
+ anaglyph(out->data[0] + out->linesize[0] * start,
+ ileft ->data[0] + s->in_off_left [0] + ileft->linesize[0] * start * s->in.row_step,
+ iright->data[0] + s->in_off_right[0] + iright->linesize[0] * start * s->in.row_step,
+ out->linesize[0],
+ ileft->linesize[0] * s->in.row_step,
+ iright->linesize[0] * s->in.row_step,
+ s->out.width, end - start,
+ ana_matrix[0], ana_matrix[1], ana_matrix[2]);
return 0;
}