Unified · Split
| @@ -915,6 +915,7 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame) · 914 unmodified lines | ||
| 915 | 915 | |
| 916 | 916 | pts = out->pts; |
| 917 | 917 | ret = filter_frame(link, out); |
| 918 | + link->frame_count++; | |
| 918 | 919 | link->frame_requested = 0; |
| 919 | 920 | ff_update_link_current_pts(link, pts); |
| 920 | 921 | return ret; |
| @@ -718,6 +718,11 @@ struct AVFilterLink { · 717 unmodified lines | ||
| 718 | 718 | * Link processing flags. |
| 719 | 719 | */ |
| 720 | 720 | unsigned flags; |
| 721 | + | |
| 722 | + /** | |
| 723 | + * Number of past frames sent through the link. | |
| 724 | + */ | |
| 725 | + int64_t frame_count; | |
| 721 | 726 | }; |
| 722 | 727 | |
| 723 | 728 | /** |
| @@ -283,6 +283,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) · 282 unmodified lines | ||
| 283 | 283 | if (isnan(select->var_values[VAR_START_T])) |
| 284 | 284 | select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base); |
| 285 | 285 | |
| 286 | + select->var_values[VAR_N ] = inlink->frame_count; | |
| 286 | 287 | select->var_values[VAR_PTS] = TS2D(frame->pts); |
| 287 | 288 | select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base); |
| 288 | 289 | select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame); |
| @@ -352,7 +353,6 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) · 63 unmodified lines | ||
| 352 | 353 | select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples; |
| 353 | 354 | } |
| 354 | 355 | |
| 355 | − select->var_values[VAR_N] += 1.0; | |
| 356 | 356 | select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS]; |
| 357 | 357 | select->var_values[VAR_PREV_T] = select->var_values[VAR_T]; |
| 358 | 358 | } |
| @@ -43,7 +43,6 @@ typedef struct { · 42 unmodified lines | ||
| 43 | 43 | double pixel_black_th; |
| 44 | 44 | unsigned int pixel_black_th_i; |
| 45 | 45 | |
| 46 | − unsigned int frame_count; ///< frame number | |
| 47 | 46 | unsigned int nb_black_pixels; ///< number of black pixels counted so far |
| 48 | 47 | } BlackDetectContext; |
| 49 | 48 | |
| @@ -149,8 +148,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 99 unmodified lines | ||
| 149 | 148 | picture_black_ratio = (double)blackdetect->nb_black_pixels / (inlink->w * inlink->h); |
| 150 | 149 | |
| 151 | 150 | av_log(ctx, AV_LOG_DEBUG, |
| 152 | − "frame:%u picture_black_ratio:%f pts:%s t:%s type:%c\n", | |
| 153 | − blackdetect->frame_count, picture_black_ratio, | |
| 151 | + "frame:%"PRId64" picture_black_ratio:%f pts:%s t:%s type:%c\n", | |
| 152 | + inlink->frame_count, picture_black_ratio, | |
| 154 | 153 | av_ts2str(picref->pts), av_ts2timestr(picref->pts, &inlink->time_base), |
| 155 | 154 | av_get_picture_type_char(picref->pict_type)); |
| 156 | 155 | |
| @@ -168,7 +167,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 11 unmodified lines | ||
| 168 | 167 | } |
| 169 | 168 | |
| 170 | 169 | blackdetect->last_picref_pts = picref->pts; |
| 171 | − blackdetect->frame_count++; | |
| 172 | 170 | blackdetect->nb_black_pixels = 0; |
| 173 | 171 | return ff_filter_frame(inlink->dst->outputs[0], picref); |
| 174 | 172 | } |
| @@ -81,7 +81,6 @@ typedef struct { · 80 unmodified lines | ||
| 81 | 81 | struct FFBufQueue queue_bottom; |
| 82 | 82 | int hsub, vsub; ///< chroma subsampling values |
| 83 | 83 | int frame_requested; |
| 84 | − int framenum; | |
| 85 | 84 | char *all_expr; |
| 86 | 85 | enum BlendMode all_mode; |
| 87 | 86 | double all_opacity; |
| @@ -382,7 +381,7 @@ static void blend_frame(AVFilterContext *ctx, · 294 unmodified lines | ||
| 382 | 381 | uint8_t *bottom = bottom_buf->data[plane]; |
| 383 | 382 | |
| 384 | 383 | param = &b->params[plane]; |
| 385 | − param->values[VAR_N] = b->framenum++; | |
| 384 | + param->values[VAR_N] = inlink->frame_count; | |
| 386 | 385 | param->values[VAR_T] = dst_buf->pts == AV_NOPTS_VALUE ? NAN : dst_buf->pts * av_q2d(inlink->time_base); |
| 387 | 386 | param->values[VAR_W] = outw; |
| 388 | 387 | param->values[VAR_H] = outh; |
| @@ -259,6 +259,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) · 258 unmodified lines | ||
| 259 | 259 | frame->width = crop->w; |
| 260 | 260 | frame->height = crop->h; |
| 261 | 261 | |
| 262 | + crop->var_values[VAR_N] = link->frame_count; | |
| 262 | 263 | crop->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ? |
| 263 | 264 | NAN : frame->pts * av_q2d(link->time_base); |
| 264 | 265 | crop->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? |
| @@ -299,8 +300,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) · 34 unmodified lines | ||
| 299 | 300 | frame->data[3] += crop->x * crop->max_step[3]; |
| 300 | 301 | } |
| 301 | 302 | |
| 302 | − crop->var_values[VAR_N] += 1.0; | |
| 303 | − | |
| 304 | 303 | return ff_filter_frame(link->dst->outputs[0], frame); |
| 305 | 304 | } |
| 306 | 305 | |
| @@ -40,7 +40,6 @@ typedef struct { · 39 unmodified lines | ||
| 40 | 40 | int fid; ///< current frame id in the queue |
| 41 | 41 | int filled; ///< 1 if the queue is filled, 0 otherwise |
| 42 | 42 | AVFrame *last; ///< last frame from the previous queue |
| 43 | − int64_t frame_count; ///< output frame counter | |
| 44 | 43 | AVFrame **clean_src; ///< frame queue for the clean source |
| 45 | 44 | int got_frame[2]; ///< frame request flag for each input stream |
| 46 | 45 | double ts_unit; ///< timestamp units for the output frames |
| @@ -215,7 +214,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 168 unmodified lines | ||
| 215 | 214 | av_frame_free(&frame); |
| 216 | 215 | frame = dm->clean_src[i]; |
| 217 | 216 | } |
| 218 | − frame->pts = dm->frame_count++ * dm->ts_unit; | |
| 217 | + frame->pts = outlink->frame_count * dm->ts_unit; | |
| 219 | 218 | ret = ff_filter_frame(outlink, frame); |
| 220 | 219 | if (ret < 0) |
| 221 | 220 | break; |
| @@ -164,7 +164,6 @@ typedef struct { · 163 unmodified lines | ||
| 164 | 164 | AVRational tc_rate; ///< frame rate for timecode |
| 165 | 165 | AVTimecode tc; ///< timecode context |
| 166 | 166 | int tc24hmax; ///< 1 if timecode is wrapped to 24 hours, 0 otherwise |
| 167 | − int frame_id; | |
| 168 | 167 | int reload; ///< reload text file for each frame |
| 169 | 168 | } DrawTextContext; |
| 170 | 169 | |
| @@ -820,6 +819,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, · 649 unmodified lines | ||
| 820 | 819 | int width, int height) |
| 821 | 820 | { |
| 822 | 821 | DrawTextContext *dtext = ctx->priv; |
| 822 | + AVFilterLink *inlink = ctx->inputs[0]; | |
| 823 | 823 | uint32_t code = 0, prev_code = 0; |
| 824 | 824 | int x = 0, y = 0, i = 0, ret; |
| 825 | 825 | int max_text_line_w = 0, len; |
| @@ -857,7 +857,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, · 31 unmodified lines | ||
| 857 | 857 | |
| 858 | 858 | if (dtext->tc_opt_string) { |
| 859 | 859 | char tcbuf[AV_TIMECODE_STR_SIZE]; |
| 860 | − av_timecode_make_string(&dtext->tc, tcbuf, dtext->frame_id++); | |
| 860 | + av_timecode_make_string(&dtext->tc, tcbuf, inlink->frame_count); | |
| 861 | 861 | av_bprint_clear(bp); |
| 862 | 862 | av_bprintf(bp, "%s%s", dtext->text, tcbuf); |
| 863 | 863 | } |
| @@ -983,6 +983,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 119 unmodified lines | ||
| 983 | 983 | if ((ret = load_textfile(ctx)) < 0) |
| 984 | 984 | return ret; |
| 985 | 985 | |
| 986 | + dtext->var_values[VAR_N] = inlink->frame_count; | |
| 986 | 987 | dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ? |
| 987 | 988 | NAN : frame->pts * av_q2d(inlink->time_base); |
| 988 | 989 | |
| @@ -993,8 +994,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 4 unmodified lines | ||
| 993 | 994 | (int)dtext->var_values[VAR_TEXT_W], (int)dtext->var_values[VAR_TEXT_H], |
| 994 | 995 | dtext->x, dtext->y); |
| 995 | 996 | |
| 996 | − dtext->var_values[VAR_N] += 1.0; | |
| 997 | − | |
| 998 | 997 | return ff_filter_frame(outlink, frame); |
| 999 | 998 | } |
| 1000 | 999 | |
| @@ -77,7 +77,6 @@ typedef struct { · 76 unmodified lines | ||
| 77 | 77 | |
| 78 | 78 | AVFrame *prv, *src, *nxt; ///< main sliding window of 3 frames |
| 79 | 79 | AVFrame *prv2, *src2, *nxt2; ///< sliding window of the optional second stream |
| 80 | − int64_t frame_count; ///< output frame counter | |
| 81 | 80 | int got_frame[2]; ///< frame request flag for each input stream |
| 82 | 81 | int hsub, vsub; ///< chroma subsampling values |
| 83 | 82 | uint32_t eof; ///< bitmask for end of stream |
| @@ -738,7 +737,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 654 unmodified lines | ||
| 738 | 737 | |
| 739 | 738 | /* scene change check */ |
| 740 | 739 | if (fm->combmatch == COMBMATCH_SC) { |
| 741 | − if (fm->lastn == fm->frame_count - 1) { | |
| 740 | + if (fm->lastn == outlink->frame_count - 1) { | |
| 742 | 741 | if (fm->lastscdiff > fm->scthresh) |
| 743 | 742 | sc = 1; |
| 744 | 743 | } else if (luma_abs_diff(fm->prv, fm->src) > fm->scthresh) { |
| @@ -746,7 +745,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 1 unmodified line | ||
| 746 | 745 | } |
| 747 | 746 | |
| 748 | 747 | if (!sc) { |
| 749 | − fm->lastn = fm->frame_count; | |
| 748 | + fm->lastn = outlink->frame_count; | |
| 750 | 749 | fm->lastscdiff = luma_abs_diff(fm->src, fm->nxt); |
| 751 | 750 | sc = fm->lastscdiff > fm->scthresh; |
| 752 | 751 | } |
| @@ -805,10 +804,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 52 unmodified lines | ||
| 805 | 804 | dst->interlaced_frame = combs[match] >= fm->combpel; |
| 806 | 805 | if (dst->interlaced_frame) { |
| 807 | 806 | av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n", |
| 808 | − fm->frame_count, av_ts2timestr(in->pts, &inlink->time_base)); | |
| 807 | + outlink->frame_count, av_ts2timestr(in->pts, &inlink->time_base)); | |
| 809 | 808 | dst->top_field_first = field; |
| 810 | 809 | } |
| 811 | − fm->frame_count++; | |
| 812 | 810 | |
| 813 | 811 | av_log(ctx, AV_LOG_DEBUG, "SC:%d | COMBS: %3d %3d %3d %3d %3d (combpel=%d)" |
| 814 | 812 | " match=%d combed=%s\n", sc, combs[0], combs[1], combs[2], combs[3], combs[4], |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | typedef struct { |
| 32 | 32 | const AVClass *class; |
| 33 | − int frame_step, frame_count; | |
| 33 | + int frame_step; | |
| 34 | 34 | } FrameStepContext; |
| 35 | 35 | |
| 36 | 36 | #define OFFSET(x) offsetof(FrameStepContext, x) |
| @@ -64,7 +64,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref) · 27 unmodified lines | ||
| 64 | 64 | { |
| 65 | 65 | FrameStepContext *framestep = inlink->dst->priv; |
| 66 | 66 | |
| 67 | − if (!(framestep->frame_count++ % framestep->frame_step)) { | |
| 67 | + if (!(inlink->frame_count % framestep->frame_step)) { | |
| 68 | 68 | return ff_filter_frame(inlink->dst->outputs[0], ref); |
| 69 | 69 | } else { |
| 70 | 70 | av_frame_free(&ref); |
| @@ -36,7 +36,6 @@ typedef struct { · 35 unmodified lines | ||
| 36 | 36 | const AVClass *class; |
| 37 | 37 | AVExpr *e[4]; ///< expressions for each plane |
| 38 | 38 | char *expr_str[4]; ///< expression strings for each plane |
| 39 | − int framenum; ///< frame counter | |
| 40 | 39 | AVFrame *picref; ///< current input buffer |
| 41 | 40 | int hsub, vsub; ///< chroma subsampling |
| 42 | 41 | int planes; ///< number of planes |
| @@ -163,7 +162,7 @@ static int geq_filter_frame(AVFilterLink *inlink, AVFrame *in) · 120 unmodified lines | ||
| 163 | 162 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 164 | 163 | AVFrame *out; |
| 165 | 164 | double values[VAR_VARS_NB] = { |
| 166 | − [VAR_N] = geq->framenum++, | |
| 165 | + [VAR_N] = inlink->frame_count, | |
| 167 | 166 | [VAR_T] = in->pts == AV_NOPTS_VALUE ? NAN : in->pts * av_q2d(inlink->time_base), |
| 168 | 167 | }; |
| 169 | 168 | |
| @@ -252,6 +252,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 251 unmodified lines | ||
| 252 | 252 | av_frame_copy_props(outpic, inpic); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | + hue->var_values[VAR_N] = inlink->frame_count; | |
| 255 | 256 | hue->var_values[VAR_T] = TS2T(inpic->pts, inlink->time_base); |
| 256 | 257 | hue->var_values[VAR_PTS] = TS2D(inpic->pts); |
| 257 | 258 | |
| @@ -281,8 +282,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 23 unmodified lines | ||
| 281 | 282 | |
| 282 | 283 | compute_sin_and_cos(hue); |
| 283 | 284 | |
| 284 | − hue->var_values[VAR_N] += 1; | |
| 285 | − | |
| 286 | 285 | if (!direct) { |
| 287 | 286 | av_image_copy_plane(outpic->data[0], outpic->linesize[0], |
| 288 | 287 | inpic->data[0], inpic->linesize[0], |
| @@ -600,6 +600,7 @@ static int try_filter_frame(AVFilterContext *ctx, AVFrame *mainpic) · 599 unmodified lines | ||
| 600 | 600 | if (over->eval_mode == EVAL_MODE_FRAME) { |
| 601 | 601 | int64_t pos = av_frame_get_pkt_pos(mainpic); |
| 602 | 602 | |
| 603 | + over->var_values[VAR_N] = inlink->frame_count; | |
| 603 | 604 | over->var_values[VAR_T] = mainpic->pts == AV_NOPTS_VALUE ? |
| 604 | 605 | NAN : mainpic->pts * av_q2d(inlink->time_base); |
| 605 | 606 | over->var_values[VAR_POS] = pos == -1 ? NAN : pos; |
| @@ -614,7 +615,6 @@ static int try_filter_frame(AVFilterContext *ctx, AVFrame *mainpic) · 8 unmodified lines | ||
| 614 | 615 | if (over->enable) |
| 615 | 616 | blend_image(ctx, mainpic, over->overpicref, over->x, over->y); |
| 616 | 617 | |
| 617 | − over->var_values[VAR_N] += 1.0; | |
| 618 | 618 | } |
| 619 | 619 | ret = ff_filter_frame(ctx->outputs[0], mainpic); |
| 620 | 620 | av_assert1(ret != AVERROR(EAGAIN)); |
| @@ -24,7 +24,6 @@ · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | typedef struct { |
| 26 | 26 | int nb_planes; |
| 27 | − int64_t frame_count; | |
| 28 | 27 | double ts_unit; |
| 29 | 28 | } SeparateFieldsContext; |
| 30 | 29 | |
| @@ -76,12 +75,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 45 unmodified lines | ||
| 76 | 75 | second->linesize[i] *= 2; |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | − inpicref->pts = sf->frame_count++ * sf->ts_unit; | |
| 80 | − second->pts = sf->frame_count++ * sf->ts_unit; | |
| 81 | − | |
| 78 | + inpicref->pts = outlink->frame_count * sf->ts_unit; | |
| 82 | 79 | ret = ff_filter_frame(outlink, inpicref); |
| 83 | 80 | if (ret < 0) |
| 84 | 81 | return ret; |
| 82 | + | |
| 83 | + second->pts = outlink->frame_count * sf->ts_unit; | |
| 85 | 84 | return ff_filter_frame(outlink, second); |
| 86 | 85 | } |
| 87 | 86 | |
| @@ -43,7 +43,6 @@ typedef struct { · 42 unmodified lines | ||
| 43 | 43 | double ts_unit; |
| 44 | 44 | int out_cnt; |
| 45 | 45 | int occupied; |
| 46 | − int64_t frame_count; | |
| 47 | 46 | |
| 48 | 47 | int nb_planes; |
| 49 | 48 | int planeheight[4]; |
| @@ -233,7 +232,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 183 unmodified lines | ||
| 233 | 232 | } |
| 234 | 233 | |
| 235 | 234 | av_frame_copy_props(frame, inpicref); |
| 236 | − frame->pts = tc->frame_count++ * tc->ts_unit; | |
| 235 | + frame->pts = outlink->frame_count * tc->ts_unit; | |
| 237 | 236 | ret = ff_filter_frame(outlink, frame); |
| 238 | 237 | } |
| 239 | 238 | av_frame_free(&inpicref); |