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