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 2CCA840C1E for ; Sat, 5 Feb 2022 12:51:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A8CF868B378; Sat, 5 Feb 2022 14:51:42 +0200 (EET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B418268B324 for ; Sat, 5 Feb 2022 14:51:35 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id j16so7467108plx.4 for ; Sat, 05 Feb 2022 04:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N9JBWcQNR0TJ8ImQWZc0hJvPr0KLKGJAk43n0V5Cjsk=; b=gJNHD89JBS0rViV8usDioMlBHJmskcAX6p3A7C9oBYE3Pga1QhBuZiZQwxAupve62c P6ZiHeKstxyPdeDWLffMi/qxJ/0PC2H8Zcf3RsGEHCLn7n5ux79ILjwN/F+Ox2oLJ4QL Y+lUZQqsXKeDsyPeus2rV6IpkieuPvWGZb39cAtTXoyxrwLGY5yqRJii+dshl4dw1Ygd vuIBGTJqbnv+Dd7QrK8R6JaeY/TNeT6//PpB+BgKZpHgFPDrU2fEeGY/VoeScP62tr5w nf53Cz4b9QiZaSEbYw/i7jxmTgt8BxySumirNVIMYxs0Cmdx1TqPbcBuJLBj0tubwO2X Zvcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N9JBWcQNR0TJ8ImQWZc0hJvPr0KLKGJAk43n0V5Cjsk=; b=2Mzmp+7OVwgKunDMUJv0YXNNzHJgVpt175sOBEc2R38UITPU5Q5pNCHO4fLnEOLSJQ VZ0rymihra7uW/vaxJaTeKSE4gENPSvbQJRtDcL1K1Cfk0UqW43FgQccGKo7MS1kGY08 Flx0o8Djx+NtHmoRBCFA/Cl80A3nQTNzf4GfzbiAkrOQnVWlB+DN7tstRZ6ls03OeVCE l/NI3iVmENgF11zbd8tF22mO7HEgiRDtBvc9u5T+Go6udIULtKyO3vmXmdsObCsFZrCq IaDGsaiQ/n0bcumPbPjmpwwL4eVaEvtncS9qadMngFuFf9vn6GSFHx5WIZst8wfgyeVF /5EA== X-Gm-Message-State: AOAM530dsX/BaB6AdncQL1B7V9hpZTWYrjWuHx1hmGhWVH4T1yc4RjBQ YbSRJ9lGGLt+LBeXGGc7dqflqTXcAFQ= X-Google-Smtp-Source: ABdhPJzdPk7KOon/uZPz1HO04uNRzKGcjCTHc/kZNLTsNQi5jpQICdqzqYgDG2s9T+WM5c18nb5eXw== X-Received: by 2002:a17:90b:1bc6:: with SMTP id oa6mr8377017pjb.127.1644065493834; Sat, 05 Feb 2022 04:51:33 -0800 (PST) Received: from archlinux.. ([161.81.112.246]) by smtp.gmail.com with ESMTPSA id q2sm3979378pgt.47.2022.02.05.04.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Feb 2022 04:51:33 -0800 (PST) From: Tom Yan To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Feb 2022 20:51:27 +0800 Message-Id: <20220205125127.20744-1-tom.ty89@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] mpegvideo_parser: check picture_structure for 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 Cc: Tom Yan 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: the top_field_first bit is only used to indicate the field order when the picture is a frame picture (which consists of two fields) but not when it is a field picture (which consists of one single top or bottom field). Signed-off-by: Tom Yan --- libavcodec/mpegvideo_parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index c5dc867d24..2ddcdb0f37 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -108,7 +108,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, uint32_t start_code; int frame_rate_index, ext_type, bytes_left; int frame_rate_ext_n, frame_rate_ext_d; - int top_field_first, repeat_first_field, progressive_frame; + int picture_structure, top_field_first, repeat_first_field, progressive_frame; int horiz_size_ext, vert_size_ext, bit_rate_ext; int did_set_size=0; int set_dim_ret = 0; @@ -181,6 +181,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, break; case 0x8: /* picture coding extension */ if (bytes_left >= 5) { + picture_structure = buf[2] & 0x3; top_field_first = buf[3] & (1 << 7); repeat_first_field = buf[3] & (1 << 1); progressive_frame = buf[4] & (1 << 7); @@ -199,7 +200,9 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, } if (!pc->progressive_sequence && !progressive_frame) { - if (top_field_first) + /* top_field_first is mandated to be 0 when + picture_structure is not 3 (i.e. not a frame picture) */ + if (top_field_first || picture_structure == 1) s->field_order = AV_FIELD_TT; else s->field_order = AV_FIELD_BB; -- 2.35.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".