summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2020-09-20 21:00:52 +0300
committerJan Ekström <jeebjp@gmail.com>2020-10-29 16:59:49 +0200
commitfbb44bc51a647862eb05ae3f9d7d49a0be9bed57 (patch)
treea97b63ae874101d625d15402d35cfca31dfd9adc /fftools
parent7369595c556516b90bf3acdf85043dc11add7d89 (diff)
ffmpeg: move field order decision making to encoder initialization
We now have the possibility of getting AVFrames here, and we should not touch the muxer's codecpar after writing the header. Results of FATE tests change as the MXF and Matroska muxers actually write down the field/frame coding type of a stream in their respective headers. Before this change, these values in codecpar would only be set after the muxer was initialized. Now, the information is also available for encoder and muxer initialization.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 20d191bcf6..788cf9c665 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1123,7 +1123,6 @@ static void do_video_out(OutputFile *of,
int ret, format_video_sync;
AVPacket pkt;
AVCodecContext *enc = ost->enc_ctx;
- AVCodecParameters *mux_par = ost->st->codecpar;
AVRational frame_rate;
int nb_frames, nb0_frames, i;
double delta, delta0;
@@ -1285,18 +1284,6 @@ static void do_video_out(OutputFile *of,
if (!check_recording_time(ost))
return;
- if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
- ost->top_field_first >= 0)
- in_picture->top_field_first = !!ost->top_field_first;
-
- if (in_picture->interlaced_frame) {
- if (enc->codec->id == AV_CODEC_ID_MJPEG)
- mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
- else
- mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
- } else
- mux_par->field_order = AV_FIELD_PROGRESSIVE;
-
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
@@ -3433,6 +3420,20 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->field_order = AV_FIELD_TT;
}
+ if (frame) {
+ if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
+ ost->top_field_first >= 0)
+ frame->top_field_first = !!ost->top_field_first;
+
+ if (frame->interlaced_frame) {
+ if (enc_ctx->codec->id == AV_CODEC_ID_MJPEG)
+ enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
+ else
+ enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
+ } else
+ enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
+ }
+
if (ost->forced_keyframes) {
if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5,