mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-26 09:12:33 +00:00
avfilter/f_graphmonitor: add nozeroeof mode
This commit is contained in:
parent
4adb6da7a6
commit
386de9319e
@ -65,6 +65,7 @@ enum {
|
|||||||
MODE_FULL,
|
MODE_FULL,
|
||||||
MODE_COMPACT,
|
MODE_COMPACT,
|
||||||
MODE_NOZERO,
|
MODE_NOZERO,
|
||||||
|
MODE_NOZEROEOF,
|
||||||
NB_MODES
|
NB_MODES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ static const AVOption graphmonitor_options[] = {
|
|||||||
{ "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL}, 0, 0, VF, "mode" },
|
{ "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL}, 0, 0, VF, "mode" },
|
||||||
{ "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VF, "mode" },
|
{ "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VF, "mode" },
|
||||||
{ "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VF, "mode" },
|
{ "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VF, "mode" },
|
||||||
|
{ "nozeroeof", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZEROEOF}, 0, 0, VF, "mode" },
|
||||||
{ "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
|
{ "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
|
||||||
{ "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
|
{ "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
|
||||||
{ "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VF, "flags" },
|
{ "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VF, "flags" },
|
||||||
@ -190,6 +192,25 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint8_t *color
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int filter_have_eof(AVFilterContext *filter)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < filter->nb_inputs; j++) {
|
||||||
|
AVFilterLink *l = filter->inputs[j];
|
||||||
|
|
||||||
|
if (!ff_outlink_get_status(l))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < filter->nb_outputs; j++) {
|
||||||
|
AVFilterLink *l = filter->outputs[j];
|
||||||
|
|
||||||
|
if (!ff_outlink_get_status(l))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int filter_have_queued(AVFilterContext *filter)
|
static int filter_have_queued(AVFilterContext *filter)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < filter->nb_inputs; j++) {
|
for (int j = 0; j < filter->nb_inputs; j++) {
|
||||||
@ -255,7 +276,7 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out,
|
|||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_QUEUE) && (s->mode != MODE_NOZERO || frames)) {
|
if ((s->flags & FLAG_QUEUE) && (s->mode < MODE_NOZERO || frames)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | queue: ");
|
snprintf(buffer, sizeof(buffer)-1, " | queue: ");
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
@ -263,52 +284,52 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out,
|
|||||||
drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
|
drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_FCIN) && (s->mode != MODE_NOZERO || l->frame_count_in)) {
|
if ((s->flags & FLAG_FCIN) && (s->mode < MODE_NOZERO || l->frame_count_in)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
|
snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_FCOUT) && (s->mode != MODE_NOZERO || l->frame_count_out)) {
|
if ((s->flags & FLAG_FCOUT) && (s->mode < MODE_NOZERO || l->frame_count_out)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
|
snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_FC_DELTA) && (s->mode != MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) {
|
if ((s->flags & FLAG_FC_DELTA) && (s->mode < MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
|
snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_SCIN) && (s->mode != MODE_NOZERO || l->sample_count_in)) {
|
if ((s->flags & FLAG_SCIN) && (s->mode < MODE_NOZERO || l->sample_count_in)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
|
snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_SCOUT) && (s->mode != MODE_NOZERO || l->sample_count_out)) {
|
if ((s->flags & FLAG_SCOUT) && (s->mode < MODE_NOZERO || l->sample_count_out)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
|
snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_SC_DELTA) && (s->mode != MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) {
|
if ((s->flags & FLAG_SC_DELTA) && (s->mode < MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
|
snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_PTS) && (s->mode != MODE_NOZERO || current_pts_us)) {
|
if ((s->flags & FLAG_PTS) && (s->mode < MODE_NOZERO || current_pts_us)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
|
snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_PTS_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
|
if ((s->flags & FLAG_PTS_DELTA) && (s->mode < MODE_NOZERO || (current_pts_us - previous_pts_us))) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
|
snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_TIME) && (s->mode != MODE_NOZERO || current_pts_us)) {
|
if ((s->flags & FLAG_TIME) && (s->mode < MODE_NOZERO || current_pts_us)) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
|
snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
}
|
}
|
||||||
if ((s->flags & FLAG_TIME_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
|
if ((s->flags & FLAG_TIME_DELTA) && (s->mode < MODE_NOZERO || (current_pts_us - previous_pts_us))) {
|
||||||
snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
|
snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
xpos += strlen(buffer) * 8;
|
xpos += strlen(buffer) * 8;
|
||||||
@ -355,6 +376,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
|
|||||||
if (s->mode == MODE_COMPACT && !filter_have_queued(filter))
|
if (s->mode == MODE_COMPACT && !filter_have_queued(filter))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (s->mode == MODE_NOZEROEOF && filter_have_eof(filter))
|
||||||
|
continue;
|
||||||
|
|
||||||
xpos = 0;
|
xpos = 0;
|
||||||
drawtext(out, xpos, ypos, filter->name, s->white);
|
drawtext(out, xpos, ypos, filter->name, s->white);
|
||||||
xpos += strlen(filter->name) * 8 + 10;
|
xpos += strlen(filter->name) * 8 + 10;
|
||||||
@ -367,6 +391,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
|
|||||||
if (s->mode == MODE_COMPACT && !frames)
|
if (s->mode == MODE_COMPACT && !frames)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (s->mode == MODE_NOZEROEOF && ff_outlink_get_status(l))
|
||||||
|
continue;
|
||||||
|
|
||||||
xpos = 10;
|
xpos = 10;
|
||||||
snprintf(buffer, sizeof(buffer)-1, "in%d: ", j);
|
snprintf(buffer, sizeof(buffer)-1, "in%d: ", j);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
@ -387,6 +414,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
|
|||||||
if (s->mode == MODE_COMPACT && !frames)
|
if (s->mode == MODE_COMPACT && !frames)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (s->mode == MODE_NOZEROEOF && ff_outlink_get_status(l))
|
||||||
|
continue;
|
||||||
|
|
||||||
xpos = 10;
|
xpos = 10;
|
||||||
snprintf(buffer, sizeof(buffer)-1, "out%d: ", j);
|
snprintf(buffer, sizeof(buffer)-1, "out%d: ", j);
|
||||||
drawtext(out, xpos, ypos, buffer, s->white);
|
drawtext(out, xpos, ypos, buffer, s->white);
|
||||||
|
Loading…
Reference in New Issue
Block a user