From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg_enc: refactor setting encoding field_order Date: Thu, 14 Sep 2023 17:10:18 +0200 Message-ID: <20230914151020.10415-1-anton@khirnov.net> (raw) Merge three blocks with slightly inconsistent checks into one, treating encoder input as interlaced when either: * at least one of ilme/ildct flags is set * the first frame in the stream is marked as interlaced * the user specified the -top option Stop modifying the frame passed to enc_open(). --- fftools/ffmpeg_enc.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index f28884e50c..e878eb02b4 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -356,29 +356,18 @@ int enc_open(OutputStream *ost, AVFrame *frame) enc_ctx->colorspace = frame->colorspace; enc_ctx->chroma_sample_location = frame->chroma_location; - // Field order: autodetection - if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && - ost->top_field_first >= 0) - if (ost->top_field_first) - frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; - else - frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; + if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) || + (frame->flags & AV_FRAME_FLAG_INTERLACED) || ost->top_field_first >= 0) { + int top_field_first = ost->top_field_first >= 0 ? + ost->top_field_first : !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); - if (frame->flags & AV_FRAME_FLAG_INTERLACED) { if (enc->id == AV_CODEC_ID_MJPEG) - enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TT:AV_FIELD_BB; + enc_ctx->field_order = top_field_first ? AV_FIELD_TT : AV_FIELD_BB; else - enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT; + enc_ctx->field_order = top_field_first ? AV_FIELD_TB : AV_FIELD_BT; } else 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; - } - break; } case AVMEDIA_TYPE_SUBTITLE: -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-09-14 15:10 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-14 15:10 Anton Khirnov [this message] 2023-09-14 15:10 ` [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg_enc: apply -top to individual encoded frames Anton Khirnov 2023-09-14 15:10 ` [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: deprecate the -top option Anton Khirnov 2023-09-18 15:19 ` [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg_enc: refactor setting encoding field_order Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230914151020.10415-1-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git