From patchwork Sun Jun 10 10:36:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 9350 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2902525jad; Sun, 10 Jun 2018 03:37:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJoW/5JXs/+bTt/p657M2E+wglc0kxulaJPZbDzrctcWMk52KQwKzjD/IxECaack6MSBPk4 X-Received: by 2002:a1c:d7c3:: with SMTP id o186-v6mr5478931wmg.67.1528627044767; Sun, 10 Jun 2018 03:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528627044; cv=none; d=google.com; s=arc-20160816; b=lPY8a9bUFgMK8jN9pjL13yfAVKzEw/9/9TyT4lPR4oMK6A3Op2wMm4WW0wwjBrdl6d Fwxy8pIEqw3HFM2mZ5AnyETNmmdplP0WpT1b/Ibd5QAx+z6rpOVFnpLcp1veMKFd2L8S jw0HwRSaf0Hy1PvFykRyPWzNEnvdmW0RZ+4+Y1/aTjvHj0nvPnOXKtTDhpgSXSk7pvKS /PNkJfeoaowAR1a6ASzghmrhCIVLhF0FZ15hk6DMprxGCYoG8WKRQ8XIZx2vZVcMr/no t8a4l4q1wMcqs27lVEb+ao8r9G7xyENqSpPy/xyxHibhNvqk7g+MD/RQIVdPeX0oMjqO WUTA== 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=lnBlGhDuoDWYh4CjOXeEN1hKBCzfYt8etvdOTg6imWg=; b=oOBN6aFhWe979jRD2u0zHdP8Y7z0ewcKfrz9lAlFXkEqKYkqH9c2CsARWeL4n6B9/O IUx2qFbPLMVGWu/fX08WMXpb3EMET1L0ufuP9Sd8p627Cpyd846VQeTRxz7YoZM+Kz2A F7S4k8cla/cLK9KlYgcDXQBQsZex1XaVHPlqwGPV2CUhg1hb3Yruc/wH9PHBIFCkFPgD Wui3pJnkdCuFn9Vb6LlbYxfxvodoRUsyrIsjhtbx6S5M0gVjKfpKeLTwVEiuF5qQKhVf zJ27P1o3ySYeDlUDgtYw/pQs0AkUJAaKwAHBOmyZHRFkBGvwGf+3uY7CbnHMSGlYZRhi 6cmw== 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 m2-v6si4118932wme.158.2018.06.10.03.37.24; Sun, 10 Jun 2018 03:37:24 -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 247F368AAC2; Sun, 10 Jun 2018 13:36:18 +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 4105368A8E2 for ; Sun, 10 Jun 2018 13:36:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 11CB4E0F70; Sun, 10 Jun 2018 12:37:00 +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 YCHFfTHOqNjJ; Sun, 10 Jun 2018 12:36:59 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E759BE1055; Sun, 10 Jun 2018 12:36:58 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jun 2018 12:36:41 +0200 Message-Id: <20180610103650.10155-3-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 03/12] avformat/mxfdec: extend mxf_handle_missing_index_segment for all clip wrapped essences 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" Also make sure we set a valid track index sid and a valid track edit rate in order for the index to be useful. Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 927653b515..1ab34f4873 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2877,35 +2877,33 @@ static void mxf_handle_small_eubc(AVFormatContext *s) } /** - * Deal with the case where OPAtom files does not have any IndexTableSegments. + * Deal with the case where ClipWrapped essences does not have any IndexTableSegments. */ -static int mxf_handle_missing_index_segment(MXFContext *mxf) +static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st) { - AVFormatContext *s = mxf->fc; - AVStream *st = NULL; + MXFTrack *track = st->priv_data; MXFIndexTableSegment *segment = NULL; MXFPartition *p = NULL; int essence_partition_count = 0; int i, ret; - st = mxf_get_opatom_stream(mxf); - if (!st) - return 0; - /* TODO: support raw video without an index if they exist */ - if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(st->codecpar->codec_id)) + if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(st->codecpar->codec_id) || track->wrapping != ClipWrapped) return 0; - /* check if file already has a IndexTableSegment */ + /* check if track already has a IndexTableSegment */ for (i = 0; i < mxf->metadata_sets_count; i++) { - if (mxf->metadata_sets[i]->type == IndexTableSegment) - return 0; + if (mxf->metadata_sets[i]->type == IndexTableSegment) { + MXFIndexTableSegment *s = (MXFIndexTableSegment*)mxf->metadata_sets[i]; + if (s->body_sid == track->body_sid) + return 0; + } } /* find the essence partition */ for (i = 0; i < mxf->partitions_count; i++) { /* BodySID == 0 -> no essence */ - if (!mxf->partitions[i].body_sid) + if (mxf->partitions[i].body_sid != track->body_sid) continue; p = &mxf->partitions[i]; @@ -2924,12 +2922,19 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf) return ret; } + /* Make sure we have nonzero unique index_sid, body_sid will be ok, because + * using the same SID for index is forbidden in MXF. */ + if (!track->index_sid) + track->index_sid = track->body_sid; + track->edit_rate = av_inv_q(st->time_base); + segment->type = IndexTableSegment; /* stream will be treated as small EditUnitByteCount */ segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3; segment->index_start_position = 0; - segment->index_duration = s->streams[0]->duration; - segment->index_sid = p->index_sid; + segment->index_duration = st->duration; + segment->index_edit_rate = track->edit_rate; + segment->index_sid = track->index_sid; segment->body_sid = p->body_sid; return 0; } @@ -3100,7 +3105,9 @@ static int mxf_read_header(AVFormatContext *s) if ((ret = mxf_parse_structural_metadata(mxf)) < 0) goto fail; - mxf_handle_missing_index_segment(mxf); + for (int i = 0; i < s->nb_streams; i++) + mxf_handle_missing_index_segment(mxf, s->streams[i]); + if ((ret = mxf_compute_index_tables(mxf)) < 0) goto fail;