PR #26343 opened by rnissl
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26343
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26343.patch

GoPro Max and Max 2 stitch for v360_vulkan.

The output ends when the shorter track ends. The last frame is not repeated and 
keeps the driving duration. When the input rates differ, the output frame rate 
is variable. Chroma samples follow the luma face edges and each track's 
location. The output keeps the front tag.

This series is the filter only. The Vulkan MJPEG encoder stays in #25174.

Lynne approved the same filter series through f79bddf161 on 
https://code.ffmpeg.org/rnissl/FFmpeg/pulls/1. The last commit, which ends the 
stitch with the shorter track, is not part of that approval.



From d8d432f96182711225b4bac8531e7a263d789437 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Tue, 20 Oct 2026 07:43:36 +0200
Subject: [PATCH 1/7] avfilter/v360_vulkan: add GoPro Max and Max 2

WIP. Max 1 takes the extra width as overlap, Max 2 uses side, center and
blend. The sample follows gopromax2_cuda, including the equirect pixel
center and a yaw of -90.
---
 libavfilter/vf_v360_vulkan.c      | 118 +++++++++++++++-----
 libavfilter/vulkan/v360.comp.glsl | 174 +++++++++++++++++++++++++++---
 2 files changed, 251 insertions(+), 41 deletions(-)

diff --git a/libavfilter/vf_v360_vulkan.c b/libavfilter/vf_v360_vulkan.c
index 1780f7c1062..2eae7c7022b 100644
--- a/libavfilter/vf_v360_vulkan.c
+++ b/libavfilter/vf_v360_vulkan.c
@@ -54,6 +54,10 @@ typedef struct V360ulkanContext {
     char *rorder;
     int   rotation_order[3];
     int   overlap;
+    int   side, center, blend;
+    int   kernel, mix;
+    int   max1;
+    int   layout_side, layout_center, gopro_overlap;
 } V360VulkanContext;
 
 static int get_rorder(char c)
@@ -455,7 +459,7 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, FF_VK_DEFAULT_EXEC_CONTEXTS, 
0, 0, 0, NULL));
 
-    SPEC_LIST_CREATE(sl, 17, 14*sizeof(int) + 3*sizeof(float))
+    SPEC_LIST_CREATE(sl, 19, 16*sizeof(int) + 3*sizeof(float))
     SPEC_LIST_ADD(sl, 0, 32, s->out);
     SPEC_LIST_ADD(sl, 1, 32, s->in);
 
@@ -471,16 +475,20 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
     SPEC_LIST_ADD(sl, 9, 32, FF_CEIL_RSHIFT(in->height, desc->log2_chroma_h));
 
     if (s->in == GOPROMAX) {
-        int cube_size = in->height;
-        int gopro_cube_width = (in->width - cube_size) / 2;
+        int cube_size = s->layout_center;
+        int gopro_cube_width = s->layout_side;
 
+        /* gopro_overlap is the full strip. Max 1 stores that strip (64 at
+           4096x1344). Max 2's blend is half of it, so blend 48 is 96 here. */
         SPEC_LIST_ADD(sl, 10, 32, cube_size);
         SPEC_LIST_ADD(sl, 11, 32, gopro_cube_width);
-        SPEC_LIST_ADD(sl, 12, 32, s->overlap);
+        SPEC_LIST_ADD(sl, 12, 32, s->gopro_overlap);
         SPEC_LIST_ADD(sl, 13, 32, gopro_cube_width + cube_size);
-        SPEC_LIST_ADD(sl, 14, 32, gopro_cube_width / 2 - s->overlap);
+        SPEC_LIST_ADD(sl, 14, 32, gopro_cube_width / 2 - s->gopro_overlap);
         SPEC_LIST_ADD(sl, 15, 32, gopro_cube_width / 2);
-        SPEC_LIST_ADD(sl, 16, 32, gopro_cube_width / 2 + s->overlap);
+        SPEC_LIST_ADD(sl, 16, 32, gopro_cube_width / 2 + s->gopro_overlap);
+        SPEC_LIST_ADD(sl, 17, 32, s->kernel);
+        SPEC_LIST_ADD(sl, 18, 32, s->mix);
     }
 
     ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT,
@@ -588,6 +596,61 @@ fail:
     return err;
 }
 
+/* Max 1: three cube faces plus a short strip (64 at 4096x1344).
+   Max 2: side | center | side, blend 48 at 5952x1920.
+   Same selection as gopromax2_cuda. The shader overlap constant is the
+   full strip; Max 2 passes 2*blend because its kernel argument is the half. */
+static int gopro_setup_layout(AVFilterContext *ctx, int in_w, int in_h)
+{
+    V360VulkanContext *s = ctx->priv;
+    int extra = in_w - 3 * in_h;
+
+    s->max1 = 0;
+    if (s->side <= 0 && s->center <= 0 && extra >= 0 && extra <= 128) {
+        s->max1 = 1;
+        if (s->overlap == 0)
+            s->overlap = extra;
+        if (in_w < in_h * 3 || in_w > in_h * 3 + s->overlap * 2) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Incompatible inputs for GoPro Max (%dx%d, overlap %d).\n",
+                   in_w, in_h, s->overlap);
+            return AVERROR(EINVAL);
+        }
+        s->layout_center = in_h;
+        s->layout_side = (in_w - in_h) / 2;
+        s->gopro_overlap = s->overlap;
+        av_log(ctx, AV_LOG_INFO,
+               "v360_vulkan max1 %dx%d overlap %d kernel %d mix %d yaw %.1f 
pitch %.1f roll %.1f\n",
+               in_w, in_h, s->overlap, s->kernel, s->mix, s->yaw, s->pitch, 
s->roll);
+        return 0;
+    }
+
+    s->layout_center = s->center > 0 ? s->center : in_h;
+    s->layout_side   = s->side   > 0 ? s->side   : (in_w - s->layout_center) / 
2;
+    if (s->blend <= 0)
+        s->blend = 48;
+    if (2 * s->blend >= s->layout_side) {
+        av_log(ctx, AV_LOG_ERROR,
+               "Max 2 blend %d must be less than half the side width %d.\n",
+               s->blend, s->layout_side);
+        return AVERROR(EINVAL);
+    }
+    if (s->layout_side <= 0 || s->layout_center <= 0 ||
+        2 * s->layout_side + s->layout_center != in_w) {
+        av_log(ctx, AV_LOG_ERROR,
+               "Max 2 layout mismatch: input %dx%d, side %d center %d "
+               "(need 2*side+center = width).\n",
+               in_w, in_h, s->layout_side, s->layout_center);
+        return AVERROR(EINVAL);
+    }
+    s->gopro_overlap = 2 * s->blend;
+    av_log(ctx, AV_LOG_INFO,
+           "v360_vulkan max2 %dx%d side %d center %d blend %d kernel %d mix %d 
yaw %.1f pitch %.1f roll %.1f\n",
+           in_w, in_h, s->layout_side, s->layout_center, s->blend,
+           s->kernel, s->mix, s->yaw, s->pitch, s->roll);
+    return 0;
+}
+
 static av_cold int v360_vulkan_config_output(AVFilterLink *outlink)
 {
     int err;
@@ -596,28 +659,16 @@ static av_cold int v360_vulkan_config_output(AVFilterLink 
*outlink)
     AVFilterLink *inlink = ctx->inputs[0];
 
     if (s->in == GOPROMAX) {
-        if (s->overlap == 0) {
-            if (inlink->h <= 960) {
-                s->overlap = 32;
-            }
-            else if (inlink->h < 1920) {
-                s->overlap = 64;
-            }
-            else
-                s->overlap = 96;
-        }
         if (ctx->nb_inputs != 2) {
-            av_log(ctx, AV_LOG_ERROR, "GoPro Max. requires 2 input 
streams.\n");
+            av_log(ctx, AV_LOG_ERROR, "GoPro Max requires 2 input streams.\n");
             return AVERROR(EINVAL);
         }
-        if ((inlink->w != ctx->inputs[1]->w) ||
-            (inlink->h != ctx->inputs[1]->h) ||
-            (inlink->w < inlink->h * 3) ||
-            (inlink->w > inlink->h * 3 + s->overlap * 2)) {
-            av_log(ctx, AV_LOG_ERROR, "Incompatible inputs for GoPro Max. 
(%dx%d + %dx%d)\n",
+        if (inlink->w != ctx->inputs[1]->w || inlink->h != ctx->inputs[1]->h) {
+            av_log(ctx, AV_LOG_ERROR, "Incompatible inputs for GoPro Max 
(%dx%d + %dx%d).\n",
                                       inlink->w, inlink->h, ctx->inputs[1]->w, 
ctx->inputs[1]->h);
             return AVERROR(EINVAL);
-       }
+        }
+        RET(gopro_setup_layout(ctx, inlink->w, inlink->h));
     }
     else if (ctx->nb_inputs != 1) {
         av_log(ctx, AV_LOG_ERROR, "Too many inputs (%d)\n", ctx->nb_inputs);
@@ -700,7 +751,7 @@ static const AVOption v360_vulkan_options[] = {
     {  "dfisheye", "dual fisheye",                                 0, 
AV_OPT_TYPE_CONST,  {.i64=DUAL_FISHEYE},    0,                   0,   FLAGS, 
"in" },
     {        "sg", "stereographic",                                0, 
AV_OPT_TYPE_CONST,  {.i64=STEREOGRAPHIC},   0,                   0,   FLAGS, 
"in" },
     {   "fisheye", "fisheye",                                      0, 
AV_OPT_TYPE_CONST,  {.i64=FISHEYE},         0,                   0,   FLAGS, 
"in" },
-    {  "gopromax", "GoPro Max (two inputs)",                       0, 
AV_OPT_TYPE_CONST,  {.i64=GOPROMAX},        0,                   0,   FLAGS, 
"in" },
+    {  "gopromax", "GoPro Max and Max 2 (two inputs)",              0, 
AV_OPT_TYPE_CONST,  {.i64=GOPROMAX},        0,                   0,   FLAGS, 
"in" },
 
     {    "output", "set output projection",              OFFSET(out), 
AV_OPT_TYPE_INT,    {.i64=FLAT},            0,    NB_PROJECTIONS-1,   FLAGS, 
"out" },
     {         "e", "equirectangular",                              0, 
AV_OPT_TYPE_CONST,  {.i64=EQUIRECTANGULAR}, 0,                   0,   FLAGS, 
"out" },
@@ -713,15 +764,26 @@ static const AVOption v360_vulkan_options[] = {
 
     {         "w", "output width",                     OFFSET(width), 
AV_OPT_TYPE_INT,    {.i64 = 0},             0,           INT16_MAX,   FLAGS, 
"w" },
     {         "h", "output height",                   OFFSET(height), 
AV_OPT_TYPE_INT,    {.i64 = 0},             0,           INT16_MAX,   FLAGS, 
"h" },
-    {       "yaw", "yaw rotation",                       OFFSET(yaw), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},     -180.f,               180.f, DYNAMIC, 
"yaw" },
-    {     "pitch", "pitch rotation",                   OFFSET(pitch), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},     -180.f,               180.f, DYNAMIC, 
"pitch" },
-    {      "roll", "roll rotation",                     OFFSET(roll), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},     -180.f,               180.f, DYNAMIC, 
"roll" },
+    {       "yaw", "yaw rotation in degrees (v360 ypr, default 0)", 
OFFSET(yaw), AV_OPT_TYPE_FLOAT, {.dbl = 0.0f}, -360.f, 360.f, DYNAMIC },
+    {     "pitch", "pitch rotation in degrees (v360 ypr, default 0)", 
OFFSET(pitch), AV_OPT_TYPE_FLOAT, {.dbl = 0.0f}, -360.f, 360.f, DYNAMIC },
+    {      "roll", "roll rotation in degrees (v360 ypr, default 0)", 
OFFSET(roll), AV_OPT_TYPE_FLOAT, {.dbl = 0.0f}, -360.f, 360.f, DYNAMIC },
     {    "rorder", "rotation order",                  OFFSET(rorder), 
AV_OPT_TYPE_STRING, {.str = "ypr"},         0,                   0, DYNAMIC, 
"rorder" },
     {     "h_fov", "set output horizontal FOV angle",  OFFSET(h_fov), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},       0.0f,              360.0f, DYNAMIC, 
"h_fov" },
     {     "v_fov", "set output vertical FOV angle",    OFFSET(v_fov), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},       0.0f,              360.0f, DYNAMIC, 
"v_fov" },
     {    "ih_fov", "set input horizontal FOV angle",  OFFSET(ih_fov), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},       0.0f,              360.0f, DYNAMIC, 
"ih_fov" },
     {    "iv_fov", "set input vertical FOV angle",    OFFSET(iv_fov), 
AV_OPT_TYPE_FLOAT,  {.dbl = 0.0f},       0.0f,              360.0f, DYNAMIC, 
"iv_fov" },
-    {   "overlap", "overlapped pixels for GoPro Max", OFFSET(overlap), 
AV_OPT_TYPE_INT,    {.i64 = 0},            0,                1024,   FLAGS, 
"overlap" },
+    {   "overlap", "Max 1 overlap in luma pixels (0 = width-3*height)", 
OFFSET(overlap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1024, FLAGS },
+    {      "side", "Max 2 side face width (0 = (in_w-center)/2)", 
OFFSET(side), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT16_MAX, FLAGS },
+    {    "center", "Max 2 center face width (0 = in_h)",         
OFFSET(center), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT16_MAX, FLAGS },
+    {     "blend", "Max 2 blend width in luma pixels",           
OFFSET(blend), AV_OPT_TYPE_INT, {.i64 = 48}, 1, 1024, FLAGS },
+    {    "kernel", "resample kernel",                            
OFFSET(kernel), AV_OPT_TYPE_INT, {.i64 = 3}, 0, 4, FLAGS, .unit = "kernel" },
+    {  "nearest", "nearest source pixel",                  0, 
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "kernel" },
+    {   "linear", "bilinear",                              0, 
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "kernel" },
+    {    "cubic", "bicubic, CUDA taps",                    0, 
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "kernel" },
+    { "lanczos4", "Lanczos 4x4",                           0, 
AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, FLAGS, .unit = "kernel" },
+    { "lanczos6", "Lanczos 6x6",                           0, 
AV_OPT_TYPE_CONST, {.i64 = 4}, 0, 0, FLAGS, .unit = "kernel" },
+    {      "mix", "overlap mix curve: 0 step, 1 linear, 2 cubic, higher degree 
is 2*mix-1",
+                                                               OFFSET(mix), 
AV_OPT_TYPE_INT, {.i64 = 2}, 0, 9, FLAGS },
 
     { NULL },
 };
diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index 982555f8d4d..981cd58f0ef 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -51,6 +51,8 @@ layout (constant_id = 13) const int gopro_face_offset_2 = 0;
 layout (constant_id = 14) const int gopro_blend_x_0 = 0;
 layout (constant_id = 15) const int gopro_blend_x_1 = 0;
 layout (constant_id = 16) const int gopro_blend_x_2 = 0;
+layout (constant_id = 17) const int gopro_kernel = 3;
+layout (constant_id = 18) const int gopro_mix = 2;
 
 layout (set = 0, binding = 0) uniform writeonly image2D output_img[];
 layout (set = 0, binding = 1) uniform sampler2D input_img[];
@@ -119,6 +121,14 @@ vec3 equirect_to_xyz(in ivec2 out_size, in ivec2 pos)
     return vec3(cos(p[1]) * sin(p[0]), sin(p[1]), cos(p[1])*cos(p[0]));
 }
 
+/* Pixel center matches gopromax2_cuda. The shared equirect ray above is a 
quarter pixel off. */
+vec3 gopro_equirect_ray(in ivec2 out_size, in ivec2 pos)
+{
+    vec2 p = (vec2(pos) + vec2(0.5)) / vec2(out_size);
+    p = (p * 2.0 - vec2(1.0)) * vec2(m_pi, m_pi2);
+    return vec3(cos(p.y) * sin(p.x), sin(p.y), cos(p.y) * cos(p.x));
+}
+
 void xyz_to_equirect(uint idx, in vec3 v, in ivec2 pos, in ivec2 in_size)
 {
     vec2 p = vec2(atan(v[0], v[2]) / m_pi, asin(v[1]) / m_pi2);
@@ -277,6 +287,137 @@ vec3 xzy_to_eac_cube(in vec3 v)
     return vec3(uv.x, uv.y, float(face));
 }
 
+int gopro_binom(int n, int k)
+{
+    int c = 1;
+
+    if (k < 0 || k > n)
+        return 0;
+    if (k > n - k)
+        k = n - k;
+    for (int i = 1; i <= k; i++)
+        c = c * (n - k + i) / i;
+    return c;
+}
+
+/* Same curve as gopromax2_cuda. 0 is a step, 1 is linear, 2 is cubic. */
+float gopro_mix_curve(float t)
+{
+    int mix = gopro_mix;
+    int n, i;
+    float y, u;
+
+    if (mix <= 0)
+        return t < 0.5 ? 0.0 : 1.0;
+    if (mix == 1)
+        return t;
+    if (mix > 9)
+        mix = 9;
+    n = mix - 1;
+    u = 1.0 - t;
+    y = 0.0;
+    for (i = n; i >= 0; i--)
+        y = y * u + float(gopro_binom(n + i, i));
+    for (i = 0; i <= n; i++)
+        y *= t;
+    return clamp(y, 0.0, 1.0);
+}
+
+vec4 gopro_fetch(sampler2D im, int x, int y, ivec2 wh)
+{
+    x = clamp(x, 0, wh.x - 1);
+    y = clamp(y, 0, wh.y - 1);
+    return texelFetch(im, ivec2(x, y), 0);
+}
+
+/* Point texels. Bicubic weights are the CUDA taps, not the CPU cubic. */
+vec4 gopro_sample(sampler2D im, float x, float y, ivec2 wh)
+{
+    float wx[6], wy[6];
+    int x0, y0, nx, ny, origin, i, j, a;
+    float fx, fy, s, tt, ttt, xv;
+    vec4 sum, row;
+
+    x = clamp(x, 0.0, float(wh.x - 1));
+    y = clamp(y, 0.0, float(wh.y - 1));
+    if (gopro_kernel <= 0)
+        return gopro_fetch(im, int(floor(x + 0.5)), int(floor(y + 0.5)), wh);
+
+    x0 = int(floor(x));
+    y0 = int(floor(y));
+    fx = x - float(x0);
+    fy = y - float(y0);
+    if (gopro_kernel == 1)
+        return mix(mix(gopro_fetch(im, x0, y0, wh),
+                       gopro_fetch(im, x0 + 1, y0, wh), fx),
+                   mix(gopro_fetch(im, x0, y0 + 1, wh),
+                       gopro_fetch(im, x0 + 1, y0 + 1, wh), fx),
+                   fy);
+
+    if (gopro_kernel == 2) {
+        tt = fx * fx;
+        ttt = tt * fx;
+        wx[0] = -fx / 3.0 + tt / 2.0 - ttt / 6.0;
+        wx[1] = 1.0 - fx / 2.0 - tt + ttt / 2.0;
+        wx[2] = fx + tt / 2.0 - ttt / 2.0;
+        wx[3] = -fx / 6.0 + ttt / 6.0;
+        tt = fy * fy;
+        ttt = tt * fy;
+        wy[0] = -fy / 3.0 + tt / 2.0 - ttt / 6.0;
+        wy[1] = 1.0 - fy / 2.0 - tt + ttt / 2.0;
+        wy[2] = fy + tt / 2.0 - ttt / 2.0;
+        wy[3] = -fy / 6.0 + ttt / 6.0;
+        nx = 4;
+        ny = 4;
+    } else {
+        a = gopro_kernel >= 4 ? 3 : 2;
+        nx = 2 * a;
+        ny = nx;
+        s = 0.0;
+        for (i = 0; i < nx; i++) {
+            xv = m_pi * (fx - float(i) + float(a - 1));
+            if (xv == 0.0)
+                wx[i] = 1.0;
+            else
+                wx[i] = sin(xv) * sin(xv / float(a)) / (xv * xv / float(a));
+            s += wx[i];
+        }
+        if (s != 0.0)
+            for (i = 0; i < nx; i++)
+                wx[i] /= s;
+        s = 0.0;
+        for (i = 0; i < ny; i++) {
+            xv = m_pi * (fy - float(i) + float(a - 1));
+            if (xv == 0.0)
+                wy[i] = 1.0;
+            else
+                wy[i] = sin(xv) * sin(xv / float(a)) / (xv * xv / float(a));
+            s += wy[i];
+        }
+        if (s != 0.0)
+            for (i = 0; i < ny; i++)
+                wy[i] /= s;
+    }
+
+    origin = nx / 2 - 1;
+    x0 -= origin;
+    y0 -= origin;
+    sum = vec4(0.0);
+    for (j = 0; j < ny; j++) {
+        row = vec4(0.0);
+        for (i = 0; i < nx; i++)
+            row += gopro_fetch(im, x0 + i, y0 + j, wh) * wx[i];
+        sum += row * wy[j];
+    }
+    return sum;
+}
+
+vec4 gopro_at(sampler2D im, vec2 nuv, ivec2 wh)
+{
+    vec2 px = nuv * vec2(wh) - vec2(0.5);
+    return gopro_sample(im, px.x, px.y, wh);
+}
+
 void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in ivec2 in_size)
 {
     vec3 uvf = xzy_to_eac_cube(v);
@@ -286,11 +427,12 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
     vec2 face_size = vec2(float(gopro_face_size_x[grid.x]) / 
float(in_img_size[0].x), 1.0);
     vec2 uv_start = vec2(face_offset[grid.x], 0.0);
     vec2 uv_end = uv_start + face_size;
+    ivec2 wh = in_img_size[idx];
     vec4 res;
 
     if (grid.x == 1) {
-        res = (grid.y == 0) ? texture(input_img[idx], mix(uv_start, uv_end, 
uv))
-                            : texture(input2_img[idx], mix(uv_start, uv_end, 
uv));
+        res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, uv_end, 
uv), wh)
+                            : gopro_at(input2_img[idx], mix(uv_start, uv_end, 
uv), wh);
     } else {
         float cube_width = float(gopro_cube_width);
         float overlap = float(gopro_overlap);
@@ -300,23 +442,22 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
         vec2 uv1 = vec2(uv.x * gratio, uv.y);
         vec2 uv2 = vec2((uv.x + blend_width) * gratio, uv.y);
         if (uv1.x < blend_u[0]) {
-            res = (grid.y == 0) ? texture(input_img[idx], mix(uv_start, 
uv_end, uv1))
-                                : texture(input2_img[idx], mix(uv_start, 
uv_end, uv1));
+            res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, 
uv_end, uv1), wh)
+                                : gopro_at(input2_img[idx], mix(uv_start, 
uv_end, uv1), wh);
         } else if (uv2.x > blend_u[2]) {
-            res = (grid.y == 0) ? texture(input_img[idx], mix(uv_start, 
uv_end, uv2))
-                                : texture(input2_img[idx], mix(uv_start, 
uv_end, uv2));
+            res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, 
uv_end, uv2), wh)
+                                : gopro_at(input2_img[idx], mix(uv_start, 
uv_end, uv2), wh);
         } else {
             vec4 res2;
             if (grid.y == 0) {
-                res = texture(input_img[idx], mix(uv_start, uv_end, uv1));
-                res2 = texture(input_img[idx], mix(uv_start, uv_end, uv2));
+                res = gopro_at(input_img[idx], mix(uv_start, uv_end, uv1), wh);
+                res2 = gopro_at(input_img[idx], mix(uv_start, uv_end, uv2), 
wh);
             }
             else {
-                res = texture(input2_img[idx], mix(uv_start, uv_end, uv1));
-                res2 = texture(input2_img[idx], mix(uv_start, uv_end, uv2));
+                res = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv1), 
wh);
+                res2 = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv2), 
wh);
             }
-            float a = (uv1.x - blend_u[0]) / (blend_u[1] - blend_u[0]);
-            res = mix(res, res2, a);
+            res = mix(res, res2, gopro_mix_curve((uv1.x - blend_u[0]) / 
(blend_u[1] - blend_u[0])));
         }
     }
 
@@ -353,7 +494,14 @@ void main()
                break;
            }
 
-        v = normalize((rot_mat * vec4(v, 0.0f)).xyz);
+        if (in_transform == GOPROMAX && out_transform == EQUIRECTANGULAR)
+            v = gopro_equirect_ray(out_size, pos);
+
+        /* The C matrix is row-major. GoPro multiplies on the right so yaw
+           matches gopromax2_cuda. Other projections keep the left multiply. */
+        v = (in_transform == GOPROMAX)
+            ? normalize((vec4(v, 0.0) * rot_mat).xyz)
+            : normalize((rot_mat * vec4(v, 0.0)).xyz);
 
         switch (in_transform) {
         case EQUIRECTANGULAR:
-- 
2.54.1


From b7bd64024ae2338ebe515adb55463e3e54cd9331 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Thu, 22 Oct 2026 23:44:15 +0200
Subject: [PATCH 2/7] avfilter/v360_vulkan: evaluate the overlap mix without a
 per-pixel binomial
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

mix=2 is the cubic t^2*(3-2t). Higher curves multiply coefficients
specialized once when the pipeline is created.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: Reinhard Nißl <[email protected]>
---
 libavfilter/vf_v360_vulkan.c      | 33 ++++++++++++++++++++++++++++++-
 libavfilter/vulkan/v360.comp.glsl | 32 ++++++++++++++++--------------
 2 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/libavfilter/vf_v360_vulkan.c b/libavfilter/vf_v360_vulkan.c
index 2eae7c7022b..18b05fbb00b 100644
--- a/libavfilter/vf_v360_vulkan.c
+++ b/libavfilter/vf_v360_vulkan.c
@@ -60,6 +60,20 @@ typedef struct V360ulkanContext {
     int   layout_side, layout_center, gopro_overlap;
 } V360VulkanContext;
 
+static int v360_mix_binom(int n, int k)
+{
+    int64_t c = 1;
+    int i;
+
+    if (k < 0 || k > n)
+        return 0;
+    if (k > n - k)
+        k = n - k;
+    for (i = 1; i <= k; i++)
+        c = c * (n - k + i) / i;
+    return (int)c;
+}
+
 static int get_rorder(char c)
 {
     switch (c) {
@@ -459,7 +473,7 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
 
     RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, FF_VK_DEFAULT_EXEC_CONTEXTS, 
0, 0, 0, NULL));
 
-    SPEC_LIST_CREATE(sl, 19, 16*sizeof(int) + 3*sizeof(float))
+    SPEC_LIST_CREATE(sl, 28, 16*sizeof(int) + 12*sizeof(float))
     SPEC_LIST_ADD(sl, 0, 32, s->out);
     SPEC_LIST_ADD(sl, 1, 32, s->in);
 
@@ -489,6 +503,23 @@ static av_cold int init_filter(AVFilterContext *ctx, 
AVFrame *in)
         SPEC_LIST_ADD(sl, 16, 32, gopro_cube_width / 2 + s->gopro_overlap);
         SPEC_LIST_ADD(sl, 17, 32, s->kernel);
         SPEC_LIST_ADD(sl, 18, 32, s->mix);
+        {
+            int mix = s->mix;
+            int n, i;
+
+            if (mix < 0)
+                mix = 0;
+            if (mix > 9)
+                mix = 9;
+            n = mix > 1 ? mix - 1 : 0;
+            for (i = 0; i < 9; i++) {
+                float c = 0.f;
+
+                if (mix > 2 && i <= n)
+                    c = (float)v360_mix_binom(n + i, i);
+                SPEC_LIST_ADD(sl, 19 + i, 32, av_float2int(c));
+            }
+        }
     }
 
     ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT,
diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index 981cd58f0ef..f39bfc0d009 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -53,6 +53,15 @@ layout (constant_id = 15) const int gopro_blend_x_1 = 0;
 layout (constant_id = 16) const int gopro_blend_x_2 = 0;
 layout (constant_id = 17) const int gopro_kernel = 3;
 layout (constant_id = 18) const int gopro_mix = 2;
+layout (constant_id = 19) const float gopro_mix_c0 = 0.0;
+layout (constant_id = 20) const float gopro_mix_c1 = 0.0;
+layout (constant_id = 21) const float gopro_mix_c2 = 0.0;
+layout (constant_id = 22) const float gopro_mix_c3 = 0.0;
+layout (constant_id = 23) const float gopro_mix_c4 = 0.0;
+layout (constant_id = 24) const float gopro_mix_c5 = 0.0;
+layout (constant_id = 25) const float gopro_mix_c6 = 0.0;
+layout (constant_id = 26) const float gopro_mix_c7 = 0.0;
+layout (constant_id = 27) const float gopro_mix_c8 = 0.0;
 
 layout (set = 0, binding = 0) uniform writeonly image2D output_img[];
 layout (set = 0, binding = 1) uniform sampler2D input_img[];
@@ -287,37 +296,30 @@ vec3 xzy_to_eac_cube(in vec3 v)
     return vec3(uv.x, uv.y, float(face));
 }
 
-int gopro_binom(int n, int k)
-{
-    int c = 1;
-
-    if (k < 0 || k > n)
-        return 0;
-    if (k > n - k)
-        k = n - k;
-    for (int i = 1; i <= k; i++)
-        c = c * (n - k + i) / i;
-    return c;
-}
-
-/* Same curve as gopromax2_cuda. 0 is a step, 1 is linear, 2 is cubic. */
+/* 0 is a step, 1 is linear, 2 is the cubic t^2*(3-2t).
+   Higher curves use coefficients specialized with the pipeline. */
 float gopro_mix_curve(float t)
 {
     int mix = gopro_mix;
     int n, i;
     float y, u;
+    float c[9] = float[9](gopro_mix_c0, gopro_mix_c1, gopro_mix_c2,
+                           gopro_mix_c3, gopro_mix_c4, gopro_mix_c5,
+                           gopro_mix_c6, gopro_mix_c7, gopro_mix_c8);
 
     if (mix <= 0)
         return t < 0.5 ? 0.0 : 1.0;
     if (mix == 1)
         return t;
+    if (mix == 2)
+        return t * t * (3.0 - 2.0 * t);
     if (mix > 9)
         mix = 9;
     n = mix - 1;
     u = 1.0 - t;
     y = 0.0;
     for (i = n; i >= 0; i--)
-        y = y * u + float(gopro_binom(n + i, i));
+        y = y * u + c[i];
     for (i = 0; i <= n; i++)
         y *= t;
     return clamp(y, 0.0, 1.0);
-- 
2.54.1


From 4bfb2a1fc1b454680aa0d94e8f1852f209c912fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Sun, 25 Oct 2026 18:20:27 +0100
Subject: [PATCH 3/7] avfilter/v360_vulkan: record the missing EAC padding

The inset against vf_v360.c is still absent, so the FIXME stays. A
later option should default to the CPU filter's fixed 2 px, or to its
default once that pad is settable. GoPro faces stay unpadded.
---
 libavfilter/vulkan/v360.comp.glsl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index f39bfc0d009..49360bcdd17 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -215,7 +215,9 @@ void xyz_to_dfisheye(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
     imageStore(output_img[idx], pos, res);
 }
 
-// FIXME: no padding
+/* FIXME: no EAC padding. CPU v360 always insets by 2 px (pixel_pad in
+   vf_v360.c). A later option should default to that 2, or to the CPU
+   filter's default once its pad is settable. GoPro faces stay unpadded. */
 vec3 eac_to_xyz(in ivec2 out_size, in ivec2 pos)
 {
     const ivec2 cube_size = out_size / ivec2(3, 2);
-- 
2.54.1


From 7493ee86218c82f38397f7f1e4d3400876dd0910 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Thu, 5 Nov 2026 09:47:44 +0100
Subject: [PATCH 4/7] avfilter/v360_vulkan: keep 0.7 px of each Max 1 side in
 the span

Folding the whole overlap pulls each half toward the seam. The outer edges stay 
put, and Max 2 still folds the whole strip.

Co-authored-by: Cursor <[email protected]>
---
 doc/filters.texi                  |  3 +++
 libavfilter/vulkan/v360.comp.glsl | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 3a516bc1cbb..a66694c313b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -30540,6 +30540,9 @@ The number of pixels of overlapped areas depends on the 
video resolution.
 In most cases, the value is automatically calculated based on input video size,
 but it may be changed on GoPro Max2 or future models.
 The option is to adjust for unknown video resolutions.
+On the original Max, each side keeps 0.7 px of that overlap in its span,
+scaled with the overlap, so both outer edges stay put. Max 2 folds the
+whole overlap out.
 
 @end table
 
diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index 49360bcdd17..b4e5b747d54 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -440,8 +440,18 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
     } else {
         float cube_width = float(gopro_cube_width);
         float overlap = float(gopro_overlap);
-        float gratio = (cube_width - overlap) / cube_width;
-        float blend_width = overlap / (cube_width - overlap);
+        /* Max 1's side is wider than the center by half the strip. Folding
+           the whole strip out pulls each half toward the seam. Keep 0.7 px
+           of each side in the span, 1.4 px across the seam. The outer edges
+           stay put and the two copies move 0.7 px into the strip. Max 2's
+           extra width is the whole strip, so this does not apply. */
+        float seam_keep = 0.0;
+        float fold;
+        if (float(gopro_cube_width - in_cube_size) * 2.0 == overlap)
+            seam_keep = 0.7 * overlap / 64.0;
+        fold = overlap - 2.0 * seam_keep;
+        float gratio = (cube_width - fold) / cube_width;
+        float blend_width = fold / (cube_width - fold);
         vec3 blend_u = vec3(gopro_blend_x) / cube_width;
         vec2 uv1 = vec2(uv.x * gratio, uv.y);
         vec2 uv2 = vec2((uv.x + blend_width) * gratio, uv.y);
-- 
2.54.1


From 4a69ae00085d617f28df1594456f76c8effd172e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Mon, 16 Nov 2026 08:34:02 +0100
Subject: [PATCH 5/7] avfilter/v360_vulkan: reach weight 1 at the end of the
 Max 1 overlap
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The fade ends when the right copy passes the far overlap edge. Max 1
folds 1.4 px less than a full overlap, so dividing by the overlap
stopped the cubic curve near 0.9985. Divide by the span the window
actually covers. Max 2 folds the whole overlap and stays the same.

Signed-off-by: Reinhard Nißl <[email protected]>
Co-authored-by: Cursor <[email protected]>
---
 libavfilter/vulkan/v360.comp.glsl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index b4e5b747d54..971faf9265e 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -453,6 +453,10 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
         float gratio = (cube_width - fold) / cube_width;
         float blend_width = fold / (cube_width - fold);
         vec3 blend_u = vec3(gopro_blend_x) / cube_width;
+        /* The mix ends when the right copy passes blend_u[2]. That point
+           is one fold short of two overlaps, so the weight uses this span.
+           Max 2 folds the whole overlap and the span stays overlap/side. */
+        float blend_span = (2.0 * overlap - fold) / cube_width;
         vec2 uv1 = vec2(uv.x * gratio, uv.y);
         vec2 uv2 = vec2((uv.x + blend_width) * gratio, uv.y);
         if (uv1.x < blend_u[0]) {
@@ -471,7 +475,7 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
                 res = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv1), 
wh);
                 res2 = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv2), 
wh);
             }
-            res = mix(res, res2, gopro_mix_curve((uv1.x - blend_u[0]) / 
(blend_u[1] - blend_u[0])));
+            res = mix(res, res2, gopro_mix_curve((uv1.x - blend_u[0]) / 
blend_span));
         }
     }
 
-- 
2.54.1


From 757279c3b7027dd1e068aa10e1acb393029160ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Tue, 17 Nov 2026 20:38:34 +0100
Subject: [PATCH 6/7] avfilter/v360_vulkan: keep the Max 2 blend inside a
 quarter of the side
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The transition is two blend widths and ends at the side midpoint.
A wider blend starts before the face, so the edge weights never reach 0 and 1.

Signed-off-by: Reinhard Nißl <[email protected]>
Co-authored-by: Cursor <[email protected]>
---
 doc/filters.texi             | 3 ++-
 libavfilter/vf_v360_vulkan.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index a66694c313b..68274f4a7d0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -30542,7 +30542,8 @@ but it may be changed on GoPro Max2 or future models.
 The option is to adjust for unknown video resolutions.
 On the original Max, each side keeps 0.7 px of that overlap in its span,
 scaled with the overlap, so both outer edges stay put. Max 2 folds the
-whole overlap out.
+whole overlap out. That blend must not exceed one quarter of the side
+width: the transition is two blend widths and ends at the side midpoint.
 
 @end table
 
diff --git a/libavfilter/vf_v360_vulkan.c b/libavfilter/vf_v360_vulkan.c
index 18b05fbb00b..b7cd67f9b44 100644
--- a/libavfilter/vf_v360_vulkan.c
+++ b/libavfilter/vf_v360_vulkan.c
@@ -660,9 +660,9 @@ static int gopro_setup_layout(AVFilterContext *ctx, int 
in_w, int in_h)
     s->layout_side   = s->side   > 0 ? s->side   : (in_w - s->layout_center) / 
2;
     if (s->blend <= 0)
         s->blend = 48;
-    if (2 * s->blend >= s->layout_side) {
+    if (s->layout_side / 2 < 2 * s->blend) {
         av_log(ctx, AV_LOG_ERROR,
-               "Max 2 blend %d must be less than half the side width %d.\n",
+               "Max 2 blend %d must not exceed one quarter of the side width 
%d.\n",
                s->blend, s->layout_side);
         return AVERROR(EINVAL);
     }
-- 
2.54.1


From a35dba831ade9dfa56072ff315d66c1cfd19a96b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= <[email protected]>
Date: Tue, 24 Nov 2026 22:57:10 +0100
Subject: [PATCH 7/7] avfilter/v360_vulkan: end the GoPro stitch with the
 shorter track
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The GoPro path stops when either track runs out of frames. The last
frame is not repeated and keeps the driving duration. Different input
rates are reported as a variable output rate.

Chroma samples follow the luma face edges and each track's location.
The output keeps the front tag.

Signed-off-by: Reinhard Nißl <[email protected]>
Co-authored-by: Cursor <[email protected]>
---
 doc/filters.texi                  |  5 +++
 libavfilter/vf_v360_vulkan.c      | 57 +++++++++++++++++++++++++++++++
 libavfilter/vulkan/v360.comp.glsl | 35 +++++++++++--------
 3 files changed, 82 insertions(+), 15 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 68274f4a7d0..c1042e5a2ad 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -30544,6 +30544,11 @@ On the original Max, each side keeps 0.7 px of that 
overlap in its span,
 scaled with the overlap, so both outer edges stay put. Max 2 folds the
 whole overlap out. That blend must not exceed one quarter of the side
 width: the transition is two blend widths and ends at the side midpoint.
+Each track keeps its own chroma location. Unspecified means centered, and
+the output keeps the front location. Face edges follow the luma boundaries.
+The output ends when the shorter track ends. The last frame is not repeated
+and keeps the driving duration.
+When the tracks have different frame rates, the output reports a variable rate.
 
 @end table
 
diff --git a/libavfilter/vf_v360_vulkan.c b/libavfilter/vf_v360_vulkan.c
index b7cd67f9b44..f718a789712 100644
--- a/libavfilter/vf_v360_vulkan.c
+++ b/libavfilter/vf_v360_vulkan.c
@@ -16,7 +16,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/hwcontext.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "vulkan_filter.h"
 
 #include "v360.h"
@@ -32,6 +34,7 @@ struct PushData {
     float rot_mat[4][4];
     float iflat_range[2];
     float flat_range[2];
+    float chroma_off[4];
 };
 
 typedef struct V360ulkanContext {
@@ -561,6 +564,25 @@ fail:
     return err;
 }
 
+static void chroma_offset(const AVFrame *frame, float off[2])
+{
+    const AVPixFmtDescriptor *desc = NULL;
+    int x, y;
+
+    off[0] = 0.f;
+    off[1] = 0.f;
+    if (frame->hw_frames_ctx) {
+        AVHWFramesContext *fc = (AVHWFramesContext 
*)frame->hw_frames_ctx->data;
+        desc = av_pix_fmt_desc_get(fc->sw_format);
+    }
+    if (!desc)
+        return;
+    if (av_chroma_location_enum_to_pos(&x, &y, frame->chroma_location) >= 0) {
+        off[0] = (x - 128) / (float)(256 << desc->log2_chroma_w);
+        off[1] = (y - 128) / (float)(256 << desc->log2_chroma_h);
+    }
+}
+
 static int v360_vulkan_filter_frame(FFFrameSync *fs)
 {
     int err;
@@ -596,10 +618,25 @@ static int v360_vulkan_filter_frame(FFFrameSync *fs)
         RET(init_filter(ctx, in[0]));
     }
 
+    s->pd.chroma_off[0] = s->pd.chroma_off[1] = 0.f;
+    s->pd.chroma_off[2] = s->pd.chroma_off[3] = 0.f;
+    if (s->in == GOPROMAX && ctx->nb_inputs == 2) {
+        chroma_offset(in[0], &s->pd.chroma_off[0]);
+        chroma_offset(in[1], &s->pd.chroma_off[2]);
+    }
     RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd, out,
                                  in, ctx->nb_inputs, s->sampler, 1,
                                  &s->pd, sizeof(s->pd)));
     RET(av_frame_copy_props(out, in[0]));
+    if (s->in == GOPROMAX && ctx->nb_inputs == 2) {
+        int timing = s->fs.in[0].sync == s->fs.sync_level ? 0 : 1;
+
+        out->pts = s->fs.pts;
+        out->duration = av_rescale_q(in[timing]->duration,
+                                     ctx->inputs[timing]->time_base,
+                                     outlink->time_base);
+        out->time_base = outlink->time_base;
+    }
 
     return ff_filter_frame(outlink, out);
 
@@ -717,10 +754,30 @@ static av_cold int v360_vulkan_config_output(AVFilterLink 
*outlink)
         s->fs.in[i].before    = EXT_STOP;
         s->fs.in[i].after     = EXT_STOP;
     }
+    /* GoPro matches the other stitchers. The front track drives the
+       duration. Output ends when the shorter track ends, without
+       repeating or extending the last frame. */
+    if (s->in == GOPROMAX && ctx->nb_inputs == 2) {
+        s->fs.in[0].sync   = 2;
+        s->fs.in[0].after  = EXT_STOP;
+        s->fs.in[1].before = EXT_STOP;
+        s->fs.in[1].after  = EXT_STOP;
+    }
     s->fs.on_event = &v360_vulkan_filter_frame;
 
     RET(ff_framesync_configure(&s->fs));
     outlink->time_base = s->fs.time_base;
+    if (s->in == GOPROMAX && ctx->nb_inputs == 2) {
+        FilterLink *outl = ff_filter_link(outlink);
+        FilterLink *front = ff_filter_link(ctx->inputs[0]);
+        FilterLink *rear = ff_filter_link(ctx->inputs[1]);
+
+        if (front->frame_rate.den && rear->frame_rate.den &&
+            av_cmp_q(front->frame_rate, rear->frame_rate))
+            outl->frame_rate = av_make_q(1, 0);
+        else
+            outl->frame_rate = front->frame_rate;
+    }
 
 fail:
     return err;
diff --git a/libavfilter/vulkan/v360.comp.glsl 
b/libavfilter/vulkan/v360.comp.glsl
index 971faf9265e..e98ef3e96bd 100644
--- a/libavfilter/vulkan/v360.comp.glsl
+++ b/libavfilter/vulkan/v360.comp.glsl
@@ -71,6 +71,7 @@ layout (push_constant, scalar) uniform pushConstants {
     mat4 rot_mat;
     vec2 iflat_range;
     vec2 flat_range;
+    vec4 chroma_off;
 };
 
 ivec2 in_img_size[4] = {
@@ -131,9 +132,9 @@ vec3 equirect_to_xyz(in ivec2 out_size, in ivec2 pos)
 }
 
 /* Pixel center matches gopromax2_cuda. The shared equirect ray above is a 
quarter pixel off. */
-vec3 gopro_equirect_ray(in ivec2 out_size, in ivec2 pos)
+vec3 gopro_equirect_ray(in ivec2 out_size, in ivec2 pos, in vec2 off)
 {
-    vec2 p = (vec2(pos) + vec2(0.5)) / vec2(out_size);
+    vec2 p = (vec2(pos) + vec2(0.5) + off) / vec2(out_size);
     p = (p * 2.0 - vec2(1.0)) * vec2(m_pi, m_pi2);
     return vec3(cos(p.y) * sin(p.x), sin(p.y), cos(p.y) * cos(p.x));
 }
@@ -416,9 +417,12 @@ vec4 gopro_sample(sampler2D im, float x, float y, ivec2 wh)
     return sum;
 }
 
-vec4 gopro_at(sampler2D im, vec2 nuv, ivec2 wh)
+vec4 gopro_at(uint idx, sampler2D im, vec2 nuv, ivec2 wh, bool front)
 {
-    vec2 px = nuv * vec2(wh) - vec2(0.5);
+    ivec2 luma = in_img_size[0];
+    ivec2 sub = max(luma / max(wh, ivec2(1)), ivec2(1));
+    vec2 off = idx == 0 ? vec2(0.0) : (front ? chroma_off.xy : chroma_off.zw);
+    vec2 px = nuv * vec2(luma) / vec2(sub) - vec2(0.5) - off;
     return gopro_sample(im, px.x, px.y, wh);
 }
 
@@ -435,8 +439,8 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
     vec4 res;
 
     if (grid.x == 1) {
-        res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, uv_end, 
uv), wh)
-                            : gopro_at(input2_img[idx], mix(uv_start, uv_end, 
uv), wh);
+        res = (grid.y == 0) ? gopro_at(idx, input_img[idx], mix(uv_start, 
uv_end, uv), wh, true)
+                            : gopro_at(idx, input2_img[idx], mix(uv_start, 
uv_end, uv), wh, false);
     } else {
         float cube_width = float(gopro_cube_width);
         float overlap = float(gopro_overlap);
@@ -460,20 +464,20 @@ void xyz_to_gopro(uint idx, in vec3 v, in ivec2 pos, in 
ivec2 in_size)
         vec2 uv1 = vec2(uv.x * gratio, uv.y);
         vec2 uv2 = vec2((uv.x + blend_width) * gratio, uv.y);
         if (uv1.x < blend_u[0]) {
-            res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, 
uv_end, uv1), wh)
-                                : gopro_at(input2_img[idx], mix(uv_start, 
uv_end, uv1), wh);
+            res = (grid.y == 0) ? gopro_at(idx, input_img[idx], mix(uv_start, 
uv_end, uv1), wh, true)
+                                : gopro_at(idx, input2_img[idx], mix(uv_start, 
uv_end, uv1), wh, false);
         } else if (uv2.x > blend_u[2]) {
-            res = (grid.y == 0) ? gopro_at(input_img[idx], mix(uv_start, 
uv_end, uv2), wh)
-                                : gopro_at(input2_img[idx], mix(uv_start, 
uv_end, uv2), wh);
+            res = (grid.y == 0) ? gopro_at(idx, input_img[idx], mix(uv_start, 
uv_end, uv2), wh, true)
+                                : gopro_at(idx, input2_img[idx], mix(uv_start, 
uv_end, uv2), wh, false);
         } else {
             vec4 res2;
             if (grid.y == 0) {
-                res = gopro_at(input_img[idx], mix(uv_start, uv_end, uv1), wh);
-                res2 = gopro_at(input_img[idx], mix(uv_start, uv_end, uv2), 
wh);
+                res = gopro_at(idx, input_img[idx], mix(uv_start, uv_end, 
uv1), wh, true);
+                res2 = gopro_at(idx, input_img[idx], mix(uv_start, uv_end, 
uv2), wh, true);
             }
             else {
-                res = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv1), 
wh);
-                res2 = gopro_at(input2_img[idx], mix(uv_start, uv_end, uv2), 
wh);
+                res = gopro_at(idx, input2_img[idx], mix(uv_start, uv_end, 
uv1), wh, false);
+                res2 = gopro_at(idx, input2_img[idx], mix(uv_start, uv_end, 
uv2), wh, false);
             }
             res = mix(res, res2, gopro_mix_curve((uv1.x - blend_u[0]) / 
blend_span));
         }
@@ -513,7 +517,8 @@ void main()
            }
 
         if (in_transform == GOPROMAX && out_transform == EQUIRECTANGULAR)
-            v = gopro_equirect_ray(out_size, pos);
+            v = gopro_equirect_ray(out_size, pos,
+                                   (i > 0) ? chroma_off.xy : vec2(0.0));
 
         /* The C matrix is row-major. GoPro multiplies on the right so yaw
            matches gopromax2_cuda. Other projections keep the left multiply. */
-- 
2.54.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to