From patchwork Tue Aug 2 13:24:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sebechlebskyjan@gmail.com X-Patchwork-Id: 66 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp219301vsd; Tue, 2 Aug 2016 06:41:58 -0700 (PDT) X-Received: by 10.28.43.129 with SMTP id r123mr58096947wmr.1.1470145318782; Tue, 02 Aug 2016 06:41:58 -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 bo4si2761555wjb.112.2016.08.02.06.41.58; Tue, 02 Aug 2016 06:41:58 -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 1094A689F86; Tue, 2 Aug 2016 16:41:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F474689F86 for ; Tue, 2 Aug 2016 16:41:43 +0300 (EEST) Received: by mail-wm0-f65.google.com with SMTP id q128so30921674wma.1 for ; Tue, 02 Aug 2016 06:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hcuvtSF1+vcMnTYvEr98u93nzTT211d/kp1Ngxv0X7I=; b=LLMEFndwmOLAdvTM9exQxcE4LrkqzEEO4Z1bRabmti/4RR31XZoxBz9w1m87+Rj+Iq wPDm/W6PBz7pITx7ANLRi9gQEpyulbMFQaQNyUG3cVGwmCFgtuRvZYvL5Py985nzjHXo snyBSGuH9fDjCFcIjD0Gmb3+MpI50uwy4fmd7ILuQA0vATdTOvFlrFyogLdGVEY497It bEOlPngCzKx4y5PUxq2B5dXYJCT9fZE15XTkv9HzSmpK+4zTFf5w3NKIPLwksd1RBJIy 8JcU0qPTEigo+vCzxGiclMvNEyHw2kL09+Gd1GMq2I4NLG15wfKoJH4BgruwOlQRU0jM +ozQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hcuvtSF1+vcMnTYvEr98u93nzTT211d/kp1Ngxv0X7I=; b=DBoTMtgbehf5miDr7+tqETV6UtaSGF+lP59X0STGy2OGl6e8TkvAJ0leYdqsL8fJpY gZeeXKXjYGAsyr3gavN11Qf2SrcJW+ct+ZGtcSE6SMRZ1gwYQ4iLobpxcjGL1sa1wJLc GX73a+mH2Hztewt2n9xjyI1GwwAGW3cRIYDd75mYrrdW4YQTujdpjg46ylf1RbXzVvkA rhndiOwpFYZ0dTPTfcZ06EL1snjsOpes+FGxXJ1Pe4bwebo0bot7e50NRrHTD5aVeZpp HC1RxT9hQD1s9bVjA3/XL6Hav7LHC2R7rRAF6YmexbN+MvL26dU61QOX50GVq7hh1oSb FLAw== X-Gm-Message-State: AEkoouuoBpBqE5LfNA/4wd2o+mhE4yGuf8nM6ZSjQARv6czS0tovGn7AxTrNDrJdu6olvg== X-Received: by 10.28.142.135 with SMTP id q129mr62525086wmd.41.1470144280338; Tue, 02 Aug 2016 06:24:40 -0700 (PDT) Received: from localhost.localdomain (157.174.broadband3.iol.cz. [85.70.174.157]) by smtp.gmail.com with ESMTPSA id n131sm22060902wmd.3.2016.08.02.06.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 06:24:39 -0700 (PDT) From: sebechlebskyjan@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Aug 2016 15:24:19 +0200 Message-Id: <1470144262-13167-9-git-send-email-sebechlebskyjan@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470144262-13167-1-git-send-email-sebechlebskyjan@gmail.com> References: <1470144262-13167-1-git-send-email-sebechlebskyjan@gmail.com> Subject: [FFmpeg-devel] [PATCH 08/11] avformat/mux: Restore original ts in write_packet on error 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: Jan Sebechlebsky MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jan Sebechlebsky Restore original timestamps in write_packet() if the actual write operation was not successfull. This allows to pass the same packet to nonblocking muxer repeatedly without corrupting the timestamps. Signed-off-by: Jan Sebechlebsky --- libavformat/mux.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavformat/mux.c b/libavformat/mux.c index 888a9f1..ef4720a 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -657,6 +657,10 @@ FF_ENABLE_DEPRECATION_WARNINGS static int write_packet(AVFormatContext *s, AVPacket *pkt) { int ret, did_split; + int64_t pts_backup, dts_backup; + + pts_backup = pkt->pts; + dts_backup = pkt->dts; if (s->output_ts_offset) { AVStream *st = s->streams[pkt->stream_index]; @@ -743,6 +747,11 @@ fail: if (did_split) av_packet_merge_side_data(pkt); + if (ret < 0) { + pkt->pts = pts_backup; + pkt->dts = dts_backup; + } + return ret; }