History

avfilter: use the new AVFrame interlace flags in all filters

James Almer committed 3 years ago

Commit 36827ea1 parent 2f561ba30 files · +132 −53Browse files

Showing the changes to libavfilter (30 of 30 files). Show all

Unified · Split

30 files
  1. libavfilter/avfilter.c +2 −2
  2. libavfilter/buffersrc.c +5 −0
  3. libavfilter/f_select.c +4 −4
  4. libavfilter/phase_template.c +2 −2
  5. libavfilter/qsvvpp.c +2 −2
  6. libavfilter/setpts.c +1 −1
  7. libavfilter/vf_coreimage.m +1 −0
  8. libavfilter/vf_deinterlace_vaapi.c +3 −2
  9. libavfilter/vf_estdif.c +4 −3
  10. libavfilter/vf_field.c +1 −0
  11. libavfilter/vf_fieldhint.c +2 −0
  12. libavfilter/vf_fieldmatch.c +11 −4
  13. libavfilter/vf_fieldorder.c +7 −3
  14. libavfilter/vf_framerate.c +1 −1
  15. libavfilter/vf_idet.c +13 −4
  16. libavfilter/vf_kerndeint.c +1 −0
  17. libavfilter/vf_nnedi.c +4 −3
  18. libavfilter/vf_pullup.c +2 −1
  19. libavfilter/vf_repeatfields.c +4 −3
  20. libavfilter/vf_scale.c +2 −1
  21. libavfilter/vf_separatefields.c +4 −3
  22. libavfilter/vf_setparams.c +6 −0
  23. libavfilter/vf_showinfo.c +2 −2
  24. libavfilter/vf_telecine.c +16 −2
  25. libavfilter/vf_tinterlace.c +14 −2
  26. libavfilter/vf_w3fdif.c +4 −3
  27. libavfilter/vf_weave.c +5 −0
  28. libavfilter/vsrc_gradients.c +1 −0
  29. libavfilter/vsrc_testsrc.c +1 −0
  30. libavfilter/yadif_common.c +7 −5
libavfilter/avfilter.c+2−2
@@ -57,8 +57,8 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end) · 56 unmodified lines
5757 ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
5858 ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den,
5959 ref->width, ref->height,
60− !ref->interlaced_frame ? 'P' : /* Progressive */
61− ref->top_field_first ? 'T' : 'B', /* Top / Bottom */
60+ !(ref->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' : /* Progressive */
61+ (ref->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B', /* Top / Bottom */
6262 ref->key_frame,
6363 av_get_picture_type_char(ref->pict_type));
6464 }
libavfilter/buffersrc.c+5−0
@@ -247,6 +247,11 @@ FF_DISABLE_DEPRECATION_WARNINGS · 246 unmodified lines
247247 FF_ENABLE_DEPRECATION_WARNINGS
248248 #endif
249249
250+ if (copy->interlaced_frame)
251+ copy->flags |= AV_FRAME_FLAG_INTERLACED;
252+ if (copy->top_field_first)
253+ copy->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
254+
250255 ret = ff_filter_frame(ctx->outputs[0], copy);
251256 if (ret < 0)
252257 return ret;
libavfilter/f_select.c+4−4
@@ -356,8 +356,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 355 unmodified lines
356356
357357 case AVMEDIA_TYPE_VIDEO:
358358 select->var_values[VAR_INTERLACE_TYPE] =
359− !frame->interlaced_frame ? INTERLACE_TYPE_P :
360− frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
359+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? INTERLACE_TYPE_P :
360+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
361361 select->var_values[VAR_PICT_TYPE] = frame->pict_type;
362362 if (select->do_scene_detect) {
363363 char buf[32];
@@ -380,8 +380,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 16 unmodified lines
380380 switch (inlink->type) {
381381 case AVMEDIA_TYPE_VIDEO:
382382 av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
383− (!frame->interlaced_frame) ? 'P' :
384− frame->top_field_first ? 'T' : 'B',
383+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' :
384+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B',
385385 av_get_picture_type_char(frame->pict_type),
386386 select->var_values[VAR_SCENE]);
387387 break;
libavfilter/phase_template.c+2−2
@@ -57,10 +57,10 @@ static enum PhaseMode fn(analyze_plane)(void *ctx, enum PhaseMode mode, AVFrame · 56 unmodified lines
5757 double bdiff, tdiff, pdiff;
5858
5959 if (mode == AUTO) {
60− mode = new->interlaced_frame ? new->top_field_first ?
60+ mode = (new->flags & AV_FRAME_FLAG_INTERLACED) ? (new->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ?
6161 TOP_FIRST : BOTTOM_FIRST : PROGRESSIVE;
6262 } else if (mode == AUTO_ANALYZE) {
63− mode = new->interlaced_frame ? new->top_field_first ?
63+ mode = (new->flags & AV_FRAME_FLAG_INTERLACED) ? (new->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ?
6464 TOP_FIRST_ANALYZE : BOTTOM_FIRST_ANALYZE : FULL_ANALYZE;
6565 }
6666
libavfilter/qsvvpp.c+2−2
@@ -460,8 +460,8 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p · 459 unmodified lines
460460 inlink->time_base, default_tb);
461461
462462 qsv_frame->surface.Info.PicStruct =
463− !qsv_frame->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
464− (qsv_frame->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
463+ !(qsv_frame->frame->flags & AV_FRAME_FLAG_INTERLACED) ? MFX_PICSTRUCT_PROGRESSIVE :
464+ ((qsv_frame->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? MFX_PICSTRUCT_FIELD_TFF :
465465 MFX_PICSTRUCT_FIELD_BFF);
466466 if (qsv_frame->frame->repeat_pict == 1)
467467 qsv_frame->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
libavfilter/setpts.c+1−1
@@ -174,7 +174,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 173 unmodified lines
174174
175175 if (frame) {
176176 if (inlink->type == AVMEDIA_TYPE_VIDEO) {
177− setpts->var_values[VAR_INTERLACED] = frame->interlaced_frame;
177+ setpts->var_values[VAR_INTERLACED] = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
178178 } else if (inlink->type == AVMEDIA_TYPE_AUDIO) {
179179 setpts->var_values[VAR_S] = frame->nb_samples;
180180 setpts->var_values[VAR_NB_SAMPLES] = frame->nb_samples;
libavfilter/vf_coreimage.m+1−0
@@ -303,6 +303,7 @@ static int request_frame(AVFilterLink *link) · 302 unmodified lines
303303 frame->duration = 1;
304304 frame->key_frame = 1;
305305 frame->interlaced_frame = 0;
306+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
306307 frame->pict_type = AV_PICTURE_TYPE_I;
307308 frame->sample_aspect_ratio = ctx->sar;
308309
libavfilter/vf_deinterlace_vaapi.c+3−2
@@ -252,7 +252,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) · 251 unmodified lines
252252 if (err < 0)
253253 goto fail;
254254
255− if (!ctx->auto_enable || input_frame->interlaced_frame) {
255+ if (!ctx->auto_enable || (input_frame->flags & AV_FRAME_FLAG_INTERLACED)) {
256256 vas = vaMapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0],
257257 &filter_params_addr);
258258 if (vas != VA_STATUS_SUCCESS) {
@@ -263,7 +263,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) · 4 unmodified lines
263263 }
264264 filter_params = filter_params_addr;
265265 filter_params->flags = 0;
266− if (input_frame->top_field_first) {
266+ if (input_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) {
267267 filter_params->flags |= field ? VA_DEINTERLACING_BOTTOM_FIELD : 0;
268268 } else {
269269 filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
@@ -304,6 +304,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) · 34 unmodified lines
304304 ctx->frame_queue[current_frame_index + 1]->pts;
305305 }
306306 output_frame->interlaced_frame = 0;
307+ output_frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
307308
308309 av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
309310 av_get_pix_fmt_name(output_frame->format),
libavfilter/vf_estdif.c+4−3
@@ -345,8 +345,8 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, · 344 unmodified lines
345345 const int rslope = s->rslope;
346346 const int redge = s->redge;
347347 const int depth = s->depth;
348− const int interlaced = in->interlaced_frame;
349− const int tff = (s->field == (s->parity == -1 ? interlaced ? in->top_field_first : 1 :
348+ const int interlaced = !!(in->flags & AV_FRAME_FLAG_INTERLACED);
349+ const int tff = (s->field == (s->parity == -1 ? interlaced ? (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
350350 s->parity ^ 1));
351351
352352 for (int plane = 0; plane < s->nb_planes; plane++) {
@@ -444,6 +444,7 @@ static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts, int64_t durati · 91 unmodified lines
444444 return AVERROR(ENOMEM);
445445 av_frame_copy_props(out, in);
446446 out->interlaced_frame = 0;
447+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
447448 out->pts = pts;
448449 out->duration = duration;
449450
@@ -502,7 +503,7 @@ static int config_input(AVFilterLink *inlink) · 52 unmodified lines
502503 return 0;
503504 }
504505
505− if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
506+ if ((s->deint && !(s->prev->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
506507 s->prev->pts *= 2;
507508 s->prev->duration *= 2;
508509 ret = ff_filter_frame(ctx->outputs[0], s->prev);
libavfilter/vf_field.c+1−0
@@ -74,6 +74,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 73 unmodified lines
7474
7575 inpicref->height = outlink->h;
7676 inpicref->interlaced_frame = 0;
77+ inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
7778
7879 for (i = 0; i < field->nb_planes; i++) {
7980 if (field->type == FIELD_TYPE_BOTTOM)
libavfilter/vf_fieldhint.c+2−0
@@ -218,9 +218,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 217 unmodified lines
218218 switch (hint) {
219219 case '+':
220220 out->interlaced_frame = 1;
221+ out->flags |= AV_FRAME_FLAG_INTERLACED;
221222 break;
222223 case '-':
223224 out->interlaced_frame = 0;
225+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
224226 break;
225227 case '=':
226228 break;
libavfilter/vf_fieldmatch.c+11−4
@@ -714,7 +714,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 713 unmodified lines
714714 in = fm->src;
715715
716716 /* parity */
717− order = fm->order != FM_PARITY_AUTO ? fm->order : (in->interlaced_frame ? in->top_field_first : 1);
717+ order = fm->order != FM_PARITY_AUTO ? fm->order : ((in->flags & AV_FRAME_FLAG_INTERLACED) ?
718+ !!(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1);
718719 field = fm->field != FM_PARITY_AUTO ? fm->field : order;
719720 av_assert0(order == 0 || order == 1 || field == 0 || field == 1);
720721 fxo = field ^ order ? fxo1m : fxo0m;
@@ -820,15 +821,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 99 unmodified lines
820821 /* mark the frame we are unable to match properly as interlaced so a proper
821822 * de-interlacer can take the relay */
822823 dst->interlaced_frame = interlaced_frame;
823− if (dst->interlaced_frame) {
824+ if (interlaced_frame) {
825+ dst->flags |= AV_FRAME_FLAG_INTERLACED;
824826 av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n",
825827 outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base));
826828 dst->top_field_first = field;
827− }
829+ if (field)
830+ dst->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
831+ else
832+ dst->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
833+ } else
834+ dst->flags &= ~AV_FRAME_FLAG_INTERLACED;
828835
829836 av_log(ctx, AV_LOG_DEBUG, "SC:%d | COMBS: %3d %3d %3d %3d %3d (combpel=%d)"
830837 " match=%d combed=%s\n", sc, combs[0], combs[1], combs[2], combs[3], combs[4],
831− fm->combpel, match, dst->interlaced_frame ? "YES" : "NO");
838+ fm->combpel, match, (dst->flags & AV_FRAME_FLAG_INTERLACED) ? "YES" : "NO");
832839
833840 fail:
834841 for (i = 0; i < FF_ARRAY_ELEMS(gen_frames); i++)
libavfilter/vf_fieldorder.c+7−3
@@ -76,11 +76,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 75 unmodified lines
7676 uint8_t *dst, *src;
7777 AVFrame *out;
7878
79− if (!frame->interlaced_frame ||
80− frame->top_field_first == s->dst_tff) {
79+ if (!(frame->flags & AV_FRAME_FLAG_INTERLACED) ||
80+ !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) == s->dst_tff) {
8181 av_log(ctx, AV_LOG_VERBOSE,
8282 "Skipping %s.\n",
83− frame->interlaced_frame ?
83+ (frame->flags & AV_FRAME_FLAG_INTERLACED) ?
8484 "frame with same field order" : "progressive frame");
8585 return ff_filter_frame(outlink, frame);
8686 }
@@ -141,6 +141,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 54 unmodified lines
141141 }
142142 }
143143 out->top_field_first = s->dst_tff;
144+ if (s->dst_tff)
145+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
146+ else
147+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
144148
145149 if (frame != out)
146150 av_frame_free(&frame);
libavfilter/vf_framerate.c+1−1
@@ -318,7 +318,7 @@ retry: · 317 unmodified lines
318318 return ret;
319319
320320 if (inpicref) {
321− if (inpicref->interlaced_frame)
321+ if (inpicref->flags & AV_FRAME_FLAG_INTERLACED)
322322 av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n");
323323
324324 if (inpicref->pts == AV_NOPTS_VALUE) {
libavfilter/vf_idet.c+13−4
@@ -185,11 +185,15 @@ static void filter(AVFilterContext *ctx) · 184 unmodified lines
185185 if (idet->last_type == TFF){
186186 idet->cur->top_field_first = 1;
187187 idet->cur->interlaced_frame = 1;
188+ idet->cur->flags |= (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST);
188189 }else if(idet->last_type == BFF){
189190 idet->cur->top_field_first = 0;
190191 idet->cur->interlaced_frame = 1;
192+ idet->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
193+ idet->cur->flags |= AV_FRAME_FLAG_INTERLACED;
191194 }else if(idet->last_type == PROGRESSIVE){
192195 idet->cur->interlaced_frame = 0;
196+ idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
193197 }
194198
195199 for(i=0; i<3; i++)
@@ -238,13 +242,15 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 42 unmodified lines
238242 // initial frame(s) and not interlaced, just pass through for
239243 // the analyze_interlaced_flag mode
240244 if (idet->analyze_interlaced_flag &&
241− !picref->interlaced_frame &&
245+ !(picref->flags & AV_FRAME_FLAG_INTERLACED) &&
242246 !idet->next) {
243247 return ff_filter_frame(ctx->outputs[0], picref);
244248 }
245249 if (idet->analyze_interlaced_flag_done) {
246− if (picref->interlaced_frame && idet->interlaced_flag_accuracy < 0)
250+ if ((picref->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
247251 picref->interlaced_frame = 0;
252+ picref->flags &= ~AV_FRAME_FLAG_INTERLACED;
253+ }
248254 return ff_filter_frame(ctx->outputs[0], picref);
249255 }
250256
@@ -282,8 +288,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 31 unmodified lines
282288 }
283289
284290 if (idet->analyze_interlaced_flag) {
285− if (idet->cur->interlaced_frame) {
291+ if (idet->cur->flags & AV_FRAME_FLAG_INTERLACED) {
286292 idet->cur->interlaced_frame = 0;
293+ idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED;
287294 filter(ctx);
288295 if (idet->last_type == PROGRESSIVE) {
289296 idet->interlaced_flag_accuracy --;
@@ -295,8 +302,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 5 unmodified lines
295302 if (idet->analyze_interlaced_flag == 1) {
296303 ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur));
297304
298− if (idet->next->interlaced_frame && idet->interlaced_flag_accuracy < 0)
305+ if ((idet->next->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
299306 idet->next->interlaced_frame = 0;
307+ idet->next->flags &= ~AV_FRAME_FLAG_INTERLACED;
308+ }
300309 idet->analyze_interlaced_flag_done = 1;
301310 av_log(ctx, AV_LOG_INFO, "Final flag accuracy %d\n", idet->interlaced_flag_accuracy);
302311 return ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->next));
libavfilter/vf_kerndeint.c+1−0
@@ -142,6 +142,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 141 unmodified lines
142142 }
143143 av_frame_copy_props(outpic, inpic);
144144 outpic->interlaced_frame = 0;
145+ outpic->flags &= ~AV_FRAME_FLAG_INTERLACED;
145146
146147 for (plane = 0; plane < 4 && inpic->data[plane] && inpic->linesize[plane]; plane++) {
147148 h = plane == 0 ? inlink->h : AV_CEIL_RSHIFT(inlink->h, kerndeint->vsub);
libavfilter/vf_nnedi.c+4−3
@@ -540,8 +540,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 539 unmodified lines
540540 const float in_scale = s->in_scale;
541541 const float out_scale = s->out_scale;
542542 const int depth = s->depth;
543− const int interlaced = in->interlaced_frame;
544− const int tff = s->field_n == (s->field < 0 ? interlaced ? in->top_field_first : 1 :
543+ const int interlaced = !!(in->flags & AV_FRAME_FLAG_INTERLACED);
544+ const int tff = s->field_n == (s->field < 0 ? interlaced ? (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
545545 (s->field & 1) ^ 1);
546546
547547
@@ -666,6 +666,7 @@ static int get_frame(AVFilterContext *ctx, int is_second) · 118 unmodified lines
666666 return AVERROR(ENOMEM);
667667 av_frame_copy_props(dst, s->prev);
668668 dst->interlaced_frame = 0;
669+ dst->flags &= ~AV_FRAME_FLAG_INTERLACED;
669670 dst->pts = s->pts;
670671
671672 ff_filter_execute(ctx, filter_slice, dst, NULL,
@@ -688,7 +689,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 16 unmodified lines
688689 return 0;
689690 }
690691
691− if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
692+ if ((s->deint && !(s->prev->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
692693 s->prev->pts *= 2;
693694 ret = ff_filter_frame(ctx->outputs[0], s->prev);
694695 s->prev = in;
libavfilter/vf_pullup.c+2−1
@@ -670,7 +670,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 669 unmodified lines
670670 (const uint8_t**)in->data, in->linesize,
671671 inlink->format, inlink->w, inlink->h);
672672
673− p = in->interlaced_frame ? !in->top_field_first : 0;
673+ p = (in->flags & AV_FRAME_FLAG_INTERLACED) ?
674+ !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0;
674675 pullup_submit_field(s, b, p );
675676 pullup_submit_field(s, b, p^1);
676677
libavfilter/vf_repeatfields.c+4−3
@@ -93,11 +93,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 92 unmodified lines
9393 s->frame->pts = AV_NOPTS_VALUE;
9494 }
9595
96− if ((state == 0 && !in->top_field_first) ||
97− (state == 1 && in->top_field_first)) {
96+ if ((state == 0 && !(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) ||
97+ (state == 1 && (in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))) {
9898 av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: "
9999 "state=%d top_field_first=%d repeat_first_field=%d\n",
100− state, in->top_field_first, in->repeat_pict);
100+ state, !!(in->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST),
101+ in->repeat_pict);
101102 state ^= 1;
102103 }
103104
libavfilter/vf_scale.c+2−1
@@ -884,7 +884,8 @@ scale: · 883 unmodified lines
884884 (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
885885 INT_MAX);
886886
887− if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) {
887+ if (scale->interlaced>0 || (scale->interlaced<0 &&
888+ (in->flags & AV_FRAME_FLAG_INTERLACED))) {
888889 ret = scale_field(scale, out, in, 0);
889890 if (ret >= 0)
890891 ret = scale_field(scale, out, in, 1);
libavfilter/vf_separatefields.c+4−3
@@ -71,13 +71,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 70 unmodified lines
7171
7272 inpicref->height = outlink->h;
7373 inpicref->interlaced_frame = 0;
74+ inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED;
7475
7576 if (!s->second) {
7677 goto clone;
7778 } else {
7879 AVFrame *second = s->second;
7980
80− extract_field(second, s->nb_planes, second->top_field_first);
81+ extract_field(second, s->nb_planes, !!(second->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
8182
8283 if (second->pts != AV_NOPTS_VALUE &&
8384 inpicref->pts != AV_NOPTS_VALUE)
@@ -94,7 +95,7 @@ clone: · 10 unmodified lines
9495 return AVERROR(ENOMEM);
9596 }
9697
97− extract_field(inpicref, s->nb_planes, !inpicref->top_field_first);
98+ extract_field(inpicref, s->nb_planes, !(inpicref->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
9899
99100 if (inpicref->pts != AV_NOPTS_VALUE)
100101 inpicref->pts *= 2;
@@ -110,7 +111,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) · 9 unmodified lines
110111
111112 if (s->second) {
112113 *out_pts = s->second->pts += pts;
113− extract_field(s->second, s->nb_planes, s->second->top_field_first);
114+ extract_field(s->second, s->nb_planes, !!(s->second->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
114115 ret = ff_filter_frame(outlink, s->second);
115116 s->second = NULL;
116117 }
libavfilter/vf_setparams.c+6−0
@@ -128,9 +128,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 127 unmodified lines
128128 /* set field */
129129 if (s->field_mode == MODE_PROG) {
130130 frame->interlaced_frame = 0;
131+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
131132 } else if (s->field_mode != MODE_AUTO) {
132133 frame->interlaced_frame = 1;
133134 frame->top_field_first = s->field_mode;
135+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
136+ if (s->field_mode)
137+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
138+ else
139+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
134140 }
135141
136142 /* set range */
libavfilter/vf_showinfo.c+2−2
@@ -722,8 +722,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 721 unmodified lines
722722 desc->name,
723723 frame->sample_aspect_ratio.num, frame->sample_aspect_ratio.den,
724724 frame->width, frame->height,
725− !frame->interlaced_frame ? 'P' : /* Progressive */
726− frame->top_field_first ? 'T' : 'B', /* Top / Bottom */
725+ !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' : /* Progressive */
726+ (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B', /* Top / Bottom */
727727 frame->key_frame,
728728 av_get_picture_type_char(frame->pict_type));
729729
libavfilter/vf_telecine.c+16−2
@@ -206,6 +206,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 205 unmodified lines
206206 }
207207 s->frame[nout]->interlaced_frame = 1;
208208 s->frame[nout]->top_field_first = !s->first_field;
209+ s->frame[nout]->flags |= AV_FRAME_FLAG_INTERLACED;
210+ if (s->first_field)
211+ s->frame[nout]->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
212+ else
213+ s->frame[nout]->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
209214 nout++;
210215 len--;
211216 s->occupied = 0;
@@ -225,6 +230,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 13 unmodified lines
225230 s->planeheight[i]);
226231 s->frame[nout]->interlaced_frame = inpicref->interlaced_frame;
227232 s->frame[nout]->top_field_first = inpicref->top_field_first;
233+ s->frame[nout]->flags |= (inpicref->flags & (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST));
228234 nout++;
229235 len -= 2;
230236 }
@@ -241,8 +247,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 10 unmodified lines
241247
242248 for (i = 0; i < nout; i++) {
243249 AVFrame *frame = av_frame_clone(s->frame[i]);
244− int interlaced = frame ? frame->interlaced_frame : 0;
245− int tff = frame ? frame->top_field_first : 0;
250+ int interlaced = frame ? !!(frame->flags & AV_FRAME_FLAG_INTERLACED) : 0;
251+ int tff = frame ? !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 0;
246252
247253 if (!frame) {
248254 av_frame_free(&inpicref);
@@ -252,6 +258,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 3 unmodified lines
252258 av_frame_copy_props(frame, inpicref);
253259 frame->interlaced_frame = interlaced;
254260 frame->top_field_first = tff;
261+ if (interlaced)
262+ frame->flags |= AV_FRAME_FLAG_INTERLACED;
263+ else
264+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
265+ if (tff)
266+ frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
267+ else
268+ frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
255269 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
256270 av_rescale(outlink->frame_count_in, s->ts_unit.num,
257271 s->ts_unit.den);
libavfilter/vf_tinterlace.c+14−2
@@ -393,6 +393,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 392 unmodified lines
393393 out->height = outlink->h;
394394 out->interlaced_frame = 1;
395395 out->top_field_first = 1;
396+ out->flags |= AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST;
396397 out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
397398
398399 /* write odd frame lines into the upper field of the new frame */
@@ -444,7 +445,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 45 unmodified lines
444445 * halving the frame rate and preserving image height */
445446 case MODE_INTERLEAVE_TOP: /* top field first */
446447 case MODE_INTERLEAVE_BOTTOM: /* bottom field first */
447− if ((tinterlace->flags & TINTERLACE_FLAG_BYPASS_IL) && cur->interlaced_frame) {
448+ if ((tinterlace->flags & TINTERLACE_FLAG_BYPASS_IL) && (cur->flags & AV_FRAME_FLAG_INTERLACED)) {
448449 av_log(ctx, AV_LOG_WARNING,
449450 "video is already interlaced, adjusting framerate only\n");
450451 out = av_frame_clone(cur);
@@ -461,6 +462,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 10 unmodified lines
461462 av_frame_copy_props(out, cur);
462463 out->interlaced_frame = 1;
463464 out->top_field_first = tff;
465+ out->flags |= AV_FRAME_FLAG_INTERLACED;
466+ if (tff)
467+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
468+ else
469+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
464470
465471 /* copy upper/lower field from cur */
466472 copy_picture_field(tinterlace, out->data, out->linesize,
@@ -482,6 +488,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 15 unmodified lines
482488 if (!out)
483489 return AVERROR(ENOMEM);
484490 out->interlaced_frame = 1;
491+ out->flags |= AV_FRAME_FLAG_INTERLACED;
485492 if (cur->pts != AV_NOPTS_VALUE)
486493 out->pts = cur->pts*2;
487494
@@ -490,13 +497,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 2 unmodified lines
490497 return ret;
491498
492499 /* output mix of current and next frame */
493− tff = next->top_field_first;
500+ tff = !!(next->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
494501 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
495502 if (!out)
496503 return AVERROR(ENOMEM);
497504 av_frame_copy_props(out, next);
498505 out->interlaced_frame = 1;
499506 out->top_field_first = !tff;
507+ out->flags |= AV_FRAME_FLAG_INTERLACED;
508+ if (tff)
509+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
510+ else
511+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
500512
501513 if (next->pts != AV_NOPTS_VALUE && cur->pts != AV_NOPTS_VALUE)
502514 out->pts = cur->pts + next->pts;
libavfilter/vf_w3fdif.c+4−3
@@ -379,8 +379,8 @@ static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg, · 378 unmodified lines
379379 const int start = (height * jobnr) / nb_jobs;
380380 const int end = (height * (jobnr+1)) / nb_jobs;
381381 const int max = s->max;
382− const int interlaced = cur->interlaced_frame;
383− const int tff = s->field == (s->parity == -1 ? interlaced ? cur->top_field_first : 1 :
382+ const int interlaced = !!(cur->flags & AV_FRAME_FLAG_INTERLACED);
383+ const int tff = s->field == (s->parity == -1 ? interlaced ? !!(cur->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1 :
384384 s->parity ^ 1);
385385 int j, y_in, y_out;
386386
@@ -487,6 +487,7 @@ static int filter(AVFilterContext *ctx, int is_second) · 100 unmodified lines
487487 return AVERROR(ENOMEM);
488488 av_frame_copy_props(out, s->cur);
489489 out->interlaced_frame = 0;
490+ out->flags &= ~AV_FRAME_FLAG_INTERLACED;
490491
491492 if (!is_second) {
492493 if (out->pts != AV_NOPTS_VALUE)
@@ -533,7 +534,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 40 unmodified lines
533534 if (!s->prev)
534535 return 0;
535536
536− if ((s->deint && !s->cur->interlaced_frame) || ctx->is_disabled) {
537+ if ((s->deint && !(s->cur->flags & AV_FRAME_FLAG_INTERLACED)) || ctx->is_disabled) {
537538 AVFrame *out = av_frame_clone(s->cur);
538539 if (!out)
539540 return AVERROR(ENOMEM);
libavfilter/vf_weave.c+5−0
@@ -150,6 +150,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 149 unmodified lines
150150 out->pts = s->double_weave ? s->prev->pts : in->pts / 2;
151151 out->interlaced_frame = 1;
152152 out->top_field_first = !s->first_field;
153+ out->flags |= AV_FRAME_FLAG_INTERLACED;
154+ if (s->first_field)
155+ out->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
156+ else
157+ out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
153158
154159 if (!s->double_weave)
155160 av_frame_free(&in);
libavfilter/vsrc_gradients.c+1−0
@@ -399,6 +399,7 @@ static int activate(AVFilterContext *ctx) · 398 unmodified lines
399399
400400 frame->key_frame = 1;
401401 frame->interlaced_frame = 0;
402+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
402403 frame->pict_type = AV_PICTURE_TYPE_I;
403404 frame->sample_aspect_ratio = (AVRational) {1, 1};
404405 frame->pts = s->pts++;
libavfilter/vsrc_testsrc.c+1−0
@@ -186,6 +186,7 @@ static int activate(AVFilterContext *ctx) · 185 unmodified lines
186186 frame->duration = 1;
187187 frame->key_frame = 1;
188188 frame->interlaced_frame = 0;
189+ frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
189190 frame->pict_type = AV_PICTURE_TYPE_I;
190191 frame->sample_aspect_ratio = test->sar;
191192 if (!test->draw_once)
libavfilter/yadif_common.c+7−5
@@ -31,8 +31,8 @@ static int return_frame(AVFilterContext *ctx, int is_second) · 30 unmodified lines
3131 int tff, ret;
3232
3333 if (yadif->parity == -1) {
34− tff = yadif->cur->interlaced_frame ?
35− yadif->cur->top_field_first : 1;
34+ tff = (yadif->cur->flags & AV_FRAME_FLAG_INTERLACED) ?
35+ !!(yadif->cur->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : 1;
3636 } else {
3737 tff = yadif->parity ^ 1;
3838 }
@@ -44,6 +44,7 @@ static int return_frame(AVFilterContext *ctx, int is_second) · 5 unmodified lines
4444
4545 av_frame_copy_props(yadif->out, yadif->cur);
4646 yadif->out->interlaced_frame = 0;
47+ yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
4748 if (yadif->current_field == YADIF_FIELD_BACK_END)
4849 yadif->current_field = YADIF_FIELD_END;
4950 }
@@ -128,10 +129,10 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 78 unmodified lines
128129 if (!yadif->prev)
129130 return 0;
130131
131− if ((yadif->deint && !yadif->cur->interlaced_frame) ||
132+ if ((yadif->deint && !(yadif->cur->flags & AV_FRAME_FLAG_INTERLACED)) ||
132133 ctx->is_disabled ||
133− (yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
134− (yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
134+ (yadif->deint && !(yadif->prev->flags & AV_FRAME_FLAG_INTERLACED) && yadif->prev->repeat_pict) ||
135+ (yadif->deint && !(yadif->next->flags & AV_FRAME_FLAG_INTERLACED) && yadif->next->repeat_pict)
135136 ) {
136137 yadif->out = av_frame_clone(yadif->cur);
137138 if (!yadif->out)
@@ -149,6 +150,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 11 unmodified lines
149150
150151 av_frame_copy_props(yadif->out, yadif->cur);
151152 yadif->out->interlaced_frame = 0;
153+ yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED;
152154
153155 if (yadif->out->pts != AV_NOPTS_VALUE)
154156 yadif->out->pts *= 2;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t