From patchwork Wed Sep 14 14:42:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 571 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp2698534vsd; Wed, 14 Sep 2016 07:43:50 -0700 (PDT) X-Received: by 10.194.17.6 with SMTP id k6mr3628481wjd.65.1473864229297; Wed, 14 Sep 2016 07:43:49 -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 hn1si4653910wjb.164.2016.09.14.07.43.25; Wed, 14 Sep 2016 07:43:49 -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 449C6689D6D; Wed, 14 Sep 2016 17:43:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7F49689CF6 for ; Wed, 14 Sep 2016 17:43:04 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id b184so2908092wma.3 for ; Wed, 14 Sep 2016 07:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=nijA1/08GuA2BuaB0EjnfXh+BSZG2g23j0ABYBLxF5w=; b=dEDLibpJHaFO2kiSdswIi4UhGFpeKhz2II1LxooCkP/yHfGLa4/0P8kRu9AetnVvw5 s6GoiefPrtIEXbJaaKB+qiI0vXTv3rhah1PlOXttdwYxShx568aCbsBLJQ377ieVP0rz 3Icbd9YQVRpKOop1DVmkN1E825eTbIutCb7QIv+W7KVxheK/MhkLRdoZS4k98NCfKoFS 7atidh4JURaJMzLT6AzfgFxE6LAIKdNpfq2LUFSH9HyoB+OlkhUaKeq6CA+KajCKupzV lboFloX7KJcT5BxTs1di8tlWGSGW2FsJstXvIGinTKeHpFF3AF3d2gDDYt2oVRA/R9Qr qoUw== 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; bh=nijA1/08GuA2BuaB0EjnfXh+BSZG2g23j0ABYBLxF5w=; b=PQWGGIsuZfM6cRW4N376+GaJe048PuDJObZvx4FTNluSEUHuHcjy2rjC8zM1+odPO7 /SVL3t6nE8z0dB8dP3TqYlIx6B0YrCOlJuBM8HuH3Xhibui+XabuCk0DiS0tXKOfcKwM U//oQ1WLIZ4dAl/tnbi1Z8ozALDk774uO7ViVHkUWgzHJ17WJh0cyB3150X/n3F1tIVR t0oeJ6tWc5ZN13cDqb5blSR1kISss4PzCCQ6/5A1yQFtIw9w4QvV3F6XRrHtjkuLkI7l YytZSr/WOvjmIzAsvT1yMh4cW7xcNvCX0mHkyjdlGNNDwQ3aYyFoJN+pwbC3/PH/Bxhx RoiQ== X-Gm-Message-State: AE9vXwMUp3cOvBMn0ZaCpT1OUqnPfZ5OgxPHu67CW1TL99O8lJdV75spHrogS9qrtduRVg== X-Received: by 10.28.98.68 with SMTP id w65mr11837790wmb.4.1473864196930; Wed, 14 Sep 2016 07:43:16 -0700 (PDT) Received: from computer.gigaset.lan (141-136-220-60.dsl.iskon.hr. [141.136.220.60]) by smtp.gmail.com with ESMTPSA id n7sm4515513wjz.32.2016.09.14.07.43.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Sep 2016 07:43:15 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Sep 2016 16:42:59 +0200 Message-Id: <1473864179-4509-1-git-send-email-onemda@gmail.com> X-Mailer: git-send-email 2.5.0 Subject: [FFmpeg-devel] [PATCH] avcodec/h264_parser: set missing pts for top/bottom field frames 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" Adopted from 4eb49fdde8f84d54a763cfb5d355527b525ee2bf revert. Signed-off-by: Paul B Mahol --- libavcodec/h264_parser.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index 615884f..cf6c3d1 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -60,6 +60,7 @@ typedef struct H264ParseContext { uint8_t parse_history[6]; int parse_history_count; int parse_last_mb; + int64_t reference_dts; } H264ParseContext; @@ -598,6 +599,26 @@ static int h264_parse(AVCodecParserContext *s, s->flags &= PARSER_FLAG_COMPLETE_FRAMES; } + if (s->dts_sync_point >= 0) { + int64_t den = avctx->time_base.den * avctx->pkt_timebase.num; + if (den > 0) { + int64_t num = avctx->time_base.num * avctx->pkt_timebase.den; + if (s->dts != AV_NOPTS_VALUE) { + // got DTS from the stream, update reference timestamp + p->reference_dts = s->dts - s->dts_ref_dts_delta * num / den; + } else if (p->reference_dts != AV_NOPTS_VALUE) { + // compute DTS based on reference timestamp + s->dts = p->reference_dts + s->dts_ref_dts_delta * num / den; + } + + if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE) + s->pts = s->dts + s->pts_dts_delta * num / den; + + if (s->dts_sync_point > 0) + p->reference_dts = s->dts; // new reference + } + } + *poutbuf = buf; *poutbuf_size = buf_size; return next; @@ -655,6 +676,7 @@ static av_cold int init(AVCodecParserContext *s) { H264ParseContext *p = s->priv_data; + p->reference_dts = AV_NOPTS_VALUE; ff_h264dsp_init(&p->h264dsp, 8, 1); return 0; }