2019-09-03 16:54:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Eugene Lyapustin
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVFILTER_V360_H
|
|
|
|
#define AVFILTER_V360_H
|
|
|
|
#include "avfilter.h"
|
|
|
|
|
2019-09-14 16:16:02 +00:00
|
|
|
enum StereoFormats {
|
|
|
|
STEREO_2D,
|
|
|
|
STEREO_SBS,
|
|
|
|
STEREO_TB,
|
|
|
|
NB_STEREO_FMTS,
|
|
|
|
};
|
|
|
|
|
2019-09-03 16:54:44 +00:00
|
|
|
enum Projections {
|
|
|
|
EQUIRECTANGULAR,
|
|
|
|
CUBEMAP_3_2,
|
|
|
|
CUBEMAP_6_1,
|
|
|
|
EQUIANGULAR,
|
|
|
|
FLAT,
|
|
|
|
DUAL_FISHEYE,
|
|
|
|
BARREL,
|
|
|
|
CUBEMAP_1_6,
|
2019-09-08 16:17:57 +00:00
|
|
|
STEREOGRAPHIC,
|
2019-09-17 20:15:07 +00:00
|
|
|
MERCATOR,
|
2019-09-19 16:36:19 +00:00
|
|
|
BALL,
|
2019-09-21 13:29:18 +00:00
|
|
|
HAMMER,
|
2019-09-25 10:01:54 +00:00
|
|
|
SINUSOIDAL,
|
2020-01-16 17:12:04 +00:00
|
|
|
FISHEYE,
|
2020-01-16 19:06:28 +00:00
|
|
|
PANNINI,
|
2020-01-17 09:46:31 +00:00
|
|
|
CYLINDRICAL,
|
2020-01-18 15:26:59 +00:00
|
|
|
PERSPECTIVE,
|
2020-01-22 21:21:32 +00:00
|
|
|
TETRAHEDRON,
|
2020-02-26 13:37:39 +00:00
|
|
|
BARREL_SPLIT,
|
2020-03-02 16:40:21 +00:00
|
|
|
TSPYRAMID,
|
2020-03-03 11:03:42 +00:00
|
|
|
HEQUIRECTANGULAR,
|
2020-06-22 12:39:35 +00:00
|
|
|
EQUISOLID,
|
2020-06-22 18:16:22 +00:00
|
|
|
ORTHOGRAPHIC,
|
2020-09-27 20:33:05 +00:00
|
|
|
OCTAHEDRON,
|
2021-06-29 22:12:41 +00:00
|
|
|
CYLINDRICALEA,
|
2019-09-03 16:54:44 +00:00
|
|
|
NB_PROJECTIONS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum InterpMethod {
|
|
|
|
NEAREST,
|
|
|
|
BILINEAR,
|
2020-03-31 11:22:10 +00:00
|
|
|
LAGRANGE9,
|
2019-09-03 16:54:44 +00:00
|
|
|
BICUBIC,
|
|
|
|
LANCZOS,
|
2020-01-17 19:01:23 +00:00
|
|
|
SPLINE16,
|
2020-01-18 12:43:33 +00:00
|
|
|
GAUSSIAN,
|
2020-10-04 12:36:30 +00:00
|
|
|
MITCHELL,
|
2019-09-03 16:54:44 +00:00
|
|
|
NB_INTERP_METHODS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Faces {
|
|
|
|
TOP_LEFT,
|
|
|
|
TOP_MIDDLE,
|
|
|
|
TOP_RIGHT,
|
|
|
|
BOTTOM_LEFT,
|
|
|
|
BOTTOM_MIDDLE,
|
|
|
|
BOTTOM_RIGHT,
|
|
|
|
NB_FACES,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Direction {
|
|
|
|
RIGHT, ///< Axis +X
|
|
|
|
LEFT, ///< Axis -X
|
|
|
|
UP, ///< Axis +Y
|
|
|
|
DOWN, ///< Axis -Y
|
|
|
|
FRONT, ///< Axis -Z
|
|
|
|
BACK, ///< Axis +Z
|
|
|
|
NB_DIRECTIONS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Rotation {
|
|
|
|
ROT_0,
|
|
|
|
ROT_90,
|
|
|
|
ROT_180,
|
|
|
|
ROT_270,
|
|
|
|
NB_ROTATIONS,
|
|
|
|
};
|
|
|
|
|
2019-09-06 11:14:29 +00:00
|
|
|
enum RotationOrder {
|
|
|
|
YAW,
|
|
|
|
PITCH,
|
|
|
|
ROLL,
|
|
|
|
NB_RORDERS,
|
|
|
|
};
|
|
|
|
|
2019-09-16 16:16:57 +00:00
|
|
|
typedef struct XYRemap {
|
2020-01-19 09:46:07 +00:00
|
|
|
int16_t u[4][4];
|
|
|
|
int16_t v[4][4];
|
2019-09-16 16:16:57 +00:00
|
|
|
float ker[4][4];
|
|
|
|
} XYRemap;
|
|
|
|
|
2020-09-29 08:48:54 +00:00
|
|
|
typedef struct SliceXYRemap {
|
|
|
|
int16_t *u[2], *v[2];
|
|
|
|
int16_t *ker[2];
|
|
|
|
uint8_t *mask;
|
|
|
|
} SliceXYRemap;
|
|
|
|
|
2019-09-03 16:54:44 +00:00
|
|
|
typedef struct V360Context {
|
|
|
|
const AVClass *class;
|
|
|
|
int in, out;
|
|
|
|
int interp;
|
2020-01-25 12:24:33 +00:00
|
|
|
int alpha;
|
2021-10-16 09:37:07 +00:00
|
|
|
int reset_rot;
|
2019-09-03 16:54:44 +00:00
|
|
|
int width, height;
|
2019-09-06 11:14:29 +00:00
|
|
|
char *in_forder;
|
|
|
|
char *out_forder;
|
|
|
|
char *in_frot;
|
|
|
|
char *out_frot;
|
|
|
|
char *rorder;
|
2019-09-03 16:54:44 +00:00
|
|
|
|
|
|
|
int in_cubemap_face_order[6];
|
|
|
|
int out_cubemap_direction_order[6];
|
|
|
|
int in_cubemap_face_rotation[6];
|
|
|
|
int out_cubemap_face_rotation[6];
|
2019-09-06 11:14:29 +00:00
|
|
|
int rotation_order[3];
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2019-09-14 16:16:02 +00:00
|
|
|
int in_stereo, out_stereo;
|
|
|
|
|
2019-09-03 16:54:44 +00:00
|
|
|
float in_pad, out_pad;
|
2019-09-22 12:01:14 +00:00
|
|
|
int fin_pad, fout_pad;
|
2019-09-03 16:54:44 +00:00
|
|
|
|
|
|
|
float yaw, pitch, roll;
|
2021-11-15 10:22:53 +00:00
|
|
|
float h_offset, v_offset;
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2019-09-07 17:54:00 +00:00
|
|
|
int ih_flip, iv_flip;
|
2019-09-03 16:54:44 +00:00
|
|
|
int h_flip, v_flip, d_flip;
|
2019-09-07 14:32:16 +00:00
|
|
|
int in_transpose, out_transpose;
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2019-09-14 08:47:01 +00:00
|
|
|
float h_fov, v_fov, d_fov;
|
2020-01-20 13:50:54 +00:00
|
|
|
float ih_fov, iv_fov, id_fov;
|
2019-09-20 19:41:12 +00:00
|
|
|
float flat_range[2];
|
2020-01-20 13:50:54 +00:00
|
|
|
float iflat_range[2];
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2020-10-06 11:51:52 +00:00
|
|
|
float rot_quaternion[2][4];
|
2019-09-16 15:53:58 +00:00
|
|
|
|
|
|
|
float output_mirror_modifier[3];
|
2019-09-07 17:54:00 +00:00
|
|
|
|
2019-09-22 12:01:14 +00:00
|
|
|
int in_width, in_height;
|
|
|
|
int out_width, out_height;
|
|
|
|
|
2019-09-14 16:16:02 +00:00
|
|
|
int pr_width[4], pr_height[4];
|
|
|
|
|
|
|
|
int in_offset_w[4], in_offset_h[4];
|
|
|
|
int out_offset_w[4], out_offset_h[4];
|
|
|
|
|
2019-09-03 16:54:44 +00:00
|
|
|
int planewidth[4], planeheight[4];
|
|
|
|
int inplanewidth[4], inplaneheight[4];
|
2019-09-09 16:36:56 +00:00
|
|
|
int uv_linesize[4];
|
2019-09-03 16:54:44 +00:00
|
|
|
int nb_planes;
|
2019-09-06 09:46:11 +00:00
|
|
|
int nb_allocated;
|
2019-09-16 16:16:57 +00:00
|
|
|
int elements;
|
2020-01-25 12:24:33 +00:00
|
|
|
int mask_size;
|
|
|
|
int max_value;
|
2020-09-29 08:48:54 +00:00
|
|
|
int nb_threads;
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2020-09-29 08:48:54 +00:00
|
|
|
SliceXYRemap *slice_remap;
|
2019-09-06 09:46:11 +00:00
|
|
|
unsigned map[4];
|
2019-09-03 16:54:44 +00:00
|
|
|
|
2020-01-25 12:24:33 +00:00
|
|
|
int (*in_transform)(const struct V360Context *s,
|
|
|
|
const float *vec, int width, int height,
|
|
|
|
int16_t us[4][4], int16_t vs[4][4], float *du, float *dv);
|
2019-09-16 16:16:57 +00:00
|
|
|
|
2020-01-25 12:24:33 +00:00
|
|
|
int (*out_transform)(const struct V360Context *s,
|
|
|
|
int i, int j, int width, int height,
|
|
|
|
float *vec);
|
2019-09-16 16:16:57 +00:00
|
|
|
|
|
|
|
void (*calculate_kernel)(float du, float dv, const XYRemap *rmap,
|
2020-01-19 09:46:07 +00:00
|
|
|
int16_t *u, int16_t *v, int16_t *ker);
|
2019-09-16 16:16:57 +00:00
|
|
|
|
2019-09-03 16:54:44 +00:00
|
|
|
int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
|
|
|
|
|
2020-01-18 17:48:02 +00:00
|
|
|
void (*remap_line)(uint8_t *dst, int width, const uint8_t *const src, ptrdiff_t in_linesize,
|
2020-01-19 09:46:07 +00:00
|
|
|
const int16_t *const u, const int16_t *const v, const int16_t *const ker);
|
2019-09-03 16:54:44 +00:00
|
|
|
} V360Context;
|
|
|
|
|
|
|
|
void ff_v360_init(V360Context *s, int depth);
|
|
|
|
void ff_v360_init_x86(V360Context *s, int depth);
|
|
|
|
|
|
|
|
#endif /* AVFILTER_V360_H */
|