FFmpeg
Data Structures | Macros | Functions | Variables
vf_v360.c File Reference

360 video conversion filter. More...

#include <math.h>
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "v360.h"

Go to the source code of this file.

Data Structures

struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define OFFSET(x)   offsetof(V360Context, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define DEFINE_REMAP1_LINE(bits, div)
 
#define DEFINE_REMAP(ws, bits)
 Generate remapping function with a given window size and pixel depth. More...
 
#define DEFINE_REMAP_LINE(ws, bits, div)
 

Functions

 AVFILTER_DEFINE_CLASS (v360)
 
static int query_formats (AVFilterContext *ctx)
 
void ff_v360_init (V360Context *s, int depth)
 
static void nearest_kernel (float du, float dv, const XYRemap *rmap, uint16_t *u, uint16_t *v, int16_t *ker)
 Save nearest pixel coordinates for remapping. More...
 
static void bilinear_kernel (float du, float dv, const XYRemap *rmap, uint16_t *u, uint16_t *v, int16_t *ker)
 Calculate kernel for bilinear interpolation. More...
 
static void calculate_bicubic_coeffs (float t, float *coeffs)
 Calculate 1-dimensional cubic coefficients. More...
 
static void bicubic_kernel (float du, float dv, const XYRemap *rmap, uint16_t *u, uint16_t *v, int16_t *ker)
 Calculate kernel for bicubic interpolation. More...
 
static void calculate_lanczos_coeffs (float t, float *coeffs)
 Calculate 1-dimensional lanczos coefficients. More...
 
static void lanczos_kernel (float du, float dv, const XYRemap *rmap, uint16_t *u, uint16_t *v, int16_t *ker)
 Calculate kernel for lanczos interpolation. More...
 
static int mod (int a, int b)
 Modulo operation with only positive remainders. More...
 
static int get_direction (char c)
 Convert char to corresponding direction. More...
 
static int get_rotation (char c)
 Convert char to corresponding rotation angle. More...
 
static int get_rorder (char c)
 Convert char to corresponding rotation order. More...
 
static int prepare_cube_in (AVFilterContext *ctx)
 Prepare data for processing cubemap input format. More...
 
static int prepare_cube_out (AVFilterContext *ctx)
 Prepare data for processing cubemap output format. More...
 
static void rotate_cube_face (float *uf, float *vf, int rotation)
 
static void rotate_cube_face_inverse (float *uf, float *vf, int rotation)
 
static void normalize_vector (float *vec)
 Normalize vector. More...
 
static void cube_to_xyz (const V360Context *s, float uf, float vf, int face, float *vec)
 Calculate 3D coordinates on sphere for corresponding cubemap position. More...
 
static void xyz_to_cube (const V360Context *s, const float *vec, float *uf, float *vf, int *direction)
 Calculate cubemap position for corresponding 3D coordinates on sphere. More...
 
static void process_cube_coordinates (const V360Context *s, float uf, float vf, int direction, float *new_uf, float *new_vf, int *face)
 Find position on another cube face in case of overflow/underflow. More...
 
static void cube3x2_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in cubemap3x2 format. More...
 
static void xyz_to_cube3x2 (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in cubemap3x2 format for corresponding 3D coordinates on sphere. More...
 
static void cube1x6_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in cubemap1x6 format. More...
 
static void cube6x1_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in cubemap6x1 format. More...
 
static void xyz_to_cube1x6 (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in cubemap1x6 format for corresponding 3D coordinates on sphere. More...
 
static void xyz_to_cube6x1 (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in cubemap6x1 format for corresponding 3D coordinates on sphere. More...
 
static void equirect_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in equirectangular format. More...
 
static int prepare_stereographic_out (AVFilterContext *ctx)
 Prepare data for processing stereographic output format. More...
 
static void stereographic_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in stereographic format. More...
 
static void xyz_to_stereographic (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in stereographic format for corresponding 3D coordinates on sphere. More...
 
static void xyz_to_equirect (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in equirectangular format for corresponding 3D coordinates on sphere. More...
 
static void xyz_to_mercator (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in mercator format for corresponding 3D coordinates on sphere. More...
 
static void mercator_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in mercator format. More...
 
static int prepare_eac_in (AVFilterContext *ctx)
 Prepare data for processing equi-angular cubemap input format. More...
 
static int prepare_eac_out (AVFilterContext *ctx)
 Prepare data for processing equi-angular cubemap output format. More...
 
static void eac_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in equi-angular cubemap format. More...
 
static void xyz_to_eac (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in equi-angular cubemap format for corresponding 3D coordinates on sphere. More...
 
static int prepare_flat_out (AVFilterContext *ctx)
 Prepare data for processing flat output format. More...
 
static void flat_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in flat format. More...
 
static void dfisheye_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format. More...
 
static void xyz_to_dfisheye (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in dual fisheye format for corresponding 3D coordinates on sphere. More...
 
static void barrel_to_xyz (const V360Context *s, int i, int j, int width, int height, float *vec)
 Calculate 3D coordinates on sphere for corresponding frame position in barrel facebook's format. More...
 
static void xyz_to_barrel (const V360Context *s, const float *vec, int width, int height, uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
 Calculate frame position in barrel facebook's format for corresponding 3D coordinates on sphere. More...
 
static void multiply_matrix (float c[3][3], const float a[3][3], const float b[3][3])
 
static void calculate_rotation_matrix (float yaw, float pitch, float roll, float rot_mat[3][3], const int rotation_order[3])
 Calculate rotation matrix for yaw/pitch/roll angles. More...
 
static void rotate (const float rot_mat[3][3], float *vec)
 Rotate vector with given rotation matrix. More...
 
static void set_mirror_modifier (int h_flip, int v_flip, int d_flip, float *modifier)
 
static void mirror (const float *modifier, float *vec)
 
static int allocate_plane (V360Context *s, int sizeof_uv, int sizeof_ker, int p)
 
static void fov_from_dfov (V360Context *s, float w, float h)
 
static void set_dimensions (int *outw, int *outh, int w, int h, const AVPixFmtDescriptor *desc)
 
static av_always_inline int v360_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption v360_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
AVFilter ff_vf_v360
 

Detailed Description

360 video conversion filter.

Principle of operation:

(for each pixel in output frame) 1) Calculate OpenGL-like coordinates (x, y, z) for pixel position (i, j) 2) Apply 360 operations (rotation, mirror) to (x, y, z) 3) Calculate pixel position (u, v) in input frame 4) Calculate interpolation window and weight for each pixel

(for each frame) 5) Remap input frame to output frame using precalculated data

Definition in file vf_v360.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(V360Context, x)

Definition at line 53 of file vf_v360.c.

Definition at line 54 of file vf_v360.c.

#define DEFINE_REMAP1_LINE (   bits,
  div 
)
Value:
static void remap1_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src, \
ptrdiff_t in_linesize, \
const uint16_t *u, const uint16_t *v, const int16_t *ker) \
{ \
const uint##bits##_t *s = (const uint##bits##_t *)src; \
uint##bits##_t *d = (uint##bits##_t *)dst; \
\
in_linesize /= div; \
for (int x = 0; x < width; x++) \
d[x] = s[v[x] * in_linesize + u[x]]; \
}
#define src
Definition: vp8dsp.c:254
uint8_t
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:252
uint8_t bits
Definition: vp3data.h:202
#define width
#define s(width, name)
Definition: cbs_vp9.c:257
for(j=16;j >0;--j)

Definition at line 195 of file vf_v360.c.

#define DEFINE_REMAP (   ws,
  bits 
)

Generate remapping function with a given window size and pixel depth.

Parameters
wssize of interpolation window
bitsnumber of bits per pixel

Definition at line 218 of file vf_v360.c.

#define DEFINE_REMAP_LINE (   ws,
  bits,
  div 
)
Value:
static void remap##ws##_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src, \
ptrdiff_t in_linesize, \
const uint16_t *u, const uint16_t *v, const int16_t *ker) \
{ \
const uint##bits##_t *s = (const uint##bits##_t *)src; \
uint##bits##_t *d = (uint##bits##_t *)dst; \
\
in_linesize /= div; \
for (int x = 0; x < width; x++) { \
const uint16_t *uu = u + x * ws * ws; \
const uint16_t *vv = v + x * ws * ws; \
const int16_t *kker = ker + x * ws * ws; \
int tmp = 0; \
for (int i = 0; i < ws; i++) { \
for (int j = 0; j < ws; j++) { \
tmp += kker[i * ws + j] * s[vv[i * ws + j] * in_linesize + uu[i * ws + j]]; \
} \
} \
\
d[x] = av_clip_uint##bits(tmp >> 14); \
} \
}
#define src
Definition: vp8dsp.c:254
uint8_t
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:252
#define _
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
uint8_t bits
Definition: vp3data.h:202
#define width
#define s(width, name)
Definition: cbs_vp9.c:257
static const int remap[16]
Definition: msvideo1enc.c:63
int
for(j=16;j >0;--j)
static uint8_t tmp[11]
Definition: aes_ctr.c:26

Definition at line 264 of file vf_v360.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( v360  )
static int query_formats ( AVFilterContext ctx)
static

Definition at line 125 of file vf_v360.c.

void ff_v360_init ( V360Context s,
int  depth 
)

Definition at line 295 of file vf_v360.c.

Referenced by config_output().

static void nearest_kernel ( float  du,
float  dv,
const XYRemap rmap,
uint16_t *  u,
uint16_t *  v,
int16_t *  ker 
)
static

Save nearest pixel coordinates for remapping.

Parameters
duhorizontal relative coordinate
dvvertical relative coordinate
rmapcalculated 4x4 window
uu remap data
vv remap data
kerker remap data

Definition at line 324 of file vf_v360.c.

Referenced by config_output().

static void bilinear_kernel ( float  du,
float  dv,
const XYRemap rmap,
uint16_t *  u,
uint16_t *  v,
int16_t *  ker 
)
static

Calculate kernel for bilinear interpolation.

Parameters
duhorizontal relative coordinate
dvvertical relative coordinate
rmapcalculated 4x4 window
uu remap data
vv remap data
kerker remap data

Definition at line 344 of file vf_v360.c.

Referenced by config_output().

static void calculate_bicubic_coeffs ( float  t,
float *  coeffs 
)
inlinestatic

Calculate 1-dimensional cubic coefficients.

Parameters
trelative coordinate
coeffscoefficients

Definition at line 366 of file vf_v360.c.

Referenced by bicubic_kernel().

static void bicubic_kernel ( float  du,
float  dv,
const XYRemap rmap,
uint16_t *  u,
uint16_t *  v,
int16_t *  ker 
)
static

Calculate kernel for bicubic interpolation.

Parameters
duhorizontal relative coordinate
dvvertical relative coordinate
rmapcalculated 4x4 window
uu remap data
vv remap data
kerker remap data

Definition at line 387 of file vf_v360.c.

Referenced by config_output().

static void calculate_lanczos_coeffs ( float  t,
float *  coeffs 
)
inlinestatic

Calculate 1-dimensional lanczos coefficients.

Parameters
trelative coordinate
coeffscoefficients

Definition at line 411 of file vf_v360.c.

Referenced by lanczos_kernel().

static void lanczos_kernel ( float  du,
float  dv,
const XYRemap rmap,
uint16_t *  u,
uint16_t *  v,
int16_t *  ker 
)
static

Calculate kernel for lanczos interpolation.

Parameters
duhorizontal relative coordinate
dvvertical relative coordinate
rmapcalculated 4x4 window
uu remap data
vv remap data
kerker remap data

Definition at line 440 of file vf_v360.c.

Referenced by config_output().

static int mod ( int  a,
int  b 
)
inlinestatic

Modulo operation with only positive remainders.

Parameters
adividend
bdivisor
Returns
positive remainder of (a / b)

Definition at line 466 of file vf_v360.c.

Referenced by decode_init_static(), filter(), l1_unscale(), l2_unscale_group(), xyz_to_equirect(), and xyz_to_mercator().

static int get_direction ( char  c)
static

Convert char to corresponding direction.

Used for cubemap options.

Definition at line 480 of file vf_v360.c.

Referenced by prepare_cube_in(), and prepare_cube_out().

static int get_rotation ( char  c)
static

Convert char to corresponding rotation angle.

Used for cubemap options.

Definition at line 504 of file vf_v360.c.

Referenced by prepare_cube_in(), and prepare_cube_out().

static int get_rorder ( char  c)
static

Convert char to corresponding rotation order.

Definition at line 523 of file vf_v360.c.

Referenced by config_output().

static int prepare_cube_in ( AVFilterContext ctx)
static

Prepare data for processing cubemap input format.

Parameters
ctxfilter context
Returns
error code

Definition at line 547 of file vf_v360.c.

Referenced by config_output().

static int prepare_cube_out ( AVFilterContext ctx)
static

Prepare data for processing cubemap output format.

Parameters
ctxfilter context
Returns
error code

Definition at line 601 of file vf_v360.c.

Referenced by config_output().

static void rotate_cube_face ( float *  uf,
float *  vf,
int  rotation 
)
inlinestatic

Definition at line 648 of file vf_v360.c.

Referenced by process_cube_coordinates(), and xyz_to_cube().

static void rotate_cube_face_inverse ( float *  uf,
float *  vf,
int  rotation 
)
inlinestatic

Definition at line 674 of file vf_v360.c.

Referenced by cube_to_xyz(), and process_cube_coordinates().

static void normalize_vector ( float *  vec)
static

Normalize vector.

Parameters
vecvector

Definition at line 705 of file vf_v360.c.

Referenced by barrel_to_xyz(), cube_to_xyz(), dfisheye_to_xyz(), eac_to_xyz(), flat_to_xyz(), stereographic_to_xyz(), and v360_slice().

static void cube_to_xyz ( const V360Context s,
float  uf,
float  vf,
int  face,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding cubemap position.

Common operation for every cubemap.

Parameters
sfilter context
ufhorizontal cubemap coordinate [0, 1)
vfvertical cubemap coordinate [0, 1)
faceface of cubemap
veccoordinates on sphere

Definition at line 724 of file vf_v360.c.

Referenced by cube1x6_to_xyz(), cube3x2_to_xyz(), and cube6x1_to_xyz().

static void xyz_to_cube ( const V360Context s,
const float *  vec,
float *  uf,
float *  vf,
int direction 
)
static

Calculate cubemap position for corresponding 3D coordinates on sphere.

Common operation for every cubemap.

Parameters
sfilter context
veccoordinated on sphere
ufhorizontal cubemap coordinate [0, 1)
vfvertical cubemap coordinate [0, 1)
directiondirection of view

Definition at line 788 of file vf_v360.c.

Referenced by xyz_to_cube1x6(), xyz_to_cube3x2(), xyz_to_cube6x1(), and xyz_to_eac().

static void process_cube_coordinates ( const V360Context s,
float  uf,
float  vf,
int  direction,
float *  new_uf,
float *  new_vf,
int face 
)
static

Find position on another cube face in case of overflow/underflow.

Used for calculation of interpolation window.

Parameters
sfilter context
ufhorizontal cubemap coordinate
vfvertical cubemap coordinate
directiondirection of view
new_ufnew horizontal cubemap coordinate
new_vfnew vertical cubemap coordinate
faceface position on cubemap

Definition at line 866 of file vf_v360.c.

Referenced by xyz_to_cube1x6(), xyz_to_cube3x2(), and xyz_to_cube6x1().

static void cube3x2_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in cubemap3x2 format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1058 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_cube3x2 ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in cubemap3x2 format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1092 of file vf_v360.c.

Referenced by config_output().

static void cube1x6_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in cubemap1x6 format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1177 of file vf_v360.c.

Referenced by config_output().

static void cube6x1_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in cubemap6x1 format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1205 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_cube1x6 ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in cubemap1x6 format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1235 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_cube6x1 ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in cubemap6x1 format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1311 of file vf_v360.c.

Referenced by config_output().

static void equirect_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in equirectangular format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1385 of file vf_v360.c.

Referenced by config_output().

static int prepare_stereographic_out ( AVFilterContext ctx)
static

Prepare data for processing stereographic output format.

Parameters
ctxfilter context
Returns
error code

Definition at line 1409 of file vf_v360.c.

Referenced by config_output().

static void stereographic_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in stereographic format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1432 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_stereographic ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in stereographic format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1459 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_equirect ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in equirectangular format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1496 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_mercator ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in mercator format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1533 of file vf_v360.c.

Referenced by config_output().

static void mercator_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in mercator format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1568 of file vf_v360.c.

Referenced by config_output().

static int prepare_eac_in ( AVFilterContext ctx)
static

Prepare data for processing equi-angular cubemap input format.

Parameters
ctxfilter context
Returns
error code

Definition at line 1592 of file vf_v360.c.

Referenced by config_output().

static int prepare_eac_out ( AVFilterContext ctx)
static

Prepare data for processing equi-angular cubemap output format.

Parameters
ctxfilter context
Returns
error code

Definition at line 1652 of file vf_v360.c.

Referenced by config_output().

static void eac_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in equi-angular cubemap format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1683 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_eac ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in equi-angular cubemap format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1786 of file vf_v360.c.

Referenced by config_output().

static int prepare_flat_out ( AVFilterContext ctx)
static

Prepare data for processing flat output format.

Parameters
ctxfilter context
Returns
error code

Definition at line 1836 of file vf_v360.c.

Referenced by config_output().

static void flat_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in flat format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1860 of file vf_v360.c.

Referenced by config_output().

static void dfisheye_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1885 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_dfisheye ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in dual fisheye format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 1927 of file vf_v360.c.

Referenced by config_output().

static void barrel_to_xyz ( const V360Context s,
int  i,
int  j,
int  width,
int  height,
float *  vec 
)
static

Calculate 3D coordinates on sphere for corresponding frame position in barrel facebook's format.

Parameters
sfilter context
ihorizontal position on frame [0, width)
jvertical position on frame [0, height)
widthframe width
heightframe height
veccoordinates on sphere

Definition at line 1976 of file vf_v360.c.

Referenced by config_output().

static void xyz_to_barrel ( const V360Context s,
const float *  vec,
int  width,
int  height,
uint16_t  us[4][4],
uint16_t  vs[4][4],
float *  du,
float *  dv 
)
static

Calculate frame position in barrel facebook's format for corresponding 3D coordinates on sphere.

Parameters
sfilter context
veccoordinates on sphere
widthframe width
heightframe height
ushorizontal coordinates for interpolation window
vsvertical coordinates for interpolation window
duhorizontal relative coordinate
dvvertical relative coordinate

Definition at line 2048 of file vf_v360.c.

Referenced by config_output().

static void multiply_matrix ( float  c[3][3],
const float  a[3][3],
const float  b[3][3] 
)
static

Definition at line 2109 of file vf_v360.c.

Referenced by calculate_rotation_matrix().

static void calculate_rotation_matrix ( float  yaw,
float  pitch,
float  roll,
float  rot_mat[3][3],
const int  rotation_order[3] 
)
inlinestatic

Calculate rotation matrix for yaw/pitch/roll angles.

Definition at line 2126 of file vf_v360.c.

Referenced by config_output().

static void rotate ( const float  rot_mat[3][3],
float *  vec 
)
inlinestatic

Rotate vector with given rotation matrix.

Parameters
rot_matrotation matrix
vecvector

Definition at line 2166 of file vf_v360.c.

Referenced by mov_read_tkhd(), and v360_slice().

static void set_mirror_modifier ( int  h_flip,
int  v_flip,
int  d_flip,
float *  modifier 
)
inlinestatic

Definition at line 2178 of file vf_v360.c.

Referenced by config_output().

static void mirror ( const float *  modifier,
float *  vec 
)
inlinestatic

Definition at line 2186 of file vf_v360.c.

Referenced by v360_slice().

static int allocate_plane ( V360Context s,
int  sizeof_uv,
int  sizeof_ker,
int  p 
)
static

Definition at line 2193 of file vf_v360.c.

Referenced by config_output().

static void fov_from_dfov ( V360Context s,
float  w,
float  h 
)
static

Definition at line 2208 of file vf_v360.c.

Referenced by config_output().

static void set_dimensions ( int outw,
int outh,
int  w,
int  h,
const AVPixFmtDescriptor desc 
)
static

Definition at line 2222 of file vf_v360.c.

Referenced by config_output().

static av_always_inline int v360_slice ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 2231 of file vf_v360.c.

Referenced by config_output().

static int config_output ( AVFilterLink outlink)
static

Definition at line 2275 of file vf_v360.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 2583 of file vf_v360.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 2607 of file vf_v360.c.

Variable Documentation

const AVOption v360_options[]
static

Definition at line 56 of file vf_v360.c.

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_v360.c:2583

Definition at line 2618 of file vf_v360.c.

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)
Definition: vf_v360.c:2275

Definition at line 2627 of file vf_v360.c.

AVFilter ff_vf_v360
Initial value:
= {
.name = "v360",
.description = NULL_IF_CONFIG_SMALL("Convert 360 projection of video."),
.priv_size = sizeof(V360Context),
.priv_class = &v360_class,
}
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static int query_formats(AVFilterContext *ctx)
Definition: vf_v360.c:125
static const AVFilterPad outputs[]
Definition: vf_v360.c:2627
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_v360.c:2607
static const AVFilterPad inputs[]
Definition: vf_v360.c:2618
#define flags(name, subs,...)
Definition: cbs_av1.c:561

Definition at line 2636 of file vf_v360.c.