static inline int generate_map()

in Transform360/vf_transform360.c [104:168]


static inline int generate_map(
    TransformContext *s, AVFilterLink *inlink,
    AVFilterLink *outlink, AVFrame *in) {
    AVFilterContext *ctx = outlink->src;
    int ret = 0;

    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
    s->planes = av_pix_fmt_count_planes(outlink->format);
    s->out_map_planes = 2;

    FrameTransformContext frame_transform_ctx = (FrameTransformContext) {
      .input_layout = s->input_layout,
      .output_layout = s->output_layout,
      .input_stereo_format = s->input_stereo_format,
      .output_stereo_format = s->output_stereo_format,
      .vflip = s->vflip,
      .input_expand_coef = s->input_expand_coef,
      .expand_coef = s->expand_coef,
      .interpolation_alg = s->interpolation_alg,
      .width_scale_factor = s->width_scale_factor,
      .height_scale_factor = s->height_scale_factor,
      .fixed_yaw = s->fixed_yaw,
      .fixed_pitch = s->fixed_pitch,
      .fixed_roll = s->fixed_roll,
      .fixed_hfov = s->fixed_hfov,
      .fixed_vfov = s->fixed_vfov,
      .fixed_cube_offcenter_x = s->fixed_cube_offcenter_x,
      .fixed_cube_offcenter_y = s->fixed_cube_offcenter_y,
      .fixed_cube_offcenter_z = s->fixed_cube_offcenter_z,
      .is_horizontal_offset = s->is_horizontal_offset,
      .enable_low_pass_filter = s->enable_low_pass_filter,
      .kernel_height_scale_factor = s->kernel_height_scale_factor,
      .min_kernel_half_height = s->min_kernel_half_height,
      .max_kernel_half_height = s->max_kernel_half_height,
      .enable_multi_threading = s->enable_multi_threading,
      .num_vertical_segments = s->num_vertical_segments,
      .num_horizontal_segments = s->num_horizontal_segments,
      .adjust_kernel = s->adjust_kernel,
      .kernel_adjust_factor = s->kernel_adjust_factor};

    s->transform = VideoFrameTransform_new(&frame_transform_ctx);
    if (!s->transform) {
      return AVERROR(ENOMEM);
    }

    int in_w, in_h, out_w, out_h;
    for (int plane = 0; plane < s->out_map_planes; ++plane) {
      out_w = outlink->w;
      out_h = outlink->h;
      in_w = inlink->w;
      in_h = inlink->h;

      if (plane == 1) {
        update_plane_sizes(desc, &in_w, &in_h, &out_w, &out_h);
      }

      if (!VideoFrameTransform_generateMapForPlane(
            s->transform, in_w, in_h, out_w, out_h, plane)) {
        av_log(ctx, AV_LOG_INFO, "Failed to generate map for plane %d\n", plane);
        return AVERROR(EINVAL);
      }
    }

    return 0;
}