Go to the documentation of this file.
59 #define OFFSET(x) offsetof(ColorChannelMixerContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
112 return v0 + (v1 -
v0) *
f;
118 lout = 1.f / (
max * 2.f);
125 int have_alpha,
int pc)
131 const float pa =
s->preserve_amount;
132 const int slice_start = (
out->height * jobnr) / nb_jobs;
133 const int slice_end = (
out->height * (jobnr+1)) / nb_jobs;
134 const uint8_t *srcg = in->
data[0] + slice_start * in->
linesize[0];
135 const uint8_t *srcb = in->
data[1] + slice_start * in->
linesize[1];
136 const uint8_t *srcr = in->
data[2] + slice_start * in->
linesize[2];
137 const uint8_t *srca = in->
data[3] + slice_start * in->
linesize[3];
138 uint8_t *dstg =
out->data[0] + slice_start *
out->linesize[0];
139 uint8_t *dstb =
out->data[1] + slice_start *
out->linesize[1];
140 uint8_t *dstr =
out->data[2] + slice_start *
out->linesize[2];
141 uint8_t *dsta =
out->data[3] + slice_start *
out->linesize[3];
145 for (j = 0; j <
out->width; j++) {
146 const uint8_t rin = srcr[j];
147 const uint8_t gin = srcg[j];
148 const uint8_t bin = srcb[j];
149 const uint8_t ain = have_alpha ? srca[j] : 0;
150 int rout, gout, bout;
152 rout =
s->lut[
R][
R][rin] +
155 (have_alpha == 1 ?
s->lut[
R][
A][ain] : 0);
156 gout =
s->lut[
G][
R][rin] +
159 (have_alpha == 1 ?
s->lut[
G][
A][ain] : 0);
160 bout =
s->lut[
B][
R][rin] +
163 (have_alpha == 1 ?
s->lut[
B][
A][ain] : 0);
172 rout, gout, bout, 255.f, &lin, &lout);
173 preservel(&frout, &fgout, &fbout, lin, lout, 255.
f);
184 if (have_alpha == 1) {
196 dstg +=
out->linesize[0];
197 dstb +=
out->linesize[1];
198 dstr +=
out->linesize[2];
199 dsta +=
out->linesize[3];
206 int have_alpha,
int depth,
int pc)
212 const float pa =
s->preserve_amount;
213 const float max = (1 << depth) - 1;
214 const int slice_start = (
out->height * jobnr) / nb_jobs;
215 const int slice_end = (
out->height * (jobnr+1)) / nb_jobs;
216 const uint16_t *srcg = (
const uint16_t *)(in->
data[0] + slice_start * in->
linesize[0]);
217 const uint16_t *srcb = (
const uint16_t *)(in->
data[1] + slice_start * in->
linesize[1]);
218 const uint16_t *srcr = (
const uint16_t *)(in->
data[2] + slice_start * in->
linesize[2]);
219 const uint16_t *srca = (
const uint16_t *)(in->
data[3] + slice_start * in->
linesize[3]);
220 uint16_t *dstg = (uint16_t *)(
out->data[0] + slice_start *
out->linesize[0]);
221 uint16_t *dstb = (uint16_t *)(
out->data[1] + slice_start *
out->linesize[1]);
222 uint16_t *dstr = (uint16_t *)(
out->data[2] + slice_start *
out->linesize[2]);
223 uint16_t *dsta = (uint16_t *)(
out->data[3] + slice_start *
out->linesize[3]);
227 for (j = 0; j <
out->width; j++) {
228 const uint16_t rin = srcr[j];
229 const uint16_t gin = srcg[j];
230 const uint16_t bin = srcb[j];
231 const uint16_t ain = have_alpha ? srca[j] : 0;
232 int rout, gout, bout;
234 rout =
s->lut[
R][
R][rin] +
237 (have_alpha == 1 ?
s->lut[
R][
A][ain] : 0);
238 gout =
s->lut[
G][
R][rin] +
241 (have_alpha == 1 ?
s->lut[
G][
A][ain] : 0);
242 bout =
s->lut[
B][
R][rin] +
245 (have_alpha == 1 ?
s->lut[
B][
A][ain] : 0);
254 rout, gout, bout,
max, &lin, &lout);
266 if (have_alpha == 1) {
270 s->lut[
A][
A][ain], depth);
278 dstg +=
out->linesize[0] / 2;
279 dstb +=
out->linesize[1] / 2;
280 dstr +=
out->linesize[2] / 2;
281 dsta +=
out->linesize[3] / 2;
388 int have_alpha,
int step,
int pc)
394 const float pa =
s->preserve_amount;
395 const int slice_start = (
out->height * jobnr) / nb_jobs;
396 const int slice_end = (
out->height * (jobnr+1)) / nb_jobs;
397 const uint8_t roffset =
s->rgba_map[
R];
398 const uint8_t goffset =
s->rgba_map[
G];
399 const uint8_t boffset =
s->rgba_map[
B];
400 const uint8_t aoffset =
s->rgba_map[
A];
401 const uint8_t *srcrow = in->
data[0] + slice_start * in->
linesize[0];
402 uint8_t *dstrow =
out->data[0] + slice_start *
out->linesize[0];
406 const uint8_t *
src = srcrow;
407 uint8_t *dst = dstrow;
410 const uint8_t rin =
src[j + roffset];
411 const uint8_t gin =
src[j + goffset];
412 const uint8_t bin =
src[j + boffset];
413 const uint8_t ain =
src[j + aoffset];
414 int rout, gout, bout;
416 rout =
s->lut[
R][
R][rin] +
419 (have_alpha == 1 ?
s->lut[
R][
A][ain] : 0);
420 gout =
s->lut[
G][
R][rin] +
423 (have_alpha == 1 ?
s->lut[
G][
A][ain] : 0);
424 bout =
s->lut[
B][
R][rin] +
427 (have_alpha == 1 ?
s->lut[
B][
A][ain] : 0);
436 rout, gout, bout, 255.f, &lin, &lout);
437 preservel(&frout, &fgout, &fbout, lin, lout, 255.
f);
448 if (have_alpha == 1) {
453 }
else if (have_alpha == -1 && in !=
out)
454 dst[j + aoffset] = 0;
458 dstrow +=
out->linesize[0];
465 int have_alpha,
int step,
int pc)
471 const float pa =
s->preserve_amount;
472 const int slice_start = (
out->height * jobnr) / nb_jobs;
473 const int slice_end = (
out->height * (jobnr+1)) / nb_jobs;
474 const uint8_t roffset =
s->rgba_map[
R];
475 const uint8_t goffset =
s->rgba_map[
G];
476 const uint8_t boffset =
s->rgba_map[
B];
477 const uint8_t aoffset =
s->rgba_map[
A];
478 const uint8_t *srcrow = in->
data[0] + slice_start * in->
linesize[0];
479 uint8_t *dstrow =
out->data[0] + slice_start *
out->linesize[0];
483 const uint16_t *
src = (
const uint16_t *)srcrow;
484 uint16_t *dst = (uint16_t *)dstrow;
487 const uint16_t rin =
src[j + roffset];
488 const uint16_t gin =
src[j + goffset];
489 const uint16_t bin =
src[j + boffset];
490 const uint16_t ain =
src[j + aoffset];
491 int rout, gout, bout;
493 rout =
s->lut[
R][
R][rin] +
496 (have_alpha == 1 ?
s->lut[
R][
A][ain] : 0);
497 gout =
s->lut[
G][
R][rin] +
500 (have_alpha == 1 ?
s->lut[
G][
A][ain] : 0);
501 bout =
s->lut[
B][
R][rin] +
504 (have_alpha == 1 ?
s->lut[
B][
A][ain] : 0);
513 rout, gout, bout, 65535.f, &lin, &lout);
514 preservel(&frout, &fgout, &fbout, lin, lout, 65535.
f);
525 if (have_alpha == 1) {
534 dstrow +=
out->linesize[0];
595 const int depth =
desc->comp[0].depth;
606 for (
i = 0;
i < 4;
i++)
633 switch (outlink->
format) {
713 const int pc =
s->preserve_color > 0;
739 char *res,
int res_len,
int flags)
773 .
name =
"colorchannelmixer",
776 .priv_class = &colorchannelmixer_class,
static int filter_slice_rgba64(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_GBRAP16
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int filter_slice_gbrp10_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static const AVOption colorchannelmixer_options[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
static void preserve_color(int preserve_color, float ir, float ig, float ib, float r, float g, float b, float max, float *icolor, float *ocolor)
static int filter_slice_gbrp14(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_always_inline int filter_slice_rgba16_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int have_alpha, int depth, int pc)
static int filter_slice_gbrp_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
const char * name
Filter name.
static int filter_slice_rgb0(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
A link between two filters.
static int filter_slice_gbrap(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int filter_slice_rgb0_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int(* filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_gbrap_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
static int filter_slice_rgba(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_GBRP10
static int filter_slice_gbrap10_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_gbrap16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
A filter pad used for either input or output.
static float lerpf(float v0, float v1, float f)
const AVFilter ff_vf_colorchannelmixer
#define AV_PIX_FMT_GBRAP10
static int filter_slice_gbrp14_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_GBRAP12
static int filter_slice_rgb48(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static av_always_inline int filter_slice_rgba_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int have_alpha, int step, int pc)
#define FILTER_INPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static const AVFilterPad colorchannelmixer_outputs[]
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_RGBA64
static av_always_inline int filter_slice_rgba_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int have_alpha, int pc)
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int filter_slice_gbrp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_gbrp9(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_gbrp10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
static void preservel(float *r, float *g, float *b, float lin, float lout, float max)
static int filter_slice_gbrap12_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
AVFILTER_DEFINE_CLASS(colorchannelmixer)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
static int filter_slice_gbrap10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int filter_slice_gbrap16_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int format
agreed upon media format
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
AVFilterContext * src
source filter
static av_always_inline int filter_slice_rgba16_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int have_alpha, int step, int pc)
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.
static int filter_slice_gbrp12_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_PIX_FMT_BGRA64
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define i(width, name, range_min, range_max)
static int filter_slice_rgba64_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int w
agreed upon image width
static int filter_slice_gbrp16_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
const char * name
Pad name.
static int filter_slice_gbrp12(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold void uninit(AVFilterContext *ctx)
static int filter_slice_rgb24(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
int h
agreed upon image height
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static int config_output(AVFilterLink *outlink)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static int filter_slice_gbrap12(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
static int filter_slice_rgb48_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_rgba_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_slice_rgb24_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
static int filter_slice_gbrp16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static enum AVPixelFormat pix_fmts[]
static const AVFilterPad colorchannelmixer_inputs[]
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int filter_slice_gbrp9_pl(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)