From patchwork Mon Sep 27 21:31:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 30606 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4550571iob; Mon, 27 Sep 2021 14:31:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL82xGs/jagPqHJxkaZr6KVwpw+KWivliGFeS4znApc5H4FYpyXIaBR5EdCI3muDEIWV3i X-Received: by 2002:a05:6402:142e:: with SMTP id c14mr2947419edx.121.1632778312248; Mon, 27 Sep 2021 14:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632778312; cv=none; d=google.com; s=arc-20160816; b=lPnCXgVLqiu9TliWhoZmS1TQHLT2FCcLtz+ewBP5rVgXsYv+TL2pTcH9mnjiGIsjsm e3C33MUR811tARkHUd2X7fTh2L90rutnxkce/tolTZj+ljehrk6RDoR2OJ/Cn/lpHL8d YVs3HUDs+gM2jX8BioCsiHqACxEUycGjrl6AOGDO0MB4Tk1atEhFB2OlV5ZWTPV7CezS G3HLyySXgigt/euuwCcIJO/3mAT/ha3iypB+zmLh2oyrBLrr/pC/YoeYypGoUfKcvTVN kk1fIMEmK4jx0NeY9XFvwXbIC2P+KtCskv5IUNA4m5IBKCWi3bQ0/Qtz7ujiIVsrK6um rA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=kIINyRHLoP0yckJT5kAVFJ6V0xmulPN/pbOn5IsNqis=; b=gSfZYf/qhm6uh25oXV4OlErhtPdQnFRHZ+EYJpTV3+g3tQBABToQ/fPF9Y/E9w59n7 fnQ9dUQdFAJ1p93wCNGh0yE549UKw/tKCVb66PNzqPzNbsYKndWOfF2I2YxSBbr2+Xql XQFaDntuJUhVY1njWpcn9rchm2IX5oy8UO6b0elC96uJiYMM1daNdnFk7d/fx82h0ZFZ co65aabtm8WxsyMfo5rm1Rld6r4bZSoKnH/PsQll+iTRBRYiemg51L8RseYM9H4hetfA 9N7fjN+FlGMtKak9xxPS2IYFBZl+oRAxW+VjfwDsyGksNyssa+HqmqO3flZ2nBFNp3oh FB9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PMj0Rat2; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 31si16649080edo.634.2021.09.27.14.31.51; Mon, 27 Sep 2021 14:31:52 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PMj0Rat2; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 67631689900; Tue, 28 Sep 2021 00:31:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D297680701 for ; Tue, 28 Sep 2021 00:31:39 +0300 (EEST) Received: by mail-lf1-f48.google.com with SMTP id u8so82374095lff.9 for ; Mon, 27 Sep 2021 14:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=hx+pMxxdA2dfsz+4BJfdzyrfAnClOt0VebFtgLAGBhw=; b=PMj0Rat2LvxgcpxC75k7FqF0R59VPEzyfg5jGm6PO3dsR21yOExIATbYUWclIxHVKc FRfQQzRxycIMgzIe+wrOmk2zO50/0RCEiEWBbb2t/MmGBb1A6t4OAQ6KrdRUu4/h6psi SJ2LnhpkX9dVakcQDeIc9VApEG7+Zb8HNpMKAOOV86HFBRRRfwEEFcp1qxQNiNMyvvL6 RBpfbtuX0HVZHmv3myxEXs/MiwD5TWED/Cr8kTTRamkGvoJDw8eF1mI6nmF5yhGWPKIn MjFdeauZ96pun+sC1vUX/C7o1Mup2lTokINEPpo7uxT2bZ4i2ZVPg1ikH0iBSbNSjw9h 8+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=hx+pMxxdA2dfsz+4BJfdzyrfAnClOt0VebFtgLAGBhw=; b=3oh/y6vr+QG7vC2X8+CKn/pcfH6Gtppa1vWtRxhM9PxuanIYw/m+J0WQnKxWq3zH51 gRjULx/YRzID+CHj0scIrxyz/BXVWsu/x3h3XjJVzN4tUGIhThHM2yunNNR+kvM3L3zL HH9+GUuRxmPpPAG4SOdbOOSuPhF3PjQUP6K5UdfG4tDklLyw9qYh5BeEwu0DTB40zQaa Y6IT/vflbf9yhjZ05o5DHl4Lhl7cOmvQSKfLRIdQk8xFJZw1tOJ+m8RnIehzd1sHaBv4 18Ku+3cnNUpu0x1KM/w5qWIVQIr9Zh+4SMKbM1+X2a/PyMdEt35Y9n339QUrMK2fp8lp c/Lg== X-Gm-Message-State: AOAM533q9YJO0oXhBqwb3F060wSM0R7A7DnsEXo90w4hlV+0fRqEXr/5 03ZTCOrN6DQiGOChAGF0v6pZF30FmW0= X-Received: by 2002:a2e:9c8:: with SMTP id 191mr2049108ljj.190.1632778298710; Mon, 27 Sep 2021 14:31:38 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id x24sm2316066lji.0.2021.09.27.14.31.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 14:31:38 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 00:31:33 +0300 Message-Id: <20210927213133.28258-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/aacdec: enable probesize-sized resyncs mid-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GMOKOCSPY99T Before adts_aac_resync would always bail out after probesize amount of bytes had been progressed from the start of the input. Add an argument for the start position, and set it to zero when reading the header (which should happen in the beginning) to mimic previous behavior of going only up to probesize. Then, when doing a resync mid-file when reading a packet, pass the current position in stream to the function. Fixes #9433 --- libavformat/aacdec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index ab97be60b5..1b0e05d256 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -80,13 +80,14 @@ static int adts_aac_probe(const AVProbeData *p) return 0; } -static int adts_aac_resync(AVFormatContext *s) +static int adts_aac_resync(AVFormatContext *s, int64_t start_pos) { uint16_t state; // skip data until an ADTS frame is found state = avio_r8(s->pb); - while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) { + while (!avio_feof(s->pb) && + (avio_tell(s->pb) - start_pos) < s->probesize) { state = (state << 8) | avio_r8(s->pb); if ((state >> 4) != 0xFFF) continue; @@ -122,7 +123,7 @@ static int adts_aac_read_header(AVFormatContext *s) avio_seek(s->pb, cur, SEEK_SET); } - ret = adts_aac_resync(s); + ret = adts_aac_resync(s, 0); if (ret < 0) return ret; @@ -187,7 +188,7 @@ retry: } if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) { av_packet_unref(pkt); - ret = adts_aac_resync(s); + ret = adts_aac_resync(s, avio_tell(s->pb)); } else ret = handle_id3(s, pkt); if (ret < 0)