| @@ -40,6 +40,7 @@ typedef struct DrawGraphContext { · 39 unmodified lines |
| 40 | 40 | int mode; |
| 41 | 41 | int slide; |
| 42 | 42 | int w, h; |
| 43 | + AVRational frame_rate; |
| 43 | 44 | |
| 44 | 45 | AVFrame *out; |
| 45 | 46 | int x; |
| @@ -48,6 +49,7 @@ typedef struct DrawGraphContext { · 2 unmodified lines |
| 48 | 49 | float *values[4]; |
| 49 | 50 | int values_size[4]; |
| 50 | 51 | int nb_values; |
| 52 | + int64_t prev_pts; |
| 51 | 53 | } DrawGraphContext; |
| 52 | 54 | |
| 53 | 55 | #define OFFSET(x) offsetof(DrawGraphContext, x) |
| @@ -77,6 +79,8 @@ static const AVOption drawgraph_options[] = { · 23 unmodified lines |
| 77 | 79 | {"picture", "display graph in single frame", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "slide"}, |
| 78 | 80 | { "size", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS }, |
| 79 | 81 | { "s", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS }, |
| 82 | + { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS }, |
| 83 | + { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS }, |
| 80 | 84 | { NULL } |
| 81 | 85 | }; |
| 82 | 86 | |
| @@ -159,6 +163,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 76 unmodified lines |
| 159 | 163 | AVDictionary *metadata; |
| 160 | 164 | AVDictionaryEntry *e; |
| 161 | 165 | AVFrame *out = s->out; |
| 166 | + AVFrame *clone = NULL; |
| 167 | + int64_t in_pts, out_pts; |
| 162 | 168 | int i; |
| 163 | 169 | |
| 164 | 170 | if (s->slide == 4 && s->nb_values >= s->values_size[0] / sizeof(float)) { |
| @@ -309,12 +315,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 144 unmodified lines |
| 309 | 315 | s->nb_values++; |
| 310 | 316 | s->x++; |
| 311 | 317 | |
| 318 | + in_pts = in->pts; |
| 319 | + |
| 312 | 320 | av_frame_free(&in); |
| 313 | 321 | |
| 314 | 322 | if (s->slide == 4) |
| 315 | 323 | return 0; |
| 316 | 324 | |
| 317 | | − return ff_filter_frame(outlink, av_frame_clone(s->out)); |
| 325 | + out_pts = av_rescale_q(in_pts, inlink->time_base, outlink->time_base); |
| 326 | + |
| 327 | + if (out_pts == s->prev_pts) |
| 328 | + return 0; |
| 329 | + |
| 330 | + clone = av_frame_clone(s->out); |
| 331 | + if (!clone) |
| 332 | + return AVERROR(ENOMEM); |
| 333 | + |
| 334 | + clone->pts = s->prev_pts = out_pts; |
| 335 | + return ff_filter_frame(outlink, clone); |
| 318 | 336 | } |
| 319 | 337 | |
| 320 | 338 | static int request_frame(AVFilterLink *outlink) |
| @@ -406,6 +424,9 @@ static int config_output(AVFilterLink *outlink) · 85 unmodified lines |
| 406 | 424 | outlink->w = s->w; |
| 407 | 425 | outlink->h = s->h; |
| 408 | 426 | outlink->sample_aspect_ratio = (AVRational){1,1}; |
| 427 | + outlink->frame_rate = s->frame_rate; |
| 428 | + outlink->time_base = av_inv_q(outlink->frame_rate); |
| 429 | + s->prev_pts = AV_NOPTS_VALUE; |
| 409 | 430 | |
| 410 | 431 | return 0; |
| 411 | 432 | } |