From patchwork Tue Oct 4 04:49:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 868 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1955107vsd; Mon, 3 Oct 2016 22:03:15 -0700 (PDT) X-Received: by 10.28.41.6 with SMTP id p6mr13023373wmp.18.1475557395539; Mon, 03 Oct 2016 22:03:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j10si2206890wjn.115.2016.10.03.22.03.11; Mon, 03 Oct 2016 22:03:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6EDEE689AD0; Tue, 4 Oct 2016 08:02:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f66.google.com (mail-it0-f66.google.com [209.85.214.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81C88680556 for ; Tue, 4 Oct 2016 08:02:48 +0300 (EEST) Received: by mail-it0-f66.google.com with SMTP id j69so8165434itb.1 for ; Mon, 03 Oct 2016 22:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=X7eVnbb7e5AHQJ+hCQ/O3RZxZlTdse6UypeJ0T7B6QA=; b=SKHZ+VFkMEtBnFzTmhi3q1tm7UeHctTEM1UVS637bpyJ2JWczLlHa0yojX2hErs/gu RifrEXeSCC5a8TQhqNH2hJ+cE7UpbpdOs284sznAqQJJNA3MpuhEEDGEQvI6sfBspQ8q hbvjoBbz/3rOrCO3cUHYa+toYb4YiZJbeSXFP3PxLdzn1ZpMh8mFfD2aFukkK+82Csqf V/wSKgzvz1sLbd4sZoibstTFVU6jgd84/ic6SIe6p3ioULZDeNwN/XXn4VZtuHadW03w N26RvBRs9a+s9J7g3hr30rtxqnsSWTKm6UYMS06QDpUMcDSgpCpz4mMj7OCpO1cB3hlm gxNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=X7eVnbb7e5AHQJ+hCQ/O3RZxZlTdse6UypeJ0T7B6QA=; b=EI2twRnX81ceFLk9LEhl2zNQDEV8YifFMWn86F/kasntmh1LjKHQ4SUgKJPfjtWZY1 gk2Ev3zaubshrKWur9j56wHkUK2M5NDmSok4LrP0M88GZQxBQIz6lk8LEonz44obh2d+ TFtbTw0HVdZNaLziXvgtXe9IwCLTs6cPDMVftkfYdq7Nxy6pU5aMOrwF+Wuz4ZgGgFIp h8can1avhsMr8wWpP/RyaysWStJIEfQ3bT5vtw5r2ot+EedK08qRnz0PkXUZZOl2hivZ RNsIPIDyRtB3d4Dou1+h3DuO3riNygTangF7jiPpwCDwWNlCtCiyI2/Ava4m9+CgONxo 4ITQ== X-Gm-Message-State: AA6/9RkvmysHUF0mn6iQE4e2O6bBzOMFHfKFA4K72KQeRQIbOJ8bVO6QpvnTK1EHLmzviw== X-Received: by 10.36.212.6 with SMTP id x6mr2346134itg.71.1475556585826; Mon, 03 Oct 2016 21:49:45 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-209-137-129.hsd1.il.comcast.net. [73.209.137.129]) by smtp.gmail.com with ESMTPSA id k2sm972795ith.11.2016.10.03.21.49.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Oct 2016 21:49:45 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Oct 2016 23:49:37 -0500 Message-Id: <20161004044939.22351-2-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161004044939.22351-1-rodger.combs@gmail.com> References: <20161004044939.22351-1-rodger.combs@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/4] lavc/h264_parser: export field order in more cases X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/h264_parser.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index 3ed7d77..bca0071 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -61,6 +61,7 @@ typedef struct H264ParseContext { int parse_history_count; int parse_last_mb; int64_t reference_dts; + int last_frame_num, last_picture_structure; } H264ParseContext; @@ -528,7 +529,19 @@ static inline int parse_nal_units(AVCodecParserContext *s, s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD; else s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD; - s->field_order = AV_FIELD_UNKNOWN; + if (p->poc.frame_num == p->last_frame_num && + p->last_picture_structure != AV_PICTURE_STRUCTURE_UNKNOWN && + p->last_picture_structure != AV_PICTURE_STRUCTURE_FRAME && + p->last_picture_structure != s->picture_structure) { + if (p->last_picture_structure == AV_PICTURE_STRUCTURE_TOP_FIELD) + s->field_order = AV_FIELD_TT; + else + s->field_order = AV_FIELD_BB; + } else { + s->field_order = AV_FIELD_UNKNOWN; + } + p->last_picture_structure = s->picture_structure; + p->last_frame_num = p->poc.frame_num; } av_freep(&nal.rbsp_buffer); @@ -677,6 +690,7 @@ static av_cold int init(AVCodecParserContext *s) H264ParseContext *p = s->priv_data; p->reference_dts = AV_NOPTS_VALUE; + p->last_frame_num = INT_MAX; ff_h264dsp_init(&p->h264dsp, 8, 1); return 0; }