From patchwork Fri Oct 2 22:23:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22712 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 2D7DF44BDEC for ; Sat, 3 Oct 2020 01:24:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E6F468AB99; Sat, 3 Oct 2020 01:24:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from srv-infra-1.infra.inf.glb.tvvideoms.com (unknown [213.205.126.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72B4968AA08 for ; Sat, 3 Oct 2020 01:24:01 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id D07CF20222; Fri, 2 Oct 2020 22:23:57 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:46 +0200 Message-Id: <20201002222346.1196-10-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20201002222346.1196-1-nicolas.gaullier@cji.paris> References: <20201002222346.1196-1-nicolas.gaullier@cji.paris> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 9/9] avformat: Add probe_stream option 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 Cc: Nicolas Gaullier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allows user to disable codec auto-detection. Probe requests are ignored, including spdif/s337m submux detection in wavdec. Note: this option is required to pass-through dolby_e data from a wav file. --- doc/formats.texi | 3 +++ libavformat/avformat.h | 9 ++++++++- libavformat/options_table.h | 1 + libavformat/utils.c | 2 ++ libavformat/version.h | 2 +- libavformat/wavdec.c | 2 +- 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/formats.texi b/doc/formats.texi index fc80ce1d2b..7de49503e8 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -31,6 +31,9 @@ latency. Must be an integer not lesser than 32. It is 5000000 by default. Set the maximum number of buffered packets when probing a codec. Default is 2500 packets. +@item probe_streams @var{bool} (@emph{input}) +Enable codec auto-detection if set to 1. Default is 1. + @item packetsize @var{integer} (@emph{output}) Set packet size. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c8c0b6c08d..a146daa21c 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1118,7 +1118,7 @@ typedef struct AVStream { /** * stream probing state * -1 -> probing finished - * 0 -> no probing requested + * 0 -> no probing requested or request cancelled by probe_streams being set to 0 * rest -> perform probing with request_probe being the minimum score to accept. */ int request_probe; @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext { * - decoding: set by user */ int max_probe_packets; + + /** + * Enable codec auto-detect. + * - encoding: unused + * - decoding: set by user + */ + int probe_streams; } AVFormatContext; #if FF_API_FORMAT_GET_SET diff --git a/libavformat/options_table.h b/libavformat/options_table.h index b4141564c8..1a75ad7f93 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -112,6 +112,7 @@ static const AVOption avformat_options[] = { {"max_streams", "maximum number of streams", OFFSET(max_streams), AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D }, {"skip_estimate_duration_from_pts", "skip duration calculation in estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D}, {"max_probe_packets", "Maximum number of packets to probe a codec", OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D }, +{"probe_streams", "codec auto-detection", OFFSET(probe_streams), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, D}, {NULL}, }; diff --git a/libavformat/utils.c b/libavformat/utils.c index a2e701ea1a..1c08081e21 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -675,6 +675,8 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st) static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) { + if (!s->probe_streams) + st->request_probe = 0; if (st->request_probe>0) { AVProbeData *pd = &st->probe_data; int end; diff --git a/libavformat/version.h b/libavformat/version.h index 40f84a220d..9bde0c37f9 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 59 +#define LIBAVFORMAT_VERSION_MINOR 60 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 9f48ff067b..00cf8c9ab2 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -69,7 +69,7 @@ typedef struct WAVDemuxContext { static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav) { AVCodecParameters *par = s->streams[0]->codecpar; - if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1) { + if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1 && s->probe_streams) { enum AVCodecID codec; int len = 1<<16; int ret = ffio_ensure_seekback(s->pb, len);