From patchwork Sun Mar 26 21:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 40846 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7a30:b0:df:834d:2c1a with SMTP id t48csp859261pzh; Sun, 26 Mar 2023 14:14:38 -0700 (PDT) X-Google-Smtp-Source: AKy350Z21Ru4ihIHAgEd5FVryuBJFQ3BLFImM3+bd5OTxjwsIlX5I/ji4NXZz2BydR/r/mK57DK/ X-Received: by 2002:a17:906:4b08:b0:928:796d:71e8 with SMTP id y8-20020a1709064b0800b00928796d71e8mr10370084eju.3.1679865278357; Sun, 26 Mar 2023 14:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679865278; cv=none; d=google.com; s=arc-20160816; b=o41zoj4Nv2MDf+eUVP4CIyWcwU9+6z1J04TOuid7jHUxdZ4Or6tuR7j/4JhhnpKrJJ Kxc2hZYocYAdqgZKgVyJom+ENqvlxQJpStyjwDNU5504R3AUqbSUFErkoX51/LHUzt1w //GR+eBe/X4I7t5lMKXVuR+kS8oVt4nTBNkKioi+yUbngPPdm8ViH0zg7ksk9HgG9Oap M598P/YAacDe2uw03aoqhYBGuSFkiIUxwmaspthSu+t62NiSI1GG2eqi6Z4amIAwn9Iu 7dbXPqyfiRmURFJLOo1GqRt6Y76A2c16TCyBxXzMA7ZdRQzhXbM7K2RwuB5+6Er0y5hu x0mw== 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=ZDBkuJL5IMcBs0ED4c3uybf81FL0wTMVxORvg1xFUEw=; b=k0YBhOO1sdYLmH35AdXAbiAmkmGpcV9lC/9LQdyYBioNNOk5LMEW4Y7X5TFZLhsADo DNT+QvpNJUWfUC/8qGzSiuN03ZN0iH/ggeMq791DgiTe9SbxQv79JPVezLLInDdmQE5z rPphXLVEw5ERvANfhTleSFqYqQpWw9A5gHL0iTwA/uY7H2l2iVzuky54Jype6S+ctU+P RdEc1e2x/b/fjRB0drTL7uHYqzuLOsuvEMA8C4lhPp8NxV/6zm7r04L1mAaaGwQLeYQR Z3YyOH5HCf9lShinbEzqeO9MFLAFeBSRAmUDwHSGwZaFxBJuDqYBewmJn8lotGH894MG lFMw== 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 cw5-20020a170906478500b009338f516161si20350227ejc.707.2023.03.26.14.14.37; Sun, 26 Mar 2023 14:14:38 -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 6C5F668C5D2; Mon, 27 Mar 2023 00:14:35 +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 8F7CC68C07E for ; Mon, 27 Mar 2023 00:14:28 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F0753E89FE; Sun, 26 Mar 2023 23:14:09 +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 L8saEEjfV0fL; Sun, 26 Mar 2023 23:14:08 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 410DEE2029; Sun, 26 Mar 2023 23:14:08 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Mar 2023 23:14:23 +0200 Message-Id: <20230326211423.2455-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mxfdec: treat Random Index Pack as end of file 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5PZ0h9u9/zj3 RIP, if exists is the last KLV item in the MXF files therefore we can stop parsing the file if it is encountered. This allows us to support files created by broken muxers such as OpenCube MXFTk Advanced 2.8.0.0.1. which dumps some extra garbage after the RIP. Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4530617207..8a7008b298 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -3739,7 +3739,10 @@ static int mxf_read_header(AVFormatContext *s) while (!avio_feof(s->pb)) { const MXFMetadataReadTableEntry *metadata; - if (klv_read_packet(&klv, s->pb) < 0) { + ret = klv_read_packet(&klv, s->pb); + if (ret < 0 || IS_KLV_KEY(klv.key, ff_mxf_random_index_pack_key)) { + if (ret >= 0 && avio_size(s->pb) > klv.next_klv) + av_log(s, AV_LOG_WARNING, "data after the RandomIndexPack, assuming end of file\n"); /* EOF - seek to previous partition or stop */ if(mxf_parse_handle_partition_or_eof(mxf) <= 0) break;