From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 92C00475EF for ; Thu, 14 Sep 2023 15:10:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AAB7668C7D4; Thu, 14 Sep 2023 18:10:52 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 40AEE68C56B for ; Thu, 14 Sep 2023 18:10:46 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E785A240200 for ; Thu, 14 Sep 2023 17:10:45 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Ur2dEdszwrdx for ; Thu, 14 Sep 2023 17:10:45 +0200 (CEST) Received: from mail1.khirnov.net (mail1.khirnov.net [IPv6:2a00:c500:561:206::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail1.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 824D42401E7 for ; Thu, 14 Sep 2023 17:10:45 +0200 (CEST) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 0D822257E for ; Thu, 14 Sep 2023 17:10:38 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id N7K3K5iFzwlN for ; Thu, 14 Sep 2023 17:10:33 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 2616D257C for ; Thu, 14 Sep 2023 17:10:33 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9BD6C3A0376 for ; Thu, 14 Sep 2023 17:10:26 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Sep 2023 17:10:18 +0200 Message-Id: <20230914151020.10415-1-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg_enc: refactor setting encoding field_order X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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".