Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ffmpeg: fix order between field order autodetection and override
Having the override before autodetection meant that the overridden
value got overwritten by the autodetected result each time,
effectively disabling the ability to utilize the `-top` option
for override purposes.

Somehow I missed this in fbb44bc ,
even though the lines were within the context. Probably the code
originally being after this logic had something to do with it,
but previously it only touched the avformat context's codecpar,
which did not affect the encoder codec context whatsoever.

Fixes #9320
Fixes #9339
  • Loading branch information
jeeb committed Jul 25, 2021
1 parent a1f7d25 commit 4c69409
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fftools/ffmpeg.c
Expand Up @@ -3483,12 +3483,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample;
}

if (ost->top_field_first == 0) {
enc_ctx->field_order = AV_FIELD_BB;
} else if (ost->top_field_first == 1) {
enc_ctx->field_order = AV_FIELD_TT;
}

// Field order: autodetection
if (frame) {
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
Expand All @@ -3503,6 +3498,13 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
}

// Field order: override
if (ost->top_field_first == 0) {
enc_ctx->field_order = AV_FIELD_BB;
} else if (ost->top_field_first == 1) {
enc_ctx->field_order = AV_FIELD_TT;
}

if (ost->forced_keyframes) {
if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5,
Expand Down

0 comments on commit 4c69409

Please sign in to comment.