| @@ -61,6 +61,13 @@ typedef struct GraphMonitorContext { · 60 unmodified lines |
| 61 | unsigned int cache_index; | 61 | unsigned int cache_index; |
| 62 | } GraphMonitorContext; | 62 | } GraphMonitorContext; |
| 63 | | 63 | |
| | 64 | enum { |
| | 65 | MODE_FULL, |
| | 66 | MODE_COMPACT, |
| | 67 | MODE_NOZERO, |
| | 68 | NB_MODES |
| | 69 | }; |
| | 70 | |
| 64 | enum { | 71 | enum { |
| 65 | FLAG_QUEUE = 1 << 0, | 72 | FLAG_QUEUE = 1 << 0, |
| 66 | FLAG_FCIN = 1 << 1, | 73 | FLAG_FCIN = 1 << 1, |
| @@ -88,11 +95,11 @@ static const AVOption graphmonitor_options[] = { · 21 unmodified lines |
| 88 | { "s", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF }, | 95 | { "s", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF }, |
| 89 | { "opacity", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF }, | 96 | { "opacity", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF }, |
| 90 | { "o", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF }, | 97 | { "o", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF }, |
| 91 | { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, VF, "mode" }, | 98 | { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_MODES-1, VF, "mode" }, |
| 92 | { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, VF, "mode" }, | 99 | { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_MODES-1, VF, "mode" }, |
| 93 | { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, VF, "mode" }, | 100 | { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL}, 0, 0, VF, "mode" }, |
| 94 | { "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, VF, "mode" }, | 101 | { "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VF, "mode" }, |
| 95 | { "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, VF, "mode" }, | 102 | { "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VF, "mode" }, |
| 96 | { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" }, | 103 | { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" }, |
| 97 | { "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" }, | 104 | { "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" }, |
| 98 | { "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VF, "flags" }, | 105 | { "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VF, "flags" }, |
| @@ -248,7 +255,7 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out, · 149 unmodified lines |
| 248 | drawtext(out, xpos, ypos, buffer, s->white); | 255 | drawtext(out, xpos, ypos, buffer, s->white); |
| 249 | xpos += strlen(buffer) * 8; | 256 | xpos += strlen(buffer) * 8; |
| 250 | } | 257 | } |
| 251 | if (s->flags & FLAG_QUEUE) { | 258 | if ((s->flags & FLAG_QUEUE) && (s->mode != MODE_NOZERO || frames)) { |
| 252 | snprintf(buffer, sizeof(buffer)-1, " | queue: "); | 259 | snprintf(buffer, sizeof(buffer)-1, " | queue: "); |
| 253 | drawtext(out, xpos, ypos, buffer, s->white); | 260 | drawtext(out, xpos, ypos, buffer, s->white); |
| 254 | xpos += strlen(buffer) * 8; | 261 | xpos += strlen(buffer) * 8; |
| @@ -256,52 +263,52 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out, · 1 unmodified line |
| 256 | drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white); | 263 | drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white); |
| 257 | xpos += strlen(buffer) * 8; | 264 | xpos += strlen(buffer) * 8; |
| 258 | } | 265 | } |
| 259 | if (s->flags & FLAG_FCIN) { | 266 | if ((s->flags & FLAG_FCIN) && (s->mode != MODE_NOZERO || l->frame_count_in)) { |
| 260 | snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in); | 267 | snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in); |
| 261 | drawtext(out, xpos, ypos, buffer, s->white); | 268 | drawtext(out, xpos, ypos, buffer, s->white); |
| 262 | xpos += strlen(buffer) * 8; | 269 | xpos += strlen(buffer) * 8; |
| 263 | } | 270 | } |
| 264 | if (s->flags & FLAG_FCOUT) { | 271 | if ((s->flags & FLAG_FCOUT) && (s->mode != MODE_NOZERO || l->frame_count_out)) { |
| 265 | snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out); | 272 | snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out); |
| 266 | drawtext(out, xpos, ypos, buffer, s->white); | 273 | drawtext(out, xpos, ypos, buffer, s->white); |
| 267 | xpos += strlen(buffer) * 8; | 274 | xpos += strlen(buffer) * 8; |
| 268 | } | 275 | } |
| 269 | if (s->flags & FLAG_FC_DELTA) { | 276 | if ((s->flags & FLAG_FC_DELTA) && (s->mode != MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) { |
| 270 | snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out); | 277 | snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out); |
| 271 | drawtext(out, xpos, ypos, buffer, s->white); | 278 | drawtext(out, xpos, ypos, buffer, s->white); |
| 272 | xpos += strlen(buffer) * 8; | 279 | xpos += strlen(buffer) * 8; |
| 273 | } | 280 | } |
| 274 | if (s->flags & FLAG_SCIN) { | 281 | if ((s->flags & FLAG_SCIN) && (s->mode != MODE_NOZERO || l->sample_count_in)) { |
| 275 | snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in); | 282 | snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in); |
| 276 | drawtext(out, xpos, ypos, buffer, s->white); | 283 | drawtext(out, xpos, ypos, buffer, s->white); |
| 277 | xpos += strlen(buffer) * 8; | 284 | xpos += strlen(buffer) * 8; |
| 278 | } | 285 | } |
| 279 | if (s->flags & FLAG_SCOUT) { | 286 | if ((s->flags & FLAG_SCOUT) && (s->mode != MODE_NOZERO || l->sample_count_out)) { |
| 280 | snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out); | 287 | snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out); |
| 281 | drawtext(out, xpos, ypos, buffer, s->white); | 288 | drawtext(out, xpos, ypos, buffer, s->white); |
| 282 | xpos += strlen(buffer) * 8; | 289 | xpos += strlen(buffer) * 8; |
| 283 | } | 290 | } |
| 284 | if (s->flags & FLAG_SC_DELTA) { | 291 | if ((s->flags & FLAG_SC_DELTA) && (s->mode != MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) { |
| 285 | snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out); | 292 | snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out); |
| 286 | drawtext(out, xpos, ypos, buffer, s->white); | 293 | drawtext(out, xpos, ypos, buffer, s->white); |
| 287 | xpos += strlen(buffer) * 8; | 294 | xpos += strlen(buffer) * 8; |
| 288 | } | 295 | } |
| 289 | if (s->flags & FLAG_PTS) { | 296 | if ((s->flags & FLAG_PTS) && (s->mode != MODE_NOZERO || current_pts_us)) { |
| 290 | snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us)); | 297 | snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us)); |
| 291 | drawtext(out, xpos, ypos, buffer, s->white); | 298 | drawtext(out, xpos, ypos, buffer, s->white); |
| 292 | xpos += strlen(buffer) * 8; | 299 | xpos += strlen(buffer) * 8; |
| 293 | } | 300 | } |
| 294 | if (s->flags & FLAG_PTS_DELTA) { | 301 | if ((s->flags & FLAG_PTS_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) { |
| 295 | snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us)); | 302 | snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us)); |
| 296 | drawtext(out, xpos, ypos, buffer, s->white); | 303 | drawtext(out, xpos, ypos, buffer, s->white); |
| 297 | xpos += strlen(buffer) * 8; | 304 | xpos += strlen(buffer) * 8; |
| 298 | } | 305 | } |
| 299 | if (s->flags & FLAG_TIME) { | 306 | if ((s->flags & FLAG_TIME) && (s->mode != MODE_NOZERO || current_pts_us)) { |
| 300 | snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q)); | 307 | snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q)); |
| 301 | drawtext(out, xpos, ypos, buffer, s->white); | 308 | drawtext(out, xpos, ypos, buffer, s->white); |
| 302 | xpos += strlen(buffer) * 8; | 309 | xpos += strlen(buffer) * 8; |
| 303 | } | 310 | } |
| 304 | if (s->flags & FLAG_TIME_DELTA) { | 311 | if ((s->flags & FLAG_TIME_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) { |
| 305 | snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q)); | 312 | snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q)); |
| 306 | drawtext(out, xpos, ypos, buffer, s->white); | 313 | drawtext(out, xpos, ypos, buffer, s->white); |
| 307 | xpos += strlen(buffer) * 8; | 314 | xpos += strlen(buffer) * 8; |
| @@ -345,7 +352,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 37 unmodified lines |
| 345 | AVFilterContext *filter = ctx->graph->filters[i]; | 352 | AVFilterContext *filter = ctx->graph->filters[i]; |
| 346 | char buffer[1024] = { 0 }; | 353 | char buffer[1024] = { 0 }; |
| 347 | | 354 | |
| 348 | if (s->mode && !filter_have_queued(filter)) | 355 | if (s->mode == MODE_COMPACT && !filter_have_queued(filter)) |
| 349 | continue; | 356 | continue; |
| 350 | | 357 | |
| 351 | xpos = 0; | 358 | xpos = 0; |
| @@ -357,7 +364,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 5 unmodified lines |
| 357 | AVFilterLink *l = filter->inputs[j]; | 364 | AVFilterLink *l = filter->inputs[j]; |
| 358 | size_t frames = ff_inlink_queued_frames(l); | 365 | size_t frames = ff_inlink_queued_frames(l); |
| 359 | | 366 | |
| 360 | if (s->mode && !frames) | 367 | if (s->mode == MODE_COMPACT && !frames) |
| 361 | continue; | 368 | continue; |
| 362 | | 369 | |
| 363 | xpos = 10; | 370 | xpos = 10; |
| @@ -377,7 +384,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 13 unmodified lines |
| 377 | AVFilterLink *l = filter->outputs[j]; | 384 | AVFilterLink *l = filter->outputs[j]; |
| 378 | size_t frames = ff_inlink_queued_frames(l); | 385 | size_t frames = ff_inlink_queued_frames(l); |
| 379 | | 386 | |
| 380 | if (s->mode && !frames) | 387 | if (s->mode == MODE_COMPACT && !frames) |
| 381 | continue; | 388 | continue; |
| 382 | | 389 | |
| 383 | xpos = 10; | 390 | xpos = 10; |