FFmpeg
Functions
graph.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/error.h"
#include "libavutil/imgutils.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/slicethread.h"
#include "libswscale/swscale.h"
#include "libswscale/utils.h"
#include "cms.h"
#include "lut3d.h"
#include "swscale_internal.h"
#include "graph.h"

Go to the source code of this file.

Functions

static int pass_alloc_output (SwsPass *pass)
 
static SwsPasspass_add (SwsGraph *graph, void *priv, enum AVPixelFormat fmt, int w, int h, SwsPass *input, int slice_align, sws_filter_run_t run)
 
static int pass_append (SwsGraph *graph, void *priv, enum AVPixelFormat fmt, int w, int h, SwsPass **pass, int slice_align, sws_filter_run_t run)
 
static int vshift (enum AVPixelFormat fmt, int plane)
 
static SwsImg shift_img (const SwsImg *img_base, int y)
 
static void run_copy (const SwsImg *out_base, const SwsImg *in_base, int y, int h, const SwsPass *pass)
 
static void run_rgb0 (const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
 
static void run_xyz2rgb (const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
 
static void run_rgb2xyz (const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
 
static void free_legacy_swscale (void *priv)
 
static void setup_legacy_swscale (const SwsImg *out, const SwsImg *in, const SwsPass *pass)
 
static SwsContextslice_ctx (const SwsPass *pass, int y)
 
static void run_legacy_unscaled (const SwsImg *out, const SwsImg *in_base, int y, int h, const SwsPass *pass)
 
static void run_legacy_swscale (const SwsImg *out_base, const SwsImg *in, int y, int h, const SwsPass *pass)
 
static void get_chroma_pos (SwsGraph *graph, int *h_chr_pos, int *v_chr_pos, const SwsFormat *fmt)
 
static void legacy_chr_pos (SwsGraph *graph, int *chr_pos, int override, int *warned)
 
static int init_legacy_subpass (SwsGraph *graph, SwsContext *sws, SwsPass *input, SwsPass **output)
 
static int add_legacy_sws_pass (SwsGraph *graph, SwsFormat src, SwsFormat dst, SwsPass *input, SwsPass **output)
 
static void free_lut3d (void *priv)
 
static void setup_lut3d (const SwsImg *out, const SwsImg *in, const SwsPass *pass)
 
static void run_lut3d (const SwsImg *out_base, const SwsImg *in_base, int y, int h, const SwsPass *pass)
 
static int adapt_colors (SwsGraph *graph, SwsFormat src, SwsFormat dst, SwsPass *input, SwsPass **output)
 
static int init_passes (SwsGraph *graph)
 
static void sws_graph_worker (void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
 
int sws_graph_create (SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **out_graph)
 Allocate and initialize the filter graph. More...
 
void sws_graph_free (SwsGraph **pgraph)
 Uninitialize any state associate with this filter graph and free it. More...
 
static int opts_equal (const SwsContext *c1, const SwsContext *c2)
 
int sws_graph_reinit (SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **out_graph)
 Wrapper around sws_graph_create() that reuses the existing graph if the format is compatible. More...
 
void sws_graph_update_metadata (SwsGraph *graph, const SwsColor *color)
 Update dynamic per-frame HDR metadata without requiring a full reinit. More...
 
void sws_graph_run (SwsGraph *graph, uint8_t *const out_data[4], const int out_linesize[4], const uint8_t *const in_data[4], const int in_linesize[4])
 Dispatch the filter graph on a single field. More...
 

Function Documentation

◆ pass_alloc_output()

static int pass_alloc_output ( SwsPass pass)
static

Definition at line 38 of file graph.c.

Referenced by pass_add().

◆ pass_add()

static SwsPass* pass_add ( SwsGraph graph,
void *  priv,
enum AVPixelFormat  fmt,
int  w,
int  h,
SwsPass input,
int  slice_align,
sws_filter_run_t  run 
)
static

Definition at line 48 of file graph.c.

Referenced by adapt_colors(), init_legacy_subpass(), init_passes(), and pass_append().

◆ pass_append()

static int pass_append ( SwsGraph graph,
void *  priv,
enum AVPixelFormat  fmt,
int  w,
int  h,
SwsPass **  pass,
int  slice_align,
sws_filter_run_t  run 
)
static

Definition at line 88 of file graph.c.

Referenced by init_legacy_subpass().

◆ vshift()

static int vshift ( enum AVPixelFormat  fmt,
int  plane 
)
static

◆ shift_img()

static SwsImg shift_img ( const SwsImg img_base,
int  y 
)
static

Definition at line 106 of file graph.c.

Referenced by run_copy(), run_legacy_swscale(), run_legacy_unscaled(), and run_lut3d().

◆ run_copy()

static void run_copy ( const SwsImg out_base,
const SwsImg in_base,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 114 of file graph.c.

Referenced by init_passes().

◆ run_rgb0()

static void run_rgb0 ( const SwsImg out,
const SwsImg in,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 135 of file graph.c.

Referenced by init_legacy_subpass().

◆ run_xyz2rgb()

static void run_xyz2rgb ( const SwsImg out,
const SwsImg in,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 156 of file graph.c.

Referenced by init_legacy_subpass().

◆ run_rgb2xyz()

static void run_rgb2xyz ( const SwsImg out,
const SwsImg in,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 164 of file graph.c.

Referenced by init_legacy_subpass().

◆ free_legacy_swscale()

static void free_legacy_swscale ( void *  priv)
static

Definition at line 178 of file graph.c.

Referenced by init_legacy_subpass().

◆ setup_legacy_swscale()

static void setup_legacy_swscale ( const SwsImg out,
const SwsImg in,
const SwsPass pass 
)
static

Definition at line 184 of file graph.c.

Referenced by init_legacy_subpass().

◆ slice_ctx()

static SwsContext* slice_ctx ( const SwsPass pass,
int  y 
)
inlinestatic

Definition at line 198 of file graph.c.

Referenced by run_legacy_swscale(), and run_legacy_unscaled().

◆ run_legacy_unscaled()

static void run_legacy_unscaled ( const SwsImg out,
const SwsImg in_base,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 217 of file graph.c.

Referenced by init_legacy_subpass().

◆ run_legacy_swscale()

static void run_legacy_swscale ( const SwsImg out_base,
const SwsImg in,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 228 of file graph.c.

Referenced by init_legacy_subpass().

◆ get_chroma_pos()

static void get_chroma_pos ( SwsGraph graph,
int *  h_chr_pos,
int *  v_chr_pos,
const SwsFormat fmt 
)
static

Definition at line 239 of file graph.c.

Referenced by add_legacy_sws_pass().

◆ legacy_chr_pos()

static void legacy_chr_pos ( SwsGraph graph,
int *  chr_pos,
int  override,
int *  warned 
)
static

Definition at line 282 of file graph.c.

Referenced by add_legacy_sws_pass().

◆ init_legacy_subpass()

static int init_legacy_subpass ( SwsGraph graph,
SwsContext sws,
SwsPass input,
SwsPass **  output 
)
static

For slice threading, we need to create sub contexts, similar to how swscale normally handles it internally. The most important difference is that we handle cascaded contexts before threaded contexts; whereas context_init_threaded() does it the other way around.

Definition at line 297 of file graph.c.

Referenced by add_legacy_sws_pass().

◆ add_legacy_sws_pass()

static int add_legacy_sws_pass ( SwsGraph graph,
SwsFormat  src,
SwsFormat  dst,
SwsPass input,
SwsPass **  output 
)
static

Definition at line 399 of file graph.c.

Referenced by adapt_colors(), and init_passes().

◆ free_lut3d()

static void free_lut3d ( void *  priv)
static

Definition at line 472 of file graph.c.

Referenced by adapt_colors().

◆ setup_lut3d()

static void setup_lut3d ( const SwsImg out,
const SwsImg in,
const SwsPass pass 
)
static

Definition at line 478 of file graph.c.

Referenced by adapt_colors().

◆ run_lut3d()

static void run_lut3d ( const SwsImg out_base,
const SwsImg in_base,
int  y,
int  h,
const SwsPass pass 
)
static

Definition at line 486 of file graph.c.

Referenced by adapt_colors().

◆ adapt_colors()

static int adapt_colors ( SwsGraph graph,
SwsFormat  src,
SwsFormat  dst,
SwsPass input,
SwsPass **  output 
)
static

Grayspace does not really have primaries, so just force the use of the equivalent other primary set to avoid a conversion. Technically, this does affect the weights used for the Grayscale conversion, but in practise, that should give the expected results more often than not.

Definition at line 497 of file graph.c.

Referenced by init_passes().

◆ init_passes()

static int init_passes ( SwsGraph graph)
static

Definition at line 565 of file graph.c.

Referenced by sws_graph_create().

◆ sws_graph_worker()

static void sws_graph_worker ( void *  priv,
int  jobnr,
int  threadnr,
int  nb_jobs,
int  nb_threads 
)
static

Definition at line 597 of file graph.c.

Referenced by sws_graph_create().

◆ sws_graph_create()

int sws_graph_create ( SwsContext ctx,
const SwsFormat dst,
const SwsFormat src,
int  field,
SwsGraph **  out_graph 
)

Allocate and initialize the filter graph.

Returns 0 or a negative error.

Definition at line 610 of file graph.c.

Referenced by sws_graph_reinit().

◆ sws_graph_free()

void sws_graph_free ( SwsGraph **  pgraph)

Uninitialize any state associate with this filter graph and free it.

Definition at line 648 of file graph.c.

Referenced by sws_frame_setup(), sws_freeContext(), sws_graph_create(), and sws_graph_reinit().

◆ opts_equal()

static int opts_equal ( const SwsContext c1,
const SwsContext c2 
)
static

Definition at line 671 of file graph.c.

Referenced by sws_graph_reinit().

◆ sws_graph_reinit()

int sws_graph_reinit ( SwsContext ctx,
const SwsFormat dst,
const SwsFormat src,
int  field,
SwsGraph **  graph 
)

Wrapper around sws_graph_create() that reuses the existing graph if the format is compatible.

This will also update dynamic per-frame metadata. Must be called after changing any of the fields in ctx, or else they will have no effect.

Definition at line 687 of file graph.c.

Referenced by sws_frame_setup().

◆ sws_graph_update_metadata()

void sws_graph_update_metadata ( SwsGraph graph,
const SwsColor color 
)

Update dynamic per-frame HDR metadata without requiring a full reinit.

Definition at line 703 of file graph.c.

Referenced by sws_graph_reinit().

◆ sws_graph_run()

void sws_graph_run ( SwsGraph graph,
uint8_t *const  out_data[4],
const int  out_linesize[4],
const uint8_t *const  in_data[4],
const int  in_linesize[4] 
)

Dispatch the filter graph on a single field.

Internally threaded.

Definition at line 711 of file graph.c.

Referenced by sws_scale_frame().