48 int jobnr,
int nb_jobs);
58 float kelvin = k / 100.0f;
60 if (kelvin <= 66.0f) {
62 rgb[1] =
saturate(0.39008157876901960784f * logf(kelvin) - 0.63184144378862745098f);
64 const float t =
fmaxf(kelvin - 60.0f, 0.0f);
71 else if (kelvin <= 19.0f)
74 rgb[2] =
saturate(0.54320678911019607843f * logf(kelvin - 10.0f) - 1.19625408914f);
77static float lerpf(
float v0,
float v1,
float f)
79 return v0 + (v1 - v0) *
f;
87 nr = lerpf(r, nr, mix); \
88 ng = lerpf(g, ng, mix); \
89 nb = lerpf(b, nb, mix); \
91 l0 = (FFMAX3(r, g, b) + FFMIN3(r, g, b)) + FLT_EPSILON; \
92 l1 = (FFMAX3(nr, ng, nb) + FFMIN3(nr, ng, nb)) + FLT_EPSILON; \
99 nr = lerpf(nr, r, preserve); \
100 ng = lerpf(ng, g, preserve); \
101 nb = lerpf(nb, b, preserve);
109 const float mix =
s->mix;
110 const float preserve =
s->preserve;
111 const float *
color =
s->color;
114 const ptrdiff_t glinesize =
frame->linesize[0];
115 const ptrdiff_t blinesize =
frame->linesize[1];
116 const ptrdiff_t rlinesize =
frame->linesize[2];
122 for (
int x = 0; x <
width; x++) {
148 const int depth =
s->depth;
151 const float preserve =
s->preserve;
152 const float mix =
s->mix;
153 const float *
color =
s->color;
156 const ptrdiff_t glinesize =
frame->linesize[0] /
sizeof(uint16_t);
157 const ptrdiff_t blinesize =
frame->linesize[1] /
sizeof(uint16_t);
158 const ptrdiff_t rlinesize =
frame->linesize[2] /
sizeof(uint16_t);
164 for (
int x = 0; x <
width; x++) {
192 const float preserve =
s->preserve;
193 const float mix =
s->mix;
194 const float *
color =
s->color;
197 const ptrdiff_t glinesize =
frame->linesize[0] /
sizeof(
float);
198 const ptrdiff_t blinesize =
frame->linesize[1] /
sizeof(
float);
199 const ptrdiff_t rlinesize =
frame->linesize[2] /
sizeof(
float);
205 for (
int x = 0; x <
width; x++) {
231 const int step =
s->step;
234 const float mix =
s->mix;
235 const float preserve =
s->preserve;
236 const float *
color =
s->color;
237 const uint8_t roffset =
s->rgba_map[
R];
238 const uint8_t goffset =
s->rgba_map[
G];
239 const uint8_t boffset =
s->rgba_map[
B];
242 const ptrdiff_t linesize =
frame->linesize[0];
246 for (
int x = 0; x <
width; x++) {
247 float g = ptr[x * step + goffset];
248 float b = ptr[x * step + boffset];
249 float r = ptr[x * step + roffset];
270 const int step =
s->step;
271 const int depth =
s->depth;
274 const float preserve =
s->preserve;
275 const float mix =
s->mix;
276 const float *
color =
s->color;
277 const uint8_t roffset =
s->rgba_map[
R];
278 const uint8_t goffset =
s->rgba_map[
G];
279 const uint8_t boffset =
s->rgba_map[
B];
282 const ptrdiff_t linesize =
frame->linesize[0] /
sizeof(uint16_t);
286 for (
int x = 0; x <
width; x++) {
287 float g = ptr[x * step + goffset];
288 float b = ptr[x * step + boffset];
289 float r = ptr[x * step + roffset];
342 s->step =
desc->nb_components;
349 s->depth =
desc->comp[0].depth;
371#define OFFSET(x) offsetof(ColorTemperatureContext, x)
372#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
375 {
"temperature",
"set the temperature in Kelvin",
OFFSET(temperature),
AV_OPT_TYPE_FLOAT, {.dbl=6500}, 1000, 40000,
VF },
384 .p.name =
"colortemperature",
386 .p.priv_class = &colortemperature_class,
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_colortemperature
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
float fmaxf(float, float)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static int mix(int c0, int c1)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_GBRP12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
#define AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRAPF32
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int(* do_slice)(AVFilterContext *s, void *arg, int jobnr, int nb_jobs)
static enum AVPixelFormat pixel_fmts[]
static int temperature_slice32(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVOption colortemperature_options[]
static int temperature_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static void kelvin2rgb(float k, float *rgb)
static int temperature_slice8p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold int config_input(AVFilterLink *inlink)
static float lerpf(float v0, float v1, float f)
static float saturate(float input)
static int temperature_slice16p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int temperature_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)