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

Go to the source code of this file.

Data Structures

struct  SwsPassBuffer
 Represents an allocated output buffer for a filter pass. 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 SwsFrame *out, const SwsFrame *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)
 
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...
 
int 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, SwsPass **out_pass)
 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, const AVFrame *dst, const AVFrame *src)
 Dispatch the filter graph on a single field of the given frames. More...
 

Typedef Documentation

◆ sws_filter_run_t

typedef void(* sws_filter_run_t) (const SwsFrame *out, const SwsFrame *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 45 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 32 of file graph.h.

Referenced by frame_shift(), and run_copy().

◆ 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 768 of file graph.c.

Referenced by ff_sws_graph_reinit().

◆ ff_sws_graph_add_pass()

int 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,
SwsPass **  out_pass 
)

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.
out_passThe newly added pass will be written here on success.
Returns
0 or a negative error code

Definition at line 107 of file graph.c.

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

◆ 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 809 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 863 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 847 of file graph.c.

Referenced by sws_frame_setup().

◆ ff_sws_graph_run()

void ff_sws_graph_run ( SwsGraph graph,
const AVFrame dst,
const AVFrame src 
)

Dispatch the filter graph on a single field of the given frames.

Internally threaded.

Definition at line 898 of file graph.c.