]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_v360: improve interpolation for equirect input at poles
authorPaul B Mahol <onemda@gmail.com>
Sat, 29 Feb 2020 21:27:11 +0000 (22:27 +0100)
committerPaul B Mahol <onemda@gmail.com>
Sat, 29 Feb 2020 21:35:02 +0000 (22:35 +0100)
libavfilter/vf_v360.c

index fc799f18c2e557caa0924b11f649f5b8eb72f0c6..b6195a01f6614626466ad5ea2797f468a49d2368 100644 (file)
@@ -639,6 +639,22 @@ static inline int reflecty(int y, int h)
     return y;
 }
 
+/**
+ * Reflect x operation for equirect.
+ *
+ * @param x input horizontal position
+ * @param y input vertical position
+ * @param w input width
+ * @param h input height
+ */
+static inline int ereflectx(int x, int y, int w, int h)
+{
+    if (y < 0 || y >= h)
+        x += w / 2;
+
+    return mod(x, w);
+}
+
 /**
  * Reflect x operation.
  *
@@ -1745,8 +1761,8 @@ static int xyz_to_equirect(const V360Context *s,
 
     for (int i = 0; i < 4; i++) {
         for (int j = 0; j < 4; j++) {
-            us[i][j] = mod(ui + j - 1, width);
-            vs[i][j] = av_clip(vi + i - 1, 0, height - 1);
+            us[i][j] = ereflectx(ui + j - 1, vi + i - 1, width, height);
+            vs[i][j] = reflecty(vi + i - 1, height);
         }
     }