From patchwork Thu Aug 8 20:28:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 14320 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6F1B84493A3 for ; Thu, 8 Aug 2019 23:35:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4857B68A42C; Thu, 8 Aug 2019 23:35:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 56B4168A42C for ; Thu, 8 Aug 2019 23:35:12 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id g17so96174297wrr.5 for ; Thu, 08 Aug 2019 13:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VvQqp5awlWwiQiVR3tkNb1uroFTmoE6ZhDHSNIcWf0s=; b=XYITEXKex8/J26+HrVOY+ga1yEnJTrhopw8+rk23NKmhp92MYnOjXZu344PSyJzix9 wDADsQqUEcp0d6QaSBYhf+hx+EcJpt8c9csZMOISfT7IpOFc4LEBJnYUdxEqft1FWFNE FrbwnTWfu2fItrb1tnKKiIrkCtN5moo8vvfn8ONTAnEqL7vm9ewrPW3oon22qp4thlSL mB3LrSVJpNY8aK2fIGlWpoRJk4Pdq7vSqckMPHHSfKAkCWcV81qRjn2MeSR1EoFqSTOF nBXvLtE1eEXAx5VtbrXQiwWtam0F+X2hyPX7m+GDUCJLNdO84Oo1eMyIridBd9oCKfFr rbNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VvQqp5awlWwiQiVR3tkNb1uroFTmoE6ZhDHSNIcWf0s=; b=JYqcyyr4UJ65rfioGHOP6cxURHoTyErK3ZRJeHj/pR3ROurnCbwQJcWTfJC4KKixmT 0ylLGhkdfp45OlFIYTU6HAq2GN3JnXw4RCj+1V/MXUW0E3GK8U27A/mqnFCYXpoZtQKa Dx14zwTkYRNtVjVMcxy7xLtUV3Qd6g62vNXICP7Jc8IgC1yJOZGZP3QMYKLytlaGoiaE 3yroFf0JqliKqxaTlfbb1W9vNaexlNztjgbaHiV8iFe61ED1R49tqrNKX/9xuwFYfnzv KCukHvQRIJW6qMhyK20A4aoXvhArTRNxxog7xsFJAzNtRcCNeor+m3AWIFevdL3HSokK 1Adw== X-Gm-Message-State: APjAAAVZGWr+qtAlvpP9T7/E5JT0JPWih/tfh+0dsbiFQ/W9YkDA80Rl ldm3SnuF2A6ygr8PGNmAi5PKztiJ X-Google-Smtp-Source: APXvYqyJ6PKBnRWhmnYvu86PFB1q+fPuP2JtK+FAthpFacVo9Bk0Jl0SX1zvcy7D0i6in98BFLesQQ== X-Received: by 2002:adf:fa42:: with SMTP id y2mr19587031wrr.170.1565296111859; Thu, 08 Aug 2019 13:28:31 -0700 (PDT) Received: from vimacnew.aircard ([5.170.8.197]) by smtp.gmail.com with ESMTPSA id v16sm92326629wrn.28.2019.08.08.13.28.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 13:28:31 -0700 (PDT) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Aug 2019 22:28:26 +0200 Message-Id: <20190808202826.36504-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] mov: Support fake moov boxes disguised as hoov 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Some broken apps generate files that have a fake box named 'hoov' instead of a proper 'moov' one. This is speculation but it seems like this box contains data to be modified later (eg as file grows in size, data gets re-written) and its name is supposed to be changed to 'moov' once it can be used as a 'moov', but for some reason this step is skipped. Since this is not the first time this happens ('moov' boxes can be found in 'free' ones) extend the existing hacks to search for the moov in such boxes and skip the moov_retry since it needs to be found right away. --- libavformat/mov.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) This code is ugly, tips for improving it are welcome, or a full rejection is ok too. Unfortunately I cannot share the sample, but VLC is able to play it. Vittorio diff --git a/libavformat/mov.c b/libavformat/mov.c index 24de5429d1..0c2986b72e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6800,10 +6800,10 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (atom.size >= 8) { a.size = avio_rb32(pb); a.type = avio_rl32(pb); - if (a.type == MKTAG('f','r','e','e') && + if (((a.type == MKTAG('f','r','e','e') && c->moov_retry) || + a.type == MKTAG('h','o','o','v')) && a.size >= 8 && - c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT && - c->moov_retry) { + c->fc->strict_std_compliance < FF_COMPLIANCE_STRICT) { uint8_t buf[8]; uint32_t *type = (uint32_t *)buf + 1; if (avio_read(pb, buf, 8) != 8) @@ -6811,7 +6811,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_seek(pb, -8, SEEK_CUR); if (*type == MKTAG('m','v','h','d') || *type == MKTAG('c','m','o','v')) { - av_log(c->fc, AV_LOG_ERROR, "Detected moov in a free atom.\n"); + av_log(c->fc, AV_LOG_ERROR, "Detected moov in a free or hoov atom.\n"); a.type = MKTAG('m','o','o','v'); } }