From patchwork Fri Oct 2 22:23:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22704 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 10A9544BDEC for ; Sat, 3 Oct 2020 01:24:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EE02968A31D; Sat, 3 Oct 2020 01:24:02 +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 ACB936882DB for ; Sat, 3 Oct 2020 01:23:55 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id EB0AF20218; Fri, 2 Oct 2020 22:23:54 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:38 +0200 Message-Id: <20201002222346.1196-2-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 1/9] avcodec/dolby_e: set constant frame_size 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" Fixes pts generation. --- libavcodec/dolby_e.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 429612ec08..b0e6d6aee3 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -577,6 +577,7 @@ static int filter_frame(DBEContext *s, AVFrame *frame) reorder = ch_reorder_n; frame->nb_samples = FRAME_SAMPLES; + s->avctx->frame_size = FRAME_SAMPLES; if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0) return ret; From patchwork Fri Oct 2 22:23:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22705 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 BFEDC44BDEC for ; Sat, 3 Oct 2020 01:24:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEFAC68A494; Sat, 3 Oct 2020 01:24:03 +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 053C76882DB for ; Sat, 3 Oct 2020 01:23:56 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 63B0F201EE; Fri, 2 Oct 2020 22:23:55 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:39 +0200 Message-Id: <20201002222346.1196-3-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 2/9] avformat/s337m: Split read_packet/get_packet 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" Prepare use of s337m_get_packet from outside. --- libavformat/s337m.c | 26 ++++++++++++++++++++------ libavformat/s337m.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 libavformat/s337m.h diff --git a/libavformat/s337m.c b/libavformat/s337m.c index 36e1047af8..7f6eecb25c 100644 --- a/libavformat/s337m.c +++ b/libavformat/s337m.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" #include "spdif.h" +#include "s337m.h" #define MARKER_16LE 0x72F81F4E #define MARKER_20LE 0x20876FF0E154 @@ -141,18 +142,20 @@ static void bswap_buf24(uint8_t *data, int size) FFSWAP(uint8_t, data[0], data[2]); } -static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) +int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc) { - AVIOContext *pb = s->pb; uint64_t state = 0; int ret, data_type, data_size, offset; - enum AVCodecID codec; - int64_t pos; + int64_t pos, orig_pos = avio_tell(pb); while (!IS_LE_MARKER(state)) { state = (state << 8) | avio_r8(pb); if (avio_feof(pb)) return AVERROR_EOF; + if (avio_tell(pb) - orig_pos + 6 >= size) { + av_log(avc, AV_LOG_ERROR, "s337m : sync bytes not found at packet pos=0x%"PRIx64" size=%d\n", orig_pos, size); + return AVERROR_INVALIDDATA; + } } if (IS_16LE_MARKER(state)) { @@ -165,10 +168,10 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) pos = avio_tell(pb); - if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, &offset, &codec)) < 0) + if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, &offset, codec)) < 0) return ret; - if ((ret = av_new_packet(pkt, offset)) < 0) + if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0) return ret; pkt->pos = pos; @@ -182,6 +185,17 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) else bswap_buf24(pkt->data, pkt->size); + return 0; +} + +static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + enum AVCodecID codec; + int ret; + + if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s)) < 0) + return ret; + if (!s->nb_streams) { AVStream *st = avformat_new_stream(s, NULL); if (!st) { diff --git a/libavformat/s337m.h b/libavformat/s337m.h new file mode 100644 index 0000000000..f7bd0c16f6 --- /dev/null +++ b/libavformat/s337m.h @@ -0,0 +1,37 @@ +/* + * SMPTE ST 337 common header + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_S337M_H +#define AVFORMAT_S337M_H + +/** + * Read s337m packets in a PCM_S16LE/S24LE stereo stream + * Returns the first inner packet found + * Note that it does not require a clean guard band + * @param pb Associated IO context + * @param pkt On success, returns a DOLBY E packet + * @param size Maximum IO read size available for reading at current position + * @param codec Returns AV_CODEC_ID_DOLBY_E + * @param avc For av_log + * @return = 0 on success (an error is raised if no s337m was found) + */ +int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc); + +#endif /* AVFORMAT_S337M_H */ From patchwork Fri Oct 2 22:23:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22706 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 957DA44BDEC for ; Sat, 3 Oct 2020 01:24:04 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7F8E168A18D; Sat, 3 Oct 2020 01:24:04 +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 52E94689F05 for ; Sat, 3 Oct 2020 01:23:56 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id BB72220221; Fri, 2 Oct 2020 22:23:55 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:40 +0200 Message-Id: <20201002222346.1196-4-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 3/9] avformat/s337m: Consider container bit resolution 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" Prepare the support of s337m in muxers other than raw (ex: wav). For example, this forbids reading 16 bits DolbyE stream from a 24 bit wav file. --- libavformat/s337m.c | 17 +++++++++++------ libavformat/s337m.h | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libavformat/s337m.c b/libavformat/s337m.c index 7f6eecb25c..790f356709 100644 --- a/libavformat/s337m.c +++ b/libavformat/s337m.c @@ -34,7 +34,7 @@ static int s337m_get_offset_and_codec(void *avc, uint64_t state, - int data_type, int data_size, + int data_type, int data_size, int container_word_bits, int *offset, enum AVCodecID *codec) { int word_bits; @@ -55,6 +55,8 @@ static int s337m_get_offset_and_codec(void *avc, avpriv_report_missing_feature(avc, "Data type %#x in SMPTE 337M", data_type & 0x1F); return AVERROR_PATCHWELCOME; } + if (container_word_bits && !(container_word_bits == 16 && word_bits == 16) && !(container_word_bits == 24 && word_bits == 20) && !(container_word_bits == 24 && word_bits == 24)) + return AVERROR_INVALIDDATA; if (codec) *codec = AV_CODEC_ID_DOLBY_E; @@ -104,7 +106,7 @@ static int s337m_probe(const AVProbeData *p) data_size = AV_RL24(buf + 3); } - if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL)) + if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 0, &offset, NULL)) continue; i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2; @@ -142,13 +144,16 @@ static void bswap_buf24(uint8_t *data, int size) FFSWAP(uint8_t, data[0], data[2]); } -int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc) +int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc, int container_word_bits) { uint64_t state = 0; int ret, data_type, data_size, offset; int64_t pos, orig_pos = avio_tell(pb); - while (!IS_LE_MARKER(state)) { + if (container_word_bits && container_word_bits != 16 && container_word_bits != 24) + return AVERROR_INVALIDDATA; + while ((container_word_bits == 24 || !IS_16LE_MARKER(state)) + && (container_word_bits == 16 || !IS_20LE_MARKER(state) && !IS_24LE_MARKER(state))) { state = (state << 8) | avio_r8(pb); if (avio_feof(pb)) return AVERROR_EOF; @@ -168,7 +173,7 @@ int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID pos = avio_tell(pb); - if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, &offset, codec)) < 0) + if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, container_word_bits, &offset, codec)) < 0) return ret; if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0) @@ -193,7 +198,7 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) enum AVCodecID codec; int ret; - if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s)) < 0) + if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), &codec, s, 0)) < 0) return ret; if (!s->nb_streams) { diff --git a/libavformat/s337m.h b/libavformat/s337m.h index f7bd0c16f6..af2c4c85a3 100644 --- a/libavformat/s337m.h +++ b/libavformat/s337m.h @@ -30,8 +30,9 @@ * @param size Maximum IO read size available for reading at current position * @param codec Returns AV_CODEC_ID_DOLBY_E * @param avc For av_log + * @param container_word_bits 16,24, or 0 for autodetect * @return = 0 on success (an error is raised if no s337m was found) */ -int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc); +int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum AVCodecID *codec, void *avc, int container_word_bits); #endif /* AVFORMAT_S337M_H */ From patchwork Fri Oct 2 22:23:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22707 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 A3B9744BDEC for ; Sat, 3 Oct 2020 01:24:05 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CFB968A760; Sat, 3 Oct 2020 01:24:05 +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 93273689F05 for ; Sat, 3 Oct 2020 01:23:56 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 0B30420220; Fri, 2 Oct 2020 22:23:56 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:41 +0200 Message-Id: <20201002222346.1196-5-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 4/9] avformat/s337m: New ff_s337m_probe() 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" Similar to ff_spdif_probe() with just an additional checking of the bit resolution of the container as it may be 16 or 24 for s337m. --- libavformat/s337m.c | 32 ++++++++++++++++++++++++++++++++ libavformat/s337m.h | 16 ++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/libavformat/s337m.c b/libavformat/s337m.c index 790f356709..614344cd46 100644 --- a/libavformat/s337m.c +++ b/libavformat/s337m.c @@ -130,6 +130,38 @@ static int s337m_probe(const AVProbeData *p) return 0; } +int ff_s337m_probe(const uint8_t *buf, int size, enum AVCodecID *codec, int container_word_bits) +{ + int pos = 0; + int consecutive_codes = 0; + + if ( size < S337M_MIN_OFFSET) + return 0; + size = FFMIN(3 * S337M_MAX_OFFSET, size); + if (container_word_bits != 16 && container_word_bits != 24) + return AVERROR_INVALIDDATA; + + do { + uint64_t state; + int data_type, data_size, offset; + while (pos < size - 12 && !buf[pos]) { + pos++; + } + if (pos >= size - 12 || pos < S337M_PROBE_GUARDBAND_MIN_BYTES || pos % (container_word_bits == 16 ? 4 : 6)) + return 0; + state = container_word_bits == 16 ? AV_RB32(buf + pos) : AV_RB48(buf + pos); + if (!IS_LE_MARKER(state)) + return 0; + data_type = container_word_bits == 16 ? AV_RL16(buf + pos + 4) : AV_RL24(buf + pos + 6); + data_size = container_word_bits == 16 ? AV_RL16(buf + pos + 6) : AV_RL24(buf + pos + 9); + if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, container_word_bits, &offset, codec)) + return 0; + pos = ++consecutive_codes * (offset + 4*(container_word_bits == 16 ? 4 : 6)); + } while (consecutive_codes < 3); + + return AVPROBE_SCORE_MAX; +} + static int s337m_read_header(AVFormatContext *s) { s->ctx_flags |= AVFMTCTX_NOHEADER; diff --git a/libavformat/s337m.h b/libavformat/s337m.h index af2c4c85a3..94e79dce5d 100644 --- a/libavformat/s337m.h +++ b/libavformat/s337m.h @@ -21,6 +21,22 @@ #ifndef AVFORMAT_S337M_H #define AVFORMAT_S337M_H +#define S337M_MIN_OFFSET 1601*4 +#define S337M_MAX_OFFSET 2002*6 + +#define S337M_PROBE_GUARDBAND_MIN_BYTES 0 + +/** + * Detect s337m packets in a PCM_S16LE/S24LE stereo stream + * Requires 3 samples with enough (S337M_PROBE_GUARDBAND_MIN_BYTES) and clean (set to zero) guard band + * @param p_buf Buffer + * @param size Buffer size + * @param codec Returns AV_CODEC_ID_DOLBY_E upon successful probing + * @param container_word_bits 16 or 24 + * @return = AVPROBE_SCORE + */ +int ff_s337m_probe(const uint8_t *p_buf, int size, enum AVCodecID *codec, int container_word_bits); + /** * Read s337m packets in a PCM_S16LE/S24LE stereo stream * Returns the first inner packet found From patchwork Fri Oct 2 22:23:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22709 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 872E244BDEC for ; Sat, 3 Oct 2020 01:24:07 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77A7F68A994; Sat, 3 Oct 2020 01:24:07 +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 DF97968A94D for ; Sat, 3 Oct 2020 01:24:00 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 4942120223; Fri, 2 Oct 2020 22:23:56 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:42 +0200 Message-Id: <20201002222346.1196-6-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 5/9] avformat/wavdec: s337m support 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" Add s337m probing/reading similarly to spdif. --- libavformat/wavdec.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index d6ab0dde35..b755ab5514 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -43,6 +43,7 @@ #include "riff.h" #include "w64.h" #include "spdif.h" +#include "s337m.h" typedef struct WAVDemuxContext { const AVClass *class; @@ -58,15 +59,17 @@ typedef struct WAVDemuxContext { int ignore_length; int max_size; int spdif; + int s337m; int smv_cur_pt; int smv_given_first; int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended int rifx; // RIFX: integer byte order for parameters is big endian } WAVDemuxContext; -static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav) +static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav) { - if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) { + AVCodecParameters *par = s->streams[0]->codecpar; + if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1) { enum AVCodecID codec; int len = 1<<16; int ret = ffio_ensure_seekback(s->pb, len); @@ -79,10 +82,20 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav) int64_t pos = avio_tell(s->pb); len = ret = avio_read(s->pb, buf, len); if (len >= 0) { - ret = ff_spdif_probe(buf, len, &codec); - if (ret > AVPROBE_SCORE_EXTENSION) { - s->streams[0]->codecpar->codec_id = codec; - wav->spdif = 1; + if (CONFIG_SPDIF_DEMUXER) { + ret = ff_spdif_probe(buf, len, &codec); + if (ret > AVPROBE_SCORE_EXTENSION) { + par->codec_id = codec; + wav->spdif = 1; + } + } + if (CONFIG_S337M_DEMUXER && !wav->spdif + && (par->codec_id == AV_CODEC_ID_PCM_S16LE || par->codec_id == AV_CODEC_ID_PCM_S24LE) && par->channels == 2) { + ret = ff_s337m_probe(buf, len, &codec, par->bits_per_coded_sample); + if (ret > AVPROBE_SCORE_EXTENSION) { + par->codec_id = codec; + wav->s337m = 1; + } } } avio_seek(s->pb, pos, SEEK_SET); @@ -91,7 +104,7 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav) } if (ret < 0) - av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF\n"); + av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF/S337M\n"); } } @@ -649,7 +662,7 @@ break_loop: ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); - set_spdif(s, wav); + set_spdif_s337m(s, wav); return 0; } @@ -751,6 +764,10 @@ smv_out: wav->data_end = avio_tell(s->pb) + left; } + if (CONFIG_S337M_DEMUXER && wav->s337m == 1) { + size = FFMIN(S337M_MAX_OFFSET, left); + ret = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, st->codecpar->bits_per_coded_sample); + } else { size = wav->max_size; if (st->codecpar->block_align > 1) { if (size < st->codecpar->block_align) @@ -759,6 +776,8 @@ smv_out: } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); + } + if (ret < 0) return ret; pkt->stream_index = 0; @@ -947,7 +966,7 @@ static int w64_read_header(AVFormatContext *s) avio_seek(pb, data_ofs, SEEK_SET); - set_spdif(s, wav); + set_spdif_s337m(s, wav); return 0; } From patchwork Fri Oct 2 22:23:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22708 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 AC69744BDEC for ; Sat, 3 Oct 2020 01:24:06 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 945EB68A91A; Sat, 3 Oct 2020 01:24:06 +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 D5F5F68A800 for ; Sat, 3 Oct 2020 01:24:00 +0300 (EEST) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 8CE6C20225; Fri, 2 Oct 2020 22:23:56 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:43 +0200 Message-Id: <20201002222346.1196-7-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 6/9] avformat/wavdec.c: Reindent after last commit 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" --- libavformat/wavdec.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index b755ab5514..5b287680e2 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -768,14 +768,14 @@ smv_out: size = FFMIN(S337M_MAX_OFFSET, left); ret = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, st->codecpar->bits_per_coded_sample); } else { - size = wav->max_size; - if (st->codecpar->block_align > 1) { - if (size < st->codecpar->block_align) - size = st->codecpar->block_align; - size = (size / st->codecpar->block_align) * st->codecpar->block_align; - } - size = FFMIN(size, left); - ret = av_get_packet(s->pb, pkt, size); + size = wav->max_size; + if (st->codecpar->block_align > 1) { + if (size < st->codecpar->block_align) + size = st->codecpar->block_align; + size = (size / st->codecpar->block_align) * st->codecpar->block_align; + } + size = FFMIN(size, left); + ret = av_get_packet(s->pb, pkt, size); } if (ret < 0) From patchwork Fri Oct 2 22:23:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22710 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 553CC44BDEC for ; Sat, 3 Oct 2020 01:24:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 46E9E68A98A; Sat, 3 Oct 2020 01:24:08 +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 15B2868A800 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 0B07B20205; Fri, 2 Oct 2020 22:23:57 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:44 +0200 Message-Id: <20201002222346.1196-8-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 7/9] avformat/wavdec: fix s337m/spdif probing beyond data_end 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" --- libavformat/wavdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 5b287680e2..9f48ff067b 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -80,7 +80,7 @@ static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav) ret = AVERROR(ENOMEM); } else { int64_t pos = avio_tell(s->pb); - len = ret = avio_read(s->pb, buf, len); + len = ret = avio_read(s->pb, buf, FFMIN(len, wav->data_end - pos)); if (len >= 0) { if (CONFIG_SPDIF_DEMUXER) { ret = ff_spdif_probe(buf, len, &codec); From patchwork Fri Oct 2 22:23:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 22711 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 1D87E44BDEC for ; Sat, 3 Oct 2020 01:24:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0956C68AB18; Sat, 3 Oct 2020 01:24:09 +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 235AC68A98A 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 8BE9320228; Fri, 2 Oct 2020 22:23:57 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Oct 2020 00:23:45 +0200 Message-Id: <20201002222346.1196-9-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 8/9] avformat/wavdec: Test s337m 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" Test s337m probing in wav container. Test dolby_e demuxing for 20 bits with program config '5.1+2'. --- tests/Makefile | 1 + tests/fate/audio.mak | 3 +++ tests/ref/fate/s337m-wav | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/ref/fate/s337m-wav diff --git a/tests/Makefile b/tests/Makefile index 7844901e53..97dbdab275 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -75,6 +75,7 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword $(1))_DECODER \ $(firstword $(3))_MUXER $(lastword $(3))_DEMUXER) DEMDEC = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER)) +DEMDEMDEC = $(call ALLYES, $(1)_DEMUXER $(2)_DEMUXER $(3:%=%_DECODER)) ENCMUX = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER) DEMMUX = $(call ALLYES, $(1)_DEMUXER $(2)_MUXER) diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak index fd9905ca0a..f2e030789a 100644 --- a/tests/fate/audio.mak +++ b/tests/fate/audio.mak @@ -24,6 +24,9 @@ fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11 fate-dolby-e: CMP = oneoff fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm +FATE_SAMPLES_AUDIO-$(call DEMDEMDEC, WAV, S337M, DOLBY_E) += fate-s337m-wav +fate-s337m-wav: CMD = framecrc -i $(TARGET_SAMPLES)/dolby_e/512.wav -vn -c:a copy + FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30 -af aresample fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30 diff --git a/tests/ref/fate/s337m-wav b/tests/ref/fate/s337m-wav new file mode 100644 index 0000000000..16bfd06cae --- /dev/null +++ b/tests/ref/fate/s337m-wav @@ -0,0 +1,11 @@ +#tb 0: 1/48000 +#media_type 0: audio +#codec_id 0: dolby_e +#sample_rate 0: 44800 +#channel_layout 0: 63f +#channel_layout_name 0: 7.1 +0, 0, 0, 1920, 11496, 0x05a9c147 +0, 1920, 1920, 1920, 11496, 0x1d44d2b4 +0, 3840, 3840, 1920, 11496, 0x4e078953 +0, 5760, 5760, 1920, 11496, 0x1c73b1a1 +0, 7680, 7680, 1920, 11262, 0xfa179fc8 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);