50 output[0] =
matrix[0][0] * input[0] +
matrix[0][1] * input[1] +
matrix[0][2] * input[2];
51 output[1] =
matrix[1][0] * input[0] +
matrix[1][1] * input[1] +
matrix[1][2] * input[2];
52 output[2] =
matrix[2][0] * input[0] +
matrix[2][1] * input[1] +
matrix[2][2] * input[2];
56 {0.5774, 0.5774, 0.5774},
57 {0.40825, 0.40825, -0.816458},
62 {0.57735, 0.40825, 0.707},
63 {0.57735, 0.40825, -0.707},
68 {0.3811, 0.5783, 0.0402},
69 {0.1967, 0.7244, 0.0782},
70 {0.0241, 0.1288, 0.8444}
74 {4.4679, -3.5873, 0.1193},
75 {-1.2186, 2.3809, -0.1624},
76 {0.0497, -0.2439, 1.2045}
90 lms[0] = lms[0] > 0.f ? logf(lms[0]) : -1024.f;
91 lms[1] = lms[1] > 0.f ? logf(lms[1]) : -1024.f;
92 lms[2] = lms[2] > 0.f ? logf(lms[2]) : -1024.f;
107 lms[0] =
expf(lms[0]);
108 lms[1] =
expf(lms[1]);
109 lms[2] =
expf(lms[2]);
131 float rgb[3], lab[3];
134 float *b_in_row = (
float *)(in->
data[1] +
i * in->
linesize[1]);
135 float *g_in_row = (
float *)(in->
data[0] +
i * in->
linesize[0]);
136 float *r_in_row = (
float *)(in->
data[2] +
i * in->
linesize[2]);
137 float *acur =
s->tmpplab +
i * outlink->
w + outlink->
w * outlink->
h;
138 float *bcur =
s->tmpplab +
i * outlink->
w + 2 * outlink->
w * outlink->
h;
139 float *lcur =
s->tmpplab +
i * outlink->
w;
141 s->line_sum[
i] = 0.f;
142 s->line_sum[
i + outlink->
h] = 0.f;
143 s->line_count_pels[
i] = 0;
145 for (
int j = 0; j < outlink->
w; j++) {
146 rgb[0] = r_in_row[j];
147 rgb[1] = g_in_row[j];
148 rgb[2] = b_in_row[j];
153 s->line_sum[
i] += lab[1];
154 s->line_sum[
i + outlink->
h] += lab[2];
155 s->line_count_pels[
i]++;
169 float asum = 0.f, bsum = 0.f;
172 for (
int y = 0; y < td->
out->
height; y++) {
173 asum +=
s->line_sum[y];
175 pixels +=
s->line_count_pels[y];
178 td->
a_avg = asum / pixels;
179 td->
b_avg = bsum / pixels;
198 float rgb[3], lab[3];
201 float *g_out_row = (
float *)(
out->data[0] +
i *
out->linesize[0]);
202 float *b_out_row = (
float *)(
out->data[1] +
i *
out->linesize[1]);
203 float *r_out_row = (
float *)(
out->data[2] +
i *
out->linesize[2]);
204 float *lcur =
s->tmpplab +
i * outlink->
w;
205 float *acur =
s->tmpplab +
i * outlink->
w + outlink->
w * outlink->
h;
206 float *bcur =
s->tmpplab +
i * outlink->
w + 2 * outlink->
w * outlink->
h;
208 for (
int j = 0; j < outlink->
w; j++) {
219 r_out_row[j] =
rgb[0];
220 g_out_row[j] =
rgb[1];
221 b_out_row[j] =
rgb[2];
234 if (!
s->tmpplab || !
s->line_count_pels || !
s->line_sum)
301 .p.name =
"grayworld",
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_grayworld
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
#define i(width, name, range_min, range_max)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
#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...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#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 FILTER_PIXFMTS(...)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
#define AV_PIX_FMT_GBRPF32
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
#define AV_PIX_FMT_GBRAPF32
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
enum AVColorTransferCharacteristic color_trc
Used for passing data between threads.
static AVFormatContext * ctx
static int config_input(AVFilterLink *inlink)
static const float lms2lab[3][3]
static const AVFilterPad grayworld_inputs[]
static void lab2rgb(const float lab[3], float rgb[3])
Convert from Logspace LAB to Linear RGB.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static const float lab2lms[3][3]
static const float lms2rgb[3][3]
static void rgb2lab(const float rgb[3], float lab[3])
Convert from Linear RGB to logspace LAB.
static av_cold void uninit(AVFilterContext *ctx)
static void compute_correction(GrayWorldContext *s, ThreadData *td)
Sum the channel totals and compute the mean for each channel.
static void apply_matrix(const float matrix[3][3], const float input[3], float output[3])
static const float rgb2lms[3][3]
static int convert_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Convert a frame from linear RGB to logspace LAB, and accumulate channel totals for each row Convert f...
static int correct_frame(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Subtract the mean logspace AB values from each pixel.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)