205 [
WP_D65] = { 0.3127, 0.3290 },
206 [
WP_C] = { 0.3100, 0.3160 },
207 [
WP_DCI] = { 0.3140, 0.3510 },
208 [
WP_E] = { 1/3.0f, 1/3.0f },
241 double in_alpha =
s->in_txchr->alpha, in_beta =
s->in_txchr->beta;
242 double in_gamma =
s->in_txchr->gamma, in_delta =
s->in_txchr->delta;
243 double in_ialpha = 1.0 / in_alpha, in_igamma = 1.0 / in_gamma, in_idelta = 1.0 / in_delta;
244 double out_alpha =
s->out_txchr->alpha, out_beta =
s->out_txchr->beta;
245 double out_gamma =
s->out_txchr->gamma, out_delta =
s->out_txchr->delta;
247 s->lin_lut =
av_malloc(
sizeof(*
s->lin_lut) * 32768 * 2);
250 s->delin_lut = &
s->lin_lut[32768];
251 for (n = 0; n < 32768; n++) {
252 double v = (n - 2048.0) / 28672.0, d, l;
255 if (v <= -out_beta) {
256 d = -out_alpha * pow(-v, out_gamma) + (out_alpha - 1.0);
257 }
else if (v < out_beta) {
260 d = out_alpha * pow(v, out_gamma) - (out_alpha - 1.0);
265 if (v <= -in_beta * in_delta) {
266 l = -pow((1.0 - in_alpha - v) * in_ialpha, in_igamma);
267 }
else if (v < in_beta * in_delta) {
270 l = pow((v + in_alpha - 1.0) * in_ialpha, in_igamma);
287 { 0.8951, 0.2664, -0.1614 },
288 { -0.7502, 1.7135, 0.0367 },
289 { 0.0389, -0.0685, 1.0296 },
291 { 0.40024, 0.70760, -0.08081 },
292 { -0.22630, 1.16532, 0.04570 },
293 { 0.00000, 0.00000, 0.91822 },
296 const double (*
ma)[3] = ma_tbl[wp_adapt];
298 double zw_src = 1.0 - wp_src->
xw - wp_src->
yw;
300 double zw_dst = 1.0 - wp_dst->
xw - wp_dst->
yw;
301 double mai[3][3], fac[3][3],
tmp[3][3];
302 double rs, gs, bs, rd, gd, bd;
305 rs =
ma[0][0] * wp_src->
xw +
ma[0][1] * wp_src->
yw +
ma[0][2] * zw_src;
306 gs =
ma[1][0] * wp_src->
xw +
ma[1][1] * wp_src->
yw +
ma[1][2] * zw_src;
307 bs =
ma[2][0] * wp_src->
xw +
ma[2][1] * wp_src->
yw +
ma[2][2] * zw_src;
308 rd =
ma[0][0] * wp_dst->
xw +
ma[0][1] * wp_dst->
yw +
ma[0][2] * zw_dst;
309 gd =
ma[1][0] * wp_dst->
xw +
ma[1][1] * wp_dst->
yw +
ma[1][2] * zw_dst;
310 bd =
ma[2][0] * wp_dst->
xw +
ma[2][1] * wp_dst->
yw +
ma[2][2] * zw_dst;
314 fac[0][1] = fac[0][2] = fac[1][0] = fac[1][2] = fac[2][0] = fac[2][1] = 0.0;
320 int w,
int h,
const int16_t *lut)
324 for (n = 0; n < 3; n++) {
325 int16_t *
data = buf[n];
327 for (y = 0; y <
h; y++) {
328 for (x = 0; x <
w; x++)
346 uint8_t *in_data[3], *out_data[3];
348 int h_in = (
td->in->height + 1) >> 1;
349 int h1 = 2 * (job_nr * h_in / n_jobs), h2 = 2 * ((job_nr + 1) * h_in / n_jobs);
350 int w =
td->in->width,
h = h2 - h1;
352 in_data[0] =
td->in->data[0] +
td->in_linesize[0] * h1;
353 in_data[1] =
td->in->data[1] +
td->in_linesize[1] * (h1 >>
td->in_ss_h);
354 in_data[2] =
td->in->data[2] +
td->in_linesize[2] * (h1 >>
td->in_ss_h);
355 out_data[0] =
td->out->data[0] +
td->out_linesize[0] * h1;
356 out_data[1] =
td->out->data[1] +
td->out_linesize[1] * (h1 >>
td->out_ss_h);
357 out_data[2] =
td->out->data[2] +
td->out_linesize[2] * (h1 >>
td->out_ss_h);
358 rgb[0] =
s->rgb[0] +
s->rgb_stride * h1;
359 rgb[1] =
s->rgb[1] +
s->rgb_stride * h1;
360 rgb[2] =
s->rgb[2] +
s->rgb_stride * h1;
366 if (
s->yuv2yuv_fastmode) {
370 s->yuv2yuv(out_data,
td->out_linesize, in_data,
td->in_linesize,
w,
h,
371 s->yuv2yuv_coeffs,
s->yuv_offset);
392 s->yuv2rgb(
rgb,
s->rgb_stride, in_data,
td->in_linesize,
w,
h,
393 s->yuv2rgb_coeffs,
s->yuv_offset[0]);
394 if (!
s->rgb2rgb_passthrough) {
396 if (!
s->lrgb2lrgb_passthrough)
397 s->dsp.multiply3x3(
rgb,
s->rgb_stride,
w,
h,
s->lrgb2lrgb_coeffs);
401 s->rgb2yuv_fsb(out_data,
td->out_linesize,
rgb,
s->rgb_stride,
w,
h,
402 s->rgb2yuv_coeffs,
s->yuv_offset[1],
s->dither_scratch);
404 s->rgb2yuv(out_data,
td->out_linesize,
rgb,
s->rgb_stride,
w,
h,
405 s->rgb2yuv_coeffs,
s->yuv_offset[1]);
413 int *y_rng,
int *uv_rng,
420 if (!
s->did_warn_range) {
422 s->did_warn_range = 1;
427 *off = 16 << (depth - 8);
428 *y_rng = 219 << (depth - 8);
429 *uv_rng = 224 << (depth - 8);
433 *y_rng = *uv_rng = (256 << (depth - 8)) - 1;
448 int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
450 #define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
451 #define supported_subsampling(lcw, lch) \
452 (((lcw) == 0 && (lch) == 0) || ((lcw) == 1 && (lch) == 0) || ((lcw) == 1 && (lch) == 1))
453 #define supported_format(d) \
454 ((d) != NULL && (d)->nb_components == 3 && \
455 !((d)->flags & AV_PIX_FMT_FLAG_RGB) && \
456 supported_depth((d)->comp[0].depth) && \
457 supported_subsampling((d)->log2_chroma_w, (d)->log2_chroma_h))
461 "Unsupported input format %d (%s) or bitdepth (%d)\n",
468 "Unsupported output format %d (%s) or bitdepth (%d)\n",
470 out_desc ? out_desc->
comp[0].
depth : -1);
474 if (
in->color_primaries !=
s->in_prm)
s->in_primaries =
NULL;
475 if (
out->color_primaries !=
s->out_prm)
s->out_primaries =
NULL;
476 if (
in->color_trc !=
s->in_trc)
s->in_txchr =
NULL;
477 if (
out->color_trc !=
s->out_trc)
s->out_txchr =
NULL;
478 if (
in->colorspace !=
s->in_csp ||
479 in->color_range !=
s->in_rng)
s->in_lumacoef =
NULL;
480 if (
out->colorspace !=
s->out_csp ||
481 out->color_range !=
s->out_rng)
s->out_lumacoef =
NULL;
483 if (!
s->out_primaries || !
s->in_primaries) {
484 s->in_prm =
in->color_primaries;
488 s->in_prm =
s->user_iprm;
490 if (!
s->in_primaries) {
492 "Unsupported input primaries %d (%s)\n",
496 s->out_prm =
out->color_primaries;
498 if (!
s->out_primaries) {
504 "Unsupported output color property %d\n",
s->user_all);
508 "Unsupported output primaries %d (%s)\n",
513 s->lrgb2lrgb_passthrough = !memcmp(
s->in_primaries,
s->out_primaries,
514 sizeof(*
s->in_primaries));
515 if (!
s->lrgb2lrgb_passthrough) {
516 double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3];
524 if (
s->out_primaries->wp !=
s->in_primaries->wp &&
526 double wpconv[3][3],
tmp[3][3];
529 s->out_primaries->wp);
535 for (m = 0; m < 3; m++)
536 for (n = 0; n < 3; n++) {
537 s->lrgb2lrgb_coeffs[m][n][0] =
lrint(16384.0 * rgb2rgb[m][n]);
538 for (o = 1; o < 8; o++)
539 s->lrgb2lrgb_coeffs[m][n][o] =
s->lrgb2lrgb_coeffs[m][n][0];
548 s->in_trc =
in->color_trc;
552 s->in_trc =
s->user_itrc;
556 "Unsupported input transfer characteristics %d (%s)\n",
564 s->out_trc =
out->color_trc;
570 "Please specify output transfer characteristics\n");
573 "Unsupported output color property %d\n",
s->user_all);
577 "Unsupported output transfer characteristics %d (%s)\n",
584 s->rgb2rgb_passthrough =
s->fast_mode || (
s->lrgb2lrgb_passthrough &&
585 !memcmp(
s->in_txchr,
s->out_txchr,
sizeof(*
s->in_txchr)));
586 if (!
s->rgb2rgb_passthrough && !
s->lin_lut) {
593 if (!
s->in_lumacoef) {
594 s->in_csp =
in->colorspace;
598 s->in_csp =
s->user_icsp;
599 s->in_rng =
in->color_range;
601 s->in_rng =
s->user_irng;
603 if (!
s->in_lumacoef) {
605 "Unsupported input colorspace %d (%s)\n",
612 if (!
s->out_lumacoef) {
613 s->out_csp =
out->colorspace;
614 s->out_rng =
out->color_range;
616 if (!
s->out_lumacoef) {
620 "Please specify output transfer characteristics\n");
623 "Unsupported output color property %d\n",
s->user_all);
627 "Unsupported output transfer characteristics %d (%s)\n",
637 s->yuv2yuv_fastmode =
s->rgb2rgb_passthrough && fmt_identical;
638 s->yuv2yuv_passthrough =
s->yuv2yuv_fastmode &&
s->in_rng ==
s->out_rng &&
639 !memcmp(
s->in_lumacoef,
s->out_lumacoef,
640 sizeof(*
s->in_lumacoef)) &&
642 if (!
s->yuv2yuv_passthrough) {
644 double rgb2yuv[3][3], (*yuv2rgb)[3] =
s->yuv2rgb_dbl_coeffs;
645 int off,
bits, in_rng;
651 "Unsupported input color range %d (%s)\n",
655 for (n = 0; n < 8; n++)
656 s->yuv_offset[0][n] = off;
660 for (n = 0; n < 3; n++) {
661 for (in_rng =
s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
663 for (o = 1; o < 8; o++)
664 s->yuv2rgb_coeffs[n][m][o] =
s->yuv2rgb_coeffs[n][m][0];
669 av_assert2(
s->yuv2rgb_coeffs[0][0][0] ==
s->yuv2rgb_coeffs[1][0][0]);
670 av_assert2(
s->yuv2rgb_coeffs[0][0][0] ==
s->yuv2rgb_coeffs[2][0][0]);
671 s->yuv2rgb =
s->dsp.yuv2rgb[(in_desc->
comp[0].
depth - 8) >> 1]
677 double (*
rgb2yuv)[3] =
s->rgb2yuv_dbl_coeffs;
678 int off, out_rng,
bits;
684 "Unsupported output color range %d (%s)\n",
688 for (n = 0; n < 8; n++)
689 s->yuv_offset[1][n] = off;
692 for (out_rng =
s->out_y_rng, n = 0; n < 3; n++, out_rng = s->out_uv_rng) {
693 for (m = 0; m < 3; m++) {
695 for (o = 1; o < 8; o++)
696 s->rgb2yuv_coeffs[n][m][o] =
s->rgb2yuv_coeffs[n][m][0];
699 av_assert2(
s->rgb2yuv_coeffs[1][2][0] ==
s->rgb2yuv_coeffs[2][0][0]);
700 s->rgb2yuv =
s->dsp.rgb2yuv[(out_desc->
comp[0].
depth - 8) >> 1]
702 s->rgb2yuv_fsb =
s->dsp.rgb2yuv_fsb[(out_desc->
comp[0].
depth - 8) >> 1]
707 if (
s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
709 double (*
rgb2yuv)[3] =
s->rgb2yuv_dbl_coeffs;
710 double (*
yuv2rgb)[3] =
s->yuv2rgb_dbl_coeffs;
715 for (out_rng =
s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng) {
716 for (in_rng =
s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
717 s->yuv2yuv_coeffs[m][n][0] =
719 (in_rng * (1 << odepth)));
720 for (o = 1; o < 8; o++)
721 s->yuv2yuv_coeffs[m][n][o] =
s->yuv2yuv_coeffs[m][n][0];
726 s->yuv2yuv =
s->dsp.yuv2yuv[(idepth - 8) >> 1][(odepth - 8) >> 1]
774 ptrdiff_t rgb_stride =
FFALIGN(
in->width *
sizeof(int16_t), 32);
775 unsigned rgb_sz = rgb_stride *
in->height;
798 out->color_trc =
s->user_trc;
803 in->color_range :
s->user_rng;
804 if (rgb_sz !=
s->rgb_sz) {
806 int uvw =
in->width >>
desc->log2_chroma_w;
822 s->dither_scratch_base[0][0] =
823 av_malloc(
sizeof(*
s->dither_scratch_base[0][0]) * (
in->width + 4));
824 s->dither_scratch_base[0][1] =
825 av_malloc(
sizeof(*
s->dither_scratch_base[0][1]) * (
in->width + 4));
826 s->dither_scratch_base[1][0] =
827 av_malloc(
sizeof(*
s->dither_scratch_base[1][0]) * (uvw + 4));
828 s->dither_scratch_base[1][1] =
829 av_malloc(
sizeof(*
s->dither_scratch_base[1][1]) * (uvw + 4));
830 s->dither_scratch_base[2][0] =
831 av_malloc(
sizeof(*
s->dither_scratch_base[2][0]) * (uvw + 4));
832 s->dither_scratch_base[2][1] =
833 av_malloc(
sizeof(*
s->dither_scratch_base[2][1]) * (uvw + 4));
834 s->dither_scratch[0][0] = &
s->dither_scratch_base[0][0][1];
835 s->dither_scratch[0][1] = &
s->dither_scratch_base[0][1][1];
836 s->dither_scratch[1][0] = &
s->dither_scratch_base[1][0][1];
837 s->dither_scratch[1][1] = &
s->dither_scratch_base[1][1][1];
838 s->dither_scratch[2][0] = &
s->dither_scratch_base[2][0][1];
839 s->dither_scratch[2][1] = &
s->dither_scratch_base[2][1][1];
840 if (!
s->rgb[0] || !
s->rgb[1] || !
s->rgb[2] ||
841 !
s->dither_scratch_base[0][0] || !
s->dither_scratch_base[0][1] ||
842 !
s->dither_scratch_base[1][0] || !
s->dither_scratch_base[1][1] ||
843 !
s->dither_scratch_base[2][0] || !
s->dither_scratch_base[2][1]) {
857 s->rgb_stride = rgb_stride /
sizeof(int16_t);
860 td.in_linesize[0] =
in->linesize[0];
861 td.in_linesize[1] =
in->linesize[1];
862 td.in_linesize[2] =
in->linesize[2];
863 td.out_linesize[0] =
out->linesize[0];
864 td.out_linesize[1] =
out->linesize[1];
865 td.out_linesize[2] =
out->linesize[2];
868 if (
s->yuv2yuv_passthrough) {
917 if (inlink->
w % 2 || inlink->
h % 2) {
919 inlink->
w, inlink->
h);
923 outlink->
w = inlink->
w;
924 outlink->
h = inlink->
h;
931 #define OFFSET(x) offsetof(ColorSpaceContext, x)
932 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
933 #define ENUM(x, y, z) { x, "", 0, AV_OPT_TYPE_CONST, { .i64 = y }, INT_MIN, INT_MAX, FLAGS, z }
936 {
"all",
"Set all color properties together",
948 {
"space",
"Output colorspace",
961 {
"range",
"Output color range",
969 {
"primaries",
"Output color primaries",
985 {
"trc",
"Output transfer characteristics",
1003 {
"format",
"Output pixel format",
1016 {
"fast",
"Ignore primary chromaticity and gamma correction",
1020 {
"dither",
"Dithering mode",
1026 {
"wpadapt",
"Whitepoint adaptation method",
1033 {
"iall",
"Set all input color properties together",
1036 {
"ispace",
"Input colorspace",
1039 {
"irange",
"Input color range",
1042 {
"iprimaries",
"Input color primaries",
1045 {
"itrc",
"Input transfer characteristics",
1073 .
name =
"colorspace",
1079 .priv_class = &colorspace_class,
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp)
void(* rgb2yuv_fn)(uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t rgb_stride, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
void(* rgb2yuv_fsb_fn)(uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t rgb_stride, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8], int *rnd[3][2])
void(* yuv2rgb_fn)(int16_t *rgb[3], ptrdiff_t rgb_stride, uint8_t *yuv[3], const ptrdiff_t yuv_stride[3], int w, int h, const int16_t yuv2rgb_coeffs[3][3][8], const int16_t yuv_offset[8])
void(* yuv2yuv_fn)(uint8_t *yuv_out[3], const ptrdiff_t yuv_out_stride[3], uint8_t *yuv_in[3], const ptrdiff_t yuv_in_stride[3], int w, int h, const int16_t yuv2yuv_coeffs[3][3][8], const int16_t yuv_offset[2][8])
static void fn() yuv2yuv(uint8_t *_dst[3], const ptrdiff_t dst_stride[3], uint8_t *_src[3], const ptrdiff_t src_stride[3], int w, int h, const int16_t c[3][3][8], const int16_t yuv_offset[2][8])
static void yuv2rgb(uint8_t *out, int ridx, int Y, int U, int V)
#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...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const struct LumaCoefficients * ff_get_luma_coefficients(enum AVColorSpace csp)
void ff_matrix_mul_3x3(double dst[3][3], const double src1[3][3], const double src2[3][3])
void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs, double rgb2yuv[3][3])
void ff_matrix_invert_3x3(const double in[3][3], double out[3][3])
void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs, const struct WhitepointCoefficients *wp, double rgb2xyz[3][3])
static void fill_whitepoint_conv_table(double out[3][3], enum WhitepointAdaptation wp_adapt, enum Whitepoint src, enum Whitepoint dst)
static const struct TransferCharacteristics * get_transfer_characteristics(enum AVColorTransferCharacteristic trc)
static int fill_gamma_table(ColorSpaceContext *s)
AVFilter ff_vf_colorspace
static int config_props(AVFilterLink *outlink)
#define supported_format(d)
static const struct WhitepointCoefficients whitepoint_coefficients[WP_NB]
static int filter_frame(AVFilterLink *link, AVFrame *in)
static int convert(AVFilterContext *ctx, void *data, int job_nr, int n_jobs)
static int query_formats(AVFilterContext *ctx)
static int create_filtergraph(AVFilterContext *ctx, const AVFrame *in, const AVFrame *out)
static const AVFilterPad inputs[]
static void uninit(AVFilterContext *ctx)
static enum AVColorTransferCharacteristic default_trc[CS_NB+1]
static const AVFilterPad outputs[]
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
static int get_range_off(AVFilterContext *ctx, int *off, int *y_rng, int *uv_rng, enum AVColorRange rng, int depth)
static const AVOption colorspace_options[]
static av_cold int init(AVFilterContext *ctx)
static const struct ColorPrimaries * get_color_primaries(enum AVColorPrimaries prm)
@ NB_WP_ADAPT_NON_IDENTITY
AVFILTER_DEFINE_CLASS(colorspace)
static enum AVColorPrimaries default_prm[CS_NB+1]
static void apply_lut(int16_t *buf[3], ptrdiff_t stride, int w, int h, const int16_t *lut)
static enum AVColorSpace default_csp[CS_NB+1]
Various defines for YUV<->RGB conversion.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const char * av_color_range_name(enum AVColorRange range)
const char * av_color_space_name(enum AVColorSpace space)
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV420P10
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_NB
Not part of ABI.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVColorPrimaries
Chromaticity coordinates of the source primaries.
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_PRI_NB
Not part of ABI.
@ AVCOL_PRI_FILM
colour filters using Illuminant C
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
@ AVCOL_PRI_SMPTE240M
functionally identical to above
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E / JEDEC P22 phosphors.
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
@ AVCOL_PRI_BT2020
ITU-R BT2020.
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVColorTransferCharacteristic
Color Transfer Characteristic.
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
@ AVCOL_TRC_BT709
also ITU-R BT1361
@ AVCOL_TRC_NB
Not part of ABI.
#define AV_PIX_FMT_YUV444P10
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
@ AVCOL_SPC_NB
Not part of ABI.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
@ AVCOL_SPC_SMPTE240M
functionally identical to above
@ AVCOL_SPC_YCGCO
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
Describe the class of an AVClass context structure.
int depth
Number of bits in the component.
AVFilterLink ** inputs
array of pointers to input links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
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...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
struct PrimaryCoefficients coeff
enum AVColorPrimaries in_prm out_prm user_prm user_iprm
const struct TransferCharacteristics * in_txchr
int * dither_scratch_base[3][2]
int16_t yuv2rgb_coeffs[3][3][8]
enum AVPixelFormat in_format user_format
enum WhitepointAdaptation wp_adapt
int16_t yuv2yuv_coeffs[3][3][8]
int * dither_scratch[3][2]
rgb2yuv_fsb_fn rgb2yuv_fsb
const struct ColorPrimaries * in_primaries
int16_t rgb2yuv_coeffs[3][3][8]
const struct LumaCoefficients * in_lumacoef
enum Colorspace user_all user_iall
const struct ColorPrimaries * out_primaries
enum AVColorRange in_rng out_rng user_rng user_irng
double rgb2yuv_dbl_coeffs[3][3]
const struct LumaCoefficients * out_lumacoef
const struct TransferCharacteristics * out_txchr
int16_t lrgb2lrgb_coeffs[3][3][8]
enum AVColorSpace in_csp out_csp user_csp user_icsp
int lrgb2lrgb_passthrough
enum AVColorTransferCharacteristic in_trc out_trc user_trc user_itrc
double yuv2rgb_dbl_coeffs[3][3]
Used for passing data between threads.
ptrdiff_t out_linesize[3]
static const uint8_t dither[8][8]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.