From patchwork Wed Feb 2 00:12:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 34060 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:6681:0:0:0:0 with SMTP id b1csp1023656pxu; Tue, 1 Feb 2022 16:13:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrBfmEwu+1BvemLeVEcfkXr4Ws3sTHc9t4jDOjzAAgdz/99N/tysvnGPQgZmZUp6oT1D9j X-Received: by 2002:a17:907:8a24:: with SMTP id sc36mr22660721ejc.318.1643760818414; Tue, 01 Feb 2022 16:13:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643760818; cv=none; d=google.com; s=arc-20160816; b=yB0NX5ZFa+5ZeBqVetHQ1gqBl2Wk/QuJHcteOwmOclv31/aRwv6sup0ay9QstoPX9T eUZiYAA8RBuwoolq7JYAkG1EoNZR4CHkZyI2SfSzXh+DJrbtdEI//06n9coDNHYhcbvZ EJF69gQX3aY3ZXvS141fMdiuH149HDtWPh9K8k0mv117/C+++uSKMv7/wml4BciWogJ2 jt9rlHulIHMD2hhAGCRYmxrS3k/NUZHkj15US4cLrwv1/sppqlXMSDK9hUSmgx3pYzYk nyO/iR8rLjFWX3y1wfEG5gLLZvsm9fFGPBT+HAltCA+MTCCGdPw5EixUu2dKWRQNc6iG r6XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=L/30UYK5QYPHwycTdb7UthJcUng1IU+gFTNdxzb4AZg=; b=JXfBqQRynHg0nOws7YFRaQEwJ0JPzF3NVRV5uMKPbnIZEZpOv+tsi7ajieb7wyJOo1 HWm5g9sgvKHtVVwXNtJr4o6mkqkYTwAIB7Zqb1BTYzKuM6pUdtmuKfTwvqTge061WV8l VTVKbZJdYMdfFgIkrEz01Z/YDEDkx8bOGZt7n+3j8ygwYPrc1M+sw4EQuekwyU/2TX7W eDZQez+wfoxUdQOG/SWQv0wxBqSbrb+DftmrSNN9MyFLipEYwwNC5WEDBug0Ho21m1KM 3BUXR1/ypNbVZcJyzx2bKOHsf2bLifLxBxZNai8Fiy8tcO94EBBAhNgAHFg2yuDLTNyC oEsQ== 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 18si9481790ejm.511.2022.02.01.16.13.37; Tue, 01 Feb 2022 16:13:38 -0800 (PST) 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 A759668B289; Wed, 2 Feb 2022 02:13:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E447668B193 for ; Wed, 2 Feb 2022 02:13:26 +0200 (EET) Received: by mail-pj1-f45.google.com with SMTP id z10-20020a17090acb0a00b001b520826011so5071927pjt.5 for ; Tue, 01 Feb 2022 16:13:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4qFv0nR0JHxaZsxcgoA98ClQ2aF77HI5wEMVVlzBiq0=; b=I+tESetKXoud/NuUZOYJNQwJJ5gPssxyuNbDBEYCq8DA+57s++s/X1sFNFezmnSlh6 1G2Hlcycdn2xq4SR/EKvSuNyFgHeHhh94s+J1Moz2BsjX9/uvhsDeyFA+mBijJLeli1K xKlISBOx7I4++L+DjEqcqlUjggY0sXpZnSQsDxITv4szwc6l+t8eRbBo2dXYxDB/Jwq8 VyX69GnzRop82P8YT65y2B8iKBkfyCep3qERrULQJujMwNNf297P5LO71FYvplME+NA/ hP9p700ERBc520fkKE/MLBqwTFHGZi4yPE2hqqFnCn+/XQ3mCMt2pQuHUIUWKbHmfwWN XdZA== X-Gm-Message-State: AOAM531yeAW1r3d9O6HTmavVnHO8itLC6KCx3pxK9Q3x+KljnstC4L7J EF8G8+l3z0pm/H6Ms8+07B30XjJhn2k= X-Received: by 2002:a17:902:ea06:: with SMTP id s6mr28471994plg.68.1643760804354; Tue, 01 Feb 2022 16:13:24 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id a125sm15103074pfa.205.2022.02.01.16.13.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Feb 2022 16:13:23 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Tue, 01 Feb 2022 16:13:11 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:12:59 -0800 Message-Id: <20220202001302.4430-1-pal@sandflow.com> X-Mailer: git-send-email 2.35.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/4] avformat/imf: open resources only when first needed X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zv86Iis9HQKZ From: Pierre-Anthony Lemieux IMF CPLs can reference thousands of files, which can result in system limits for the number of open files to be exceeded. The following patch opens and closes files as needed. Addresses https://trac.ffmpeg.org/ticket/9623 --- libavformat/imfdec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index d67c9b8898..e6a1020ecc 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -103,10 +103,11 @@ typedef struct IMFVirtualTrackPlaybackCtx { int32_t index; /**< Track index in playlist */ AVRational current_timestamp; /**< Current temporal position */ AVRational duration; /**< Overall duration */ - uint32_t resource_count; /**< Number of resources */ + uint32_t resource_count; /**< Number of resources (<= INT32_MAX) */ unsigned int resources_alloc_sz; /**< Size of the buffer holding the resource */ IMFVirtualTrackResourcePlaybackCtx *resources; /**< Buffer holding the resources */ - uint32_t current_resource_index; /**< Current resource */ + int32_t current_resource_index; /**< Index of the current resource in resources, + or < 0 if a current resource has yet to be selected */ int64_t last_pts; /**< Last timestamp */ } IMFVirtualTrackPlaybackCtx; @@ -435,7 +436,6 @@ static int open_track_file_resource(AVFormatContext *s, IMFContext *c = s->priv_data; IMFAssetLocator *asset_locator; void *tmp; - int ret; asset_locator = find_asset_map_locator(&c->asset_locator_map, track_file_resource->track_file_uuid); if (!asset_locator) { @@ -452,7 +452,7 @@ static int open_track_file_resource(AVFormatContext *s, UID_ARG(asset_locator->uuid), asset_locator->absolute_uri); - if (track->resource_count > UINT32_MAX - track_file_resource->base.repeat_count + if (track->resource_count > INT32_MAX - track_file_resource->base.repeat_count || (track->resource_count + track_file_resource->base.repeat_count) > INT_MAX / sizeof(IMFVirtualTrackResourcePlaybackCtx)) return AVERROR(ENOMEM); @@ -470,8 +470,6 @@ static int open_track_file_resource(AVFormatContext *s, vt_ctx.locator = asset_locator; vt_ctx.resource = track_file_resource; vt_ctx.ctx = NULL; - if ((ret = open_track_resource_context(s, &vt_ctx)) != 0) - return ret; track->resources[track->resource_count++] = vt_ctx; track->duration = av_add_q(track->duration, av_make_q((int)track_file_resource->base.duration @@ -501,6 +499,7 @@ static int open_virtual_track(AVFormatContext *s, if (!(track = av_mallocz(sizeof(IMFVirtualTrackPlaybackCtx)))) return AVERROR(ENOMEM); + track->current_resource_index = -1; track->index = track_index; track->duration = av_make_q(0, 1); @@ -551,6 +550,7 @@ static int set_context_streams_from_tracks(AVFormatContext *s) AVStream *first_resource_stream; /* Open the first resource of the track to get stream information */ + open_track_resource_context(s, &c->tracks[i]->resources[0]); first_resource_stream = c->tracks[i]->resources[0].ctx->streams[0]; av_log(s, AV_LOG_DEBUG, "Open the first resource of track %d\n", c->tracks[i]->index); @@ -741,7 +741,8 @@ static IMFVirtualTrackResourcePlaybackCtx *get_resource_context_for_timestamp(AV track->index); if (open_track_resource_context(s, &(track->resources[i])) != 0) return NULL; - avformat_close_input(&(track->resources[track->current_resource_index].ctx)); + if (track->current_resource_index > 0) + avformat_close_input(&track->resources[track->current_resource_index].ctx); track->current_resource_index = i; } From patchwork Wed Feb 2 00:13:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 34061 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:6681:0:0:0:0 with SMTP id b1csp1023740pxu; Tue, 1 Feb 2022 16:13:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLUc6CHfzG4jjpynxUA6Ot4jsC6SZGocLVjYI7ahOV1zOQTEWYVr9F/cSlmxeOGGkS5QEe X-Received: by 2002:aa7:d6d4:: with SMTP id x20mr27699576edr.307.1643760828186; Tue, 01 Feb 2022 16:13:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643760828; cv=none; d=google.com; s=arc-20160816; b=peheLDwTbGvWMFdw2MXTeKP+r7yQfYsoU1Mq+vDH3+f2RNvm8og3n9UFDa+gZ1ZtzL XHH7V2/LBI9vZ/trpBc7dJNjKYaVyssOff1wnQ/sEDiX7R5uAW5bs0oSJmGsMLKQ0guS UzgmNfLvEyzfzWs6a/VhP/URo3px79m/nYepUD1AetMouVF8KYixYWVqjRUxPnSfABk6 prDWHbWUJ53VZuxYwb3D7YJIyaHhkPCemRPLw+Iu5NHTj6OszFgi8BkUCtg6om/Id9Bl YF3V3oNcj10nqDV8qEO56qg07Qr0fYzjryyfMq5MUEcOwHUXasYtUvk29Xzay3Nh6Ynx OSnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=fuPjymneHfKVoXgBt4+QtlDKzLJWRsUSsYyeuIwE/tk=; b=Fbhs8q02h4yHuAlsILtBVwSe1P/qaVfDwdi6SHopvxvYu8IMN9rTHGNZpZjY7F0Gzw SC8m6x0DsvHY16i5x90rOQnjiusCya8lkOw840SyxfOzjyhyCgrMaKEPZFdCtAXEGNBM afRqKaXn0c0RerEfSHBufiWB4OphogujaXX9DlKk2OML5Rcrbztnb8Vp54IrG+WHh912 54lYPkQKLYV8JsnT79vNeTEdCizPLFJ3KDI2k44v+r0Kax7qa/acLqC2tBgDdvvSEjaN 9rO3MDwMjk/xeTUVeyzgIkA4KYFAZIbPbBbPfBmy57nUCWj6xuvHGEb5VUJyj0bgYihv 0Luw== 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 b65si10514619edf.281.2022.02.01.16.13.47; Tue, 01 Feb 2022 16:13:48 -0800 (PST) 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 B46AE68B2A7; Wed, 2 Feb 2022 02:13:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6FA3A68B265 for ; Wed, 2 Feb 2022 02:13:29 +0200 (EET) Received: by mail-pf1-f169.google.com with SMTP id e28so17325404pfj.5 for ; Tue, 01 Feb 2022 16:13:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=64XwETk71LJ6Y7sWuZnNEgO3/A6mTDbnorGFhpK7uA8=; b=4vAlig9G21fK67s6b+ZBCrF4vJcFJlQm+47PiELEcIcCTgeuosdY9ZeoikccRURg5T A+70jA12v46FSYuhk/y7sNjuoA1r1LFfgJhiIA05JgK8MI4l/2W2pRZhDZkC8O6Y4u3R LR8gCg5icGnujm/CGv0StXed5Tylir0IcFx0TzVU0myt1LFAOq0hKBXDsGlODBm/VZsR BwydgW4kfsUeb1LrUwm8MHbzw3T+Bv0KyQpVtZ0J7Z9uO1ai7/Dd3IDtqr/rB12Y7OpQ ZQMgRS+UUYH+Cvqpmrf1jDTSWpVelspI7u+AJEZSOWuMApElrUQZGSO3DfHQaJ3jqVC8 Q4Ww== X-Gm-Message-State: AOAM530kols0ykOAQ8p/wrozQJzzLT+/YHbo4BarucvpUuyzEbfQBWHB 7pI+vbsaGWsireCV89GyIAmQx7WQoIM= X-Received: by 2002:a05:6a00:23d3:: with SMTP id g19mr27179899pfc.27.1643760807292; Tue, 01 Feb 2022 16:13:27 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id j19sm12532794pfd.125.2022.02.01.16.13.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Feb 2022 16:13:26 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Tue, 01 Feb 2022 16:13:14 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:13:00 -0800 Message-Id: <20220202001302.4430-2-pal@sandflow.com> X-Mailer: git-send-email 2.35.0.windows.1 In-Reply-To: <20220202001302.4430-1-pal@sandflow.com> References: <20220202001302.4430-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avformat/imf: fix missing error reporting when opening resources X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: T890sa7s0vWQ From: Pierre-Anthony Lemieux --- libavformat/imfdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index e6a1020ecc..658ddc40f2 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -550,7 +550,9 @@ static int set_context_streams_from_tracks(AVFormatContext *s) AVStream *first_resource_stream; /* Open the first resource of the track to get stream information */ - open_track_resource_context(s, &c->tracks[i]->resources[0]); + ret = open_track_resource_context(s, &c->tracks[i]->resources[0]); + if (ret) + return ret; first_resource_stream = c->tracks[i]->resources[0].ctx->streams[0]; av_log(s, AV_LOG_DEBUG, "Open the first resource of track %d\n", c->tracks[i]->index); From patchwork Wed Feb 2 00:13:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 34062 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:6681:0:0:0:0 with SMTP id b1csp1023850pxu; Tue, 1 Feb 2022 16:13:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvPSEfdoXK4tuq1JBFWCgDCdQhairAdwSoLuojyuwBUHvkfrI0ElATfUFpNXuFrUjSKEiT X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr23547178ejc.74.1643760839045; Tue, 01 Feb 2022 16:13:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643760839; cv=none; d=google.com; s=arc-20160816; b=U9dJVBaqMl82ydxLcMMcwfQkot6+kb86xAOv4HlqgH0hI9U+jJtDlCF4IBdiykPfRP cF5jjzniR7f+LEghVTqeBIjtzm6iFo1APPuevvMkafLZi6f9XNz+UkQPXEXcr54bMUJl lBKRyAdpNg3kHCVR+u7ITQb9MoAHrEEnHUo8ot/Sf0OvNb4Z75zvYbBZ/Sls8414fg4H jq9aThFf6PBsmZw9TGYTJm8gajzgYnUkp8ZG9QQgprIZCL6pEloRxitGttZTJasKHMvP KCeRUuxOaEKOKviUoOfYQ9a6p8NcwVvYcVZr0OJem8F/wMjXtWjZISq+wInlnat4Ewi0 2f8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=YxQ3HJ6qz1F9ZcM0gJpW2bBXD4jGdS1YXRUXinawEg8=; b=dwvhOXu5m7fOxWQdnsK7hDEic6hWcf7hl6s+c5bo5m+zEpKbF3eF6i7TyNBXQjL8tf sZCUQp3XW8jKiOpVLifKVg+tapJmnyuDWbZbWouZeLeTdtm8ZgxI4HSMCKio7Ht3b6+T Tp2JpBsb5KTzlxv/LC/mxHa1kPKleWSc1oQXyEst9Ld6k3OOboegytjy1eHHz+SmhnsS HgN7xUvUo7nS2Tvp76bQc2y2O4EykYhL5beXYYheLTZmZarKiMBDzdarNCetD0baFWOl yUjSLneyUW6zGfKykCT6T1PufCUkReD7UHTW7aideDNOgeRmvOzpWXUUBTDcruRB0534 de7w== 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 j8si13803374edw.248.2022.02.01.16.13.58; Tue, 01 Feb 2022 16:13:59 -0800 (PST) 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 C081068B2AC; Wed, 2 Feb 2022 02:13:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4351968B265 for ; Wed, 2 Feb 2022 02:13:32 +0200 (EET) Received: by mail-pj1-f51.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so4326078pjp.0 for ; Tue, 01 Feb 2022 16:13:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W2pmOBjz9oskvTC83uAmLy0eP5dv0Xnrp5olgi0TFHo=; b=hS6ejatj59FCqlUugOtV5VoN5V/tOB1mKJNqLrCHjSZTv5b0nGaSb+DDLJn+ycjOci ord8ZF8n8R63bPbw9X45nivNixOb4JKdIB/SOrniuBxcB18p5MCP9DuxFMQFQLlpeMdc dvB4TIfWJlrNJeuIJ2RPkwMYFqt8vm1jtTVpSua+LYe8p0/PGRUKkl7xC/3/GpMEp1Ua 24Z68l0ygCm8GT/OzxDC59Kc+foRtm25KqZ2uC9Xnt6799qH+Xm8iOOeibXfQuTcSWv3 D8wBLYQN15xExzY+7/tgwzmYSOellSg8+CmEcc9YSQWhMl6FV1inud5MlqRxxoBNi35d Ik/A== X-Gm-Message-State: AOAM533Pl2fVugMwvk9q1wTtpZ44uFiG7NonH1SiWAjUfFeFgI8ld5U9 cBVnoYtFLpXuRxgpIV6NMNaZavAFwTw= X-Received: by 2002:a17:902:f205:: with SMTP id m5mr28198482plc.71.1643760810178; Tue, 01 Feb 2022 16:13:30 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id a4sm3760545pjs.24.2022.02.01.16.13.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Feb 2022 16:13:29 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Tue, 01 Feb 2022 16:13:17 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:13:01 -0800 Message-Id: <20220202001302.4430-3-pal@sandflow.com> X-Mailer: git-send-email 2.35.0.windows.1 In-Reply-To: <20220202001302.4430-1-pal@sandflow.com> References: <20220202001302.4430-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/4] avformat/imf: fix packet pts, dts and muxing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xUjfkacNcp4T From: Pierre-Anthony Lemieux The IMF demuxer does not set the DTS and PTS of packets accurately in all scenarios. Moreover, audio packets are not trimmed when they exceed the duration of the underlying resource. Addresses https://trac.ffmpeg.org/ticket/9611 --- libavformat/imfdec.c | 263 ++++++++++++++++++++++++++++--------------- 1 file changed, 171 insertions(+), 92 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 658ddc40f2..5be4411cb1 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -65,8 +65,10 @@ #include "avio_internal.h" #include "imf.h" #include "internal.h" +#include "libavcodec/packet.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" +#include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "mxf.h" #include "url.h" @@ -97,6 +99,9 @@ typedef struct IMFVirtualTrackResourcePlaybackCtx { IMFAssetLocator *locator; FFIMFTrackFileResource *resource; AVFormatContext *ctx; + AVRational start_time; + AVRational end_time; + AVRational ts_offset; } IMFVirtualTrackResourcePlaybackCtx; typedef struct IMFVirtualTrackPlaybackCtx { @@ -108,7 +113,6 @@ typedef struct IMFVirtualTrackPlaybackCtx { IMFVirtualTrackResourcePlaybackCtx *resources; /**< Buffer holding the resources */ int32_t current_resource_index; /**< Index of the current resource in resources, or < 0 if a current resource has yet to be selected */ - int64_t last_pts; /**< Last timestamp */ } IMFVirtualTrackPlaybackCtx; typedef struct IMFContext { @@ -342,6 +346,7 @@ static int open_track_resource_context(AVFormatContext *s, int ret = 0; int64_t entry_point; AVDictionary *opts = NULL; + AVStream *st; if (track_resource->ctx) { av_log(s, @@ -383,23 +388,28 @@ static int open_track_resource_context(AVFormatContext *s, } av_dict_free(&opts); - /* Compare the source timebase to the resource edit rate, - * considering the first stream of the source file - */ - if (av_cmp_q(track_resource->ctx->streams[0]->time_base, - av_inv_q(track_resource->resource->base.edit_rate))) + /* make sure there is only one stream in the file */ + + if (track_resource->ctx->nb_streams != 1) { + ret = AVERROR_INVALIDDATA; + goto cleanup; + } + + st = track_resource->ctx->streams[0]; + + /* Warn if the resource time base does not match the file time base */ + if (av_cmp_q(st->time_base, av_inv_q(track_resource->resource->base.edit_rate))) av_log(s, AV_LOG_WARNING, - "Incoherent source stream timebase %d/%d regarding resource edit rate: %d/%d", - track_resource->ctx->streams[0]->time_base.num, - track_resource->ctx->streams[0]->time_base.den, + "Incoherent source stream timebase " AVRATIONAL_FORMAT + "regarding resource edit rate: " AVRATIONAL_FORMAT, + st->time_base.num, + st->time_base.den, track_resource->resource->base.edit_rate.den, track_resource->resource->base.edit_rate.num); - entry_point = (int64_t)track_resource->resource->base.entry_point - * track_resource->resource->base.edit_rate.den - * AV_TIME_BASE - / track_resource->resource->base.edit_rate.num; + entry_point = av_rescale_q(track_resource->resource->base.entry_point, st->time_base, + av_inv_q(track_resource->resource->base.edit_rate)); if (entry_point) { av_log(s, @@ -407,7 +417,7 @@ static int open_track_resource_context(AVFormatContext *s, "Seek at resource %s entry point: %" PRIu32 "\n", track_resource->locator->absolute_uri, track_resource->resource->base.entry_point); - ret = avformat_seek_file(track_resource->ctx, -1, entry_point, entry_point, entry_point, 0); + ret = avformat_seek_file(track_resource->ctx, 0, entry_point, entry_point, entry_point, 0); if (ret < 0) { av_log(s, AV_LOG_ERROR, @@ -470,11 +480,16 @@ static int open_track_file_resource(AVFormatContext *s, vt_ctx.locator = asset_locator; vt_ctx.resource = track_file_resource; vt_ctx.ctx = NULL; - track->resources[track->resource_count++] = vt_ctx; - track->duration = av_add_q(track->duration, + vt_ctx.start_time = track->duration; + vt_ctx.ts_offset = av_sub_q(vt_ctx.start_time, + av_div_q(av_make_q((int)track_file_resource->base.entry_point, 1), + track_file_resource->base.edit_rate)); + vt_ctx.end_time = av_add_q(track->duration, av_make_q((int)track_file_resource->base.duration * track_file_resource->base.edit_rate.den, track_file_resource->base.edit_rate.num)); + track->resources[track->resource_count++] = vt_ctx; + track->duration = vt_ctx.end_time; } return 0; @@ -701,11 +716,14 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma return track; } -static IMFVirtualTrackResourcePlaybackCtx *get_resource_context_for_timestamp(AVFormatContext *s, - IMFVirtualTrackPlaybackCtx *track) +static int get_resource_context_for_timestamp(AVFormatContext *s, IMFVirtualTrackPlaybackCtx *track, IMFVirtualTrackResourcePlaybackCtx **resource) { - AVRational edit_unit_duration = av_inv_q(track->resources[0].resource->base.edit_rate); - AVRational cumulated_duration = av_make_q(0, edit_unit_duration.den); + *resource = NULL; + + if (av_cmp_q(track->current_timestamp, track->duration) >= 0) { + av_log(s, AV_LOG_DEBUG, "Reached the end of the virtual track\n"); + return AVERROR_EOF; + } av_log(s, AV_LOG_DEBUG, @@ -714,119 +732,180 @@ static IMFVirtualTrackResourcePlaybackCtx *get_resource_context_for_timestamp(AV av_q2d(track->current_timestamp), av_q2d(track->duration)); for (uint32_t i = 0; i < track->resource_count; ++i) { - cumulated_duration = av_add_q(cumulated_duration, - av_make_q((int)track->resources[i].resource->base.duration - * edit_unit_duration.num, - edit_unit_duration.den)); - if (av_cmp_q(av_add_q(track->current_timestamp, edit_unit_duration), cumulated_duration) <= 0) { + if (av_cmp_q(track->resources[i].end_time, track->current_timestamp) > 0) { av_log(s, AV_LOG_DEBUG, - "Found resource %d in track %d to read for timestamp %lf " - "(on cumulated=%lf): entry=%" PRIu32 + "Found resource %d in track %d to read at timestamp %lf: " + "entry=%" PRIu32 ", duration=%" PRIu32 - ", editrate=" AVRATIONAL_FORMAT - " | edit_unit_duration=%lf\n", + ", editrate=" AVRATIONAL_FORMAT, i, track->index, av_q2d(track->current_timestamp), - av_q2d(cumulated_duration), track->resources[i].resource->base.entry_point, track->resources[i].resource->base.duration, - AVRATIONAL_ARG(track->resources[i].resource->base.edit_rate), - av_q2d(edit_unit_duration)); + AVRATIONAL_ARG(track->resources[i].resource->base.edit_rate)); if (track->current_resource_index != i) { + int ret; + av_log(s, AV_LOG_DEBUG, "Switch resource on track %d: re-open context\n", track->index); - if (open_track_resource_context(s, &(track->resources[i])) != 0) - return NULL; + + ret = open_track_resource_context(s, &(track->resources[i])); + if (ret != 0) + return ret; if (track->current_resource_index > 0) avformat_close_input(&track->resources[track->current_resource_index].ctx); track->current_resource_index = i; } - return &(track->resources[track->current_resource_index]); + *resource = &(track->resources[track->current_resource_index]); + return 0; } } - return NULL; + + av_log(s, AV_LOG_ERROR, "Could not find IMF track resource to read\n"); + return AVERROR_STREAM_NOT_FOUND; +} + +static int imf_time_to_ts(int64_t *ts, AVRational t, AVRational time_base) +{ + int dst_num; + int dst_den; + AVRational r; + + r = av_div_q(t, time_base); + + if ((av_reduce(&dst_num, &dst_den, r.num, r.den, INT64_MAX) != 1)) + return 1; + + if (dst_den != 1) + return 1; + + *ts = dst_num; + + return 0; } static int imf_read_packet(AVFormatContext *s, AVPacket *pkt) { - IMFContext *c = s->priv_data; - IMFVirtualTrackResourcePlaybackCtx *resource_to_read = NULL; - AVRational edit_unit_duration; + IMFVirtualTrackResourcePlaybackCtx *resource = NULL; int ret = 0; IMFVirtualTrackPlaybackCtx *track; - FFStream *track_stream; + int64_t delta_ts; + AVStream *st; + AVRational next_timestamp; track = get_next_track_with_minimum_timestamp(s); - if (av_cmp_q(track->current_timestamp, track->duration) == 0) - return AVERROR_EOF; + ret = get_resource_context_for_timestamp(s, track, &resource); + if (ret) + return ret; - resource_to_read = get_resource_context_for_timestamp(s, track); + ret = av_read_frame(resource->ctx, pkt); + if (ret) { + av_log(s, AV_LOG_ERROR, "Failed to read frame\n"); + return ret; + } - if (!resource_to_read) { - edit_unit_duration - = av_inv_q(track->resources[track->current_resource_index].resource->base.edit_rate); + av_log(s, AV_LOG_DEBUG, "Got packet: pts=%" PRId64 ", dts=%" PRId64 + ", duration=%" PRId64 ", stream_index=%d, pos=%" PRId64 + ", time_base=" AVRATIONAL_FORMAT "\n", pkt->pts, pkt->dts, pkt->duration, + pkt->stream_index, pkt->pos, pkt->time_base.num, pkt->time_base.den); - if (av_cmp_q(av_add_q(track->current_timestamp, edit_unit_duration), track->duration) > 0) - return AVERROR_EOF; + /* IMF resources contain only one stream */ - av_log(s, AV_LOG_ERROR, "Could not find IMF track resource to read\n"); - return AVERROR_STREAM_NOT_FOUND; + if (pkt->stream_index != 0) + return AVERROR_INVALIDDATA; + st = resource->ctx->streams[0]; + + pkt->stream_index = track->index; + + /* adjust the packet PTS and DTS based on the temporal position of the resource within the timeline */ + + ret = imf_time_to_ts(&delta_ts, resource->ts_offset, st->time_base); + + if (!ret) { + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts += delta_ts; + if (pkt->dts != AV_NOPTS_VALUE) + pkt->dts += delta_ts; + } else { + av_log(s, AV_LOG_WARNING, "Incoherent time stamp " AVRATIONAL_FORMAT " for time base " AVRATIONAL_FORMAT, + resource->ts_offset.num, resource->ts_offset.den, pkt->time_base.num, + pkt->time_base.den); } - while (!ff_check_interrupt(c->interrupt_callback) && !ret) { - ret = av_read_frame(resource_to_read->ctx, pkt); - av_log(s, - AV_LOG_DEBUG, - "Got packet: pts=%" PRId64 - ", dts=%" PRId64 - ", duration=%" PRId64 - ", stream_index=%d, pos=%" PRId64 - "\n", - pkt->pts, - pkt->dts, - pkt->duration, - pkt->stream_index, - pkt->pos); - - track_stream = ffstream(s->streams[track->index]); - if (ret >= 0) { - /* Update packet info from track */ - if (pkt->dts < track_stream->cur_dts && track->last_pts > 0) - pkt->dts = track_stream->cur_dts; - - pkt->pts = track->last_pts; - pkt->dts = pkt->dts - - (int64_t)track->resources[track->current_resource_index].resource->base.entry_point; - pkt->stream_index = track->index; - - /* Update track cursors */ - track->current_timestamp - = av_add_q(track->current_timestamp, - av_make_q((int)pkt->duration - * resource_to_read->ctx->streams[0]->time_base.num, - resource_to_read->ctx->streams[0]->time_base.den)); - track->last_pts += pkt->duration; + /* advance the track timestamp by the packet duration */ - return 0; - } else if (ret != AVERROR_EOF) { - av_log(s, - AV_LOG_ERROR, - "Could not get packet from track %d: %s\n", - track->index, - av_err2str(ret)); - return ret; + next_timestamp = av_add_q(track->current_timestamp, + av_mul_q(av_make_q((int)pkt->duration, 1), st->time_base)); + + /* if necessary, clamp the next timestamp to the end of the current resource */ + + if (av_cmp_q(next_timestamp, resource->end_time) > 0) { + + int64_t new_pkt_dur; + + /* shrink the packet duration */ + + ret = imf_time_to_ts(&new_pkt_dur, + av_sub_q(resource->end_time, track->current_timestamp), + st->time_base); + + if (!ret) + pkt->duration = new_pkt_dur; + else + av_log(s, AV_LOG_WARNING, "Incoherent time base in packet duration calculation"); + + /* shrink the packet itself for audio essence */ + + if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + + if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE) { + /* AV_CODEC_ID_PCM_S24LE is the only PCM format supported in IMF */ + /* in this case, explicitly shrink the packet */ + + int bytes_per_sample = av_get_exact_bits_per_sample(st->codecpar->codec_id) >> 3; + int64_t nbsamples = av_rescale_q(pkt->duration, + st->time_base, + av_make_q(1, st->codecpar->sample_rate)); + av_shrink_packet(pkt, nbsamples * st->codecpar->channels * bytes_per_sample); + + } else { + /* in all other cases, use side data to skip samples */ + int64_t skip_samples; + + ret = imf_time_to_ts(&skip_samples, + av_sub_q(next_timestamp, resource->end_time), + av_make_q(1, st->codecpar->sample_rate)); + + if (ret || skip_samples < 0 || skip_samples > UINT32_MAX) { + av_log(s, AV_LOG_WARNING, "Cannot skip audio samples"); + } else { + uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); + if (!side_data) + return AVERROR(ENOMEM); + + AV_WL32(side_data + 4, skip_samples); /* skip from end of this packet */ + side_data[6] = 1; /* reason for end is convergence */ + } + } + + next_timestamp = resource->end_time; + + } else { + av_log(s, AV_LOG_WARNING, "Non-audio packet duration reduced"); } } - return AVERROR_EOF; + track->current_timestamp = next_timestamp; + + return 0; } static int imf_close(AVFormatContext *s) From patchwork Wed Feb 2 00:13:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 34063 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a10:6681:0:0:0:0 with SMTP id b1csp1023948pxu; Tue, 1 Feb 2022 16:14:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRV53ArC05leLTgArte8UXoQQKrmkUJ4FiBYhxyMtcC8fdmuAXoIpLSjr3P/bEfdpF32XL X-Received: by 2002:a17:907:da6:: with SMTP id go38mr14852771ejc.124.1643760850766; Tue, 01 Feb 2022 16:14:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643760850; cv=none; d=google.com; s=arc-20160816; b=mZI/8iLrjHgptK3M/Dsi8yYdN9SOpEru9um+z3wbMZ02quts8JrWyQjP1cpN4LqsKV /oXhRQbXVGqJq8dly3QmdQv8iZwm4tU8pcL3zDvdHg8tQVh2fC2BnnAr1x9NTq6ShqXB CRSK2UjolDFPotQFEji/cEq0qtNqVEVt29Omx54rW9xVaTee2Q7fR8atWgyfJ0Gvdnr4 74iD4FfLOK1c8UEMe1nqV58a5vPwM2r0h8PTG2R/CxJqnWC+93q2VeAl9+n2AHBFfVjh VYZozZtP2irWdQiIuW2ByMOEmyvvekiVWLGi2H0Za1PRmxiykQ032xY7ISNrpZCjNKYO jEpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=8vovRa4jVGwObmEbneYDxjoDUDS4dQWBpXQIsTC0MnA=; b=p3MIysB74MKMUXSqfHeNDjPlHMDjZ6gxTkSvqkyogHASLJyD3XjqXKf0g76/Y7YdsB 2V6GL047awOCq1KXpAyNR4zOlh1/MFSKYLB/j2+gldQ6iWVNiS6SosWSN/eH2aJmal3r t6qKIOw2t1fgBXYIWbmftUPXeG4yGIt1emGjXtcBHzhSjvILavFk3hnOuLRhfRT5oU5S uxXuR1a/kwPSN9b+eNmP7yNKYsyfxiBS3qF74+3l77qctzXWvs0Tb/5uxUV5ILaYBIri +uFepmUwJ6gjzFUswjiQk0boylPFh9UjomGaSwPQOU/4Kcd1gOTVZ+zBNsMfZoManRu+ OJYw== 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 gt38si10660738ejc.446.2022.02.01.16.14.10; Tue, 01 Feb 2022 16:14:10 -0800 (PST) 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 C5EC168B2B7; Wed, 2 Feb 2022 02:13:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 331D868B2A9 for ; Wed, 2 Feb 2022 02:13:35 +0200 (EET) Received: by mail-pf1-f173.google.com with SMTP id a8so17310144pfa.6 for ; Tue, 01 Feb 2022 16:13:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2tWRCuRwFFjrnhDHQjJyUbrPHNKSW3xnAmcUmhvJBs=; b=wWyoNE7Tl5zm2Y1Si57keOYiRGVWwdHnvj/cp7fZ6NG2Qf072L6AcFKqpiRSQz4Pqz XIYWsGL0vsjStRnLqXkpUBvIB9brA6Eg7IADj0zHZnHqcqJ4cq8qz9isk1DW/7fOmA+Z JEdxpPBVy7Rjl971LBGw1hVLNMBBfnei09k5kUlTL8/vVJLsF4wUrmoy/8pUgNyauRVv HqHsaoO1M4VSN74pCCb647CDGc4pSED7xnO7aZ6YYkhSUfpWB7WUQRKAbxzglCyS93SY FRilfxSc16oMPuyLlXXwa1R78eAYE9pHSHg23WsFnXdQV/imDtwzqAATH/dmEqzC2J2o wBbg== X-Gm-Message-State: AOAM530/W0yalbWk5JWwDMkbKeqeoDSPocZipsFV71hUvsjVpDU6gtFQ 00rfiihvzCkVLcS7+3u2YqjslUHzhdY= X-Received: by 2002:a63:216:: with SMTP id 22mr22859399pgc.89.1643760813301; Tue, 01 Feb 2022 16:13:33 -0800 (PST) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id x187sm21740989pgx.10.2022.02.01.16.13.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Feb 2022 16:13:32 -0800 (PST) Received: by localhost (sSMTP sendmail emulation); Tue, 01 Feb 2022 16:13:20 -0800 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:13:02 -0800 Message-Id: <20220202001302.4430-4-pal@sandflow.com> X-Mailer: git-send-email 2.35.0.windows.1 In-Reply-To: <20220202001302.4430-1-pal@sandflow.com> References: <20220202001302.4430-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/4] avformat/imf: document IMFVirtualTrackResourcePlaybackCtx X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Z/NJ28woMwBo From: Pierre-Anthony Lemieux --- libavformat/imfdec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 5be4411cb1..02e7bcc33f 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -96,12 +96,12 @@ typedef struct IMFAssetLocatorMap { } IMFAssetLocatorMap; typedef struct IMFVirtualTrackResourcePlaybackCtx { - IMFAssetLocator *locator; - FFIMFTrackFileResource *resource; - AVFormatContext *ctx; - AVRational start_time; - AVRational end_time; - AVRational ts_offset; + IMFAssetLocator *locator; /**< Location of the resource */ + FFIMFTrackFileResource *resource; /**< Underlying IMF CPL resource */ + AVFormatContext *ctx; /**< Context associated with the resource */ + AVRational start_time; /**< inclusive start time of the resource on the CPL timeline (s) */ + AVRational end_time; /**< exclusive end time of the resource on the CPL timeline (s) */ + AVRational ts_offset; /**< start_time minus the entry point into the resource (s) */ } IMFVirtualTrackResourcePlaybackCtx; typedef struct IMFVirtualTrackPlaybackCtx {