FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_tonemap_opencl.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "opencl.h"
#include "opencl_source.h"
#include "video.h"
#include "colorspace.h"

Go to the source code of this file.

Data Structures

struct  TonemapOpenCLContext
 

Macros

#define DETECTION_FRAMES   63
 
#define OPENCL_SOURCE_NB   3
 
#define OFFSET(x)   offsetof(TonemapOpenCLContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  TonemapAlgorithm {
  TONEMAP_NONE, TONEMAP_LINEAR, TONEMAP_GAMMA, TONEMAP_CLIP,
  TONEMAP_REINHARD, TONEMAP_HABLE, TONEMAP_MOBIUS, TONEMAP_MAX,
  TONEMAP_NONE, TONEMAP_LINEAR, TONEMAP_GAMMA, TONEMAP_CLIP,
  TONEMAP_REINHARD, TONEMAP_HABLE, TONEMAP_MOBIUS, TONEMAP_MAX
}
 

Functions

static int get_rgb2rgb_matrix (enum AVColorPrimaries in, enum AVColorPrimaries out, double rgb2rgb[3][3])
 
static int tonemap_opencl_init (AVFilterContext *avctx)
 
static int tonemap_opencl_config_output (AVFilterLink *outlink)
 
static int launch_kernel (AVFilterContext *avctx, cl_kernel kernel, AVFrame *output, AVFrame *input, float peak)
 
static int tonemap_opencl_filter_frame (AVFilterLink *inlink, AVFrame *input)
 
static av_cold void tonemap_opencl_uninit (AVFilterContext *avctx)
 
 AVFILTER_DEFINE_CLASS (tonemap_opencl)
 

Variables

static const char *const linearize_funcs [AVCOL_TRC_NB]
 
static const char *const delinearize_funcs [AVCOL_TRC_NB]
 
static const char *const tonemap_func [TONEMAP_MAX]
 
static const float sdr_avg = 0.25f
 
static const AVOption tonemap_opencl_options []
 
static const AVFilterPad tonemap_opencl_inputs []
 
static const AVFilterPad tonemap_opencl_outputs []
 
const AVFilter ff_vf_tonemap_opencl
 

Macro Definition Documentation

◆ DETECTION_FRAMES

#define DETECTION_FRAMES   63

Definition at line 38 of file vf_tonemap_opencl.c.

◆ OPENCL_SOURCE_NB

#define OPENCL_SOURCE_NB   3

Definition at line 111 of file vf_tonemap_opencl.c.

◆ OFFSET

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

Definition at line 483 of file vf_tonemap_opencl.c.

◆ FLAGS

Definition at line 484 of file vf_tonemap_opencl.c.

Enumeration Type Documentation

◆ TonemapAlgorithm

Enumerator
TONEMAP_NONE 
TONEMAP_LINEAR 
TONEMAP_GAMMA 
TONEMAP_CLIP 
TONEMAP_REINHARD 
TONEMAP_HABLE 
TONEMAP_MOBIUS 
TONEMAP_MAX 
TONEMAP_NONE 
TONEMAP_LINEAR 
TONEMAP_GAMMA 
TONEMAP_CLIP 
TONEMAP_REINHARD 
TONEMAP_HABLE 
TONEMAP_MOBIUS 
TONEMAP_MAX 

Definition at line 40 of file vf_tonemap_opencl.c.

Function Documentation

◆ get_rgb2rgb_matrix()

static int get_rgb2rgb_matrix ( enum AVColorPrimaries  in,
enum AVColorPrimaries  out,
double  rgb2rgb[3][3] 
)
static

Definition at line 93 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_init().

◆ tonemap_opencl_init()

static int tonemap_opencl_init ( AVFilterContext avctx)
static

Definition at line 116 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_filter_frame().

◆ tonemap_opencl_config_output()

static int tonemap_opencl_config_output ( AVFilterLink outlink)
static

Definition at line 280 of file vf_tonemap_opencl.c.

◆ launch_kernel()

static int launch_kernel ( AVFilterContext avctx,
cl_kernel  kernel,
AVFrame output,
AVFrame input,
float  peak 
)
static

Definition at line 304 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_filter_frame().

◆ tonemap_opencl_filter_frame()

static int tonemap_opencl_filter_frame ( AVFilterLink inlink,
AVFrame input 
)
static

Definition at line 336 of file vf_tonemap_opencl.c.

◆ tonemap_opencl_uninit()

static av_cold void tonemap_opencl_uninit ( AVFilterContext avctx)
static

Definition at line 459 of file vf_tonemap_opencl.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( tonemap_opencl  )

Variable Documentation

◆ linearize_funcs

const char* const linearize_funcs[AVCOL_TRC_NB]
static
Initial value:
= {
[AVCOL_TRC_SMPTE2084] = "eotf_st2084",
[AVCOL_TRC_ARIB_STD_B67] = "inverse_oetf_hlg",
}

Definition at line 73 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_init().

◆ delinearize_funcs

const char* const delinearize_funcs[AVCOL_TRC_NB]
static
Initial value:
= {
[AVCOL_TRC_BT709] = "inverse_eotf_bt1886",
[AVCOL_TRC_BT2020_10] = "inverse_eotf_bt1886",
}

Definition at line 78 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_init().

◆ tonemap_func

const char* const tonemap_func[TONEMAP_MAX]
static
Initial value:
= {
[TONEMAP_NONE] = "direct",
[TONEMAP_LINEAR] = "linear",
[TONEMAP_GAMMA] = "gamma",
[TONEMAP_CLIP] = "clip",
[TONEMAP_REINHARD] = "reinhard",
[TONEMAP_HABLE] = "hable",
[TONEMAP_MOBIUS] = "mobius",
}

Definition at line 83 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_init().

◆ sdr_avg

const float sdr_avg = 0.25f
static

Definition at line 114 of file vf_tonemap_opencl.c.

Referenced by tonemap_opencl_init().

◆ tonemap_opencl_options

const AVOption tonemap_opencl_options[]
static

Definition at line 485 of file vf_tonemap_opencl.c.

◆ tonemap_opencl_inputs

const AVFilterPad tonemap_opencl_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = &tonemap_opencl_filter_frame,
},
}

Definition at line 522 of file vf_tonemap_opencl.c.

◆ tonemap_opencl_outputs

const AVFilterPad tonemap_opencl_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = &tonemap_opencl_config_output,
},
}

Definition at line 531 of file vf_tonemap_opencl.c.

◆ ff_vf_tonemap_opencl

const AVFilter ff_vf_tonemap_opencl
Initial value:
= {
.name = "tonemap_opencl",
.description = NULL_IF_CONFIG_SMALL("Perform HDR to SDR conversion with tonemapping."),
.priv_size = sizeof(TonemapOpenCLContext),
.priv_class = &tonemap_opencl_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 539 of file vf_tonemap_opencl.c.

TONEMAP_REINHARD
@ TONEMAP_REINHARD
Definition: vf_tonemap_opencl.c:45
tonemap_opencl_config_output
static int tonemap_opencl_config_output(AVFilterLink *outlink)
Definition: vf_tonemap_opencl.c:280
TONEMAP_HABLE
@ TONEMAP_HABLE
Definition: vf_tonemap_opencl.c:46
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
TONEMAP_GAMMA
@ TONEMAP_GAMMA
Definition: vf_tonemap_opencl.c:43
TonemapOpenCLContext
Definition: vf_tonemap_opencl.c:51
tonemap_opencl_filter_frame
static int tonemap_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
Definition: vf_tonemap_opencl.c:336
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
tonemap_opencl_outputs
static const AVFilterPad tonemap_opencl_outputs[]
Definition: vf_tonemap_opencl.c:531
tonemap_opencl_uninit
static av_cold void tonemap_opencl_uninit(AVFilterContext *avctx)
Definition: vf_tonemap_opencl.c:459
TONEMAP_NONE
@ TONEMAP_NONE
Definition: vf_tonemap_opencl.c:41
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:626
AV_PIX_FMT_OPENCL
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
Definition: pixfmt.h:358
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: filters.h:206
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:628
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
tonemap_opencl_inputs
static const AVFilterPad tonemap_opencl_inputs[]
Definition: vf_tonemap_opencl.c:522
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
ff_opencl_filter_config_input
int ff_opencl_filter_config_input(AVFilterLink *inlink)
Check that the input link contains a suitable hardware frames context and extract the device from it.
Definition: opencl.c:46
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:613
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
ff_opencl_filter_init
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
Definition: opencl.c:135
TONEMAP_MOBIUS
@ TONEMAP_MOBIUS
Definition: vf_tonemap_opencl.c:47
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:632
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
TONEMAP_CLIP
@ TONEMAP_CLIP
Definition: vf_tonemap_opencl.c:44
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
TONEMAP_LINEAR
@ TONEMAP_LINEAR
Definition: vf_tonemap_opencl.c:42