| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright 2007 Bobby Bingham | ||
| 3 | * Copyright 2012 Robert Nagy <ronag89 gmail com> | ||
| 4 | * Copyright 2012 Anton Khirnov <anton khirnov net> | ||
| 5 | * Copyright 2018 Calvin Walton <calvin.walton@kepstin.ca> | ||
| 6 | * | ||
| 7 | * This file is part of FFmpeg. | ||
| 8 | * | ||
| 9 | * FFmpeg is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU Lesser General Public | ||
| 11 | * License as published by the Free Software Foundation; either | ||
| 12 | * version 2.1 of the License, or (at your option) any later version. | ||
| 13 | * | ||
| 14 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 17 | * Lesser General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU Lesser General Public | ||
| 20 | * License along with FFmpeg; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @file | ||
| 26 | * a filter enforcing given constant framerate | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include <float.h> | ||
| 30 | #include <stdint.h> | ||
| 31 | |||
| 32 | #include "libavutil/avassert.h" | ||
| 33 | #include "libavutil/eval.h" | ||
| 34 | #include "libavutil/mathematics.h" | ||
| 35 | #include "libavutil/opt.h" | ||
| 36 | #include "avfilter.h" | ||
| 37 | #include "ccfifo.h" | ||
| 38 | #include "filters.h" | ||
| 39 | #include "video.h" | ||
| 40 | |||
| 41 | enum EOFAction { | ||
| 42 | EOF_ACTION_ROUND, | ||
| 43 | EOF_ACTION_PASS, | ||
| 44 | EOF_ACTION_NB | ||
| 45 | }; | ||
| 46 | |||
| 47 | static const char *const var_names[] = { | ||
| 48 | "source_fps", | ||
| 49 | "ntsc", | ||
| 50 | "pal", | ||
| 51 | "film", | ||
| 52 | "ntsc_film", | ||
| 53 | NULL | ||
| 54 | }; | ||
| 55 | |||
| 56 | enum var_name { | ||
| 57 | VAR_SOURCE_FPS, | ||
| 58 | VAR_FPS_NTSC, | ||
| 59 | VAR_FPS_PAL, | ||
| 60 | VAR_FPS_FILM, | ||
| 61 | VAR_FPS_NTSC_FILM, | ||
| 62 | VARS_NB | ||
| 63 | }; | ||
| 64 | |||
| 65 | static const double ntsc_fps = 30000.0 / 1001.0; | ||
| 66 | static const double pal_fps = 25.0; | ||
| 67 | static const double film_fps = 24.0; | ||
| 68 | static const double ntsc_film_fps = 24000.0 / 1001.0; | ||
| 69 | |||
| 70 | typedef struct FPSContext { | ||
| 71 | const AVClass *class; | ||
| 72 | |||
| 73 | double start_time; ///< pts, in seconds, of the expected first frame | ||
| 74 | |||
| 75 | char *framerate; ///< expression that defines the target framerate | ||
| 76 | int rounding; ///< AVRounding method for timestamps | ||
| 77 | int eof_action; ///< action performed for last frame in FIFO | ||
| 78 | |||
| 79 | /* Set during outlink configuration */ | ||
| 80 | int64_t in_pts_off; ///< input frame pts offset for start_time handling | ||
| 81 | int64_t out_pts_off; ///< output frame pts offset for start_time handling | ||
| 82 | |||
| 83 | /* Runtime state */ | ||
| 84 | int status; ///< buffered input status | ||
| 85 | int64_t status_pts; ///< buffered input status timestamp | ||
| 86 | |||
| 87 | AVFrame *frames[2]; ///< buffered frames | ||
| 88 | int frames_count; ///< number of buffered frames | ||
| 89 | CCFifo cc_fifo; ///< closed captions | ||
| 90 | |||
| 91 | int64_t next_pts; ///< pts of the next frame to output | ||
| 92 | |||
| 93 | /* statistics */ | ||
| 94 | int cur_frame_out; ///< number of times current frame has been output | ||
| 95 | int frames_in; ///< number of frames on input | ||
| 96 | int frames_out; ///< number of frames on output | ||
| 97 | int dup; ///< number of frames duplicated | ||
| 98 | int drop; ///< number of framed dropped | ||
| 99 | } FPSContext; | ||
| 100 | |||
| 101 | #define OFFSET(x) offsetof(FPSContext, x) | ||
| 102 | #define V AV_OPT_FLAG_VIDEO_PARAM | ||
| 103 | #define F AV_OPT_FLAG_FILTERING_PARAM | ||
| 104 | static const AVOption fps_options[] = { | ||
| 105 | { "fps", "A string describing desired output framerate", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = "25" }, 0, 0, V|F }, | ||
| 106 | { "start_time", "Assume the first PTS should be this value.", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX}, -DBL_MAX, DBL_MAX, V|F }, | ||
| 107 | { "round", "set rounding method for timestamps", OFFSET(rounding), AV_OPT_TYPE_INT, { .i64 = AV_ROUND_NEAR_INF }, 0, 5, V|F, .unit = "round" }, | ||
| 108 | { "zero", "round towards 0", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_ZERO }, 0, 0, V|F, .unit = "round" }, | ||
| 109 | { "inf", "round away from 0", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_INF }, 0, 0, V|F, .unit = "round" }, | ||
| 110 | { "down", "round towards -infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_DOWN }, 0, 0, V|F, .unit = "round" }, | ||
| 111 | { "up", "round towards +infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_UP }, 0, 0, V|F, .unit = "round" }, | ||
| 112 | { "near", "round to nearest", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_NEAR_INF }, 0, 0, V|F, .unit = "round" }, | ||
| 113 | { "eof_action", "action performed for last frame", OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_ROUND }, 0, EOF_ACTION_NB-1, V|F, .unit = "eof_action" }, | ||
| 114 | { "round", "round similar to other frames", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ROUND }, 0, 0, V|F, .unit = "eof_action" }, | ||
| 115 | { "pass", "pass through last frame", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, 0, 0, V|F, .unit = "eof_action" }, | ||
| 116 | { NULL } | ||
| 117 | }; | ||
| 118 | |||
| 119 | AVFILTER_DEFINE_CLASS(fps); | ||
| 120 | |||
| 121 | 36 | static av_cold int init(AVFilterContext *ctx) | |
| 122 | { | ||
| 123 | 36 | FPSContext *s = ctx->priv; | |
| 124 | |||
| 125 | 36 | s->status_pts = AV_NOPTS_VALUE; | |
| 126 | 36 | s->next_pts = AV_NOPTS_VALUE; | |
| 127 | |||
| 128 | 36 | return 0; | |
| 129 | } | ||
| 130 | |||
| 131 | /* Remove the first frame from the buffer, returning it */ | ||
| 132 | 515 | static AVFrame *shift_frame(AVFilterContext *ctx, FPSContext *s) | |
| 133 | { | ||
| 134 | AVFrame *frame; | ||
| 135 | |||
| 136 | /* Must only be called when there are frames in the buffer */ | ||
| 137 | av_assert1(s->frames_count > 0); | ||
| 138 | |||
| 139 | 515 | frame = s->frames[0]; | |
| 140 | 515 | s->frames[0] = s->frames[1]; | |
| 141 | 515 | s->frames[1] = NULL; | |
| 142 | 515 | s->frames_count--; | |
| 143 | |||
| 144 | /* Update statistics counters */ | ||
| 145 | 515 | s->frames_out += s->cur_frame_out; | |
| 146 |
2/2✓ Branch 0 taken 304 times.
✓ Branch 1 taken 211 times.
|
515 | if (s->cur_frame_out > 1) { |
| 147 | 304 | av_log(ctx, AV_LOG_DEBUG, "Duplicated frame with pts %"PRId64" %d times\n", | |
| 148 | 304 | frame->pts, s->cur_frame_out - 1); | |
| 149 | 304 | s->dup += s->cur_frame_out - 1; | |
| 150 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 129 times.
|
211 | } else if (s->cur_frame_out == 0) { |
| 151 | 82 | av_log(ctx, AV_LOG_DEBUG, "Dropping frame with pts %"PRId64"\n", | |
| 152 | frame->pts); | ||
| 153 | 82 | s->drop++; | |
| 154 | } | ||
| 155 | 515 | s->cur_frame_out = 0; | |
| 156 | |||
| 157 | 515 | return frame; | |
| 158 | } | ||
| 159 | |||
| 160 | 36 | static av_cold void uninit(AVFilterContext *ctx) | |
| 161 | { | ||
| 162 | 36 | FPSContext *s = ctx->priv; | |
| 163 | |||
| 164 | AVFrame *frame; | ||
| 165 | |||
| 166 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | while (s->frames_count > 0) { |
| 167 | ✗ | frame = shift_frame(ctx, s); | |
| 168 | ✗ | av_frame_free(&frame); | |
| 169 | } | ||
| 170 | 36 | ff_ccfifo_uninit(&s->cc_fifo); | |
| 171 | |||
| 172 | 36 | av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, " | |
| 173 | "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup); | ||
| 174 | 36 | } | |
| 175 | |||
| 176 | 18 | static int config_props(AVFilterLink* outlink) | |
| 177 | { | ||
| 178 | 18 | AVFilterContext *ctx = outlink->src; | |
| 179 | 18 | AVFilterLink *inlink = ctx->inputs[0]; | |
| 180 | 18 | FilterLink *il = ff_filter_link(inlink); | |
| 181 | 18 | FilterLink *ol = ff_filter_link(outlink); | |
| 182 | 18 | FPSContext *s = ctx->priv; | |
| 183 | |||
| 184 | double var_values[VARS_NB], res; | ||
| 185 | int ret; | ||
| 186 | |||
| 187 | 18 | var_values[VAR_SOURCE_FPS] = av_q2d(il->frame_rate); | |
| 188 | 18 | var_values[VAR_FPS_NTSC] = ntsc_fps; | |
| 189 | 18 | var_values[VAR_FPS_PAL] = pal_fps; | |
| 190 | 18 | var_values[VAR_FPS_FILM] = film_fps; | |
| 191 | 18 | var_values[VAR_FPS_NTSC_FILM] = ntsc_film_fps; | |
| 192 | 18 | ret = av_expr_parse_and_eval(&res, s->framerate, | |
| 193 | var_names, var_values, | ||
| 194 | NULL, NULL, NULL, NULL, NULL, 0, ctx); | ||
| 195 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if (ret < 0) |
| 196 | ✗ | return ret; | |
| 197 | |||
| 198 | 18 | ol->frame_rate = av_d2q(res, INT_MAX); | |
| 199 | 18 | outlink->time_base = av_inv_q(ol->frame_rate); | |
| 200 | |||
| 201 | /* Calculate the input and output pts offsets for start_time */ | ||
| 202 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
18 | if (s->start_time != DBL_MAX && s->start_time != AV_NOPTS_VALUE) { |
| 203 | 2 | double first_pts = s->start_time * AV_TIME_BASE; | |
| 204 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | if (first_pts < INT64_MIN || first_pts > INT64_MAX) { |
| 205 | ✗ | av_log(ctx, AV_LOG_ERROR, "Start time %f cannot be represented in internal time base\n", | |
| 206 | s->start_time); | ||
| 207 | ✗ | return AVERROR(EINVAL); | |
| 208 | } | ||
| 209 | 2 | s->in_pts_off = av_rescale_q_rnd(first_pts, AV_TIME_BASE_Q, inlink->time_base, | |
| 210 | 2 | s->rounding | AV_ROUND_PASS_MINMAX); | |
| 211 | 2 | s->out_pts_off = av_rescale_q_rnd(first_pts, AV_TIME_BASE_Q, outlink->time_base, | |
| 212 | 2 | s->rounding | AV_ROUND_PASS_MINMAX); | |
| 213 | 2 | s->next_pts = s->out_pts_off; | |
| 214 | 2 | av_log(ctx, AV_LOG_VERBOSE, "Set first pts to (in:%"PRId64" out:%"PRId64") from start time %f\n", | |
| 215 | s->in_pts_off, s->out_pts_off, s->start_time); | ||
| 216 | } | ||
| 217 | |||
| 218 | 18 | ret = ff_ccfifo_init(&s->cc_fifo, ol->frame_rate, ctx); | |
| 219 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if (ret < 0) { |
| 220 | ✗ | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | |
| 221 | ✗ | return ret; | |
| 222 | } | ||
| 223 | |||
| 224 | 18 | av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", ol->frame_rate.num, ol->frame_rate.den); | |
| 225 | |||
| 226 | 18 | return 0; | |
| 227 | } | ||
| 228 | |||
| 229 | /* Read a frame from the input and save it in the buffer */ | ||
| 230 | 515 | static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink) | |
| 231 | { | ||
| 232 | AVFrame *frame; | ||
| 233 | int ret; | ||
| 234 | int64_t in_pts; | ||
| 235 | |||
| 236 | /* Must only be called when we have buffer room available */ | ||
| 237 | av_assert1(s->frames_count < 2); | ||
| 238 | |||
| 239 | 515 | ret = ff_inlink_consume_frame(inlink, &frame); | |
| 240 | /* Caller must have run ff_inlink_check_available_frame first */ | ||
| 241 | av_assert1(ret); | ||
| 242 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
|
515 | if (ret < 0) |
| 243 | ✗ | return ret; | |
| 244 | |||
| 245 | /* Convert frame pts to output timebase. | ||
| 246 | * The dance with offsets is required to match the rounding behaviour of the | ||
| 247 | * previous version of the fps filter when using the start_time option. */ | ||
| 248 | 515 | in_pts = frame->pts; | |
| 249 | 515 | frame->pts = s->out_pts_off + av_rescale_q_rnd(in_pts - s->in_pts_off, | |
| 250 | inlink->time_base, outlink->time_base, | ||
| 251 | 515 | s->rounding | AV_ROUND_PASS_MINMAX); | |
| 252 | |||
| 253 | 515 | av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n", | |
| 254 | 515 | in_pts, frame->pts); | |
| 255 | |||
| 256 | 515 | ff_ccfifo_extract(&s->cc_fifo, frame); | |
| 257 | 515 | s->frames[s->frames_count++] = frame; | |
| 258 | 515 | s->frames_in++; | |
| 259 | |||
| 260 | 515 | return 1; | |
| 261 | } | ||
| 262 | |||
| 263 | /* Write a frame to the output */ | ||
| 264 | 1557 | static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlink, int *again) | |
| 265 | { | ||
| 266 | AVFrame *frame; | ||
| 267 | |||
| 268 | av_assert1(s->frames_count == 2 || (s->status && s->frames_count == 1)); | ||
| 269 | |||
| 270 | /* We haven't yet determined the pts of the first frame */ | ||
| 271 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1541 times.
|
1557 | if (s->next_pts == AV_NOPTS_VALUE) { |
| 272 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (s->frames[0]->pts != AV_NOPTS_VALUE) { |
| 273 | 16 | s->next_pts = s->frames[0]->pts; | |
| 274 | 16 | av_log(ctx, AV_LOG_VERBOSE, "Set first pts to %"PRId64"\n", s->next_pts); | |
| 275 | } else { | ||
| 276 | ✗ | av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no " | |
| 277 | "timestamp.\n"); | ||
| 278 | ✗ | frame = shift_frame(ctx, s); | |
| 279 | ✗ | av_frame_free(&frame); | |
| 280 | ✗ | *again = 1; | |
| 281 | ✗ | return 0; | |
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | /* There are two conditions where we want to drop a frame: | ||
| 286 | * - If we have two buffered frames and the second frame is acceptable | ||
| 287 | * as the next output frame, then drop the first buffered frame. | ||
| 288 | * - If we have status (EOF) set, drop frames when we hit the | ||
| 289 | * status timestamp. */ | ||
| 290 |
4/4✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 497 times.
|
1557 | if ((s->frames_count == 2 && s->frames[1]->pts <= s->next_pts) || |
| 291 |
4/4✓ Branch 0 taken 66 times.
✓ Branch 1 taken 994 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 48 times.
|
1060 | (s->status && s->status_pts <= s->next_pts)) { |
| 292 | |||
| 293 | 515 | frame = shift_frame(ctx, s); | |
| 294 | 515 | av_frame_free(&frame); | |
| 295 | 515 | *again = 1; | |
| 296 | 515 | return 0; | |
| 297 | |||
| 298 | /* Output a copy of the first buffered frame */ | ||
| 299 | } else { | ||
| 300 | 1042 | frame = av_frame_clone(s->frames[0]); | |
| 301 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1042 times.
|
1042 | if (!frame) |
| 302 | ✗ | return AVERROR(ENOMEM); | |
| 303 | // Make sure Closed Captions will not be duplicated | ||
| 304 | 1042 | ff_ccfifo_inject(&s->cc_fifo, frame); | |
| 305 | 1042 | frame->pts = s->next_pts++; | |
| 306 | 1042 | frame->duration = 1; | |
| 307 | |||
| 308 | 1042 | av_log(ctx, AV_LOG_DEBUG, "Writing frame with pts %"PRId64" to pts %"PRId64"\n", | |
| 309 | 1042 | s->frames[0]->pts, frame->pts); | |
| 310 | 1042 | s->cur_frame_out++; | |
| 311 | 1042 | *again = 1; | |
| 312 | 1042 | return ff_filter_frame(outlink, frame); | |
| 313 | } | ||
| 314 | } | ||
| 315 | |||
| 316 | /* Convert status_pts to outlink timebase */ | ||
| 317 | 18 | static void update_eof_pts(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink, int64_t status_pts) | |
| 318 | { | ||
| 319 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
|
18 | int eof_rounding = (s->eof_action == EOF_ACTION_PASS) ? AV_ROUND_UP : s->rounding; |
| 320 | 18 | s->status_pts = av_rescale_q_rnd(status_pts, inlink->time_base, outlink->time_base, | |
| 321 | 18 | eof_rounding | AV_ROUND_PASS_MINMAX); | |
| 322 | |||
| 323 | 18 | av_log(ctx, AV_LOG_DEBUG, "EOF is at pts %"PRId64"\n", s->status_pts); | |
| 324 | 18 | } | |
| 325 | |||
| 326 | 2113 | static int activate(AVFilterContext *ctx) | |
| 327 | { | ||
| 328 | 2113 | FPSContext *s = ctx->priv; | |
| 329 | 2113 | AVFilterLink *inlink = ctx->inputs[0]; | |
| 330 | 2113 | AVFilterLink *outlink = ctx->outputs[0]; | |
| 331 | |||
| 332 | int ret; | ||
| 333 | 2113 | int again = 0; | |
| 334 | int64_t status_pts; | ||
| 335 | |||
| 336 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2108 times.
|
2113 | FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); |
| 337 | |||
| 338 | /* No buffered status: normal operation */ | ||
| 339 |
2/2✓ Branch 0 taken 2042 times.
✓ Branch 1 taken 66 times.
|
2108 | if (!s->status) { |
| 340 | |||
| 341 | /* Read available input frames if we have room */ | ||
| 342 |
4/4✓ Branch 0 taken 1066 times.
✓ Branch 1 taken 1491 times.
✓ Branch 3 taken 515 times.
✓ Branch 4 taken 551 times.
|
2557 | while (s->frames_count < 2 && ff_inlink_check_available_frame(inlink)) { |
| 343 | 515 | ret = read_frame(ctx, s, inlink, outlink); | |
| 344 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
|
515 | if (ret < 0) |
| 345 | ✗ | return ret; | |
| 346 | } | ||
| 347 | |||
| 348 | /* We do not yet have enough frames to produce output */ | ||
| 349 |
2/2✓ Branch 0 taken 551 times.
✓ Branch 1 taken 1491 times.
|
2042 | if (s->frames_count < 2) { |
| 350 | /* Check if we've hit EOF (or otherwise that an error status is set) */ | ||
| 351 | 551 | ret = ff_inlink_acknowledge_status(inlink, &s->status, &status_pts); | |
| 352 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 533 times.
|
551 | if (ret > 0) |
| 353 | 18 | update_eof_pts(ctx, s, inlink, outlink, status_pts); | |
| 354 | |||
| 355 |
2/2✓ Branch 0 taken 533 times.
✓ Branch 1 taken 18 times.
|
551 | if (!ret) { |
| 356 | /* If someone wants us to output, we'd better ask for more input */ | ||
| 357 |
2/2✓ Branch 1 taken 530 times.
✓ Branch 2 taken 3 times.
|
533 | FF_FILTER_FORWARD_WANTED(outlink, inlink); |
| 358 | 3 | return 0; | |
| 359 | } | ||
| 360 | } | ||
| 361 | } | ||
| 362 | |||
| 363 | /* Buffered frames are available, so generate an output frame */ | ||
| 364 |
2/2✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 18 times.
|
1575 | if (s->frames_count > 0) { |
| 365 | 1557 | ret = write_frame(ctx, s, outlink, &again); | |
| 366 | /* Couldn't generate a frame, so schedule us to perform another step */ | ||
| 367 |
3/4✓ Branch 0 taken 1557 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 563 times.
✓ Branch 4 taken 994 times.
|
1557 | if (again && ff_inoutlink_check_flow(inlink, outlink)) |
| 368 | 563 | ff_filter_set_ready(ctx, 100); | |
| 369 | 1557 | return ret; | |
| 370 | } | ||
| 371 | |||
| 372 | /* No frames left, so forward the status */ | ||
| 373 |
2/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
18 | if (s->status && s->frames_count == 0) { |
| 374 | 18 | ff_outlink_set_status(outlink, s->status, s->next_pts); | |
| 375 | 18 | return 0; | |
| 376 | } | ||
| 377 | |||
| 378 | ✗ | return FFERROR_NOT_READY; | |
| 379 | } | ||
| 380 | |||
| 381 | static const AVFilterPad avfilter_vf_fps_outputs[] = { | ||
| 382 | { | ||
| 383 | .name = "default", | ||
| 384 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 385 | .config_props = config_props, | ||
| 386 | }, | ||
| 387 | }; | ||
| 388 | |||
| 389 | const FFFilter ff_vf_fps = { | ||
| 390 | .p.name = "fps", | ||
| 391 | .p.description = NULL_IF_CONFIG_SMALL("Force constant framerate."), | ||
| 392 | .p.priv_class = &fps_class, | ||
| 393 | .p.flags = AVFILTER_FLAG_METADATA_ONLY, | ||
| 394 | .init = init, | ||
| 395 | .uninit = uninit, | ||
| 396 | .priv_size = sizeof(FPSContext), | ||
| 397 | .activate = activate, | ||
| 398 | FILTER_INPUTS(ff_video_default_filterpad), | ||
| 399 | FILTER_OUTPUTS(avfilter_vf_fps_outputs), | ||
| 400 | }; | ||
| 401 |