]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_stereo3d.c
Merge commit '4dfbc7a7559ccab666a8fd39de4224eb4b02c768'
[ffmpeg] / libavfilter / vf_stereo3d.c
index f9d344a42775847bd7a110e1b3dbd9c3e6750ae8..8e9cc83af11eda17aa2ce0c12d6abe665d4cf9af 100644 (file)
@@ -30,6 +30,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
+#include "stereo3d.h"
 
 enum StereoCode {
     ANAGLYPH_RC_GRAY,   // anaglyph red/cyan gray
@@ -150,6 +151,7 @@ typedef struct Stereo3DContext {
     double ts_unit;
     int blanks;
     int in_off_left[4], in_off_right[4];
+    Stereo3DDSPContext dsp;
 } Stereo3DContext;
 
 #define OFFSET(x) offsetof(Stereo3DContext, x)
@@ -300,6 +302,37 @@ static int query_formats(AVFilterContext *ctx)
     return ff_set_common_formats(ctx, fmts_list);
 }
 
+static inline uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
+{
+    int sum;
+
+    sum  = coeff[0] * left[0] + coeff[3] * right[0]; //red in
+    sum += coeff[1] * left[1] + coeff[4] * right[1]; //green in
+    sum += coeff[2] * left[2] + coeff[5] * right[2]; //blue in
+
+    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;
+    }
+}
+
 static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
@@ -517,38 +550,11 @@ static int config_output(AVFilterLink *outlink)
     s->hsub = desc->log2_chroma_w;
     s->vsub = desc->log2_chroma_h;
 
-    return 0;
-}
-
-static inline uint8_t ana_convert(const int *coeff, const uint8_t *left, const uint8_t *right)
-{
-    int sum;
-
-    sum  = coeff[0] * left[0] + coeff[3] * right[0]; //red in
-    sum += coeff[1] * left[1] + coeff[4] * right[1]; //green in
-    sum += coeff[2] * left[2] + coeff[5] * right[2]; //blue in
-
-    return av_clip_uint8(sum >> 16);
-}
+    s->dsp.anaglyph = anaglyph;
+    if (ARCH_X86)
+        ff_stereo3d_init_x86(&s->dsp);
 
-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;
-    }
+    return 0;
 }
 
 typedef struct ThreadData {
@@ -568,7 +574,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
     int end   = (height * (jobnr+1)) / nb_jobs;
     const int **ana_matrix = s->ana_matrix;
 
-    anaglyph(out->data[0] + out->linesize[0] * start,
+    s->dsp.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],