Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2016/03/04 03:44:00... | ... |
@@ -13161,6 +13161,20 @@ Similar as above, but shows difference between blue and red chroma. |
13161 | 13161 |
@item color |
13162 | 13162 |
Displays actual color value on waveform. |
13163 | 13163 |
@end table |
13164 |
+ |
|
13165 |
+@item graticule, g |
|
13166 |
+Set which graticule to display. |
|
13167 |
+ |
|
13168 |
+@table @samp |
|
13169 |
+@item none |
|
13170 |
+Do not display graticule. |
|
13171 |
+ |
|
13172 |
+@item green |
|
13173 |
+Display green graticule showing legal broadcast ranges. |
|
13174 |
+@end table |
|
13175 |
+ |
|
13176 |
+@item opacity, o |
|
13177 |
+Set graticule opacity. |
|
13164 | 13178 |
@end table |
13165 | 13179 |
|
13166 | 13180 |
@section xbr |
... | ... |
@@ -49,6 +49,8 @@ typedef struct WaveformContext { |
49 | 49 |
int mirror; |
50 | 50 |
int display; |
51 | 51 |
int envelope; |
52 |
+ int graticule; |
|
53 |
+ float opacity; |
|
52 | 54 |
int estart[4]; |
53 | 55 |
int eend[4]; |
54 | 56 |
int *emax[4][4]; |
... | ... |
@@ -60,6 +62,7 @@ typedef struct WaveformContext { |
60 | 60 |
int size; |
61 | 61 |
void (*waveform)(struct WaveformContext *s, AVFrame *in, AVFrame *out, |
62 | 62 |
int component, int intensity, int offset, int column); |
63 |
+ void (*graticulef)(struct WaveformContext *s, AVFrame *out); |
|
63 | 64 |
const AVPixFmtDescriptor *desc; |
64 | 65 |
} WaveformContext; |
65 | 66 |
|
... | ... |
@@ -95,6 +98,12 @@ static const AVOption waveform_options[] = { |
95 | 95 |
{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64=CHROMA}, 0, 0, FLAGS, "filter" }, |
96 | 96 |
{ "achroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ACHROMA}, 0, 0, FLAGS, "filter" }, |
97 | 97 |
{ "color", NULL, 0, AV_OPT_TYPE_CONST, {.i64=COLOR}, 0, 0, FLAGS, "filter" }, |
98 |
+ { "graticule", "set graticule", OFFSET(graticule), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "graticule" }, |
|
99 |
+ { "g", "set graticule", OFFSET(graticule), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "graticule" }, |
|
100 |
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "graticule" }, |
|
101 |
+ { "green", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "graticule" }, |
|
102 |
+ { "opacity", "set graticule opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS }, |
|
103 |
+ { "o", "set graticule opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS }, |
|
98 | 104 |
{ NULL } |
99 | 105 |
}; |
100 | 106 |
|
... | ... |
@@ -1081,7 +1090,163 @@ static void color(WaveformContext *s, AVFrame *in, AVFrame *out, |
1081 | 1081 |
} |
1082 | 1082 |
|
1083 | 1083 |
static const uint8_t black_yuva_color[4] = { 0, 127, 127, 255 }; |
1084 |
+static const uint8_t green_yuva_color[4] = { 255, 0, 0, 255 }; |
|
1084 | 1085 |
static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 }; |
1086 |
+static const uint8_t lines[4][2] = { { 16, 235 }, { 16, 240 }, { 16, 240 }, { 0, 255 } }; |
|
1087 |
+ |
|
1088 |
+static void blend_vline(uint8_t *dst, int height, int linesize, float o1, float o2, int v) |
|
1089 |
+{ |
|
1090 |
+ int y; |
|
1091 |
+ |
|
1092 |
+ for (y = 0; y < height; y++) { |
|
1093 |
+ dst[0] = v * o1 + dst[0] * o2; |
|
1094 |
+ |
|
1095 |
+ dst += linesize; |
|
1096 |
+ } |
|
1097 |
+} |
|
1098 |
+ |
|
1099 |
+static void blend_vline16(uint16_t *dst, int height, int linesize, float o1, float o2, int v) |
|
1100 |
+{ |
|
1101 |
+ int y; |
|
1102 |
+ |
|
1103 |
+ for (y = 0; y < height; y++) { |
|
1104 |
+ dst[0] = v * o1 + dst[0] * o2; |
|
1105 |
+ |
|
1106 |
+ dst += linesize / 2; |
|
1107 |
+ } |
|
1108 |
+} |
|
1109 |
+ |
|
1110 |
+static void blend_hline(uint8_t *dst, int width, float o1, float o2, int v) |
|
1111 |
+{ |
|
1112 |
+ int x; |
|
1113 |
+ |
|
1114 |
+ for (x = 0; x < width; x++) { |
|
1115 |
+ dst[x] = v * o1 + dst[x] * o2; |
|
1116 |
+ } |
|
1117 |
+} |
|
1118 |
+ |
|
1119 |
+static void blend_hline16(uint16_t *dst, int width, float o1, float o2, int v) |
|
1120 |
+{ |
|
1121 |
+ int x; |
|
1122 |
+ |
|
1123 |
+ for (x = 0; x < width; x++) { |
|
1124 |
+ dst[x] = v * o1 + dst[x] * o2; |
|
1125 |
+ } |
|
1126 |
+} |
|
1127 |
+ |
|
1128 |
+static void graticule_none(WaveformContext *s, AVFrame *out) |
|
1129 |
+{ |
|
1130 |
+} |
|
1131 |
+ |
|
1132 |
+static void graticule_green_row(WaveformContext *s, AVFrame *out) |
|
1133 |
+{ |
|
1134 |
+ const float o1 = s->opacity; |
|
1135 |
+ const float o2 = 1. - o1; |
|
1136 |
+ int c, p, l, offset = 0; |
|
1137 |
+ |
|
1138 |
+ for (c = 0; c < s->ncomp; c++) { |
|
1139 |
+ if (!((1 << c) & s->pcomp)) |
|
1140 |
+ continue; |
|
1141 |
+ |
|
1142 |
+ for (p = 0; p < s->ncomp; p++) { |
|
1143 |
+ const int is_chroma = (p == 1 || p == 2); |
|
1144 |
+ const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); |
|
1145 |
+ const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); |
|
1146 |
+ const int v = green_yuva_color[p]; |
|
1147 |
+ for (l = 0; l < FF_ARRAY_ELEMS(lines[0]); l++) { |
|
1148 |
+ int x = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]); |
|
1149 |
+ uint8_t *dst = out->data[p] + (x >> shift_w); |
|
1150 |
+ |
|
1151 |
+ blend_vline(dst, out->height >> shift_h, out->linesize[p], o1, o2, v); |
|
1152 |
+ } |
|
1153 |
+ } |
|
1154 |
+ |
|
1155 |
+ offset += 256 * s->display; |
|
1156 |
+ } |
|
1157 |
+} |
|
1158 |
+ |
|
1159 |
+static void graticule16_green_row(WaveformContext *s, AVFrame *out) |
|
1160 |
+{ |
|
1161 |
+ const float o1 = s->opacity; |
|
1162 |
+ const float o2 = 1. - o1; |
|
1163 |
+ const int mult = s->size / 256; |
|
1164 |
+ int c, p, l, offset = 0; |
|
1165 |
+ |
|
1166 |
+ for (c = 0; c < s->ncomp; c++) { |
|
1167 |
+ if (!((1 << c) & s->pcomp)) |
|
1168 |
+ continue; |
|
1169 |
+ |
|
1170 |
+ for (p = 0; p < s->ncomp; p++) { |
|
1171 |
+ const int is_chroma = (p == 1 || p == 2); |
|
1172 |
+ const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); |
|
1173 |
+ const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); |
|
1174 |
+ const int v = green_yuva_color[p] * mult; |
|
1175 |
+ for (l = 0; l < FF_ARRAY_ELEMS(lines[0]); l++) { |
|
1176 |
+ int x = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) * mult; |
|
1177 |
+ uint16_t *dst = (uint16_t *)(out->data[p]) + (x >> shift_w); |
|
1178 |
+ |
|
1179 |
+ blend_vline16(dst, out->height >> shift_h, out->linesize[p], o1, o2, v); |
|
1180 |
+ } |
|
1181 |
+ } |
|
1182 |
+ |
|
1183 |
+ offset += s->size * s->display; |
|
1184 |
+ } |
|
1185 |
+} |
|
1186 |
+ |
|
1187 |
+static void graticule_green_column(WaveformContext *s, AVFrame *out) |
|
1188 |
+{ |
|
1189 |
+ const float o1 = s->opacity; |
|
1190 |
+ const float o2 = 1. - o1; |
|
1191 |
+ int c, p, l, offset = 0; |
|
1192 |
+ |
|
1193 |
+ for (c = 0; c < s->ncomp; c++) { |
|
1194 |
+ if (!((1 << c) & s->pcomp)) |
|
1195 |
+ continue; |
|
1196 |
+ |
|
1197 |
+ for (p = 0; p < s->ncomp; p++) { |
|
1198 |
+ const int is_chroma = (p == 1 || p == 2); |
|
1199 |
+ const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); |
|
1200 |
+ const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); |
|
1201 |
+ const int v = green_yuva_color[p]; |
|
1202 |
+ for (l = 0; l < FF_ARRAY_ELEMS(lines[0]); l++) { |
|
1203 |
+ int y = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]); |
|
1204 |
+ uint8_t *dst = out->data[p] + (y >> shift_h) * out->linesize[p]; |
|
1205 |
+ |
|
1206 |
+ blend_hline(dst, out->width >> shift_w, o1, o2, v); |
|
1207 |
+ } |
|
1208 |
+ } |
|
1209 |
+ |
|
1210 |
+ offset += 256 * s->display; |
|
1211 |
+ } |
|
1212 |
+} |
|
1213 |
+ |
|
1214 |
+static void graticule16_green_column(WaveformContext *s, AVFrame *out) |
|
1215 |
+{ |
|
1216 |
+ const float o1 = s->opacity; |
|
1217 |
+ const float o2 = 1. - o1; |
|
1218 |
+ const int mult = s->size / 256; |
|
1219 |
+ int c, p, l, offset = 0; |
|
1220 |
+ |
|
1221 |
+ for (c = 0; c < s->ncomp; c++) { |
|
1222 |
+ if (!((1 << c) & s->pcomp)) |
|
1223 |
+ continue; |
|
1224 |
+ |
|
1225 |
+ for (p = 0; p < s->ncomp; p++) { |
|
1226 |
+ const int is_chroma = (p == 1 || p == 2); |
|
1227 |
+ const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); |
|
1228 |
+ const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); |
|
1229 |
+ const int v = green_yuva_color[p] * mult; |
|
1230 |
+ for (l = 0; l < FF_ARRAY_ELEMS(lines[0]); l++) { |
|
1231 |
+ int y = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) * mult; |
|
1232 |
+ uint16_t *dst = (uint16_t *)(out->data[p] + (y >> shift_h) * out->linesize[p]); |
|
1233 |
+ |
|
1234 |
+ blend_hline16(dst, out->width >> shift_w, o1, o2, v); |
|
1235 |
+ } |
|
1236 |
+ } |
|
1237 |
+ |
|
1238 |
+ offset += s->size * s->display; |
|
1239 |
+ } |
|
1240 |
+} |
|
1085 | 1241 |
|
1086 | 1242 |
static int config_input(AVFilterLink *inlink) |
1087 | 1243 |
{ |
... | ... |
@@ -1094,9 +1259,15 @@ static int config_input(AVFilterLink *inlink) |
1094 | 1094 |
s->max = 1 << s->bits; |
1095 | 1095 |
s->intensity = s->fintensity * (s->max - 1); |
1096 | 1096 |
|
1097 |
+ s->graticulef = graticule_none; |
|
1098 |
+ |
|
1097 | 1099 |
switch (s->filter) { |
1098 | 1100 |
case LOWPASS: |
1099 | 1101 |
s->size = 256; |
1102 |
+ if (s->graticule && s->mode == 1) |
|
1103 |
+ s->graticulef = s->bits > 8 ? graticule16_green_column : graticule_green_column; |
|
1104 |
+ else if (s->graticule && s->mode == 0) |
|
1105 |
+ s->graticulef = s->bits > 8 ? graticule16_green_row : graticule_green_row; |
|
1100 | 1106 |
s->waveform = s->bits > 8 ? lowpass16 : lowpass; break; |
1101 | 1107 |
case FLAT: |
1102 | 1108 |
s->size = 256 * 3; |
... | ... |
@@ -1124,6 +1295,7 @@ static int config_input(AVFilterLink *inlink) |
1124 | 1124 |
case AV_PIX_FMT_GBRP10: |
1125 | 1125 |
case AV_PIX_FMT_GBRP12: |
1126 | 1126 |
s->bg_color = black_gbrp_color; |
1127 |
+ s->graticulef = graticule_none; |
|
1127 | 1128 |
break; |
1128 | 1129 |
default: |
1129 | 1130 |
s->bg_color = black_yuva_color; |
... | ... |
@@ -1233,6 +1405,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
1233 | 1233 |
s->waveform(s, in, out, k, s->intensity, offset, s->mode); |
1234 | 1234 |
} |
1235 | 1235 |
} |
1236 |
+ s->graticulef(s, out); |
|
1236 | 1237 |
|
1237 | 1238 |
av_frame_free(&in); |
1238 | 1239 |
return ff_filter_frame(outlink, out); |