From patchwork Thu Sep 7 15:11:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 5036 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp320986jao; Thu, 7 Sep 2017 08:11:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDbJhOPmCHIJR9uFLoG/yQNwZyxcvHVvwk1btIpAldxSeiZJg1DEetDZ5AnN0aCvveQM/L9 X-Received: by 10.28.196.134 with SMTP id u128mr799183wmf.93.1504797116391; Thu, 07 Sep 2017 08:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504797116; cv=none; d=google.com; s=arc-20160816; b=eMKXVeJr7jMatg1R/fjU4euTCBzHJyt45iD8MCIj1Rl52eng26x1qd9nEDl5Qgl4eu BHqsAJYUl9xDUiyMiQo1bGF6M23EMJSmUV17BWO6xVrhE0ZY9bj8vU7aN0GNo+SiHC1D 2VS/5zL1yMf+1Uokro5xZMzfjHlJDfsqLdSJSOzb0m7aS5zTwqsDCxkrrGScFHn8LQ7E Zd9YCNxHFGmhWnxXK+HHzFQ0ze20Wn7MBKAB+Ny6pmZfctVZPrVX9lyzthBoaDXY0pn9 mtyQ9abWK1IIdkFI/wdfx/hj98X95jMyA/+zGovQIDS4kg3GkvOM2bPjg5HViJbW75Vd Be6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=jrbQYG1hwcvp4Xujcb5/5yQr4EhDPqpj9LJRBV9yChU=; b=w6qZ+JJWmC2a0s46Wkc1+Yajgl9TC4XIT33ltZqaN4vWiT252zIHtGrLr42Q0v94nY FdUDothWf8FSMmtwBXehb1U0CAugyHJIINBXuzCgZdnsdQTZAIsE7HFjkKoBr+grMSim R2UgSZtD/ijlXGmi3UzB0OzIGJqf4Z1sm/+Y929Q1borRgea62re8T3p1+zTytTaTrox Z8TAdsPNUM1yAY/7nK6nUSg6g9XfE2zJmo/5c/EwizgCNpfpZ9iwZuqU2bryomYuFmZh /qG/sGP2sA0h5ANNoDS/VU/kqqvc70iFNNVBMYueuqytM3SYjsxvoyhEpBiPgNmHEnXi ydZw== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k51si2312636wrf.82.2017.09.07.08.11.55; Thu, 07 Sep 2017 08:11:56 -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; 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 043C3688383; Thu, 7 Sep 2017 18:11:49 +0300 (EEST) 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 0BA15680AF6 for ; Thu, 7 Sep 2017 18:11:43 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C3554E1B2F; Thu, 7 Sep 2017 17:11:46 +0200 (CEST) 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 iPmuoNDAj403; Thu, 7 Sep 2017 17:11:45 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B7FC2E1B09; Thu, 7 Sep 2017 17:11:45 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Sep 2017 17:11:39 +0200 Message-Id: <20170907151140.616-1-cus@passwd.hu> X-Mailer: git-send-email 2.13.5 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: factorize packet pts setter function 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" Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 91731a7533..3e2f5011ee 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3060,6 +3060,32 @@ static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par, return 0; } +static int mxf_set_pts(MXFContext *mxf, AVStream *st, AVPacket *pkt, int64_t next_ofs) +{ + AVCodecParameters *par = st->codecpar; + MXFTrack *track = st->priv_data; + + if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) { + /* mxf->current_edit_unit good - see if we have an + * index table to derive timestamps from */ + MXFIndexTable *t = &mxf->index_tables[0]; + + if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) { + pkt->dts = mxf->current_edit_unit + t->first_dts; + pkt->pts = t->ptses[mxf->current_edit_unit]; + } else if (track && track->intra_only) { + /* intra-only -> PTS = EditUnit. + * let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */ + pkt->pts = mxf->current_edit_unit; + } + } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { + int ret = mxf_set_audio_pts(mxf, par, pkt); + if (ret < 0) + return ret; + } + return 0; +} + static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) { KLVPacket klv; @@ -3083,8 +3109,6 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) int index = mxf_get_stream_index(s, &klv); int64_t next_ofs, next_klv; AVStream *st; - MXFTrack *track; - AVCodecParameters *par; if (index < 0) { av_log(s, AV_LOG_ERROR, @@ -3094,7 +3118,6 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) } st = s->streams[index]; - track = st->priv_data; if (s->streams[index]->discard == AVDISCARD_ALL) goto skip; @@ -3129,26 +3152,9 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt) pkt->stream_index = index; pkt->pos = klv.offset; - par = st->codecpar; - - if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) { - /* mxf->current_edit_unit good - see if we have an - * index table to derive timestamps from */ - MXFIndexTable *t = &mxf->index_tables[0]; - - if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) { - pkt->dts = mxf->current_edit_unit + t->first_dts; - pkt->pts = t->ptses[mxf->current_edit_unit]; - } else if (track && track->intra_only) { - /* intra-only -> PTS = EditUnit. - * let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */ - pkt->pts = mxf->current_edit_unit; - } - } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { - ret = mxf_set_audio_pts(mxf, par, pkt); - if (ret < 0) - return ret; - } + ret = mxf_set_pts(mxf, st, pkt, next_ofs); + if (ret < 0) + return ret; /* seek for truncated packets */ avio_seek(s->pb, next_klv, SEEK_SET);