From patchwork Sun Jun 10 10:36:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 9355 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2903225jad; Sun, 10 Jun 2018 03:38:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJp3/XaKR5jLZHLgEpYdBL+RS1M1afaOjtN3lYz7MmOyX5R41lSYhmOhdD8ngpXwsD4wcHM X-Received: by 2002:a5d:48cd:: with SMTP id p13-v6mr10795923wrs.0.1528627114112; Sun, 10 Jun 2018 03:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528627114; cv=none; d=google.com; s=arc-20160816; b=PkrvC0Oma6h1TJhz9BY0/OzzikkceUeBcBJH5UwJlYwrOXkD7LLx7jv0rH0AbtMq3k uJ+a6sC+WKjr3q0JyGs1js/fLqzii4I4mBSSPNmcaYWKYxIiQOdGt41YdmhFoKmSIh2n bEtwMtOnM63KtTVh+wrppakSkrc4cpIuvgMjbIUZ4SdwqdW5n6+flzCfxtVlQsh5j0Fw R3gjD0EDO4/ra3/n8dYu2ZDP7E7JQYpHMp/AfaP3h9+8o/yyf1ZOLvb3xFYnAkH/dEBP craq/YZfQVg3vQGDcojn2VDeJElaQHqnBXDvL/577jGYZP4YedEYap5mWvVU/IYV5Vvi t+PA== 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:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=6CeSysbHAiFu72KejodWBhAhVJNhb2jH6vhhU8ejKkk=; b=DrIYrCAGgKjAczeoBfMswLJy0pDAMCcBNqAPgui1G+yZNyRrV6hAONY7Q8oV49Nrec lsQ+83Xraib+8i3JPIiOTx3hZt2SMEXrCHYCVupcGtSykH6tUOWjBKAWzS/SnEKy10d0 HzbsyfTGUtM6cRyLSzgtKyI6sYaIvFdAq5erxcNn5UdU3qNXl5mI0/DfeYAufiGQsxlP xRzNy4fBS7ZpCuvGcnK0aPmleEY1kw2ulPcBqghlHOjnvo+3cdkexedR4omT+8dj1jPy Rqyoc11LO4I26nhWzXYDYciXTogKilRyC8Dsjm2alsJ6gWQzBCakaFlVzkglfsV9TCAt Xjmg== 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 x3-v6si13509753wrd.120.2018.06.10.03.38.33; Sun, 10 Jun 2018 03:38:34 -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 4794468AF03; Sun, 10 Jun 2018 13:36:33 +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 A540168ACDA for ; Sun, 10 Jun 2018 13:36:32 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 79EC0E0E49; Sun, 10 Jun 2018 12:37:21 +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 JLZF-8Qfq2VT; Sun, 10 Jun 2018 12:37:20 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 71CBEE1055; Sun, 10 Jun 2018 12:37:20 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jun 2018 12:36:49 +0200 Message-Id: <20180610103650.10155-11-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180610103650.10155-1-cus@passwd.hu> References: <20180610103650.10155-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 11/12] avformat/mxfdec: take into account index_edit_rate 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" Fixes samples/ffmpeg-bugs/roundup/issue591/02785736.mxf Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 04ec302110..8f9a3a752d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1461,11 +1461,13 @@ static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid) } /* EditUnit -> absolute offset */ -static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag) +static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, AVRational edit_rate, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag) { int i; int64_t offset_temp = 0; + edit_unit = av_rescale_q(edit_unit, index_table->segments[0]->index_edit_rate, edit_rate); + for (i = 0; i < index_table->nb_segments; i++) { MXFIndexTableSegment *s = index_table->segments[i]; @@ -1494,7 +1496,7 @@ static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t } if (edit_unit_out) - *edit_unit_out = edit_unit; + *edit_unit_out = av_rescale_q(edit_unit, edit_rate, s->index_edit_rate); return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out, partition_out); } else { @@ -1702,6 +1704,13 @@ static int mxf_compute_index_tables(MXFContext *mxf) /* fix zero IndexDurations */ for (k = 0; k < t->nb_segments; k++) { + if (!t->segments[k]->index_edit_rate.num || !t->segments[k]->index_edit_rate.den) { + av_log(mxf->fc, AV_LOG_WARNING, "IndexSID %i segment %i has invalid IndexEditRate\n", + t->index_sid, k); + if (mxf_track) + t->segments[k]->index_edit_rate = mxf_track->edit_rate; + } + if (t->segments[k]->index_duration) continue; @@ -3145,7 +3154,7 @@ static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_ while (b - a > 1) { m = (a + b) >> 1; - if (mxf_edit_unit_absolute_offset(mxf, t, m, NULL, &offset, NULL, 0) < 0) + if (mxf_edit_unit_absolute_offset(mxf, t, m, track->edit_rate, NULL, &offset, NULL, 0) < 0) return -1; if (offset < current_offset) a = m; @@ -3217,7 +3226,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, AVStream *st, int64_t if (!t || track->wrapping == UnknownWrapped) return -1; - if (mxf_edit_unit_absolute_offset(mxf, t, edit_unit + track->edit_units_per_packet, NULL, &next_ofs, NULL, 0) < 0 && + if (mxf_edit_unit_absolute_offset(mxf, t, edit_unit + track->edit_units_per_packet, track->edit_rate, NULL, &next_ofs, NULL, 0) < 0 && (next_ofs = mxf_essence_container_end(mxf, t->body_sid)) <= 0) { av_log(mxf->fc, AV_LOG_ERROR, "unable to compute the size of the last packet\n"); return -1; @@ -3550,7 +3559,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti if (source_track->wrapping == UnknownWrapped) av_log(mxf->fc, AV_LOG_WARNING, "attempted seek in an UnknownWrapped essence\n"); - if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, &partition, 1)) < 0) + if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, source_track->edit_rate, &sample_time, &seekpos, &partition, 1)) < 0) return ret; ff_update_cur_dts(s, st, sample_time);