1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/vf_stereo3d: rewrite in preparation for SIMD

Also slightly faster.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2015-10-03 22:12:17 +02:00
parent 8d1226e623
commit e306e43633

View File

@ -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); 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 { typedef struct ThreadData {
AVFrame *ileft, *iright; AVFrame *ileft, *iright;
AVFrame *out; 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 height = s->out.height;
int start = (height * jobnr ) / nb_jobs; int start = (height * jobnr ) / nb_jobs;
int end = (height * (jobnr+1)) / nb_jobs; int end = (height * (jobnr+1)) / nb_jobs;
uint8_t *dst = out->data[0];
const int **ana_matrix = s->ana_matrix; 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++) { anaglyph(out->data[0] + out->linesize[0] * start,
o = out->linesize[0] * y; ileft ->data[0] + s->in_off_left [0] + ileft->linesize[0] * start * s->in.row_step,
il = s->in_off_left[0] + y * ileft->linesize[0] * s->in.row_step; iright->data[0] + s->in_off_right[0] + iright->linesize[0] * start * s->in.row_step,
ir = s->in_off_right[0] + y * iright->linesize[0] * s->in.row_step; out->linesize[0],
for (x = 0; x < out_width; x++, il += 3, ir += 3, o+= 3) { ileft->linesize[0] * s->in.row_step,
dst[o ] = ana_convert(ana_matrix[0], lsrc + il, rsrc + ir); iright->linesize[0] * s->in.row_step,
dst[o + 1] = ana_convert(ana_matrix[1], lsrc + il, rsrc + ir); s->out.width, end - start,
dst[o + 2] = ana_convert(ana_matrix[2], lsrc + il, rsrc + ir); ana_matrix[0], ana_matrix[1], ana_matrix[2]);
}
}
return 0; return 0;
} }