From patchwork Sun Oct 2 21:08:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 840 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1286582vsd; Sun, 2 Oct 2016 14:09:21 -0700 (PDT) X-Received: by 10.28.94.18 with SMTP id s18mr7440581wmb.44.1475442561825; Sun, 02 Oct 2016 14:09:21 -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 14si15599875wmn.119.2016.10.02.14.09.21; Sun, 02 Oct 2016 14:09:21 -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=@rothenpieler.org; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 010F8689DF7; Mon, 3 Oct 2016 00:08:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6AEE689895 for ; Mon, 3 Oct 2016 00:08:44 +0300 (EEST) Received: from localhost.localdomain (ip4d173c0b.dynamic.kabel-deutschland.de [77.23.60.11]) by btbn.de (Postfix) with ESMTPSA id 85C262A39C0; Sun, 2 Oct 2016 23:08:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1475442538; bh=tg+dYUML5Qn60R0ak3H8dQD6k+ft1swxff8reX/2aXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ii3DABQaEVzLen5Z34GqJdd9QE38ICPHs+SF7qtoINci2Ogf1WYCsfNCL4LriCNg8 hv39oTZrQcj8aq4LYiuOGCN517us6D++zGCDSVx7sCivgSPvSFzecGuPQIqIc235As SJL/gwGUQim/TRrpgxiDraGceZG8ZmJ96vfYQnjs= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Oct 2016 23:08:53 +0200 Message-Id: <20161002210853.1228-3-timo@rothenpieler.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161002210853.1228-1-timo@rothenpieler.org> References: <20161002165813.17366-1-timo@rothenpieler.org> <20161002210853.1228-1-timo@rothenpieler.org> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/cuvid: set best_effort_timestamp instead of frame pts 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 Cc: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/cuvid.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index e9a1dd7..5ceb94e 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -451,25 +451,25 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) frame->width = avctx->width; frame->height = avctx->height; if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) - frame->pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); + frame->pkt_pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); else - frame->pts = parsed_frame.dispinfo.timestamp; + frame->pkt_pts = parsed_frame.dispinfo.timestamp; if (parsed_frame.second_field) { if (ctx->prev_pts == INT64_MIN) { - ctx->prev_pts = frame->pts; - frame->pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); + ctx->prev_pts = frame->pkt_pts; + frame->pkt_pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); } else { - int pts_diff = (frame->pts - ctx->prev_pts) / 2; - ctx->prev_pts = frame->pts; - frame->pts += pts_diff; + int pts_diff = (frame->pkt_pts - ctx->prev_pts) / 2; + ctx->prev_pts = frame->pkt_pts; + frame->pkt_pts += pts_diff; } } /* CUVIDs opaque reordering breaks the internal pkt logic. * So set pkt_pts and clear all the other pkt_ fields. */ - frame->pkt_pts = frame->pts; + av_frame_set_best_effort_timestamp(frame, frame->pkt_pts); av_frame_set_pkt_pos(frame, -1); av_frame_set_pkt_duration(frame, 0); av_frame_set_pkt_size(frame, -1);