From patchwork Sun Jun 10 10:36:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 9351 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2902861jad; Sun, 10 Jun 2018 03:37:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJUhDfrRU5C6pzrmthn6X9qIOtPvGivMLsauuLLEz0eI1iuMiTFXNJdn56uGOM/0dXh1DHs X-Received: by 2002:a1c:ac02:: with SMTP id v2-v6mr3925734wme.79.1528627078207; Sun, 10 Jun 2018 03:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528627078; cv=none; d=google.com; s=arc-20160816; b=U5X8u5dChfKIlW2wEzO3O4HYdTIsx3V9KfqSMKpOL9DOWQD/wu1bNeHrsxgFWfU5fr IiQKxRpmT2b+Fv2ZCL+d4vmeXtsZwqYhW3onHQccybg6KEuIOUUjoAE8uGb83kaFYHpv f+OYbV0VDkXKFjVvDFDA3y9ACU6zlV58BexRC3oy6DGE5OQOSDRPWsOiovS4aiPs68ez JIzX/yZHJZ/HLwl3+z4HwFbELTLXJfUDKBmIuh9K13ofFACkOdwehUhJ5Xieys9bnHNM 3HvYXRvG4oYE23HTFFR+sTm7WlWV0WzugiUk6ZJBEAVDxqz6yYIteUoDken1yV8IsYHa ZH2w== 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=yK8qOmKzesebJB2r+LYwGCIaVRsIo6dOOg5GlIhVOgA=; b=jtXErRJNQOWnJgZkucG9xh+v9WOAE55cuij6KWsdWQ7IAbBboUQPkLXX1Mc5vxaSOe N5HAxCT1kzYBZw6pyBgaZ7Q3iJE3UIqDbKWilDSrd0RUsylWPix9vc/UaPonr4PrcTpL TvQ5THBH5MUN5TX9GdD90UfgFuJVvpxVPyZXxCg2bShwIGDZLp+/cZ5ywWMsUcgrWC5e 1BbycjxRPYhecuw9gNIXFUC9jsUaN+NNOFmOXosCp/H88341BAB9fI6+la6z3nWiDA+O wVq6jTMzttccBw8v1r2xW5du4x06qmR3H139ZgFc1PwDxlBxx50bU7UGtUIZWFEXgABh qyQQ== 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 b10-v6si33860457wrf.58.2018.06.10.03.37.57; Sun, 10 Jun 2018 03:37: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; 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 35B9368AD09; Sun, 10 Jun 2018 13:36:25 +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 D293A68ACF9 for ; Sun, 10 Jun 2018 13:36:23 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id AF6DBE0E49; Sun, 10 Jun 2018 12:37:12 +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 wi8sLrBmcgjO; Sun, 10 Jun 2018 12:37:12 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D4823E0F70; Sun, 10 Jun 2018 12:37:11 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jun 2018 12:36:46 +0200 Message-Id: <20180610103650.10155-8-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 08/12] avformat/mxfdec: add support for returning the partition for mxf_edit_unit_absolute_offset and mxf_absolute_bodysid_offset 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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 0f4cc9c3a3..8054e051cf 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1399,7 +1399,7 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment /** * Computes the absolute file offset of the given essence container offset */ -static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out) +static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out, MXFPartition **partition_out) { MXFPartition *last_p = NULL; int a, b, m, m0; @@ -1427,6 +1427,8 @@ static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t of if (last_p && (!last_p->essence_length || last_p->essence_length > (offset - last_p->body_offset))) { *offset_out = last_p->essence_offset + (offset - last_p->body_offset); + if (partition_out) + *partition_out = last_p; return 0; } @@ -1461,7 +1463,7 @@ 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, int nag) +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) { int i; int64_t offset_temp = 0; @@ -1496,7 +1498,7 @@ static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t if (edit_unit_out) *edit_unit_out = edit_unit; - return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out); + return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out, partition_out); } else { /* EditUnitByteCount == 0 for VBR indexes, which is fine since they use explicit StreamOffsets */ offset_temp += s->edit_unit_byte_count * s->index_duration; @@ -3160,7 +3162,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, 0) < 0) + if (mxf_edit_unit_absolute_offset(mxf, t, m, NULL, &offset, NULL, 0) < 0) return -1; if (offset < current_offset) a = m; @@ -3189,7 +3191,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset /* find mxf->current_edit_unit so that the next edit unit starts ahead of current_offset */ while (mxf->current_edit_unit >= 0) { - if (mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + 1, NULL, &next_ofs, 0) < 0) + if (mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + 1, NULL, &next_ofs, NULL, 0) < 0) return -2; if (next_ofs <= last_ofs) { @@ -3412,12 +3414,12 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) edit_units = FFMIN(track->edit_units_per_packet, track->original_duration - mxf->current_edit_unit); - if ((ret = mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit, NULL, &pos, 1)) < 0) + if ((ret = mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit, NULL, &pos, NULL, 1)) < 0) return ret; /* compute size by finding the next edit unit or the end of the essence container * not pretty, but it works */ - if ((ret = mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + edit_units, NULL, &next_pos, 0)) < 0 && + if ((ret = mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + edit_units, NULL, &next_pos, NULL, 0)) < 0 && (next_pos = mxf_essence_container_end(mxf, t->body_sid)) <= 0) { av_log(s, AV_LOG_ERROR, "unable to compute the size of the last packet\n"); return AVERROR_INVALIDDATA; @@ -3578,7 +3580,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti sample_time = FFMIN(sample_time, source_track->original_duration - 1); } - if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) < 0) + if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, NULL, 1)) < 0) return ret; ff_update_cur_dts(s, st, sample_time);