FFmpeg
Data Structures | Typedefs | Functions
graph.h File Reference
#include <stdbool.h>
#include "libavutil/slicethread.h"
#include "swscale.h"
#include "format.h"

Go to the source code of this file.

Data Structures

struct  SwsImg
 Represents a view into a single field of frame data. More...
 
struct  SwsPass
 Represents a single filter pass in the scaling graph. More...
 
struct  SwsGraph
 Filter graph, which represents a 'baked' pixel format conversion. More...
 

Typedefs

typedef void(* sws_filter_run_t) (const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)
 Output h lines of filtered data. More...
 

Functions

static av_always_inline av_const int ff_fmt_vshift (enum AVPixelFormat fmt, int plane)
 
static av_const SwsImg ff_sws_img_shift (const SwsImg *base, const int y)
 
int ff_sws_graph_create (SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **out_graph)
 Allocate and initialize the filter graph. More...
 
SwsPassff_sws_graph_add_pass (SwsGraph *graph, enum AVPixelFormat fmt, int width, int height, SwsPass *input, int align, void *priv, sws_filter_run_t run)
 Allocate and add a new pass to the filter graph. More...
 
void ff_sws_graph_free (SwsGraph **graph)
 Uninitialize any state associate with this filter graph and free it. More...
 
void ff_sws_graph_update_metadata (SwsGraph *graph, const SwsColor *color)
 Update dynamic per-frame HDR metadata without requiring a full reinit. More...
 
int ff_sws_graph_reinit (SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, int field, SwsGraph **graph)
 Wrapper around ff_sws_graph_create() that reuses the existing graph if the format is compatible. More...
 
void ff_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...
 

Typedef Documentation

◆ sws_filter_run_t

typedef void(* sws_filter_run_t) (const SwsImg *out, const SwsImg *in, int y, int h, const SwsPass *pass)

Output h lines of filtered data.

out and in point to the start of the image buffer for this pass.

Definition at line 60 of file graph.h.

Function Documentation

◆ ff_fmt_vshift()

static av_always_inline av_const int ff_fmt_vshift ( enum AVPixelFormat  fmt,
int  plane 
)
static

Definition at line 39 of file graph.h.

Referenced by ff_sws_img_shift(), and run_copy().

◆ ff_sws_img_shift()

static av_const SwsImg ff_sws_img_shift ( const SwsImg base,
const int  y 
)
inlinestatic

Definition at line 45 of file graph.h.

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

◆ ff_sws_graph_create()

int ff_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 599 of file graph.c.

Referenced by ff_sws_graph_reinit().

◆ ff_sws_graph_add_pass()

SwsPass* ff_sws_graph_add_pass ( SwsGraph graph,
enum AVPixelFormat  fmt,
int  width,
int  height,
SwsPass input,
int  align,
void *  priv,
sws_filter_run_t  run 
)

Allocate and add a new pass to the filter graph.

Parameters
graphFilter graph to add the pass to.
fmtPixel format of the output image.
wWidth of the output image.
hHeight of the output image.
inputPrevious pass to read from, or NULL for the input image.
alignMinimum slice alignment for this pass, or 0 for no threading.
privPrivate state for the filter run function.
runFilter function to run.
Returns
The newly created pass, or NULL on error.

Definition at line 47 of file graph.c.

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

◆ ff_sws_graph_free()

void ff_sws_graph_free ( SwsGraph **  graph)

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

Definition at line 637 of file graph.c.

Referenced by ff_sws_graph_create(), ff_sws_graph_reinit(), sws_frame_setup(), and sws_freeContext().

◆ ff_sws_graph_update_metadata()

void ff_sws_graph_update_metadata ( SwsGraph graph,
const SwsColor color 
)

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

Definition at line 692 of file graph.c.

Referenced by ff_sws_graph_reinit().

◆ ff_sws_graph_reinit()

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

Wrapper around ff_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 676 of file graph.c.

Referenced by sws_frame_setup().

◆ ff_sws_graph_run()

void ff_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 700 of file graph.c.