Unified · Split
| @@ -57,8 +57,8 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end) · 56 unmodified lines | ||
| 57 | 57 | ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c", |
| 58 | 58 | ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den, |
| 59 | 59 | 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 */ | |
| 62 | 62 | ref->key_frame, |
| 63 | 63 | av_get_picture_type_char(ref->pict_type)); |
| 64 | 64 | } |
| @@ -247,6 +247,11 @@ FF_DISABLE_DEPRECATION_WARNINGS · 246 unmodified lines | ||
| 247 | 247 | FF_ENABLE_DEPRECATION_WARNINGS |
| 248 | 248 | #endif |
| 249 | 249 | |
| 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 | + | |
| 250 | 255 | ret = ff_filter_frame(ctx->outputs[0], copy); |
| 251 | 256 | if (ret < 0) |
| 252 | 257 | return ret; |
| @@ -356,8 +356,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 355 unmodified lines | ||
| 356 | 356 | |
| 357 | 357 | case AVMEDIA_TYPE_VIDEO: |
| 358 | 358 | 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; | |
| 361 | 361 | select->var_values[VAR_PICT_TYPE] = frame->pict_type; |
| 362 | 362 | if (select->do_scene_detect) { |
| 363 | 363 | char buf[32]; |
| @@ -380,8 +380,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 16 unmodified lines | ||
| 380 | 380 | switch (inlink->type) { |
| 381 | 381 | case AVMEDIA_TYPE_VIDEO: |
| 382 | 382 | 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', | |
| 385 | 385 | av_get_picture_type_char(frame->pict_type), |
| 386 | 386 | select->var_values[VAR_SCENE]); |
| 387 | 387 | break; |
| @@ -57,10 +57,10 @@ static enum PhaseMode fn(analyze_plane)(void *ctx, enum PhaseMode mode, AVFrame · 56 unmodified lines | ||
| 57 | 57 | double bdiff, tdiff, pdiff; |
| 58 | 58 | |
| 59 | 59 | 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) ? | |
| 61 | 61 | TOP_FIRST : BOTTOM_FIRST : PROGRESSIVE; |
| 62 | 62 | } 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) ? | |
| 64 | 64 | TOP_FIRST_ANALYZE : BOTTOM_FIRST_ANALYZE : FULL_ANALYZE; |
| 65 | 65 | } |
| 66 | 66 | |
| @@ -460,8 +460,8 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p · 459 unmodified lines | ||
| 460 | 460 | inlink->time_base, default_tb); |
| 461 | 461 | |
| 462 | 462 | 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 : | |
| 465 | 465 | MFX_PICSTRUCT_FIELD_BFF); |
| 466 | 466 | if (qsv_frame->frame->repeat_pict == 1) |
| 467 | 467 | qsv_frame->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED; |
| @@ -174,7 +174,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 173 unmodified lines | ||
| 174 | 174 | |
| 175 | 175 | if (frame) { |
| 176 | 176 | 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); | |
| 178 | 178 | } else if (inlink->type == AVMEDIA_TYPE_AUDIO) { |
| 179 | 179 | setpts->var_values[VAR_S] = frame->nb_samples; |
| 180 | 180 | setpts->var_values[VAR_NB_SAMPLES] = frame->nb_samples; |
| @@ -303,6 +303,7 @@ static int request_frame(AVFilterLink *link) · 302 unmodified lines | ||
| 303 | 303 | frame->duration = 1; |
| 304 | 304 | frame->key_frame = 1; |
| 305 | 305 | frame->interlaced_frame = 0; |
| 306 | + frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 306 | 307 | frame->pict_type = AV_PICTURE_TYPE_I; |
| 307 | 308 | frame->sample_aspect_ratio = ctx->sar; |
| 308 | 309 | |
| @@ -252,7 +252,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) · 251 unmodified lines | ||
| 252 | 252 | if (err < 0) |
| 253 | 253 | goto fail; |
| 254 | 254 | |
| 255 | − if (!ctx->auto_enable || input_frame->interlaced_frame) { | |
| 255 | + if (!ctx->auto_enable || (input_frame->flags & AV_FRAME_FLAG_INTERLACED)) { | |
| 256 | 256 | vas = vaMapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0], |
| 257 | 257 | &filter_params_addr); |
| 258 | 258 | if (vas != VA_STATUS_SUCCESS) { |
| @@ -263,7 +263,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) · 4 unmodified lines | ||
| 263 | 263 | } |
| 264 | 264 | filter_params = filter_params_addr; |
| 265 | 265 | filter_params->flags = 0; |
| 266 | − if (input_frame->top_field_first) { | |
| 266 | + if (input_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) { | |
| 267 | 267 | filter_params->flags |= field ? VA_DEINTERLACING_BOTTOM_FIELD : 0; |
| 268 | 268 | } else { |
| 269 | 269 | 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 | ||
| 304 | 304 | ctx->frame_queue[current_frame_index + 1]->pts; |
| 305 | 305 | } |
| 306 | 306 | output_frame->interlaced_frame = 0; |
| 307 | + output_frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 307 | 308 | |
| 308 | 309 | av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n", |
| 309 | 310 | av_get_pix_fmt_name(output_frame->format), |
| @@ -345,8 +345,8 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, · 344 unmodified lines | ||
| 345 | 345 | const int rslope = s->rslope; |
| 346 | 346 | const int redge = s->redge; |
| 347 | 347 | 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 : | |
| 350 | 350 | s->parity ^ 1)); |
| 351 | 351 | |
| 352 | 352 | 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 | ||
| 444 | 444 | return AVERROR(ENOMEM); |
| 445 | 445 | av_frame_copy_props(out, in); |
| 446 | 446 | out->interlaced_frame = 0; |
| 447 | + out->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 447 | 448 | out->pts = pts; |
| 448 | 449 | out->duration = duration; |
| 449 | 450 | |
| @@ -502,7 +503,7 @@ static int config_input(AVFilterLink *inlink) · 52 unmodified lines | ||
| 502 | 503 | return 0; |
| 503 | 504 | } |
| 504 | 505 | |
| 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) { | |
| 506 | 507 | s->prev->pts *= 2; |
| 507 | 508 | s->prev->duration *= 2; |
| 508 | 509 | ret = ff_filter_frame(ctx->outputs[0], s->prev); |
| @@ -74,6 +74,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 73 unmodified lines | ||
| 74 | 74 | |
| 75 | 75 | inpicref->height = outlink->h; |
| 76 | 76 | inpicref->interlaced_frame = 0; |
| 77 | + inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 77 | 78 | |
| 78 | 79 | for (i = 0; i < field->nb_planes; i++) { |
| 79 | 80 | if (field->type == FIELD_TYPE_BOTTOM) |
| @@ -218,9 +218,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 217 unmodified lines | ||
| 218 | 218 | switch (hint) { |
| 219 | 219 | case '+': |
| 220 | 220 | out->interlaced_frame = 1; |
| 221 | + out->flags |= AV_FRAME_FLAG_INTERLACED; | |
| 221 | 222 | break; |
| 222 | 223 | case '-': |
| 223 | 224 | out->interlaced_frame = 0; |
| 225 | + out->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 224 | 226 | break; |
| 225 | 227 | case '=': |
| 226 | 228 | break; |
| @@ -714,7 +714,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 713 unmodified lines | ||
| 714 | 714 | in = fm->src; |
| 715 | 715 | |
| 716 | 716 | /* 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); | |
| 718 | 719 | field = fm->field != FM_PARITY_AUTO ? fm->field : order; |
| 719 | 720 | av_assert0(order == 0 || order == 1 || field == 0 || field == 1); |
| 720 | 721 | fxo = field ^ order ? fxo1m : fxo0m; |
| @@ -820,15 +821,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 99 unmodified lines | ||
| 820 | 821 | /* mark the frame we are unable to match properly as interlaced so a proper |
| 821 | 822 | * de-interlacer can take the relay */ |
| 822 | 823 | dst->interlaced_frame = interlaced_frame; |
| 823 | − if (dst->interlaced_frame) { | |
| 824 | + if (interlaced_frame) { | |
| 825 | + dst->flags |= AV_FRAME_FLAG_INTERLACED; | |
| 824 | 826 | av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n", |
| 825 | 827 | outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base)); |
| 826 | 828 | 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; | |
| 828 | 835 | |
| 829 | 836 | av_log(ctx, AV_LOG_DEBUG, "SC:%d | COMBS: %3d %3d %3d %3d %3d (combpel=%d)" |
| 830 | 837 | " 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"); | |
| 832 | 839 | |
| 833 | 840 | fail: |
| 834 | 841 | for (i = 0; i < FF_ARRAY_ELEMS(gen_frames); i++) |
| @@ -76,11 +76,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 75 unmodified lines | ||
| 76 | 76 | uint8_t *dst, *src; |
| 77 | 77 | AVFrame *out; |
| 78 | 78 | |
| 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) { | |
| 81 | 81 | av_log(ctx, AV_LOG_VERBOSE, |
| 82 | 82 | "Skipping %s.\n", |
| 83 | − frame->interlaced_frame ? | |
| 83 | + (frame->flags & AV_FRAME_FLAG_INTERLACED) ? | |
| 84 | 84 | "frame with same field order" : "progressive frame"); |
| 85 | 85 | return ff_filter_frame(outlink, frame); |
| 86 | 86 | } |
| @@ -141,6 +141,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 54 unmodified lines | ||
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | 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; | |
| 144 | 148 | |
| 145 | 149 | if (frame != out) |
| 146 | 150 | av_frame_free(&frame); |
| @@ -318,7 +318,7 @@ retry: · 317 unmodified lines | ||
| 318 | 318 | return ret; |
| 319 | 319 | |
| 320 | 320 | if (inpicref) { |
| 321 | − if (inpicref->interlaced_frame) | |
| 321 | + if (inpicref->flags & AV_FRAME_FLAG_INTERLACED) | |
| 322 | 322 | av_log(ctx, AV_LOG_WARNING, "Interlaced frame found - the output will not be correct.\n"); |
| 323 | 323 | |
| 324 | 324 | if (inpicref->pts == AV_NOPTS_VALUE) { |
| @@ -185,11 +185,15 @@ static void filter(AVFilterContext *ctx) · 184 unmodified lines | ||
| 185 | 185 | if (idet->last_type == TFF){ |
| 186 | 186 | idet->cur->top_field_first = 1; |
| 187 | 187 | idet->cur->interlaced_frame = 1; |
| 188 | + idet->cur->flags |= (AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST); | |
| 188 | 189 | }else if(idet->last_type == BFF){ |
| 189 | 190 | idet->cur->top_field_first = 0; |
| 190 | 191 | idet->cur->interlaced_frame = 1; |
| 192 | + idet->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; | |
| 193 | + idet->cur->flags |= AV_FRAME_FLAG_INTERLACED; | |
| 191 | 194 | }else if(idet->last_type == PROGRESSIVE){ |
| 192 | 195 | idet->cur->interlaced_frame = 0; |
| 196 | + idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 193 | 197 | } |
| 194 | 198 | |
| 195 | 199 | for(i=0; i<3; i++) |
| @@ -238,13 +242,15 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 42 unmodified lines | ||
| 238 | 242 | // initial frame(s) and not interlaced, just pass through for |
| 239 | 243 | // the analyze_interlaced_flag mode |
| 240 | 244 | if (idet->analyze_interlaced_flag && |
| 241 | − !picref->interlaced_frame && | |
| 245 | + !(picref->flags & AV_FRAME_FLAG_INTERLACED) && | |
| 242 | 246 | !idet->next) { |
| 243 | 247 | return ff_filter_frame(ctx->outputs[0], picref); |
| 244 | 248 | } |
| 245 | 249 | 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) { | |
| 247 | 251 | picref->interlaced_frame = 0; |
| 252 | + picref->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 253 | + } | |
| 248 | 254 | return ff_filter_frame(ctx->outputs[0], picref); |
| 249 | 255 | } |
| 250 | 256 | |
| @@ -282,8 +288,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 31 unmodified lines | ||
| 282 | 288 | } |
| 283 | 289 | |
| 284 | 290 | if (idet->analyze_interlaced_flag) { |
| 285 | − if (idet->cur->interlaced_frame) { | |
| 291 | + if (idet->cur->flags & AV_FRAME_FLAG_INTERLACED) { | |
| 286 | 292 | idet->cur->interlaced_frame = 0; |
| 293 | + idet->cur->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 287 | 294 | filter(ctx); |
| 288 | 295 | if (idet->last_type == PROGRESSIVE) { |
| 289 | 296 | idet->interlaced_flag_accuracy --; |
| @@ -295,8 +302,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 5 unmodified lines | ||
| 295 | 302 | if (idet->analyze_interlaced_flag == 1) { |
| 296 | 303 | ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur)); |
| 297 | 304 | |
| 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) { | |
| 299 | 306 | idet->next->interlaced_frame = 0; |
| 307 | + idet->next->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 308 | + } | |
| 300 | 309 | idet->analyze_interlaced_flag_done = 1; |
| 301 | 310 | av_log(ctx, AV_LOG_INFO, "Final flag accuracy %d\n", idet->interlaced_flag_accuracy); |
| 302 | 311 | return ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->next)); |
| @@ -142,6 +142,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 141 unmodified lines | ||
| 142 | 142 | } |
| 143 | 143 | av_frame_copy_props(outpic, inpic); |
| 144 | 144 | outpic->interlaced_frame = 0; |
| 145 | + outpic->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 145 | 146 | |
| 146 | 147 | for (plane = 0; plane < 4 && inpic->data[plane] && inpic->linesize[plane]; plane++) { |
| 147 | 148 | h = plane == 0 ? inlink->h : AV_CEIL_RSHIFT(inlink->h, kerndeint->vsub); |
| @@ -540,8 +540,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 539 unmodified lines | ||
| 540 | 540 | const float in_scale = s->in_scale; |
| 541 | 541 | const float out_scale = s->out_scale; |
| 542 | 542 | 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 : | |
| 545 | 545 | (s->field & 1) ^ 1); |
| 546 | 546 | |
| 547 | 547 | |
| @@ -666,6 +666,7 @@ static int get_frame(AVFilterContext *ctx, int is_second) · 118 unmodified lines | ||
| 666 | 666 | return AVERROR(ENOMEM); |
| 667 | 667 | av_frame_copy_props(dst, s->prev); |
| 668 | 668 | dst->interlaced_frame = 0; |
| 669 | + dst->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 669 | 670 | dst->pts = s->pts; |
| 670 | 671 | |
| 671 | 672 | ff_filter_execute(ctx, filter_slice, dst, NULL, |
| @@ -688,7 +689,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 16 unmodified lines | ||
| 688 | 689 | return 0; |
| 689 | 690 | } |
| 690 | 691 | |
| 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) { | |
| 692 | 693 | s->prev->pts *= 2; |
| 693 | 694 | ret = ff_filter_frame(ctx->outputs[0], s->prev); |
| 694 | 695 | s->prev = in; |
| @@ -670,7 +670,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 669 unmodified lines | ||
| 670 | 670 | (const uint8_t**)in->data, in->linesize, |
| 671 | 671 | inlink->format, inlink->w, inlink->h); |
| 672 | 672 | |
| 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; | |
| 674 | 675 | pullup_submit_field(s, b, p ); |
| 675 | 676 | pullup_submit_field(s, b, p^1); |
| 676 | 677 | |
| @@ -93,11 +93,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 92 unmodified lines | ||
| 93 | 93 | s->frame->pts = AV_NOPTS_VALUE; |
| 94 | 94 | } |
| 95 | 95 | |
| 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))) { | |
| 98 | 98 | av_log(ctx, AV_LOG_WARNING, "Unexpected field flags: " |
| 99 | 99 | "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); | |
| 101 | 102 | state ^= 1; |
| 102 | 103 | } |
| 103 | 104 | |
| @@ -884,7 +884,8 @@ scale: · 883 unmodified lines | ||
| 884 | 884 | (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, |
| 885 | 885 | INT_MAX); |
| 886 | 886 | |
| 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))) { | |
| 888 | 889 | ret = scale_field(scale, out, in, 0); |
| 889 | 890 | if (ret >= 0) |
| 890 | 891 | ret = scale_field(scale, out, in, 1); |
| @@ -71,13 +71,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 70 unmodified lines | ||
| 71 | 71 | |
| 72 | 72 | inpicref->height = outlink->h; |
| 73 | 73 | inpicref->interlaced_frame = 0; |
| 74 | + inpicref->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 74 | 75 | |
| 75 | 76 | if (!s->second) { |
| 76 | 77 | goto clone; |
| 77 | 78 | } else { |
| 78 | 79 | AVFrame *second = s->second; |
| 79 | 80 | |
| 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)); | |
| 81 | 82 | |
| 82 | 83 | if (second->pts != AV_NOPTS_VALUE && |
| 83 | 84 | inpicref->pts != AV_NOPTS_VALUE) |
| @@ -94,7 +95,7 @@ clone: · 10 unmodified lines | ||
| 94 | 95 | return AVERROR(ENOMEM); |
| 95 | 96 | } |
| 96 | 97 | |
| 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)); | |
| 98 | 99 | |
| 99 | 100 | if (inpicref->pts != AV_NOPTS_VALUE) |
| 100 | 101 | inpicref->pts *= 2; |
| @@ -110,7 +111,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) · 9 unmodified lines | ||
| 110 | 111 | |
| 111 | 112 | if (s->second) { |
| 112 | 113 | *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)); | |
| 114 | 115 | ret = ff_filter_frame(outlink, s->second); |
| 115 | 116 | s->second = NULL; |
| 116 | 117 | } |
| @@ -128,9 +128,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 127 unmodified lines | ||
| 128 | 128 | /* set field */ |
| 129 | 129 | if (s->field_mode == MODE_PROG) { |
| 130 | 130 | frame->interlaced_frame = 0; |
| 131 | + frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 131 | 132 | } else if (s->field_mode != MODE_AUTO) { |
| 132 | 133 | frame->interlaced_frame = 1; |
| 133 | 134 | 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; | |
| 134 | 140 | } |
| 135 | 141 | |
| 136 | 142 | /* set range */ |
| @@ -722,8 +722,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 721 unmodified lines | ||
| 722 | 722 | desc->name, |
| 723 | 723 | frame->sample_aspect_ratio.num, frame->sample_aspect_ratio.den, |
| 724 | 724 | 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 */ | |
| 727 | 727 | frame->key_frame, |
| 728 | 728 | av_get_picture_type_char(frame->pict_type)); |
| 729 | 729 | |
| @@ -206,6 +206,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 205 unmodified lines | ||
| 206 | 206 | } |
| 207 | 207 | s->frame[nout]->interlaced_frame = 1; |
| 208 | 208 | 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; | |
| 209 | 214 | nout++; |
| 210 | 215 | len--; |
| 211 | 216 | s->occupied = 0; |
| @@ -225,6 +230,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 13 unmodified lines | ||
| 225 | 230 | s->planeheight[i]); |
| 226 | 231 | s->frame[nout]->interlaced_frame = inpicref->interlaced_frame; |
| 227 | 232 | 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)); | |
| 228 | 234 | nout++; |
| 229 | 235 | len -= 2; |
| 230 | 236 | } |
| @@ -241,8 +247,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 10 unmodified lines | ||
| 241 | 247 | |
| 242 | 248 | for (i = 0; i < nout; i++) { |
| 243 | 249 | 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; | |
| 246 | 252 | |
| 247 | 253 | if (!frame) { |
| 248 | 254 | av_frame_free(&inpicref); |
| @@ -252,6 +258,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 3 unmodified lines | ||
| 252 | 258 | av_frame_copy_props(frame, inpicref); |
| 253 | 259 | frame->interlaced_frame = interlaced; |
| 254 | 260 | 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; | |
| 255 | 269 | frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) + |
| 256 | 270 | av_rescale(outlink->frame_count_in, s->ts_unit.num, |
| 257 | 271 | s->ts_unit.den); |
| @@ -393,6 +393,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 392 unmodified lines | ||
| 393 | 393 | out->height = outlink->h; |
| 394 | 394 | out->interlaced_frame = 1; |
| 395 | 395 | out->top_field_first = 1; |
| 396 | + out->flags |= AV_FRAME_FLAG_INTERLACED | AV_FRAME_FLAG_TOP_FIELD_FIRST; | |
| 396 | 397 | out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1)); |
| 397 | 398 | |
| 398 | 399 | /* 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 | ||
| 444 | 445 | * halving the frame rate and preserving image height */ |
| 445 | 446 | case MODE_INTERLEAVE_TOP: /* top field first */ |
| 446 | 447 | 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)) { | |
| 448 | 449 | av_log(ctx, AV_LOG_WARNING, |
| 449 | 450 | "video is already interlaced, adjusting framerate only\n"); |
| 450 | 451 | out = av_frame_clone(cur); |
| @@ -461,6 +462,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 10 unmodified lines | ||
| 461 | 462 | av_frame_copy_props(out, cur); |
| 462 | 463 | out->interlaced_frame = 1; |
| 463 | 464 | 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; | |
| 464 | 470 | |
| 465 | 471 | /* copy upper/lower field from cur */ |
| 466 | 472 | copy_picture_field(tinterlace, out->data, out->linesize, |
| @@ -482,6 +488,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 15 unmodified lines | ||
| 482 | 488 | if (!out) |
| 483 | 489 | return AVERROR(ENOMEM); |
| 484 | 490 | out->interlaced_frame = 1; |
| 491 | + out->flags |= AV_FRAME_FLAG_INTERLACED; | |
| 485 | 492 | if (cur->pts != AV_NOPTS_VALUE) |
| 486 | 493 | out->pts = cur->pts*2; |
| 487 | 494 | |
| @@ -490,13 +497,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 2 unmodified lines | ||
| 490 | 497 | return ret; |
| 491 | 498 | |
| 492 | 499 | /* output mix of current and next frame */ |
| 493 | − tff = next->top_field_first; | |
| 500 | + tff = !!(next->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); | |
| 494 | 501 | out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| 495 | 502 | if (!out) |
| 496 | 503 | return AVERROR(ENOMEM); |
| 497 | 504 | av_frame_copy_props(out, next); |
| 498 | 505 | out->interlaced_frame = 1; |
| 499 | 506 | 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; | |
| 500 | 512 | |
| 501 | 513 | if (next->pts != AV_NOPTS_VALUE && cur->pts != AV_NOPTS_VALUE) |
| 502 | 514 | out->pts = cur->pts + next->pts; |
| @@ -379,8 +379,8 @@ static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg, · 378 unmodified lines | ||
| 379 | 379 | const int start = (height * jobnr) / nb_jobs; |
| 380 | 380 | const int end = (height * (jobnr+1)) / nb_jobs; |
| 381 | 381 | 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 : | |
| 384 | 384 | s->parity ^ 1); |
| 385 | 385 | int j, y_in, y_out; |
| 386 | 386 | |
| @@ -487,6 +487,7 @@ static int filter(AVFilterContext *ctx, int is_second) · 100 unmodified lines | ||
| 487 | 487 | return AVERROR(ENOMEM); |
| 488 | 488 | av_frame_copy_props(out, s->cur); |
| 489 | 489 | out->interlaced_frame = 0; |
| 490 | + out->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 490 | 491 | |
| 491 | 492 | if (!is_second) { |
| 492 | 493 | if (out->pts != AV_NOPTS_VALUE) |
| @@ -533,7 +534,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 40 unmodified lines | ||
| 533 | 534 | if (!s->prev) |
| 534 | 535 | return 0; |
| 535 | 536 | |
| 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) { | |
| 537 | 538 | AVFrame *out = av_frame_clone(s->cur); |
| 538 | 539 | if (!out) |
| 539 | 540 | return AVERROR(ENOMEM); |
| @@ -150,6 +150,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 149 unmodified lines | ||
| 150 | 150 | out->pts = s->double_weave ? s->prev->pts : in->pts / 2; |
| 151 | 151 | out->interlaced_frame = 1; |
| 152 | 152 | 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; | |
| 153 | 158 | |
| 154 | 159 | if (!s->double_weave) |
| 155 | 160 | av_frame_free(&in); |
| @@ -399,6 +399,7 @@ static int activate(AVFilterContext *ctx) · 398 unmodified lines | ||
| 399 | 399 | |
| 400 | 400 | frame->key_frame = 1; |
| 401 | 401 | frame->interlaced_frame = 0; |
| 402 | + frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 402 | 403 | frame->pict_type = AV_PICTURE_TYPE_I; |
| 403 | 404 | frame->sample_aspect_ratio = (AVRational) {1, 1}; |
| 404 | 405 | frame->pts = s->pts++; |
| @@ -186,6 +186,7 @@ static int activate(AVFilterContext *ctx) · 185 unmodified lines | ||
| 186 | 186 | frame->duration = 1; |
| 187 | 187 | frame->key_frame = 1; |
| 188 | 188 | frame->interlaced_frame = 0; |
| 189 | + frame->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 189 | 190 | frame->pict_type = AV_PICTURE_TYPE_I; |
| 190 | 191 | frame->sample_aspect_ratio = test->sar; |
| 191 | 192 | if (!test->draw_once) |
| @@ -31,8 +31,8 @@ static int return_frame(AVFilterContext *ctx, int is_second) · 30 unmodified lines | ||
| 31 | 31 | int tff, ret; |
| 32 | 32 | |
| 33 | 33 | 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; | |
| 36 | 36 | } else { |
| 37 | 37 | tff = yadif->parity ^ 1; |
| 38 | 38 | } |
| @@ -44,6 +44,7 @@ static int return_frame(AVFilterContext *ctx, int is_second) · 5 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | av_frame_copy_props(yadif->out, yadif->cur); |
| 46 | 46 | yadif->out->interlaced_frame = 0; |
| 47 | + yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 47 | 48 | if (yadif->current_field == YADIF_FIELD_BACK_END) |
| 48 | 49 | yadif->current_field = YADIF_FIELD_END; |
| 49 | 50 | } |
| @@ -128,10 +129,10 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 78 unmodified lines | ||
| 128 | 129 | if (!yadif->prev) |
| 129 | 130 | return 0; |
| 130 | 131 | |
| 131 | − if ((yadif->deint && !yadif->cur->interlaced_frame) || | |
| 132 | + if ((yadif->deint && !(yadif->cur->flags & AV_FRAME_FLAG_INTERLACED)) || | |
| 132 | 133 | 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) | |
| 135 | 136 | ) { |
| 136 | 137 | yadif->out = av_frame_clone(yadif->cur); |
| 137 | 138 | if (!yadif->out) |
| @@ -149,6 +150,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 11 unmodified lines | ||
| 149 | 150 | |
| 150 | 151 | av_frame_copy_props(yadif->out, yadif->cur); |
| 151 | 152 | yadif->out->interlaced_frame = 0; |
| 153 | + yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED; | |
| 152 | 154 | |
| 153 | 155 | if (yadif->out->pts != AV_NOPTS_VALUE) |
| 154 | 156 | yadif->out->pts *= 2; |