From patchwork Sat Dec 28 00:35:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17012 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F245F44839E for ; Sat, 28 Dec 2019 02:36:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB6B068AABF; Sat, 28 Dec 2019 02:36:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6F25768A77A for ; Sat, 28 Dec 2019 02:36:21 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2644FE3E63; Sat, 28 Dec 2019 01:36:21 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zfRio-TVj35g; Sat, 28 Dec 2019 01:36:19 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 46CCBE392A; Sat, 28 Dec 2019 01:36:19 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Dec 2019 01:35:52 +0100 Message-Id: <20191228003553.27350-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH 1/2] avdevice/xcbgrab: fix packet timestamps 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Since 648b8cca6c56a4fa1760efc72dfe1363a5c6e31e and c991e9cd91845044e93a9c89dd25b48ae707461b timestamps were not set properly. Signed-off-by: Marton Balint --- libavdevice/xcbgrab.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c index 82ea09ca96..861eef07b5 100644 --- a/libavdevice/xcbgrab.c +++ b/libavdevice/xcbgrab.c @@ -57,6 +57,7 @@ typedef struct XCBGrabContext { #endif int64_t time_frame; AVRational time_base; + int64_t frame_duration; int x, y; int width, height; @@ -195,13 +196,12 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt) return 0; } -static void wait_frame(AVFormatContext *s, AVPacket *pkt) +static int64_t wait_frame(AVFormatContext *s, AVPacket *pkt) { XCBGrabContext *c = s->priv_data; int64_t curtime, delay; - int64_t frame_time = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q); - c->time_frame += frame_time; + c->time_frame += c->frame_duration; for (;;) { curtime = av_gettime(); @@ -211,7 +211,7 @@ static void wait_frame(AVFormatContext *s, AVPacket *pkt) av_usleep(delay); } - pkt->pts = curtime; + return curtime; } #if CONFIG_LIBXCB_SHM @@ -418,8 +418,9 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt) xcb_query_pointer_reply_t *p = NULL; xcb_get_geometry_reply_t *geo = NULL; int ret = 0; + int64_t pts; - wait_frame(s, pkt); + pts = wait_frame(s, pkt); if (c->follow_mouse || c->draw_mouse) { pc = xcb_query_pointer(c->conn, c->screen->root); @@ -442,6 +443,8 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt) #endif if (!c->has_shm) ret = xcbgrab_frame(s, pkt); + pkt->dts = pkt->pts = pts; + pkt->duration = c->frame_duration; #if CONFIG_LIBXCB_XFIXES if (ret >= 0 && c->draw_mouse && p->same_screen) @@ -581,6 +584,7 @@ static int create_stream(AVFormatContext *s) c->time_base = (AVRational){ st->avg_frame_rate.den, st->avg_frame_rate.num }; + c->frame_duration = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q); c->time_frame = av_gettime(); st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;