From patchwork Sun Nov 7 17:38:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 31325 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:dc01:0:0:0:0:0 with SMTP id b1csp2740342iok; Sun, 7 Nov 2021 09:38:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBi2P8ZMkXPk3+ZSeMbLPoDme1bxS9ehPOxZaet2TIilkNvWcldl8OWZujWhVmfRpKi0gZ X-Received: by 2002:a05:6402:1801:: with SMTP id g1mr72617962edy.107.1636306710159; Sun, 07 Nov 2021 09:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636306710; cv=none; d=google.com; s=arc-20160816; b=ZDtwlH9NPLLR+TK77tjqWgdaj4xZTmrKuC9mL3aU+TY02K1NmQ1HFWqefy1hHb3jUv 8UJM8vkvyqvpJdjr4iHRz+PnkImrsxY+Gdpffe2vdND+92TqB7HSLysn8hZSM0yHFhZw t3gnUw5AEMJ7pd9QcxDO6HL8o4SmB8CW8kIMX9WbjwEnM/qYoCb7rrHO5Or59gSiQvuB cEaRtN430dw235Tf+FImuLSt00jilpTtuQ34BxAvaytQber6VgWSHr/dtKnsZsAr2f+P 0IloCe2L9FqIQdgBW+iDAKzBdhaDrKUZSmUgvUkvdR0oANlKiITUNI9zdz182db95uo3 0Aew== 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=nXudTZQOotzAoL2SqILLo8ELCDjl/5q3QEeaxGdVjUc=; b=KMeVBkDfW+QSG3dxwT+izWIClAy1rxx1wjIzcG+TpskxIU/RFBuW3qSYaCCYSzDeml dwoweQJAJq5jOxPhFE3gh9f1verjQrsQSwTLwo6jS3GjVqcqsWB42iNWFC4GGzjKyIly ks1fHv0G4DKQCU5sC+PGbDgpPbyrWVOHeCKuIlbRfyGHyoPs9/Lf1NnosTjO+aGHrYcc mPZKTtJGPEKfshyp1qPYQd66SOVwpEkxWABxsuSTcX/aO0Ss274RiZgWxpXaW4DxzXax emRdakmiinXD35VCS1eSMY1beqWMoFaivWE7xEvsZBJO8/U43RZ1VFCr2cgmGk4DXFLq T8UQ== 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 m1si29632684edc.187.2021.11.07.09.38.29; Sun, 07 Nov 2021 09:38:30 -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 02B0868A7FD; Sun, 7 Nov 2021 19:38:26 +0200 (EET) 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 B0867689D0A for ; Sun, 7 Nov 2021 19:38:19 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E3508E625C; Sun, 7 Nov 2021 18:38:18 +0100 (CET) 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 LKnvDoNYDkWD; Sun, 7 Nov 2021 18:38:17 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0A347E6257; Sun, 7 Nov 2021 18:38:17 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Nov 2021 18:38:10 +0100 Message-Id: <20211107173810.31787-1-cus@passwd.hu> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/demux: allow total size of packets in raw_packet_buffer to reach probesize 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: ZZvzNfGbBkpA Previously this was hardcoded to 2500000 bytes, so probing of the stream codecs was always limited by this, and not probesize. Also keep track of the actual size of packets in raw_packet_buffer and not the remaining size for simplicity. Fixes ticket #5860. Signed-off-by: Marton Balint --- libavformat/demux.c | 10 +++++----- libavformat/internal.h | 5 ++--- libavformat/options.c | 1 - libavformat/utils.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 71a1a9bf03..745dc8687c 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -328,7 +328,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, if (s->pb && !si->data_offset) si->data_offset = avio_tell(s->pb); - si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; + si->raw_packet_buffer_size = 0; update_stream_avctx(s); @@ -432,7 +432,7 @@ no_packet: } } - end = si->raw_packet_buffer_remaining_size <= 0 + end = si->raw_packet_buffer_size >= s->probesize || sti->probe_packets <= 0; if (end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) { @@ -544,13 +544,13 @@ FF_ENABLE_DEPRECATION_WARNINGS if (pktl) { AVStream *const st = s->streams[pktl->pkt.stream_index]; - if (si->raw_packet_buffer_remaining_size <= 0) + if (si->raw_packet_buffer_size >= s->probesize) if ((err = probe_codec(s, st, NULL)) < 0) return err; if (ffstream(st)->request_probe <= 0) { avpriv_packet_list_get(&si->raw_packet_buffer, &si->raw_packet_buffer_end, pkt); - si->raw_packet_buffer_remaining_size += pkt->size; + si->raw_packet_buffer_size -= pkt->size; return 0; } } @@ -631,7 +631,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return err; } pkt1 = &si->raw_packet_buffer_end->pkt; - si->raw_packet_buffer_remaining_size -= pkt1->size; + si->raw_packet_buffer_size += pkt1->size; if ((err = probe_codec(s, st, pkt1)) < 0) return err; diff --git a/libavformat/internal.h b/libavformat/internal.h index f1ae7db365..1f301dd17a 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -127,10 +127,9 @@ typedef struct FFFormatContext { */ AVPacket *pkt; /** - * Remaining size available for raw_packet_buffer, in bytes. + * Sum of the size of packets in raw_packet_buffer, in bytes. */ -#define RAW_PACKET_BUFFER_SIZE 2500000 - int raw_packet_buffer_remaining_size; + int raw_packet_buffer_size; /** * Offset to remap timestamps to be non-negative. diff --git a/libavformat/options.c b/libavformat/options.c index 753aa9b8dc..72c9bdcefe 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -174,7 +174,6 @@ AVFormatContext *avformat_alloc_context(void) } si->offset = AV_NOPTS_VALUE; - si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; si->shortest_end = AV_NOPTS_VALUE; return s; diff --git a/libavformat/utils.c b/libavformat/utils.c index 509c0ecdce..bbc61dccbb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -303,7 +303,7 @@ void ff_flush_packet_queue(AVFormatContext *s) avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end); avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end); - si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; + si->raw_packet_buffer_size = 0; } int av_find_default_stream_index(AVFormatContext *s)