117 typedef struct Range {
129 static const Range nominal_range[] = {{{0, 1}, {4096, 65536}}, {{4096, 65536}, {60161, 65536}}, {{60161, 65536}, {1, 1}}};
130 static const Range preferred_range[] = {{{0, 1}, {1280, 65536}}, {{1280, 65536}, {62977, 65536}}, {{62977, 65536}, {1, 1}}};
131 static const Range total_range[] = {{{0, 1}, {256, 65536}}, {{256, 65536}, {65280, 65536}}, {{65280, 65536}, {1, 1}}};
132 static const Range spec1_range[] = {{{0, 1}, {16, 256}}, {{16, 256}, {236, 256}}, {{236, 256}, {256, 256}}};
133 static const Range spec2_range[] = {{{0, 1}, {16, 256}}, {{16, 256}, {22, 256}}, {{22, 256}, {226, 256}}, {{226, 256}, {236, 256}}, {{236, 256}, {256, 256}}};
135 static const Range highlights_range[] = {{{0,1}, {214,256}}, {{214, 256}, {224, 256}}, {{224, 256}, {256, 256}}};
137 static const Fill spec1_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}};
138 static const Fill spec2_fills[] = {{{0.5f, 0.f, .5f, 1.f}}, {{0.f, 1.f, 1.f, 1.f}}, {{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 1.f, 0.f, 1.f}}, {{1.f, 0.f, 0.f, 1.f}}};
140 static const Fill highlights_fills[] = {{{-1.f, -1.f, -1.f, 1.f}}, {{1.f, 0.3f, 0.6f, 1.f}}, {{1.f, 0.2f, .5f, 1.f}}};
149 return 0.5 * sin(x) + 0.5;
154 return 0.25 * sin(2.0 * x *
M_PI -
M_PI) + 0.5;
159 return 0.25 * sin(2.0 * x *
M_PI) + 0.5;
164 return 0.25 * cos(2.0 * x *
M_PI +
M_PI) + 0.75;
169 return 0.25 * sin(2.0 * x *
M_PI) + 0.5;
174 return 0.75 - 0.25 * cos(2.0 * x *
M_PI);
179 return 0.25 + 0.25 * cos(2.0 * x *
M_PI);
184 return 0.5 + 0.15 * sin(5.0 * x *
M_PI +
M_PI);
189 return 0.5 + 0.15 * cos(6.0 * x *
M_PI +
M_PI_2);
195 {-7.5631093e-16, 7.4289183e-13, -2.8525484e-10, 5.4446085e-08, -5.5596238e-06, 3.0569325e-04, -2.3137421e-03, 1.2152095e-02 },
196 { 1.3217636e-15, -1.2214648e-12, 4.4319712e-10, -8.0197993e-08, 7.6598370e-06, -3.6523704e-04, 8.4836670e-03, -2.5536888e-02 },
197 {-1.1446568e-15, 1.0013446e-12, -3.5651575e-10, 6.6775016e-08, -6.7120346e-06, 2.7346619e-04, 4.7969657e-03, 1.1971441e-02 },
200 {-3.9848859e-18, 9.4821649e-14, -6.7371977e-11, 1.8469937e-08, -2.5359307e-06, 1.7959053e-04, 3.9782564e-04, 2.8845935e-04 },
201 { 6.8408539e-16, -6.5499979e-13, 2.4562526e-10, -4.5989298e-08, 4.5723324e-06, -2.2111913e-04, 5.2023164e-03, -1.1226064e-02 },
202 {-2.9921470e-15, 2.5864165e-12, -8.7403799e-10, 1.4713388e-07, -1.2701505e-05, 4.5159935e-04, 3.1087989e-03, 1.9122831e-02 },
205 { 3.6196089e-16, -3.3623041e-13, 1.2324010e-10, -2.2769060e-08, 2.2297792e-06, -1.2567829e-04, 9.9791629e-03, 5.7247918e-02 },
206 { 5.0262888e-16, -5.3193896e-13, 2.2451715e-10, -4.7529623e-08, 5.1374873e-06, -2.3260136e-04, 3.1502825e-03, 1.5362491e-02 },
207 {-1.7782261e-16, 2.2487839e-13, -1.0610236e-10, 2.4112644e-08, -2.6331623e-06, 8.9499751e-05, 2.1386328e-03, 5.3824268e-01 },
210 { 9.4850045e-16, -8.6629383e-13, 3.0310944e-10, -5.1340396e-08, 4.6024275e-06, -2.2744239e-04, 4.5559993e-03, 2.5662350e-01 },
211 { 9.6461041e-17, -6.9209477e-14, 1.7625397e-11, -2.0229773e-09, 1.4900110e-07, -1.9315187e-05, 5.8967339e-03, 3.9544827e-03 },
212 { 5.1785449e-16, -3.6663004e-13, 1.0249990e-10, -1.5431998e-08, 1.5007941e-06, -1.2001502e-04, 7.6951526e-03, 3.2292815e-01 },
215 {-4.3683890e-15, 3.7020347e-12, -1.1712592e-09, 1.6401790e-07, -8.6842919e-06, -1.8542465e-06, 8.4485325e-03, 1.6267077e-01 },
216 {-4.0011069e-16, 2.7861423e-13, -6.3388921e-11, 5.8872238e-09, -5.4466522e-07, 1.8037114e-05, 1.0599869e-02, 7.6914696e-02 },
217 {-2.8242609e-15, 2.9234108e-12, -1.1726546e-09, 2.2552115e-07, -2.0059387e-05, 5.0595552e-04, 1.7714932e-02, 2.7271836e-01 },
220 {-9.5484131e-16, 9.6988184e-13, -4.0058766e-10, 8.5743924e-08, -9.9644797e-06, 5.9197908e-04, -1.0361579e-02, 3.3164429e-02 },
221 { 1.2731941e-17, -9.4238449e-15, 2.2808841e-12, -1.1548296e-10, -2.3888913e-08, 3.8986680e-06, 2.5879330e-03, 1.2769733e-01 },
222 { 4.6004608e-16, -5.0686849e-13, 2.2753449e-10, -5.3074099e-08, 6.7196096e-06, -4.4120020e-04, 1.3435551e-02, 2.8293355e-01 },
225 { 0, 0, 0, 0, 0.000001983938313, -0.0007618323, 0.2, -
M_PI_2 },
226 { 0, 0, 0, 0, 0.000001983938313, -0.0007618323, 0.2, -
M_PI_2 },
227 { 0, 0, 0, 0, 0.000001983938313, -0.0007618323, 0.2, -
M_PI_2 },
229 .offset = { 0., -9., 9. },
232 { -1.6820e-15, 1.4982e-12, -5.0442e-10, 8.0490e-08, -6.1903e-06, 1.5821e-04, 6.4359e-03, 6.2887e-01 },
233 { 1.2526e-15, -1.2203e-12, 4.7013e-10, -8.9360e-08, 8.3839e-06, -3.6642e-04, 1.4784e-02, -9.8075e-03 },
234 { 1.4755e-15, -1.6765e-12, 7.3188e-10, -1.5522e-07, 1.6406e-05, -7.7883e-04, 1.4502e-02, 2.1597e-01 },
237 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
238 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
239 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
241 .offset = { 0., 0., 0 },
245 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
246 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
247 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
249 .offset = { 0., 0., 0 },
253 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
254 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
255 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
257 .offset = { 0., 0., 0 },
261 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
262 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
263 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
265 .offset = { 0., 0., 0 },
269 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
270 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
271 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
273 .offset = { 0., 0., 0 },
277 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
278 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
279 { 0, 0, 0, 0, 0, 0, 1./256, 0 },
281 .offset = { 0., 0., 0 },
327 const uint8_t *
index,
const uint8_t *
src,
336 #define OFFSET(x) offsetof(PseudoColorContext, x)
337 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
403 static inline float lerpf(
float v0,
float v1,
float f)
405 return v0 + (v1 -
v0) *
f;
408 #define PCLIP(v, max, dst, src, x) \
409 if (v >= 0 && v <= max) { \
410 dst[x] = lerpf(src[x], v, opacity);\
416 const uint8_t *
index,
427 for (y = 0; y <
height; y++) {
428 for (x = 0; x <
width; x++) {
429 int v = lut[
index[x]];
440 const uint8_t *
index,
451 for (y = 0; y <
height; y++) {
452 for (x = 0; x <
width; x++) {
453 int v = lut[
index[(y << 1) * ilinesize + (x << 1)]];
463 const uint8_t *
index,
474 for (y = 0; y <
height; y++) {
475 for (x = 0; x <
width; x++) {
476 int v = lut[
index[(y >> 1) * ilinesize + (x >> 1)]];
486 const uint8_t *
index,
497 for (y = 0; y <
height; y++) {
498 for (x = 0; x <
width; x++) {
499 int v = lut[
index[x << 1]];
510 const uint8_t *
index,
521 for (y = 0; y <
height; y++) {
522 for (x = 0; x <
width; x++) {
523 int v = lut[
index[x >> 1]];
534 const uint8_t *iindex,
543 const uint16_t *
index = (
const uint16_t *)iindex;
544 const uint16_t *
src = (
const uint16_t *)ssrc;
545 uint16_t *dst = (uint16_t *)ddst;
548 for (y = 0; y <
height; y++) {
549 for (x = 0; x <
width; x++) {
550 int v = lut[
index[x]];
554 index += ilinesize / 2;
555 src += slinesize / 2;
556 dst += dlinesize / 2;
561 const uint8_t *iindex,
570 const uint16_t *
index = (
const uint16_t *)iindex;
571 const uint16_t *
src = (
const uint16_t *)ssrc;
572 uint16_t *dst = (uint16_t *)ddst;
575 for (y = 0; y <
height; y++) {
576 for (x = 0; x <
width; x++) {
577 int v = lut[
index[x << 1]];
581 index += ilinesize / 2;
582 src += slinesize / 2;
583 dst += dlinesize / 2;
588 const uint8_t *iindex,
597 const uint16_t *
index = (
const uint16_t *)iindex;
598 const uint16_t *
src = (
const uint16_t *)ssrc;
599 uint16_t *dst = (uint16_t *)ddst;
602 for (y = 0; y <
height; y++) {
603 for (x = 0; x <
width; x++) {
604 int v = lut[
index[x >> 1]];
608 index += ilinesize / 2;
609 src += slinesize / 2;
610 dst += dlinesize / 2;
615 const uint8_t *iindex,
624 const uint16_t *
index = (
const uint16_t *)iindex;
625 const uint16_t *
src = (
const uint16_t *)ssrc;
626 uint16_t *dst = (uint16_t *)ddst;
633 for (y = 0; y <
height; y++) {
634 for (x = 0; x <
width; x++) {
635 int v = lut[
index[(y << 1) * ilinesize + (x << 1)]];
645 const uint8_t *iindex,
654 const uint16_t *
index = (
const uint16_t *)iindex;
655 const uint16_t *
src = (
const uint16_t *)ssrc;
656 uint16_t *dst = (uint16_t *)ddst;
663 for (y = 0; y <
height; y++) {
664 for (x = 0; x <
width; x++) {
665 int v = lut[
index[(y >> 1) * ilinesize + (x >> 1)]];
674 #define RGB_TO_Y_BT709(r, g, b) \
675 ((0.21260*219.0/255.0) * (r) + (0.71520*219.0/255.0) * (g) + \
676 (0.07220*219.0/255.0) * (b))
678 #define RGB_TO_U_BT709(r1, g1, b1, max) \
679 (-(0.11457*224.0/255.0) * r1 - (0.38543*224.0/255.0) * g1 + \
680 (0.50000*224.0/255.0) * b1 + max * 0.5)
682 #define RGB_TO_V_BT709(r1, g1, b1, max) \
683 ((0.50000*224.0/255.0) * r1 - (0.45415*224.0/255.0) * g1 - \
684 (0.04585*224.0/255.0) * b1 + max * 0.5)
688 #define Wg (1 - Wr - Wb)
692 #define YUV_BT709_TO_R(y, u, v, max) \
693 ((y + v * (1 - Wr) / Vmax) * max)
694 #define YUV_BT709_TO_G(y, u, v, max) \
695 ((y - (u * Wb * (1 - Wb) / (Umax * Wg)) - (v * Wr * (1 - Wr) / (Vmax * Wg))) * max)
696 #define YUV_BT709_TO_B(y, u, v, max) \
697 ((y + u * (1 - Wb) / Umax) * max)
703 for (
int i = 0;
i < 8;
i++) {
704 res += pow(x,
i) * poly[7-
i];
718 depth =
desc->comp[0].depth;
719 s->max = (1 << depth) - 1;
722 if (
s->index >=
s->nb_planes) {
731 vsub =
desc->log2_chroma_h;
733 s->height[0] =
s->height[3] =
inlink->h;
735 s->width[0] =
s->width[3] =
inlink->w;
740 s->var_values[
VAR_YMIN] = 16 * (1 << (depth - 8));
741 s->var_values[
VAR_UMIN] = 16 * (1 << (depth - 8));
742 s->var_values[
VAR_VMIN] = 16 * (1 << (depth - 8));
744 s->var_values[
VAR_YMAX] = 235 * (1 << (depth - 8));
745 s->var_values[
VAR_UMAX] = 240 * (1 << (depth - 8));
746 s->var_values[
VAR_VMAX] = 240 * (1 << (depth - 8));
760 "Error when parsing the expression '%s' for the component %d and color %d.\n",
772 "Error when evaluating the expression '%s' for the value %d for the component %d.\n",
780 if (
s->preset >= 0) {
783 for (
int seg = 0; seg < nb_segments; seg++) {
789 for (
int i = start;
i < end;
i++) {
799 if (
g >= 0.
f &&
b >= 0.
f &&
r >= 0.
f) {
818 s->lut[3][
i] =
a *
s->max;
821 const double lf =
i / (
double)
s->max * 256.;
842 }
else if (
rgb && curve.
yuv) {
855 s->lut[3][
i] = 1.f *
s->max;
983 for (
int plane = 0; plane <
s->nb_planes; plane++) {
984 const int slice_start = (
s->height[plane] * jobnr) / nb_jobs;
985 const int slice_end = (
s->height[plane] * (jobnr+1)) / nb_jobs;
986 const int islice_start = (
s->height[
s->index] * jobnr) / nb_jobs;
987 ptrdiff_t ilinesize = in->
linesize[
s->index];
988 ptrdiff_t slinesize = in->
linesize[plane];
989 ptrdiff_t dlinesize =
out->linesize[plane];
990 const uint8_t *
index = in->
data[
s->index] + islice_start * ilinesize;
995 index,
src, dst, ilinesize, slinesize,
996 dlinesize,
s->lut[plane],
s->opacity);
1026 char *res,
int res_len,
int flags)
1050 for (
i = 0;
i < 4;
i++) {
1059 .
name =
"pseudocolor",
1062 .priv_class = &pseudocolor_class,